Acta Iniorrnatica 6, 277m296 (1976) by Springer-Verlag 1976 An Alternative Approach to the Improvement of LR(k) Parsers R. C. Backhouse Received June 30, 1975 S~mmary. The methods of improving LR (I 0 parsers proposed by" DeRemer and Korenjak are shown to be based on a single concept--that of modifying the con- textual information on which parsing decisions axe made. This concept is then used to derive a straightforward algorithm for eliminating unit productions from an LR parser. 1.0. Introduction Knuth C9] gave two ways of testing whether a given context-free grammar G is LR (k) for some fixed integer k ~_ 0. The first method is to construct a grammar defining a regular language and then test for a prefix condition on that language. The second method is to actually construct a parser for the language and then test if the parser is deterministic. In subsequent papers [l, 3, 4, 6, 10, 12] it is the second method which has been analysed; since Knuth's original paper no mention of the first method has appeared. (Indeed in the recently published book by Aho and UUman ~2] this approach has been relegated to an exercise.) In this note we consider the first method and show that it yields some insight into the work of Korenjak CtO] and DeRemer C6] on improving LR (k) parsers and that it leads to a simple algorithm for eliminating unit productions from an LR(k) grammar. 2.0. LR(k) and SLR(k) Grammars 2.1. Notations It is assumed that the reader is familiar with context-free Ianguages, regular languages and, in particular, with methods of constructing a reduced finite-state machine Eseee.g. 7, p. 58] from a regular grammar. The notation used in this paper is for the most part standard and is summarised below. A context-free grammar G-~ (N, T, ]>, S) consists of two finite disjoint sets N and T of non-terminal symbols and terminal symbols respectively, the symbol S in N is a distinguished start symbol and each production p in the finite set P has the form ~: A--,-~ where A EN and gE(Nu T)*. The set Nv T is denoted by V and e denotes the empty word. We shall normally use small Latin letters 19"