-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgrammar_ast.txt
36 lines (36 loc) · 1.58 KB
/
grammar_ast.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
PROGRAM -> MAIN_DEF.
DECLARATION -> VAR_TYPE VAR_LIST semi_colon.
NI+++ VAR_TYPE -> int.
NF+++ VAR_TYPE -> float.
VAR_LIST -> VAR_LIST comma VAR_ITEM.
VAR_LIST -> VAR_ITEM.
VAR_ITEM -> var_name.
MAIN_DEF -> int main left_parenthesis right_parenthesis left_curly_bracket FUNCTION_BODY right_curly_bracket.
FUNCTION_BODY -> INTERNAL_DECLARATIONS STATEMENT_LIST.
INTERNAL_DECLARATIONS -> DECLARATION INTERNAL_DECLARATIONS.
INTERNAL_DECLARATIONS -> .
STATEMENT_LIST -> STATEMENT STATEMENT_LIST.
STATEMENT_LIST -> .
STATEMENT -> IF_STATEMENT.
STATEMENT -> EXPRESSION semi_colon.
STATEMENT -> WHILE_STATEMENT.
STATEMENT -> RETURN_STATEMENT.
STATEMENT -> semi_colon.
WHILE_STATEMENT -> while left_parenthesis EXPRESSION right_parenthesis left_curly_bracket STATEMENT right_curly_bracket.
IF_STATEMENT -> if left_parenthesis EXPRESSION right_parenthesis left_curly_bracket STATEMENT right_curly_bracket.
IF_STATEMENT -> if left_parenthesis EXPRESSION right_parenthesis left_curly_bracket STATEMENT right_curly_bracket else left_curly_bracket STATEMENT right_curly_bracket.
RETURN_STATEMENT -> return EXPRESSION semi_colon.
RETURN_STATEMENT -> return semi_colon.
EXPRESSION -> ASSIGN_EXP.
ASSIGN_EXP -> var_name equal BINARY_EXP.
ASSIGN_EXP -> BINARY_EXP.
NB+++ BINARY_EXP -> BINARY_EXP BINARY_OP PRIMARY_EXPR.
NB+++ BINARY_EXP -> PRIMARY_EXPR.
--- BINARY_OP -> boolean_op.
--- BINARY_OP -> rel_op.
--- BINARY_OP -> arith_op.
PRIMARY_EXPR -> var_name.
PRIMARY_EXPR -> CONSTANT.
PRIMARY_EXPR -> left_parenthesis EXPRESSION right_parenthesis.
CONSTANT -> int_literal.
CONSTANT -> float_literal.