Abstract :
Recent work [AJU, E1, E2] has shown that substantial improvements in both the size and the running time of a bottom-up parser often can be realized by constructing the parser using an ambiquous underlying grammar. Various heuristic techniques are used to resolve action conflicts in the parser which result from the ambiquity of the grammar. In this paper we present a method for construction of such a parser, which includes previous methods and generalizes on them. Our method has the property that we can decide equivalence of the constructed parser to an original unambiquous grammar generating the intended language. Section I contains some terminology and a brief review of the theory of LR parsing. In Section II we define a "n-skeletal grammar." We then present the algorithm for construction of a "skeletal LR (k) parser." A skeletal LR(k) parser for G is shown to parse correctly every word in L(G), and to have the immediate error detection property of the canonical LR(k) technique. However, it shares with the precedence techniques of [GH, F] the defect that the parser may accept a proper superset of the intended language. An algorithm to decide whether a skeletal LR parser is "valid" for G (i.e., accepts exactly L (G)) is given in Section III. This algorithm applies to the precedence techniques as well. In Section IV we define "local consistency" of a skeletal LR parser, a condition which is shown to be sufficient for validity of the parser, and which can be tested with substantially less computation than is required for the general decision algorithm of Section III. Finally, the local consistency condition is applied in Section V to show two wide classes of grammars for which valid skeletal LR parsers can be constructed.