Simple LR parser: Difference between revisions

Content deleted Content added
m Added short description
Tags: Mobile edit Mobile app edit iOS app edit App description add
m Replaced 1 bare URLs by {{Cite web}}; Replaced "Archived copy" by actual titles
 
(2 intermediate revisions by 2 users not shown)
Line 5:
SLR and the more general methods [[LALR parser]] and [[Canonical LR parser]] have identical methods and similar tables at parse time; they differ only in the mathematical grammar analysis algorithms used by the parser generator tool. SLR and LALR generators create tables of identical size and identical parser states. SLR generators accept fewer grammars than LALR generators like [[yacc]] and [[GNU bison|Bison]].{{citation needed|date=November 2024}} Many computer languages don't readily fit the restrictions of SLR, as is. Bending the language's natural grammar into [[SLR grammar]] form requires more compromises and grammar hackery. So LALR generators have become much more widely used than SLR generators, despite being somewhat more complicated tools. SLR methods remain a useful learning step in college classes on compiler theory.{{citation needed|date=November 2024}}
 
SLR and LALR were both developed by [[Frank DeRemer]] as the first practical uses of [[Donald Knuth]]'s LR parser theory.<ref>{{Cite web| title=Introduction to Computational Linguistics - LR Parsers | url=https://wiki.eecs.yorku.ca/course_archive/2013-14/W/6339/_media/lrk.pdf | archive-url=https://web.archive.org/web/20210415164259/https://wiki.eecs.yorku.ca/course_archive/2013-14/W/6339/_media/lrk.pdf | archive-date=2021-04-15}}</ref><ref>{{Cite web| title=Introduction to LR-Parsing | url=https://www.seas.upenn.edu/~cis5110/notes/cis511-sl9.pdf | archive-url=https://web.archive.org/web/20240629070724/https://www.seas.upenn.edu/~cis5110/notes/cis511-sl9.pdf | archive-date=2024-06-29}}</ref> The tables created for real grammars by full LR methods were impractically large, larger than most computer memories of that decade, with 100 times or more parser states than the SLR and LALR methods.<ref>{{cite book | url=https://books.google.com/books?id=nEA9AAAAIAAJ&pg=PA87 | title=LR Parsing: Theory and Practice | isbn=978-0-521-30413-9 | last1=Chapman | first1=Nigel P. | date=17 December 1987 | publisher=CUP Archive }}</ref>
 
== Lookahead sets ==