Recursive ascent parser: Difference between revisions

Content deleted Content added
Goeie (talk | contribs)
No edit summary
Goeie (talk | contribs)
No edit summary
Line 1:
Recursive ascent parsing is a technique for implementing an [[LALR]] parser which uses mutually-recursive functions rather than tables. Thus, the parser is ''directly encoded'' in the host language similar to [[recursive descent]]. Direct encoding usually yields a parser which is faster than its table-driven equivalent<ref>{{cite web|title=Very fast LR parsing|author=Thomas J Penello|year=1986|url=http://portal.acm.org/citation.cfm?id=13310.13326}}</ref> for the same reason that compilation is faster than interpretation. It is also (nominally) possible to hand edit a recursive ascent parser, whereas a tabular implementation is nigh unreadable to the average human.
 
Recursive ascent was first described by Thomas Penello in his article {{cite web|title=Very fast LR parsing|url=http://portal.acm.org/citation.cfm?id=13310.13326}} in 1986. He was not intending to create a hand-editable implementation of an LR parser, but rather a maintainable and efficient parser implemented in [[assembly language]]. The technique was later expounded upon by G.H. Roberts<ref>{{cite web|title=Recursive ascent: an LR analog to recursive descent|year=1988|author=G.H. Roberts|url=http://portal.acm.org/citation.cfm?id=47907.47909}}</ref> in 1988 as well as in an article by Leermakers, Augusteijn, Kruseman Aretz<ref>{{cite web|title=A functional LR parser|author=Leermakers, Augusteijn, Kruseman Aretz|year=1992|url=http://portal.acm.org/citation.cfm?id=146986.146994}}</ref> in 1992 in the journal ''Theoretical Computer Science''. An extremely readable description of the technique was written by Morell and Middleton<ref>{{cite web|title=Recursive-ascent parsing|author=Larry Morell and David Middleton|year=2003|url=http://portal.acm.org/citation.cfm?id=770849}}</ref> in 2003. A good exposition can also be found in a TOPLAS article by Sperber and Thiemann<ref>{{cite web|title=Generation of LR parsers by partial evaluation|author=Sperber and Thiemann Aretz|year=2000|url=http://portal.acm.org/citation.cfm?id=349219&dl=GUIDE&coll=GUIDE&CFID=56087236&CFTOKEN=74111863}}</ref>.
 
Recursive ascent has also been merged with recursive descent, yielding a technique known as [[recursive ascent/descent]]. This implementation technique is arguably easier to hand-edit due to the reduction in states and fact that some of these states are more intuitively top-down rather than bottom up. It can also yield some minimal performance improvements over conventional recursive ascent<ref>{{cite web|title=ScalaBison