摘要
随着计算机技术的快速发展,越来越多的编程语言出现在了大众的视野中。设计一门新的编程语言,最重要的工作就是实现其对应的编译系统。文章基于LL1文法设计并实现了一款解释器。LL1文法是一种上下文无关的简单文法,使用该文法可以简化解释器的实现过程。解释器主要由前端和后端两大部分组成,前端主要包括词法分析和语法分析,后端主要包括解释执行器和符号表。前端通过词法分析和语法分析将用户的源程序转换成抽象语法树,后端将遍历抽象语法树完成类型检查、符号表的建立以及用户程序的执行。
With the rapid development of computer technology,more and more programming languages have appeared in the public's field of vision.To design a new programming language,the most important task is to implement its corresponding compilation system.Therefore,this paper designs and implements an interpreter based on the LL1 grammar.The LL1 grammar is a context-free simple grammar that can be used to simplify the implementation of the interpreter.The interpreter is mainly composed of two parts:the frontend and the backend.The frontend mainly includes lexical analysis and syntax analysis,and the backend mainly includes an explanation executor and a symbol table.The frontend transforms the user's source program into an abstract syntax tree through lexical analysis and parsing.The backend will traverse the abstract syntax tree to complete type checking,symbol table creation,and user program execution.
作者
刘辉
严碧波
LIU hui;YAN Bi-bo(Electronics Information School of Yangtze University,Jingzhou 434023,China)
出处
《电脑与信息技术》
2019年第5期9-11,15,共4页
Computer and Information Technology
关键词
LL1
解释器
词法分析
语法分析
符号表
LL1
interpreter
lexical analysis
syntax analysis
symbol table