You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @lujiajing1126 - sorry for the delay in my response. In general, left recursive grammars post a particularly difficult problem for parser combinator libraries. However, it will be difficult to help you solve the issue without seeing more of the code (so I can examine how other parsers are being constructed).
Is it possible to share a larger snippet or a gist with the code you are using?
In reference to your question, there is nothing built into parser-ts that would allow for memoization, but it certainly seems possible to build a memoization layer on top of parser-ts.
Hey @lujiajing1126 - sorry for the delay in my response. In general, left recursive grammars post a particularly difficult problem for parser combinator libraries. However, it will be difficult to help you solve the issue without seeing more of the code (so I can examine how other parsers are being constructed).
Is it possible to share a larger snippet or a gist with the code you are using?
In reference to your question, there is nothing built into parser-ts that would allow for memoization, but it certainly seems possible to build a memoization layer on top of parser-ts.
On L233, I've defined a binary expression parser. The so-called binary expression consists of two operands on the left and right of the operator.
In the original goyacc version, the left and right are both Expression. However, with parser-ts I am not able to do this due to the left-recursion problem.
I would like to use
parser-ts
to parse PromQL of which formal definition may be found below,You may notice that the
BinaryExpr
will recursively checkExpr
whereBinaryExpr
is also listed with a high priority.But with the following code,
we will encounter "Maximum call stack size exceeded error".
As is suggested from https://stackoverflow.com/questions/29158248/parser-combinators-and-left-recursion, we may "memorize" the (position, parser) tuple to avoid this issue. So is that possible to do this with
parser-ts
?The text was updated successfully, but these errors were encountered: