Closed SamuelMartens closed 2 years ago
@SamuelMartens, thanks for the report. The former versions actually had a number of problems and the latest version has improvements.
I put your grammar in a.peg and run peglint a.peg --source '' --trace
to see what's going on inside the parser. I found that Code <- T( !DefStart ( !EndOfLine . )*)
can match an empty string and doesn't increment the current position. That's why it will end up falling into the infinite loop.
I changed Code
definition to be Code <- T( !DefStart ( !EndOfLine . )+)
, and I confirmed it fixes the problem. Is this change acceptable?
@SamuelMartens I am going to close it because the parser behavior in the latest cpp-peglib is actually correct. Thanks!
Hello. I've been using peglib for a year and recently decided to update it. This piece of grammar used to work, but now it gets stuck in the infinite loop somewhere, even if you try to run it on the empty file.
I've found this problem can be solved if I modify
Code
definition to thisCode <- T( !DefStart ( !EndOfLine . )* EndOfLine )
This makes me think the parser reaches the end of the file at some point, but if the current definition is not completed, it is stuck. Thank you.