Having trouble understanding "Left recurrsion" #786
-
This code
I don't quite get what this means. While the input isn't infinite this should work fine since there are a lot of ways to break out of this loop. I want to be able to call methods on expressions that may or may not contain another expression call or method. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Smaller example:
On paper, this grammar appears to be able to parse PEGs are eager and top down. When a rule is encountered, pest will try to match that rule entirely before going forward. With the above grammar, when you try to parse an No input gets consumed before you end up with trying to parse the same rule, therefore no progress can be made. "Left recursion" means that a right hand option can start with the same left hand nonterminal (perhaps with a few extra steps). In your specific grammar, when parsing a |
Beta Was this translation helpful? Give feedback.
Smaller example:
On paper, this grammar appears to be able to parse
"a"
followed by any number of"+"
; but with PEG rules, that can't actually happen.PEGs are eager and top down. When a rule is encountered, pest will try to match that rule entirely before going forward. With the above grammar, when you try to parse an
S
from some input, pest will try to complete an innerS
first, but to parse thatS
, it will need to parse anS
first, but to parse thatS
, it will need to parse anS
first.No input gets consumed before you end up with trying to parse the same rule, therefore no progress can be made.
"Left recursion" means that a right hand option can start with the…