-
Take the PEG
and the input
I would expect the input to parse, but it doesn't:
It's as if the There is a similar problem with |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
PEST parsers are greedy, so when they match they consume the input and there's going back. So with implicit whitespace You should take the newlines out of WHITESPACE and manually account for them. You should only put newlines in WHITESPACE if you are working in a language where newlines, " " and "\t" are all optional/trivial -- this happens in a language with explicit statement terminators ( Maybe something like this:
Or if you wanted to be more pedantic try this PESTbin Note: It took me a minute to realize that your example has whitespace after b ba |
Beta Was this translation helpful? Give feedback.
PEST parsers are greedy, so when they match they consume the input and there's going back. So with implicit whitespace
the
~ in
baa ~ "\n"becomes
baa ~ WHITESPACE* ~ "\n". WHITESPACE gobbles the newline(s) and so it doesn't find
"\n"` and fails.You should take the newlines out of WHITESPACE and manually account for them. You should only put newlines in WHITESPACE if you are working in a language where newlines, " " and "\t" are all optional/trivial -- this happens in a language with explicit st…