English

On LR(k)-parsers of polynomial size

Formal Languages and Automata Theory 2015-11-19 v1

Abstract

Usually, a parser for an LR(k)LR(k)-grammar GG is a deterministic pushdown transducer which produces backwards the unique rightmost derivation for a given input string xL(G)x \in L(G). The best known upper bound for the size of such a parser is O(2GΣk+klogΣ+logG)O(2^{|G||\Sigma|^k+k\log |\Sigma| + \log |G|}) where G|G| and Σ|\Sigma| are the sizes of the grammar GG and the terminal alphabet Σ\Sigma, respectively. If we add to a parser the possibility to manipulate a directed graph of size O(Gn)O(|G|n) where nn is the length of the input then we obtain an extended parser. The graph is used for an efficient parallel simulation of all potential leftmost derivations of the current right sentential form such that the unique rightmost derivation of the input can be computed. Given an arbitrary LR(k)LR(k)-grammar GG, we show how to construct an extended parser of O(G+#LAN2kklogk)O(|G| + \#LA |N|2^k k \log k) size where N|N| is the number of nonterminal symbols and #LA\#LA is the number of relevant lookaheads with respect to the grammar GG. As the usual parser, this extended parser uses only tables as data structure. Using some ingenious data structures and increasing the parsing time by a small constant factor, the size of the extended parser can be reduced to O(G+#LANk2)O(|G| + \#LA|N|k^2). The parsing time is O(ld(input)+kGn)O(ld(input) + k|G|n) where ld(input)ld(input) is the length of the derivation of the input. Moreover, we have constructed a one pass parser.

Keywords

Cite

@article{arxiv.1511.05770,
  title  = {On LR(k)-parsers of polynomial size},
  author = {Norbert Blum},
  journal= {arXiv preprint arXiv:1511.05770},
  year   = {2015}
}

Comments

An extended abstract of this paper appeared in 37th International Colloquium, ICALP 2010, Bordeaux, France, July 2010, Proceedings, Part II, LNCS 6199, pp. 163--174, Springer-Verlag Berlin Heidelberg 2010