首页 | 本学科首页   官方微博 | 高级检索  
     

LALR(1)解析器的再工程:YACC和CUP剖析
引用本文:张昱,张磊.LALR(1)解析器的再工程:YACC和CUP剖析[J].计算机工程,2005,31(15):50-52.
作者姓名:张昱  张磊
作者单位:中国科学技术大学计算机科学技术系,合肥,230027;中国科学技术大学计算机科学技术系,合肥,230027
基金项目:国家自然科学基金资助项目(60173049);Intel中国研究中心(ICRC)基金资助项目
摘    要:现有的前端分析多数是通过编写相应的可能含有二义的LALR(1)文法规范,利用YACC或其变种自动生成的。在这些解析器的Java再工程中,可以用CUP去替代YACC,这样再工程的焦点转移到对文法规范的变换。由于YACC及CUP在二义的解决、解析器的构造等有细微的差别,因此对复杂的文法规范的变换并不是一件容易的事。该文通过剖析YACC和CUP,指出了它们的不同之处,并总结出有二义的YACC文法到CUP文法变换的基本原则和几个变换法则。

关 键 词:LALR(1)  解析器  YACC  CUP  二义性  冲突
文章编号:1000-3428(2005)15-0050-03
收稿时间:06 20 2004 12:00AM
修稿时间:2004-06-20

Reengineering LALR(1) Parsers: YACC and CUP Anatomizing
ZHANG Yu,ZHANG Lei.Reengineering LALR(1) Parsers: YACC and CUP Anatomizing[J].Computer Engineering,2005,31(15):50-52.
Authors:ZHANG Yu  ZHANG Lei
Abstract:Most of the existing parsers are auto-generated by YACC or its variants via writing corresponding and possibly ambiguous LALR(1)syntax specifications. It is simple to reengineer these parsers to Java with CUP instead of YACC, which focuses all intentions on translating thesyntax specifications. Since there are some subtle differences between YACC and CUP in recolving conflicts and constructing parsers, etc., it is noteasy to translate a complex syntax specification.By means of anatomizing YACC and CUP, this paper indicates the discrepancies among them.Moreover, one basic fundamental and several transform principles are summarized, which can be used to translate any YACC syntax specificationinto CUP one.
Keywords:LALR(1)  Parser  Yet another compiler-compiler (YACC)  Constructor of useful parsers (CUP)  Ambiguity  Conflict  
本文献已被 CNKI 维普 万方数据 等数据库收录!
设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号