[Pyparsing] parsing an operator-precedence-based grammar with reasonable performance?
Brought to you by:
ptmcg
From: Andrew W. <and...@gm...> - 2008-07-05 03:43:32
|
I am trying to write a parser for a regexp-like matching language using pyparsing. It can be implemented in terms of operator precedence. I tried using the operatorPrecedence function, but the performance is unacceptable for expressions containing nested parentheses. Parsing time appears to increase exponentially with the number of nested parentheses, and the parsing time for each set of nested parentheses appears to increase exponentially with the number of operators in the grammar. Even parsing something as simple as "(foo(bar))" with a grammar of 4 binary and 2 unary operators takes ridiculously long (about 2 minutes). Is there any way to parse operator-precedence-based grammars using pypasing that doesn't increase exponentially in run time with the number of nested parentheses? |