Description: (1)设计符号表
确定符号表的组织方式,一般应包括名字栏和信息栏,其中名字栏作为关键字。要考虑能够存储有关名字的信息,并可以高效地完成如下操作:
a.查找:根据给定的名字,在符号表中查找其信息。如果该名字在符号表中不存在,则将其加入到符号表中,否则返回指向该名字的指针;
b.删除:从符号表中删除给定名字的表项。
(2)设计词法分析器(也可以使用FLEX生成词法分析器)
设计各单词的状态转换图,并为不同的单词设计种别码。将词法分析器设计成供语法分析器调用的子程序。功能包括:
a. 能够拼出语言中的各个单词;
b. 将拼出的标识符填入符号表;
c. 返回(种别码, 属性值)。
(3)语法分析与中间代码产生器(也可以使用BISON生成语法分析程序)
要求用递归下降分析法、预测分析法或SLR分析法,实现对表达式、各种说明语句、控制语句进行语法分析。
若语法正确,则输出一棵语法树。
若语法错误,要求指出出错性质和出错位置(行号)。出错处理应设计成一个出错处理子程序。-(1) Design symbol table
Determine the symbol table of organization, the general should include the name bar and bar, where the name column as a keyword. To be considered capable of storing information about the name, and the following operations can be efficiently completed:
a find: Find its information according to the name given in the symbol table. If the name does not exist in the symbol table, then it is added to the symbol table, otherwise it returns a pointer to the name of the pointer
Delete: delete the given name from the symbol table entry.
(2) design of lexical analyzer (You can also use the FLEX generate the lexical analyzer)
The design of each word in the state transition diagram, and a word design for different kind as code. The lexical analyzer is designed for the parser calls the subroutine. Features include:
a. to spell out each word in the language
b. spell identifier fill in the symbol table
c. return (other code, attribute values).
(3) syntax analysis an Platform: |
Size: 2048 |
Author:夏帆 |
Hits: