Faster generation of LALR(1) parsers
-
摘要: 根据LR(0)自动机的构造理论及Deremer和Pennello的LALR(1)向前看符号集计算公式,提出求解公式中的lookback关系和includes关系的高效算法. 研究过程表明,LR(0)项目集闭包计算和项目集的查找是LR(0)分析器构造过程中的主要性能瓶颈.对这两个计算过程给出了高效的数据结构和算法设计,实现了LALR(1)分析器的快速生成.系统实现及实验数据表明,LALR(1)分析器的生成速度超过了自由软件基金会的LALR(1)分析器生成器Bison.Abstract: Deremer & Pennello-s formula for computing LALR(1) lookaheads was studied in practice, by introducing a forward searching method for the computation of lookback and includes relations which were defined in the formula. Efficient algorithms for implementing of the two relations were designed. Several experiments were conducted to show that the computation of LR(0) items closure and searching for a sate in LR(0) state machine are the main bottlenecks of parser generation. Effective and efficient data structures and algorithms for the optimization of these two computations were also proposed. Experimental results show that the speed of LALR(1) parser generation implemented by improved algorithm is even faster than the speed of Bison, a well-known defacto industrial standard of LALR(1) parser generator.
-
Key words:
- parser generation /
- LALR(1) /
- lookaheads
-
[1] 李虎. GLR分析器自动生成及相关研究 .北京:北京航空航天大学计算机学院, 2006 Li Hu. On GLR parser generation and related issues . Beijing: School of Computer Science and Technology, Beijing University of Aeronautics and Astronautics, 2006(in Chinese) [2] Park J C H, Choe K M, Chang C H. A new analysis of LALR formalism[J]. ACM Transactions on Programming Languages and Systems, 1985, 7(1): 159-175 [3] Alfred V A,Ravi S,Jeffrey D U. Compilers: principles,techniques,and tools[M]. Beijing: China Post and Telecommunications Press, 2002 [4] Deremer F, Pennello T. Efficient computation of LALR(1) look-ahead sets[J]. ACMTOPLAS, 1982, 4(4): 615-649 [5] Sippu S, Soisalon-Soininen E. Parsing theory, Vol.II: LR( k ) & LL( k ) parsing[M]. Berlin: Springer-Verlag, 1990 [6] Donnelly C, Stallmen R. The Bison manual: using the YACC-compatible parser generator, for Bison version 1.875[M]. Boston: GNU Press, 2004 [7] Manuel Astudillo. GOLD parsing system .2007 . http://www.devincook.com/GOLDParser
点击查看大图
计量
- 文章访问数: 3068
- HTML全文浏览量: 140
- PDF下载量: 1736
- 被引次数: 0