Affiliation:
1. Univ. di Genova, Genoa, Italy
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 FIRST
k
and EFF
k
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 FIRST
k
function.
Publisher
Association for Computing Machinery (ACM)
Reference14 articles.
1. AHO A. V. AND ULLMAN J.D. The Tbeory o{ Parsing Translation and Compding vol. 2. Prentice-Hall Englewood Cliffs N.J. 1973. AHO A. V. AND ULLMAN J.D. The Tbeory o{ Parsing Translation and Compding vol. 2. Prentice-Hall Englewood Cliffs N.J. 1973.
2. Building collections of LR(K) items with partial expansion of lookahead strings
3. A new method for implementing LR(k) tables
Cited by
6 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Adaptive LL(*) parsing;ACM SIGPLAN Notices;2014-12-31
2. Adaptive LL(*) parsing;Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications;2014-10-15
3. On LR Parsing with Selective Delays;Lecture Notes in Computer Science;2013
4. LL
and
LR
translators need
k
>1 lookahead;ACM SIGPLAN Notices;1996-02
5. A new parsing method for non-LR(1) grammars;Software: Practice and Experience;1992-05