Closed sasq64 closed 4 years ago
@sasq64, could you give me the simplest grammar and source text to reproduce it? Thanks!
As soon as the grammar tries to evaluate an expression, which uses precedence climibng, I get a parse error. Is precedence not compatible with packrat perhaps?
Yes, if just remove the precedence {}
clause it parses (except of course can't do correct math :)
@sasq64, I added enable_packrat_parsing()
to precedence expression parsing tests, but I couldn't reproduce the problem. The tests work fine. https://github.com/yhirose/cpp-peglib/commit/c1f087a91e5b1d6d2d569ca4a5f9d2108246dd16
Could you give me the smallest possible grammar that can reveal the problem? Thanks for your help!
Parsing 1+2
fails using
Root <- Expression EOT
Decimal <- [0-9]+
_ <- ' '+
EOT <- !.
Expression <- Atom (Operator Atom)* {
precedence
L - +
L / *
}
Atom <- _? (Decimal / '(' Expression ')') _?
Operator <- '+' / '-' / '*' / '/'
If I take away the whitespace rules from Atom
it works.
@sasq64, thanks for the sample. I can now reproduce it. I'll try to fix it when I have time. Thanks!
Should be ok now.
Thank you, my parsing just got a nice 30% or so speed bump.
If I try to enable packrat parsing with my grammar, I get syntax errors for even the simplest input.
What specific requirements does packrat put on the grammar?