Skip to main content

1990 | Buch

Parsing Theory

Volume II LR(k) and LL(k) Parsing

verfasst von: Professor Seppo Sippu, Professor Eljas Soisalon-Soininen

Verlag: Springer Berlin Heidelberg

Buchreihe : Monographs in Theoretical Computer Science. An EATCS Series

insite
SUCHEN

Über dieses Buch

This work is Volume II of a two-volume monograph on the theory of deterministic parsing of context-free grammars. Volume I, "Languages and Parsing" (Chapters 1 to 5), was an introduction to the basic concepts of formal language theory and context-free parsing. Volume II (Chapters 6 to 10) contains a thorough treat­ ment of the theory of the two most important deterministic parsing methods: LR(k) and LL(k) parsing. Volume II is a continuation of Volume I; together these two volumes form an integrated work, with chapters, theorems, lemmas, etc. numbered consecutively. Volume II begins with Chapter 6 in which the classical con­ structions pertaining to LR(k) parsing are presented. These include the canonical LR(k) parser, and its reduced variants such as the LALR(k) parser and the SLR(k) parser. The grammarclasses for which these parsers are deterministic are called LR(k) grammars, LALR(k) grammars and SLR(k) grammars; properties of these grammars are also investigated in Chapter 6. A great deal of attention is paid to the rigorous development of the theory: detailed mathematical proofs are provided for most of the results presented.

Inhaltsverzeichnis

Frontmatter
6. LR(k) Parsing
Abstract
In this chapter we shall consider a general method for deriving deterministic right parsers for context-free grammars. The method will be called “LR(k) parsing”. The acronym “LR(k)” refers to the most general deterministic parsing method in which the input string is parsed (1) in a single Left-to-right scan, (2) producing a Right parse, and (3) using lookahead of length k.
Seppo Sippu, Eljas Soisalon-Soininen
7. Construction and Implementation of LR(1) Parsers
Abstract
This chapter is devoted to the practical issues involved in the construction and use of deterministic LR(1) parsers. We shall show how the practical versions of LR (1) parsers, most notably the LALR (1) parsers, can be constructed efficiently, and we shall present methods for encoding LR(1) parsers as efficient RAM programs. Two versions of RAM program implementation are considered: in the first implementation the parsing program is table-driven, that is, the rules of the parser are encoded in a two-dimensional array which is simulated by a program body; in the other implementation the tabular information is further transformed into a set of program statements.
Seppo Sippu, Eljas Soisalon-Soininen
8. LL(k) Parsing
Abstract
In this chapter we shall generalize the notion of strong LL(k) parsing presented in Chapter 5 and consider a method for deterministic left parsing that applies to a slightly wider class of context-free grammars than does the strong LL(k) parsing method. This method will be called “canonical LL(k) parsing”. As in strong LL(k) parsing, the acronym “LL(k)” means that the input string is parsed (1) in a single Left-to-right scan, (2) producing a Left parse, and (3) using lookahead of length k.
Seppo Sippu, Eljas Soisalon-Soininen
9. Syntax Error Handling
Abstract
In the previous chapters we have seen that the various parsers discussed, at least whenever they are deterministic, detect an error in any nonsentence. This means, that on any nonsentence there is a computation ending with an error configuration. For practical parsers, mere error detection is not enough; the parser should also emit a meaningful error message and recover from the error. A recovery means that the error configuration is transformed into a non-error configuration at which normal parsing can be resumed. Moreover, the transformation should be done so that as few input symbols as possible will be discarded. The goal of the error recovery is to maximize the amount of input text that can be handled in normal parsing mode and thus to detect as many errors as possible. On the other hand, the error recovery should be designed so that as few extraneous messages as possible will be emitted: only actual errors should be reported. Unfortunately, these goals are often contradictory: being able to detect and report many errors will often cause many extraneous error messages, and few extraneous error messages may imply undetected errors. Also it should be noted that a formal analysis of the quality of an error recovery method is difficult, if not impossible, because of the obvious ambiguity in the meaning of the phrase “actual error”.
Seppo Sippu, Eljas Soisalon-Soininen
10. Testing Grammars for Parsability
Abstract
In the preceding chapters we have studied in detail the major methods of deterministic context-free parsing: strong LL(k) parsing (Chapter 5), simple precedence parsing (Chapter 5), canonical LR(k) parsing, LALR(k) parsing, and SLR(k) parsing (Chapters 6 and 7), and canonical LL(k) parsing (Chapter 8). Each of these methods induces a class of grammars that are “parsable” using that method, that is, a class of grammars for which a deterministic parser employing that method can be constructed. For example, the LL(k) grammars constitute the class of grammars parsable by the LL(k) parsing method. By definition, a context-free grammar is an LL(k) grammar if and only if its canonical LL(k) parser is deterministic.
Seppo Sippu, Eljas Soisalon-Soininen
Backmatter
Metadaten
Titel
Parsing Theory
verfasst von
Professor Seppo Sippu
Professor Eljas Soisalon-Soininen
Copyright-Jahr
1990
Verlag
Springer Berlin Heidelberg
Electronic ISBN
978-3-662-08424-3
Print ISBN
978-3-642-08079-1
DOI
https://doi.org/10.1007/978-3-662-08424-3