A general context-free parsing algorithm running in linear time on every LR(k) grammar without using lookahead (original) (raw)
Related papers
A New Approach to the Construction of Generalized LR Parsing Algorithms
We present a Generalized LR parsing algorithm for unrestricted context-free grammars working in complexity O(n 3 ). It differs from previous approaches in the use of dynamic programming techniques to cope with the non determinism, instead of a graph-structured stack. The steps for deriving our algorithm from classical Earley's parsing algorithm are shown.
Construction of efficient generalized LR parsers
Automata Implementation, 1998
We show how LR parsers for the analysis of arbitrary context free grammars can be derived from classical Earley's parsing algorithm. The result is a Generalized LR parsing algorithm working at complexity O(n^3) in the worst case, which is achieved by the use of dynamic programming to represent the non-deterministic evolution of the stack instead of graph-structured stack representations, as has often been the case in previous approaches. The algorithm behaves better in practical cases, achieving linear complexity on LR
Practical Arbitrary Lookahead LR Parsing
Journal of Computer and System Sciences, 1990
We present a practical technique for computing lookahead for an LR(0) parser, that progressively attempts single-symbol, multi-symbol, and arbitrary lookahead. The technique determines the amount of lookahead required, and the user is spared the task of guessing it. The class of context-free grammars defined by our technique is a subset of the LR-regular grammars; we show that unlike LR-regular, the problem of determining whether an arbitrary grammar is in the class, is decidable. When restricted to k-symbol lookahead, the technique has the power of LALR(k) parsers. It has been successfully used to resolve multi-symbol lookahead conflicts in grammars for FORTRAN, Ada, C, COBOL, and PL/I, and its performance compares favorably with that of two well-known, commercially available parser generators.
A new parsing method for non-LR(1) grammars
Software: Practice and Experience, 1992
Ow of the difficult problems that faces a compiler writer is to devise a grammar that is suitable for both eflkient parsing and semantic attribution. This paper describes a system that resolves conflirts in LR(1) parsing by taking advantage of information in the parse tree. The system, which functions as part of a compiler generator, rewrites the user's grammar to remove parsing contlicts. It then places code into the generated compiler that rewrites the parse tree during parsing so as to produce the tree of the original grammar. The compiler writer can then write the semantic attribution to fit hi or her original grammar without any knowledge of the changes made. The method is expected to be ef6cient in most cases, even in parsing systems that do not explicitly build the entire parse tree. The method complements previous work in its capabilities and advantages. The system has been implemented and integrated into a compiler generator system.
A unifying model for lookahead LR parsing
Computer Languages, 1991
A~tract-We present a construction method for lookahead LR parsers that unifies several of the construction algorithms available in the literature. The model allows single, multiple and arbitrary symbol lookahead, each only when required. Three user-supplied parameters are used by the construction method; specific settings of these parameters yield well-known grammar classes such as LALR(k), SLR(k), and several subsets of the LR-Regular class, among others. Thus, rather than using several severely incompatible parser generators, or making unnatural changes to the grammar to accommodate the parsing technique, one may manipulate these parameters to obtain a suitable parser. The model captures the essence of the problem of computing lookahead for LR parsers, and provides a better understanding of the relationships among the corresponding classes of context-free grammars. Algorithms Languages Theory Context-free grammar LR parsing LALR(k) SLR(k) NQLALR(I) Lookahead FSA LR-Regular
Efficient parsing algorithms for general context-free parsers
Information Sciences, 1975
A family of parsing algorithms for general context-free grammars is described. Its members have a top-down structure, while performing tests similar to those introduced in both LR and LL algorithms. A theoretical study shows that the algorithms have the same time and space bounds as Earley's algorithms, which are particular members of the family. Empirical comparisons show the effectiveness of the new members of the family, which appear to be definitely better than Earley's algorithms, except for a few pathological grammars. parsers, Report R173 M.B.L.E. Research Lab. Brussels (Belgium), 1971.
A practical arbitrary look-ahead LR parsing technique
Sigplan Notices, 1986
We present a practical technique that provides an LR(0)p arser with either fixed or arbitrary lookahead. The construction algorithm is based on certain paths in the LR(0)state diagram, which must be restricted to a maximum length m.T he technique determines the amount of look-ahead required, and the user is spared the task of guessing it. Instead, the user provides m.I ns ituations where single symbol look-ahead is sufficient, the corresponding grammar class (called LAR(m)) is identical to the NQLALR(1)c lass. For practical grammars that require arbitrary look-ahead, the storage requirements typically do not exceed an amount linear in the size of the corresponding LR(0)p arser.T he technique is shown to work for a practical programming language grammar,and has been used to solve particular cases of the PL/1 keyword problem.
Generalized LR parsing for extensions of context-free grammars
Current Issues in Linguistic Theory, 2000
We present a Generalized LR parsing algorithm for extensions of context-free grammars. It di ers from previous approaches in the use of dynamic programming techniques to cope with non determinism, instead of a graph-structured stack. The steps for deriving the algorithm from the classical Earley's parsing algorithm are shown.