CS [45]12[01] Spring 2023
So far we've been looking at top-down parsing. A top-down parser is limited in the grammars it can handle because it must be able to commit to predicted productions high in the parse tree based on relatively little information. For example, it must be able to choose the correct production from the start symbol based on the first token in the input. This limitation motivates bottom-up parsing, in which the parser can choose productions after seeing more input. For example, bottom-up parsers can handle left-recursive productions whereas top-down parsers cannot. In fact, bottom-up parsers work best when productions are left-recursive, although they can handle right-recursive productions too. In the following figure, the shaded areas represent the part of the parse tree that must be predicted when some of the input has been read. An powerful yet ingeniously simple bottom-up parser is that due to Jay Earley. It can parse all context-free grammars, including ambiguous ones. Its worst-case ti
Bottom-Up Parsing So far we've been looking at top-down parsing. A top-down parser is limited in the grammars it can handle because it must be able to commit to predicted productions high in the parse tree based on relatively little information. For example, it must be able to choose the correct production from the start symbol based on the first token in the input. This limitation motivates bottom-up parsing, in which the parser can choose productions after seeing more input. For example, bottom-up parsers can handle left-recursive productions whereas top-down parsers cannot. In fact,…
saved by
related reading
- Laurence Tratt: Which Parsing Approach?tratt.net
- Context-free grammar - Wikipediaen.wikipedia.org
- lecture07web.stanford.edu
- Reading 12: Regular Expressions & Grammarsweb.mit.edu
- Chris's Wiki :: blog/programming/WhyRDParsersForMeutcc.utoronto.ca
- Chomsky hierarchy - Wikipediaen.wikipedia.org
- Shunting yard algorithm - Wikipediaen.wikipedia.org
- Reading 19: Parsersweb.mit.edu
- Pratt Parsers: Expression Parsing Made Easy - journal.stuffwithstuff.comjournal.stuffwithstuff.com
- Parsing Expressions · Crafting Interpreterscraftinginterpreters.com
- web.stanford.edu/class/cs143/lectures/lecture06.pdfweb.stanford.edu
- 2. Kaleidoscope: Implementing a Parser and AST — LLVM 23.0.0git documentationllvm.org