RIPAL: Responsive and Intuitive Parsing for the Analysis of Language

Pages

LR(0) parser construction motivations

Background

We've seen the process for using a parse table to apply the LR(0) parsing algorithm in order to recognizing a string as part of a context-free language. In this section, we will briefly outline the reasoning for extending our LR(0) parsing knowledge to construct this LR(0) parser.

Recall

Previously, we illustrated and formally described the LR(0) parsing process.

In order to apply this process, we needed the following information:

  1. The general LR(0) parsing algorithm
  2. The parse table for the particular language that we are trying to recognize strings from

Core motivation

We commonly use context-free grammars to specify context-free languages, including those that are part of the LR(0) subset of this class of languages.

Since the only non-static piece of information we need to recognize such as language is its parse table, if we had the ability to generate this table from the language's grammar, then we would have a streamlined process for constructing LR(0) parse tables (and hence parsers).

Visualization of the entire flow

The following diagram illustrates the end-to-end of flow of recognizing a string as part of an LR(0) context-free language specified by a grammar:

Flow diagram illustrating the full LR(0) parsing flow. The parser consists of an LR(0) parse table and the LR(0) parsing algorithm. The LR(0) parse table is constructed by passing the LR(0) context-free grammar through the process of parse table construction. The input string is passed to the LR(0) parser. On success, a parse tree is generated.

We've already covered the LR(0) parser structure and parsing algorithm.

Conversely, we have not yet been covered LR(0) parse table construction.

Conclusion

We have gone over the motivation for delving into LR(0) parser construction. Next, we will delve into some of the underlying concepts required to start the parser construction process.


GitHub Repository: https://github.com/bprollinson/ripal

Copyright © 2017 Brendan Rollinson-Lorimer