The problem is, that PEGs (parsing expression grammars) do not allow left-recursive rules.
I have read the available answers on this topic, however problem specific (like this one) or quite simple (e.g. x = symbol:(x '.')
).
I've created the following very simple grammar to illustrate the problem
EXAMPLE = x+
x = symbol:(x y* / x y z)
y = symbol:('.' x)
z = symbol:('$')
This grammar can be tested using the PEG.js parser generator.
Could someone who is "fluent" in formal languages describe how one would rewrite this rule / set of rules to PEG? Or is there a general approach / algorithm that allows one to resolve left recursions?
Edit: I just found this Wikipedia page, which describes a way to remove left recursions, I will look into it and try to apply it to the grammar shown above.