北京航空航天大学学报 ›› 2008, Vol. 34 ›› Issue (01): 117-121.

• 论文 • 上一篇    下一篇

LALR(1)分析器快速生成

李虎1, 杨晓津2, 刘超1   

  1. 1. 北京航空航天大学 计算机学院, 北京 100083;
    2. 总参第61研究所, 北京 100039
  • 收稿日期:2007-01-15 出版日期:2008-01-31 发布日期:2010-09-17
  • 作者简介:李 虎(1974-),男,吉林长春人,讲师,tiger.li@sei.buaa.edu.cn.
  • 基金资助:

    国家自然科学基金资助项目(60573084,60703057); 国家高技术研究发展(863)计划资助项目(2006AA01Z176)

Faster generation of LALR(1) parsers

Li Hu1, Yang Xiaojin2, Liu Chao1   

  1. 1. School of Computer Science and Technology, Beijing University of Aeronautics and Astronautics, Beijing 100083, China;
    2. Institute 61, General Staff PLA, Beijing 100039, Chin
  • Received:2007-01-15 Online:2008-01-31 Published:2010-09-17

摘要: 根据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.

中图分类号: 


版权所有 © 《北京航空航天大学学报》编辑部
通讯地址:北京市海淀区学院路37号 北京航空航天大学学报编辑部 邮编:100191 E-mail:jbuaa@buaa.edu.cn
本系统由北京玛格泰克科技发展有限公司设计开发