Can analyze the following types of statements, build symbol tables and generate intermediate code (three-address instructions and quaternary form):
Able to identify semantic errors in test cases, including
It gives the exact location of the error.The format of the output error message is as follows: Semantic error at Line [line number]: [description text]
Requirement: Give the semantic actions corresponding to the following language components
Requirements: It is divided into system outline design and system detailed design.
Design of core data structure
This structure is the node of the parse tree, which is used to store the content, attribute, depth and child node information of the word.
Supports returning all instances of all classes.When returning attribute information, if the node does not have the attribute, an error will be reported.
Sub-node information and attribute information can be added.
This structure is a quadruple, which is used to store the content of the quadruple.
Analysis operations on quadruples are also included
Requirements: Expand a description of the following.
The system has no way to deal with variables used without declaration.Because the dictionary is used when storing the attributes of the variable, when the variable is called, if the variable is not declared, then there is no it in the symbol table, and there is no key about its dictionary, then the program will report a keyerror error.
The test sample is as follows:
struct student {int age;}int sum(int x, int y) {int ret;ret = x + y;return ret;}int main() {float a;a = 1.567;int b;int[5][5] c;c[1][1] = 10;b = c[1][1];int d;int *e;d = sum(b, c[1][1]);if(d > 10) {a = 1.0;} else {a = 2.0;}while(b < 10) {d = d + 1;b = b + 1;}return 0;}