I&#x27;ve implemented parsing left recursions with a memoized recursive descent parser generator. It requires hints to tell the generator it is left recursion[1] - but even with this inconvenience, I think it&#x27;s more convenient than having to refactor a left-recursive grammar into a right recursive one and then flipping the precedence back. I&#x27;m still finishing building the first useful parser using it, there may still be bugs.<p>It works by dynamically refactoring the grammar at each recursion. [2] The dynamic refactoring only happens if left recursion is hinted for that rule.<p>[1] See the `left(..)` call in `prefixexp` that tells the parser generator about the left recursion.
<a href="https:&#x2F;&#x2F;github.com&#x2F;meric&#x2F;l2l&#x2F;blob&#x2F;parser-generator&#x2F;l2l&#x2F;lua.lua#L261" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;meric&#x2F;l2l&#x2F;blob&#x2F;parser-generator&#x2F;l2l&#x2F;lua.l...</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;meric&#x2F;l2l&#x2F;blob&#x2F;parser-generator&#x2F;l2l&#x2F;grammar.lua#L514" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;meric&#x2F;l2l&#x2F;blob&#x2F;parser-generator&#x2F;l2l&#x2F;gramm...</a>