Generation of LR parsers by partial evaluation (original) (raw)

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.

A programmer-friendly LL(1) parser generator

Software: Practice and Experience, 1988

LL(1) grammars have the conceptual and practical advantage that they allow the compiler writer to view the grammar as a program; this allows a more natural positioning of semantic actions and a simple attribute mechanism. Resulting parsers can be constructed that achieve fully automatic error-recovery, which allows the compiler writer to ignore totally the issue of syntax errors. Measurement shows that such parsers can be reasonably efficient. KEY WORDS Compiler construction Error detection LL(1) parser generation * Ada is a registered trademark of the U.S. Government (Ada Joint Program Office).

Abstract LDTA’04 Preliminary Version Parameterized LR Parsing

2008

Common LR parser generators lack abstraction facilities for defining recurring patterns of productions. Although there are generators capable of supporting regular expressions on the right hand side of productions, no generator supports user defined patterns in grammars. Parameterized LR parsing extends standard LR parsing technology by admitting grammars with parameterized non-terminal symbols. A generator can implement such a grammar in two ways, either by expansion or directly. We develop the theory required for the direct implementation and show that it leads to significantly smaller parse tables and that it has fewer parsing conflicts than the expanded grammar. Attribute evaluation for a parameterized non-terminal is possible in the same way as before, if the semantic functions related to the non-terminal are polymorphic with respect to the parameter. We have implemented parameterized LR parsing in the context of Essence, a partial-evaluation based LR parser generator for Schem...

Parameterized LR Parsing

Electronic Notes in Theoretical Computer Science

Common LR parser generators lack abstraction facilities for defining recurring patterns of productions. Although there are generators capable of supporting regular expressions on the right hand side of productions, no generator supports user defined patterns in grammars.Parameterized LR parsing extends standard LR parsing technology by admitting grammars with parameterized non-terminal symbols. A generator can implement such a grammar in two ways, either by expansion or directly. We develop the theory required for the direct implementation and show that it leads to significantly smaller parse tables and that it has fewer parsing conflicts than the expanded grammar. Attribute evaluation for a parameterized non-terminal is possible in the same way as before, if the semantic functions related to the non-terminal are polymorphic with respect to the parameter.We have implemented parameterized LR parsing in the context of Essence, a partial-evaluation based LR parser generator for Scheme.

ANTLR: A predicated-LL(k) parser generator

Software: Practice and Experience, 1995

Despite the parsing power of© © algorithms, e.g. YACC 1 , programmers often choose to write recursive-descent parsers by hand to obtain increased flexibility, better error handling, and ease of debugging. We introduce ANTLR, a public-domain parser generator that combines the flexibility of hand-coded parsing with the convenience of a parser generator, which is a component of PCCTS 2 . ANTLR has many features that make it easier to use than other language tools. Most important, ANTLR provides predicates which let the programmer systematically direct the parse via arbitrary expressions using semantic and syntactic context; in practice, the use of predicates eliminates the need to hand-tweak the ANTLR output, even for difficult parsing problems. ANTLR also integrates the description of lexical and syntactic analysis, accepts " ! g rammars for $ # & % w ith extended BNF notation, and can automatically generate abstract syntax trees.

LL (*): The foundation of the ANTLR parser generator

2011

Despite the power of Parser Expression Grammars (PEGs) and GLR, parsing is not a solved problem. Adding nondeterminism (parser speculation) to traditional LL and LR parsers can lead to unexpected parse-time behavior and introduces practical issues with error handling, single-step debugging, and side-effecting embedded grammar actions. This paper introduces the LL(*) parsing strategy and an associated grammar analysis algorithm that constructs LL(*) parsing decisions from ANTLR grammars. At parse-time, decisions gracefully throttle up from conventional fixed k ≥ 1 lookahead to arbitrary lookahead and, finally, fail over to backtracking depending on the complexity of the parsing decision and the input symbols. LL(*) parsing strength reaches into the context-sensitive languages, in some cases beyond what GLR and PEGs can express. By statically removing as much speculation as possible, LL(*) provides the expressivity of PEGs while retaining LL's good error handling and unrestricted grammar actions. Widespread use of ANTLR (over 70,000 downloads/year) shows that it is effective for a wide variety of applications.

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

Construction Methods of LR Parsers

1981

This paper presents five different LR parser generators and an error recovery method which is derived directly from the LR parser. The parsers presented include the original LR (1) parser defined by Knuth. The SLR(1) and LALR(1) parsers defined by DeRemer, and the weak and strong compatible LR parsers presented by Pager. All five parsers have been implemented by the author using two programs. Furthermore, the implementation of the SLR (1) parser generator includes an error recovery method and produces an SLR(1) parser with error recovery built in.