Packrat parsers can support left recursion.

Alessandro Warth, James R. Douglass, Todd D. Millstein
2008
1 reference

Abstract

Packrat parsing offers several advantages over other parsing techniques, such as the guarantee of linear parse times while supporting backtracking and unlimited look-ahead. Unfortunately, the limited support for left recursion in packrat parser implementations makes them difficult to use for a large class of grammars (Java's, for example). This paper presents a modification to the memoization mechanism used by packrat parser implementations that makes it possible for them to support (even indirectly or mutually) left-recursive rules. While it is possible for a packrat parser with our modification to yield super-linear parse times for some left-recursive grammars, our experimentsshow that this is not the case for typical uses of left recursion.

1 repository
1 reference

Code References

python/cpython
1 file
Tools/peg_generator/pegen/parser.py
1
L104 # variable; perhaps this is similar to a paper by Warth et al.
Link copied to clipboard!