Hello, I'm new here but I've been working on a Java PEG parser
generator, so I thought I'd describe what my version would do. It fails,
as the a* part essentially gobbles up all the input.
Taking the simpler case of "ab" the steps it goes through to fail are
(1) resolve a (at character 0) to 'a'
(2) retry resolution for character 0. This time the a* takes in the
current resolution at character 0, so it queries the result at character
1. This resolves to 'b', so the first a*, then resolves to ('a'), 'b'.
(3) It then tries to check for 'a' | 'b' after the a*, but there is no
more input, so it fails. Or rather it sticks with its best completed
resolution which is just 'a' (from step (1)).
But this is just like saying a = ('a' | 'b' )* 'a' | 'b', which would
also fail without the left-recursion, so I'm happy with the result of my
algorithm.
Matthew
On 31/01/12 23:31, Ondřej Bílka wrote:
What your parser does on following rule:
a = a* 'a' | 'b'
say on string ababbba
_______________________________________________
PEG mailing list
PEG@lists.csail.mit.edu
https://lists.csail.mit.edu/mailman/listinfo/peg