| 11 | class ScopeSymbolTable; |
| 12 | |
| 13 | enum ASTNodeType |
| 14 | { |
| 15 | // used variable: symbol=variable symbol |
| 16 | NT_VAR_IDENTIFIER, |
| 17 | // literal constant: token=constant token |
| 18 | NT_CONSTANT, |
| 19 | // inline constructor (like {1, 2, 3,}): child[i] = either expression or NT_INLINE_CONSTRUCTOR |
| 20 | NT_INLINE_CONSTRUCTOR, |
| 21 | // infix expression: |
| 22 | // token = operator token |
| 23 | NT_EXPRESSION, |
| 24 | // prefix expressions ++, --, -, !, ~: token=operator token |
| 25 | NT_PREFIX_EXPRESSION, |
| 26 | // postfix expressions: token=operator token |
| 27 | NT_POSTFIX_EXPRESSION, |
| 28 | // C-style cast expression: type=type to cast to |
| 29 | NT_CAST_EXPRESSION, |
| 30 | // conditional expression (?:) |
| 31 | NT_CONDITIONAL_EXPRESSION, |
| 32 | // function call: symbol=function symbol, token=constructor token, children=arguments |
| 33 | NT_FUNCTION_CALL, |
| 34 | // function header declaration: symbol=function name, type=return type, child[i] = NT_FUNCTION_PARAMETER |
| 35 | NT_FUNCTION_HEADER, |
| 36 | // function parameter declaration: symbol=parameter name, token=parameter qualifier (in, out, inout), type=parameter type |
| 37 | // child[0]=array size, child[1]=default value, child[2]=NT_PRIMITIVE_TYPE (optional) |
| 38 | NT_FUNCTION_PARAMETER, |
| 39 | // variable name declaration: token=input modifier, symbol=parameter name, child[0]=type, child[1]=array size, child[2]=intial value |
| 40 | NT_NAME_DECLARATION, |
| 41 | // var declaration, child[0]=type, child[i]=NT_NAME_DECLARATION |
| 42 | NT_VAR_DECLARATION_LIST, |
| 43 | // struct declaration: child[i]=NT_STRUCT_MEMBER |
| 44 | NT_STRUCT, |
| 45 | // struct member declaration: child[0]=NT_TYPE_DECLARATION, child[i]=names |
| 46 | NT_STRUCT_MEMBER, |
| 47 | // [expr] bracket declaration list: child[i]=constant expression |
| 48 | NT_BRACKET_LIST, |
| 49 | |
| 50 | // program |
| 51 | NT_PROGRAM, |
| 52 | // block scope ({...}) |
| 53 | NT_BLOCK, |
| 54 | // expression statement: child[0]=NULL or NT_EXPRESSION |
| 55 | NT_EXPRESSION_STATEMENT, |
| 56 | // if statement: child[0]=condition, child[1]=branch, child[2]=else branch |
| 57 | NT_IF, |
| 58 | // while statement: child[0]=condition, child[1]=loop body |
| 59 | NT_WHILE, |
| 60 | // do statement: child[0]=condition, child[1]=loop body |
| 61 | NT_DO, |
| 62 | // for statement: child[0]=initializer or NULL, child[1]=condition or NULL, child[2]=increment or NULL, child[3]=body |
| 63 | NT_FOR, |
| 64 | // switch statement: children - NT_CASE, last child - condition |
| 65 | NT_SWITCH, |
| 66 | // case label with following statements: child[0]=case expression or NULL if default label, child[1] - NT_BLOCK |
| 67 | NT_CASE, |
| 68 | // jump statement (break, return, etc.): child[0]=return value |
| 69 | NT_JUMP, |
| 70 | // function definition: child[0]=function header, child[1]=function body, chil[2]=NT_FUNCTION_ATTRIBUTE_LIST (optional) |