作者投稿和查稿 主编审稿 专家审稿 编委审稿 远程编辑

›› 2001, Vol. 27 ›› Issue (07): 188-190.

• 论文 • 上一篇    下一篇

LR分析法在词法分析器自动构造中的应用

温敬和   

  1. 上海第二工业大学 上海 200031
  • 发布日期:2001-07-25

Application of LR Analysis Method Used in Automatic Generation of Lexical Analyzer

WEN Jinghe   

  1. Shanghai Second Polytechnic UniversityShanghai200031
  • Published:2001-07-25

摘要: 提出了一种新的自动构造编译程序词法分析器的方法,分析法通常用于语法分析,但只要适当修改分析总控程序,就可将分LRLRLR析法用于词法分析器的自动构造。该方法的优点不仅在于将词法分析器自动构造方法与语法分析器自动构造方法统一,简化了编译程序的设计和构造,而且该方法自动化程度较高,只要确定描述单词的文法和词形编码表,便可自动生成任何程序设计语言编译程序的词法分析器。

关键词: 编译程序, 翻译程序, 词法分析, 语法分析, 自动构造

Abstract: sA new method to automatically generate a lexical analyzer used in compiler is proposed in this paper. As a rule, LR analysis method is used ingrammar analysis. If we adopt some changes on the LR analysis control program, LR analysis method can be used in automatic generation of lexical analyzer. The advantage of this method is that it not only use the same way for constructing both the lexical analyzer and grammar analyzer in order to predigesting the constructing of compiler, but also its automatization is more excellent.As long as the grammars which describe the rule of words in certain programming language and the table of word coding are inputted, a lexical analyzer will be produced automatically.

中图分类号: