Nodetype |
Type |
Description |
CONST |
int/str |
For interger and string constants. As a special case, if the constant is NULL, the type is set to void. |
ID |
int/str/ user-defined type |
For all variable literals. |
PLUS/MINUS/MUL/DIV |
int |
For arithmetic operators '+', '-', '*', '/', '%'. 'ptr1' and 'ptr2' must be of type int and set to the AST's of the left and the right operands respectively. |
GT/LT/GE/LE |
boolean |
For relational operators '>', '<', '>=', '<='. 'ptr1' and 'ptr2' must be of type int and set to the AST's of the left and the right operands respectively. |
EQ/NE |
boolean |
For relational operator '==' or '!='. 'ptr1' and 'ptr2' must be set to AST of the left and the right operands respectively and both must be of the same type. |
IF |
void |
For the conditional construct 'if'. 'ptr1' must be set to the AST of the logical expression and must be of type 'boolean', 'ptr2' must be set to the AST of list of statements corresponding to the 'then part' and 'ptr3' must be set to the AST of list of statements corresponding to the 'else part'. |
WHILE |
void |
For conditional construct 'while'. 'ptr1' is set to the conditional logical expression and 'ptr2' is set to AST of list of statements under the body of while construct. |
READ |
void |
For input statement 'read', 'ptr1' must have nodetype ID or FIELD and type of 'ptr1' must be either 'int' or 'str'. |
WRITE |
void |
For output statement 'write', 'ptr1' must be of type 'int' and 'str' and must be set to AST of the expression whose value is to be written to the standard output. |
ASGN |
void |
For assignment statement (<var> = <expr>). 'ptr1' must be set to an AST of nodetype ID or FIELD and 'ptr2' must be set to an AST of expression whose value will be assigned to lvalue given by 'ptr1'. The types of the variable and the expression must match. |
SLIST |
void |
To form a tree with multiple statements. The execution semantics is that the sequence of statements represented by the left subtree 'ptr1' must be evaluated before evaluating 'ptr2'. |
BODY |
int/str/ user-defined type |
For body of a function, type indicates the return type of the function. This is created when the definition of a function is processed. |
RET |
int/str/ user-defined type |
For return statement of a function. |
FUNCTION |
int/str/ user-defined type |
For function calls. The type must be same as the return type of the function. The field 'arglist' must be set to list of arguments for the function. |
MAIN |
int |
For main function. |
FIELD |
int/str/ user-defined type |
For user-defined types,( to handle expressions of the form ID . ID, ID . ID . ID , etc). |