|
ABSTRACT
A new method for building LR(k) states and parsing tables is presented. The method aims at giving a feasible construction of a collection of LR(k) parsing tables, especially when k > 1. for nontrivial grammars. To this purpose, the algorithm first attempts to build a set of normal states for the given grammar, each one associated to a single parsing action in {accept, reduce, shift}. When such an action cannot be uniquely determined, that is, when up to k input symbols have to be examined (inadequacy), further states, belonging to a new type, called look-ahead states, are computed. The action associated with inadequate states is a new parsing action, look. States are built without actual computation of the FIRSTk and EFFk functions; that is, nonterminals are kept in the context string of items composing each state, and their expansion to terminals is deferred until indispensable to solve inadequacy. The aforementioned method is illustrated; then the canonical collection of states and the canonical tables are compared with those obtained from the proposed method. A sufficient condition is stated, by which the size of parsing tables, obtained by applying this new method, is smaller than that of canonical tables. Experimental results show that such a condition is verified by the grammars of several programming languagues and that significant speed is gained by avoiding the computation of the FIRSTk function.
REFERENCES
Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.
| |
1
|
|
| |
2
|
|
 |
3
|
|
| |
4
|
ANCONA, M., FASSINO, C., AND GIANUZZI, V. Optimization of LR(k) reduced tables. Tech. Rep. 39/88, IMA-CNR, Genoa, Italy, 1988.
|
| |
5
|
ANCONA, M., AND GIANUZZI V. Implementation of reduced LR(k) tables when k > 1. Tech. Rep. 47, IMA-CNR, Genoa, Italy, 1980.
|
| |
6
|
ANCONA, M., AND GIANUZZI, V. A new method for implementing LR(k) tables. Inf. Process. Lett. 13, 4 and 5 (1981), 171-176.
|
 |
7
|
|
| |
8
|
CULIK, C., AND COHEN, R. LR-regular grammars-An extension of LR(k) grammars. J. Comput. Syst. Sci. 7 (1973), 66-96.
|
 |
9
|
|
| |
10
|
|
| |
11
|
JOHNSON, S.C. YACC--Yet another compiler compiler. Computing Science Tech. Rep. 32, AT&T Bell Laborafories. Murray Hill. N.J.. 1975.
|
| |
12
|
KNUTtt, D.E. On the translation of languages from left to right. Inf. Control 8 (1965), 607-639.
|
| |
13
|
MCKEEMAN, W. M., HORNING, J. J., AND WORTMAN, D.B. A Compiler Generator. Prentice- Hall, Englewood Cliffs, N.J., 1974.
|
| |
14
|
MORGAVI, M. An algorithm to build sets of states and parsing tables for LR(k) grammars lin
|
| |
15
|
SEITE, B. A YACC extension for LRR grammar parsing. Ph.D. dissertation. INRIA, France, 1986.
|
 |
16
|
|
| |
17
|
|
CITED BY 2
|
|
M. Ancona , G. Dodero , A. Clematis, Reusing a compiler, Proceedings of the 1994 ACM symposium on Applied computing, p.82-87, March 06-08, 1994, Phoenix, Arizona, United States
|
|
|
|
REVIEW
"Marian Gheorghe : Reviewer"
The authors present a new method for building
LR(k) parsing tables, called reduced
tables, and the associated reduced parser (a shift-reduce parsing
algorithm) driven by these tables. The reduced tables are o
more...
|