Extending Lookahead for LR Parsers

Abstract A practical method is presented for extending the lookahead of LR parsers, by the addition of “reduce-arcs.” Applied to an LR(0) parser, this gives a machine which is close in size to the corresponding LALR(1) machine, but is capable of making use of unbounded lookahead. The class of grammars parsable by this method is a subset of the LR-regular grammars which is shown to be properly included in the LALR( k ) grammars, if limited to k symbols of lookahead, but also includes non-LR grammars if no such limit is imposed. Application is foreseen to error recovery in LALR(1) parsers, as well as the handling of occasional non-LALR(1) situations in normal parsing.

[1]  F. L. Deremer,et al.  Practical translators for LR(k) languages , 1969 .

[2]  Karel Culik,et al.  LR-Regular Grammars - an Extension of LR(k) Grammars , 1973, J. Comput. Syst. Sci..

[3]  Wilf Roger Lalonde Practical lr analysis of regular right part grammars. , 1975 .

[4]  G. David Ripley,et al.  Error recovery for Simple LR(k) parsers , 1976, ACM '76.

[5]  Alfred V. Aho,et al.  The Theory of Parsing, Translation, and Compiling , 1972 .

[6]  Frank DeRemer,et al.  A forward move algorithm for LR error recovery , 1978, POPL '78.

[7]  Jeffrey D. Ullman,et al.  Formal languages and their relation to automata , 1969, Addison-Wesley series in computer science and information processing.

[8]  Donald E. Knuth,et al.  On the Translation of Languages from Left to Right , 1965, Inf. Control..

[9]  Alfred V. Aho,et al.  LR Parsing , 1974, ACM Comput. Surv..

[10]  Wilf R. LaLonde,et al.  An LALR(k) Parser Generator , 1971, IFIP Congress.

[11]  Franklin L. DeRemer,et al.  Simple LR(k) grammars , 1971, Commun. ACM.

[12]  M. Dennis Mickunas,et al.  Automatic error recovery for LR parsers , 1978, CACM.