cpp-peglib icon indicating copy to clipboard operation
cpp-peglib copied to clipboard

Support Left recursive PEG Grammars

Open yhirose opened this issue 3 years ago • 3 comments

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

yhirose avatar Jun 18 '22 00:06 yhirose

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

mingodad avatar Jun 18 '22 06:06 mingodad

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

yhirose avatar Jun 18 '22 16:06 yhirose

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

  • https://github.com/orlandohill/peg-left-recursion
  • https://github.com/sacek/LPegLJ
  • https://github.com/sacek/LPeg/commit/17bb675e024824008969a9ab48e350e7a2b40320

mingodad avatar Jun 18 '22 17:06 mingodad