## Generation of LR Parsers by Partial Evaluation (2000)

Venue: | ACM Transactions on Programming Languages and Systems |

Citations: | 8 - 2 self |

### BibTeX

@ARTICLE{Sperber00generationof,

author = {Michael Sperber and Peter Thiemann},

title = {Generation of LR Parsers by Partial Evaluation},

journal = {ACM Transactions on Programming Languages and Systems},

year = {2000},

volume = {22},

pages = {2000}

}

### Years of Citing Articles

### OpenURL

### Abstract

this paper appeared in Proceedings of the ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation, 1995 under the title "The Essence of LR Parsing." Authors' addresses: Michael Sperber, Wilhelm-Schickard-Institut fur Informatik, Universitat Tubingen, Sand 13, D72076 Tubingen, Germany, sperber@informatik.uni-tuebingen.de.

### Citations

639 | Partial Evaluation and Automatic Program Generation. Available online: http://www.itu.dk/people/sestoft/pebook - Jones, Gomard, et al. - 1993 |

447 |
Semantics of Context-Free Languages
- Knuth
- 1968
(Show Context)
Citation Context ...e. To take advantage of the results of the parsing process, the parser must associate a semantics with the input string. The most common way to do this is the attribute grammar mechanism [Knuth 1968; =-=Knuth 1971]. Many po-=-pular parser generators [Johnson 1975] restrict themselves to S-attributed grammars where all attributes can be evaluated "on the fly" during parsing. This is actually no principal restricti... |

236 | Tutorial notes on partial evaluation
- Consel, Danvy
- 1993
(Show Context)
Citation Context ...components of its free variables, the generated call refers to a previously generated procedure. Otherwise, it must generate an appropriate specialized procedure. Consel's and Danvy's tutorial notes [=-=Consel and Danvy 1993-=-] give an overview of partial evaluation. The textbook by Jones, Gomard, and Sestoft [Jones et al. 1993] gives a more in-depth study of techniques and applications of the field. 4.1 Binding-Time Impro... |

179 |
Yacc: Yet another compiler compiler
- Johnson
- 1979
(Show Context)
Citation Context ...mal language processors. LR parsing is popular because many realistic grammars are immediately amenable to this technique. Also, several LR parser generators are readily available, most notably Yacc [=-=Johnson 1975-=-]. However, as easy as it is to use a tool like Yacc, the techniques underlying LR parser generators are harder to comprehend and to implement than LL techniques, which An earlier version of parts of ... |

173 | Partial evaluation of computation process an approach to a compiler-compiler. Higher Order Symbol
- Futamura
- 1999
(Show Context)
Citation Context ...extension results from applying a program-generator generator (PGG) to p. Customarily, a PGG results from double self-application of a partial evaluator as described by the third Futamura projection [=-=Futamura 1971-=-; Turchin 1979; Jones et al. 1993]. PGGs are also called compiler generators (cogen) or partial evaluation compilers (pecom) because they can turn interpreters into compilers. We will call a PGG const... |

156 |
Revised report on the algorithmic language Scheme
- Clinger, Rees
- 1991
(Show Context)
Citation Context ...results in LR parsers that are considerably simpler and more compact than formulations using a stack automaton. The specifications of the parsing algorithms translate directly into Scheme [IEEE 1991; =-=Kelsey et al. 1998-=-] programs. The general parsers run independently and take both a grammar and an input string as operands. Hence, they are easy to write and debug. Adding attribute evaluation for synthesized attribut... |

155 |
On the translation of languages from left to right
- Knuth
- 1965
(Show Context)
Citation Context ...orithms, Experimentation, Languages, Performance Additional Key Words and Phrases: LR parsing, parser generation, partial evaluation, functional programming, continuations 1. INTRODUCTION LR parsing [=-=Knuth 1965-=-] is the predominant parsing technique in compiler front ends and other formal language processors. LR parsing is popular because many realistic grammars are immediately amenable to this technique. Al... |

122 | An experiment in partial evaluation: The generation of a compiler generator - Jones, Sestoft, et al. - 1985 |

93 | A partial evaluator for the untyped lambda-calculus
- Gomard, Jones
- 1991
(Show Context)
Citation Context ... using self-application. We have used such a program-generator generator [Thiemann 1996a] to generate our parser generators. The Trick seems to be as old as offline partial evaluation [Dybkjaer 1985; =-=Gomard and Jones 1991-=-; Bondorf 1993; Jones et al. 1993] as it is necessary for effective selfapplication. No existing offline partial evaluator automates The Trick. However, there is a formalization that incorporates The ... |

91 | Efficient type inference for higherorder binding-time analysis
- Henglein
- 1991
(Show Context)
Citation Context ... partial evaluators: These partial evaluators treat cons, car, and cdr as ordinary primitive operations, rather than as data constructors and selectors. Traditional monovariant binding-time analyses [=-=Henglein 1991-=-] expect the arguments to a primitive to be static data of base type if the specializer is to reduce the primitive. Since our parser passes a procedure to the primitive cons, the binding-time analysis... |

90 |
Automatic autoprojection of higher order recursive equations
- Bondorf
- 1991
(Show Context)
Citation Context ...f a partial evaluator cogen. Specialization with generating extensions (also called the cogen approach) is attractive because it is considerably faster than specialization with a generic specializer [=-=Bondorf 1991-=-]. 5. IMPLEMENTING DIRECT-STYLE FUNCTIONAL LR PARSING The formal specification of functional LR parsing gives rise to a naive working implementation of a general LR parser. The naive parser becomes su... |

55 |
Storing a sparse table
- Tarjan, Yao
- 1971
(Show Context)
Citation Context ...le representation of an LR automaton may become quite large. Choosing an appropriate sparse representation while preserving efficient access to the table requires significant algorithmics and coding [=-=Tarjan and Yao 1979-=-; Dencker et al. 1984]. Consequently, the resulting LR parsers are usually unreadable. This in turn makes finding errors and tending to parsing conflicts difficult, as testing is only possible with th... |

41 |
Simple LR(k) Grammars
- DeRemer
- 1971
(Show Context)
Citation Context ... most realistic formal languages are already amenable to treatment by SLR or LALR parsers which introduce lookahead into essentially LR(0) parsers. The SLR(k) parser corresponding to an LR(0) parser [=-=DeRemer 1971-=-] with states q (0) 0 ; : : : ; q (0) n has states closures q 0 ; : : : ; qn . In contrast to the LR(k) parser, the SLR(k) automaton has the following states: q i := fA ! ff \Delta fi (ae) j A ! ff \D... |

32 |
The Functional Treatment of Parsing
- Leermakers
- 1993
(Show Context)
Citation Context ...as testing is only possible with the generated parsers. The (less known) alternative is to start from a functional specification of LR(k) parsing and derive the implementation by program calculation [=-=Leermakers 1993-=-]. We follow this approach and present two inherently functional formulations of general LR(k) parsing. Both formulations use the recursive ascent technique [Pennello 1986; Roberts 1988], analogous to... |

29 |
T.: Efficient Computation of LALR(1) Look-Ahead Sets
- DeRemer, Pennello
- 1982
(Show Context)
Citation Context ...ely replacing follow k with the (more involved) LALR lookahead function. Unfortunately, all efficient methods of computing LALR lookahead sets require access to the entire LR(0) automaton in advance [=-=DeRemer and Pennello 1982-=-; Park et al. 1985; Ives 1986; Park and Choe 1987; Ives 1987b; Ives 1987a]. Since the parser does not have access to a representation of the automaton, introducing the LALR method would require comput... |

29 |
Handwriting cogen to avoid problems with static typing
- Holst, Launchbury
- 1991
(Show Context)
Citation Context ...e partial evaluation can automatically generate stand-alone parser generators using either self-application of the partial evaluator [Jones et al. 1985; Turchin 1979] or a compiler generator (cogen) [=-=Launchbury and Holst 1991-=-]. The generated parsers are simple in structure, consisting of mutually recursive procedures that encode parser states. To achieve good results with offline partial evaluation, realistic programs som... |

27 | Cogen in six lines
- Thiemann
- 1996
(Show Context)
Citation Context ...[goto(q; X)](��; s)s[q](C; ��; s:s) Fig. 15. Direct-style LR(k) parser with attribute evaluation One of the authors has developed a partial evaluator which is able to handle eval and apply cor=-=rectly [Thiemann 1996-=-b] which results in a clear, concise, and efficient solution to the problem. 8.3 Error Recovery Realistic applications of parsers require sensible handling of parsing errors. Specifically, the parser ... |

25 |
An order-algebraic definition of Knuthian semantics
- Chirica, Martin
- 1979
(Show Context)
Citation Context ...be evaluated "on the fly" during parsing. This is actually no principal restriction in a language with higher-order functions, since more general attribution schemes can be simulated using f=-=unctions [Chirica and Martin 1979-=-]. An S-attributed grammar is a context-free grammar where each nonterminal A is associated with a synthesized attribute s A and each production is augmented with an attribution. An attribution of a p... |

24 |
Optimization of parser tables for portable compilers
- Dencker, Dürre, et al.
- 1984
(Show Context)
Citation Context ...an LR automaton may become quite large. Choosing an appropriate sparse representation while preserving efficient access to the table requires significant algorithmics and coding [Tarjan and Yao 1979; =-=Dencker et al. 1984-=-]. Consequently, the resulting LR parsers are usually unreadable. This in turn makes finding errors and tending to parsing conflicts difficult, as testing is only possible with the generated parsers. ... |

21 | Eta-expansion does the Trick
- Danvy, Malmkjær
- 1996
(Show Context)
Citation Context ... replacing C[d] by a loop C[d] ) foreach s 2 F do if s = d then C[s] else continue A suitable partial evaluation system will automatically propagate the context C to the static value inside the loop [=-=Danvy et al. 1996-=-]. With such context propagation in place, we only need to replace d by a loop to get the effect of The Trick: d ) foreach s 2 F do if s = d then s else continue This loop translates directly into a S... |

20 |
Very fast LR parsing
- Pennello
- 1986
(Show Context)
Citation Context ...on by program calculation [Leermakers 1993]. We follow this approach and present two inherently functional formulations of general LR(k) parsing. Both formulations use the recursive ascent technique [=-=Pennello 1986-=-; Roberts 1988], analogous to recursive descent as commonly used in LL parsers. Neither of our approaches requires the handling of an explicit parse table or a parsing stack. Recursive ascent results ... |

19 |
Similix 5.0
- Bondorf
- 1993
(Show Context)
Citation Context ... attribute evaluation. The resulting algorithms are used in the parser generator of the M��rk system for preprocessor generation. As already mentioned in the paper, Mossin [Mossin 1993] uses Simil=-=ix [Bondorf 1993-=-] to obtain specialized LR(1) parsers from general parsers. He starts from 32 \Delta M. Sperber and P. Thiemann a stack-based first-order approach which does not specialize well. He transforms the sta... |

18 |
R.: Bison: The Yacc-compatible Parser Generator
- Donnelly, Stallman
- 2006
(Show Context)
Citation Context ...al-world parser generators, the performance of the generated parsers is competitive. When compiled with a high-performance Scheme implementation, they are about as fast as parsers generated by Bison [=-=Donnelly and Stallman 1995-=-]. Overview The paper is organized as follows: the first three sections introduce Generation of LR Parsers by Partial Evaluation \Delta 3 some notational preliminaries, the basic concepts of functiona... |

17 |
A supercompiler system based on the language Refal
- Turchin
- 1979
(Show Context)
Citation Context ... suffices to achieve good results. Also, offline partial evaluation can automatically generate stand-alone parser generators using either self-application of the partial evaluator [Jones et al. 1985; =-=Turchin 1979-=-] or a compiler generator (cogen) [Launchbury and Holst 1991]. The generated parsers are simple in structure, consisting of mutually recursive procedures that encode parser states. To achieve good res... |

15 |
LR Parsing: Theory and Practice
- Chapman
- 1987
(Show Context)
Citation Context ... descent. The traditional model underlying LR parsing complicates understanding and implementing parsers even further. Traditional expositions and implementations use a stack automaton [Johnson 1975; =-=Chapman 1987-=-; Sippu and Soisalon-Soininen 1990; Wilhelm and Maurer 1995]. An LR parser generated this way is essentially an interpreter of a table representation of the automaton. A naive table representation of ... |

13 | Towards partial evaluation of full scheme
- Thiemann
- 1996
(Show Context)
Citation Context ...[goto(q; X)](��; s)s[q](C; ��; s:s) Fig. 15. Direct-style LR(k) parser with attribute evaluation One of the authors has developed a partial evaluator which is able to handle eval and apply cor=-=rectly [Thiemann 1996-=-b] which results in a clear, concise, and efficient solution to the problem. 8.3 Error Recovery Realistic applications of parsers require sensible handling of parsing errors. Specifically, the parser ... |

12 |
IEEE Standard for the Scheme Programming Language
- IEEE
- 1991
(Show Context)
Citation Context ...ive ascent results in LR parsers that are considerably simpler and more compact than formulations using a stack automaton. The specifications of the parsing algorithms translate directly into Scheme [=-=IEEE 1991-=-; Kelsey et al. 1998] programs. The general parsers run independently and take both a grammar and an input string as operands. Hence, they are easy to write and debug. Adding attribute evaluation for ... |

10 |
Partial evaluation of general parsers
- Mossin
(Show Context)
Citation Context ... generated by traditionally built parser generators such as Bison [Donnelly and Stallman 1995] as well as those produced by the partial evaluation of a stack-based implementation presented by Mossin [=-=Mossin 1993-=-]. Table I. Size of specialized parsers for k = 1 (in cons-cells) G Size (G) Mossin LR CPS-LR SLR G 1 24 1608 652 1236 491 G 2 48 3751 2070 2999 1197 G 3 123 6181 5870 7294 2700 The two implementation... |

9 |
Recursive Ascent: An LR Analog to Recursive Descent
- Roberts
- 1988
(Show Context)
Citation Context ...alculation [Leermakers 1993]. We follow this approach and present two inherently functional formulations of general LR(k) parsing. Both formulations use the recursive ascent technique [Pennello 1986; =-=Roberts 1988-=-], analogous to recursive descent as commonly used in LL parsers. Neither of our approaches requires the handling of an explicit parse table or a parsing stack. Recursive ascent results in LR parsers ... |

7 |
Lalr--A generator for efficient parsers
- Grosch
- 1990
(Show Context)
Citation Context ...alistic algorithms: the user-assisted method of Yacc [Johnson 1975] based on error productions and the fully automatic technique by Rohrich [Rohrich 1980] as implemented in the Lalr parser generator [=-=Grosch 1990-=-]. Since effective error recovery requires fairly fine-grained control over the operation of the parser, the continuation-based parser is considerably more amenable to the implementation of these tech... |

6 |
Unifying view of recent LALR(1) lookahead set algorithms
- Ives
- 1986
(Show Context)
Citation Context ...d) LALR lookahead function. Unfortunately, all efficient methods of computing LALR lookahead sets require access to the entire LR(0) automaton in advance [DeRemer and Pennello 1982; Park et al. 1985; =-=Ives 1986-=-; Park and Choe 1987; Ives 1987b; Ives 1987a]. Since the parser does not have access to a representation of the automaton, introducing the LALR method would require computing one and operating on that... |

5 |
B.N.: Controlled mixed computation and its application to systematic development of language-oriented parsers
- Ershov, Ostrovski
- 1987
(Show Context)
Citation Context ...mation complicates the program considerably and requires intricate binding-time improvements and other optimizations to achieve good specialization. Dybkjaer [Dybkjaer 1985] and Ershov and Ostrovsky [=-=Ershov and Ostrovsky 1987-=-] describe previous attempts to specialize general parsers. Pagan [Pagan 1991] describes, among other examples for partial computation, the construction of LL and LR parser generators. However, his ap... |

5 |
A new analysis of LALR formalisms
- Park, Choe, et al.
- 1985
(Show Context)
Citation Context ... the (more involved) LALR lookahead function. Unfortunately, all efficient methods of computing LALR lookahead sets require access to the entire LR(0) automaton in advance [DeRemer and Pennello 1982; =-=Park et al. 1985-=-; Ives 1986; Park and Choe 1987; Ives 1987b; Ives 1987a]. Since the parser does not have access to a representation of the automaton, introducing the LALR method would require computing one and operat... |

5 | Methods for the automatic construction of error correcting parsers - OHRICH, J - 1980 |

4 |
The C Programming Language. PrenticeHall, 2nd edition
- Kernighan, Ritchie
- 1988
(Show Context)
Citation Context ...ison-generated parsers in speed. These results prove the practicability of our approach. Moreover, we have used the continuation-based parser generator to develop the front end of an ANSI C compiler [=-=Kernighan and Ritchie 1988-=-]. Since it is possible to test a given grammar with the general parser, our observation has been that users typically only apply the parser generator towards the end of the development cycle. During ... |

3 |
Parsers and partial evaluation: an experiment
- Dybkjaer
- 1985
(Show Context)
Citation Context ...pops elements off the stack. The transformation complicates the program considerably and requires intricate binding-time improvements and other optimizations to achieve good specialization. Dybkjaer [=-=Dybkjaer 1985-=-] and Ershov and Ostrovsky [Ershov and Ostrovsky 1987] describe previous attempts to specialize general parsers. Pagan [Pagan 1991] describes, among other examples for partial computation, the constru... |

3 |
Response on remarks on recent algorithms for LALR lookahead sets
- Ives
(Show Context)
Citation Context ...ortunately, all efficient methods of computing LALR lookahead sets require access to the entire LR(0) automaton in advance [DeRemer and Pennello 1982; Park et al. 1985; Ives 1986; Park and Choe 1987; =-=Ives 1987-=-b; Ives 1987a]. Since the parser does not have access to a representation of the automaton, introducing the LALR method would require computing one and operating on that, instead of relying on the par... |

2 |
Fundamental Algorithms (2nd ed.), Volume 1 of The Art of Computer Programming
- Knuth
- 1973
(Show Context)
Citation Context ...e in practice. To take advantage of the results of the parsing process, the parser must associate a semantics with the input string. The most common way to do this is the attribute grammar mechanism [=-=Knuth 1968; Knuth 19-=-71]. Many popular parser generators [Johnson 1975] restrict themselves to S-attributed grammars where all attributes can be evaluated "on the fly" during parsing. This is actually no princip... |

2 |
Remarks on recent algorithms for LALR lookahead sets
- Park, Choe
- 1987
(Show Context)
Citation Context ...kahead function. Unfortunately, all efficient methods of computing LALR lookahead sets require access to the entire LR(0) automaton in advance [DeRemer and Pennello 1982; Park et al. 1985; Ives 1986; =-=Park and Choe 1987-=-; Ives 1987b; Ives 1987a]. Since the parser does not have access to a representation of the automaton, introducing the LALR method would require computing one and operating on that, instead of relying... |

2 |
Attribute-directed functional LR parsing. Unpublished manuscript
- Sperber
- 1994
(Show Context)
Citation Context ...lhs *lhs*) ! (input *input*)) : : : Fig. 7. Direct-style parser using imperative features 6. CONTINUATION-BASED LR PARSING It is possible to express LR parsing in Sec. 3 in a continuation-based form [=-=Sperber 1994-=-]. The continuation-based parser is not merely the result of a straightforward CPS transformation, but an intrinsic expression of LR parsing with continuations. Therefore, the continuation-based parse... |

1 |
For a better support of static data flow. See Hughes [1991
- Consel, Danvy
- 1991
(Show Context)
Citation Context ....2, a few changes are necessary to the naive implementation of the parser to make it specialize well. Sometimes, programs are transformed to continuation-passing style to make them specialize better [=-=Consel and Danvy 1991-=-]. However, our use of continuations in the parser is not motivated by binding-time considerations, rather it is intrinsic in the formulation of the 18 \Delta M. Sperber and P. Thiemann parsing algori... |

1 |
Practical translators for LR(k) parsers
- DeRemer
- 1969
(Show Context)
Citation Context ...ease, often dramatically for realistic grammars (see Table I in the next section). The LALR method uses a more precise method of computing the lookahead, but also works by decorating an LR(0) parser [=-=DeRemer 1969-=-]. Thus, the same methodology as with the SLR case is applicable, merely replacing follow k with the (more involved) LALR lookahead function. Unfortunately, all efficient methods of computing LALR loo... |

1 | Functional Programming Languages and Computer Architecture, Volume 523 - Hughes - 1991 |

1 |
An LALR(1) lookahead set algorithm. Unpublished manuscript
- Ives
- 1987
(Show Context)
Citation Context ...ortunately, all efficient methods of computing LALR lookahead sets require access to the entire LR(0) automaton in advance [DeRemer and Pennello 1982; Park et al. 1985; Ives 1986; Park and Choe 1987; =-=Ives 1987-=-b; Ives 1987a]. Since the parser does not have access to a representation of the automaton, introducing the LALR method would require computing one and operating on that, instead of relying on the par... |

1 |
Parsing Theory, Volume II (LR(k) and LL(k
- Sippu, Soisalon-Soininen
- 1990
(Show Context)
Citation Context ...traditional model underlying LR parsing complicates understanding and implementing parsers even further. Traditional expositions and implementations use a stack automaton [Johnson 1975; Chapman 1987; =-=Sippu and Soisalon-Soininen 1990-=-; Wilhelm and Maurer 1995]. An LR parser generated this way is essentially an interpreter of a table representation of the automaton. A naive table representation of an LR automaton may become quite l... |