Closed andrewchambers closed 6 months ago
Can you work around this issue by modifying the PEG as shown below?
foo <- "foo\n" / "foobar\n"
The shorter string has to be put before the longer ones.
That's a good suggestion but maybe does not work for more complicated grammars where such interactions are less obvious.
In the end I have rewritten my code to buffer lines before passing it to the parser after a known terminator, this issue no longer affects me, I don't mind closing it.
@andrewchambers , I have fixed this issue. I inform you, just in case.
If you have a grammar like:
and input the string "foo\n..........", then packcc will read 8 bytes for this rule when it really only needed to read 4.
As an example of where this is a problem, consider an interactive parser where the user enters data line by line, if the user types "foo\n", the parser will request two or more lines of input from the user when only one was actually needed.