yhirose / cpp-peglib

A single file C++ header-only PEG (Parsing Expression Grammars) library
MIT License
916 stars 113 forks source link

Support Left recursive PEG Grammars #214

Open yhirose opened 2 years ago

yhirose commented 2 years ago

https://medium.com/@gvanrossum_83706/left-recursive-peg-grammars-65dab3c580e1

mingodad commented 2 years ago

Packcc https://github.com/arithy/packcc has it but it has a high toll on memory usage.

yhirose commented 2 years ago

cpp-peglib supports 'Infix expression by Precedence climbing', and the feature can properly express 'Operator associativity'. But the downside of this approach is that it introduces the special PEG syntax. If the parser supports left recursive PEG grammars, we can specify such operator associativity with the normal PEG syntax.

https://github.com/yhirose/cpp-peglib#parsing-infix-expression-by-precedence-climbing

mingodad commented 2 years ago

Some people say that direct left recursion is easier than indirect left recursion. I found this links that can help somehow: