aidhound / hotxlfp

A Python Excel Formula Parser similar to the javascript handsontable formulaparser
MIT License
28 stars 12 forks source link

bug - cannot nest a parser within a parser #7

Closed nitish-deckspire closed 3 years ago

nitish-deckspire commented 3 years ago

You cannot nest another parser as a function within the parser because yacc is being used in a global way.

Code to reproduce:


import hotxlfp

def parse(formula):
    parser = hotxlfp.Parser(debug=True)
    setattr(parser, '_name', 'p_init')
    result = parser.parse(formula)
    return result['result']

parser2 = hotxlfp.Parser(debug=True)
setattr(parser2, '_name', 'p_ext')
parser2.set_function('EVAL', parse)
parser2.parse('EVAL("1+1")') # result = 2
parser2.parse('EVAL("1+1")') # result = None
leonelcamara commented 3 years ago

Thanks! I'll add some tests for this and release a new version.