Backtracking when using or() and | operator. #166
-
So I'm new with this library and I've come across some problems with non-terminal containing multiple production rules. The parser doesn’t seem to backtrack when it comes across an error. Here's an exemple: S-> AB When given the sentence : abc it returns an error because the parser hits on B-> b and doesn't seem to backtrack when it reads c. When we switch the rule production to B-> bc | b it works but my production rules are much bigger and complicated than this example. Is there a good way to write our production rules in order to allow backtracking? Also, from what I've tested, it seems that the parser works Top-Down. Is it the case? And is it possible to change it to Bottom-up? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
PetitParser is a recursive descent top-down parser. It uses the semantics of parsing expression grammars and as such it picks the first succeeding choice (ordered choice) and never backtracks. |
Beta Was this translation helpful? Give feedback.
PetitParser is a recursive descent top-down parser. It uses the semantics of parsing expression grammars and as such it picks the first succeeding choice (ordered choice) and never backtracks.