-
Notifications
You must be signed in to change notification settings - Fork 0
/
GRAMMAR
97 lines (97 loc) · 3.29 KB
/
GRAMMAR
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
PROGRAMP -> PROGRAM
PROGRAM -> STMT_LIST
STMT_LIST -> STMT STMT_LIST
STMT_LIST -> ''
STMT -> PRINTSTMT
STMT -> ASMT
STMT -> REASMT END
STMT -> EXPR END
STMT -> IF L_PAREN EXPR R_PAREN L_BRACKET B_STMT_LIST R_BRACKET
STMT -> IF L_PAREN EXPR R_PAREN L_BRACKET B_STMT_LIST R_BRACKET ELSE L_BRACKET B_STMT_LIST R_BRACKET
STMT -> WHILE L_PAREN I_EXPR R_PAREN L_BRACKET B_STMT_LIST R_BRACKET
STMT -> FOR L_PAREN ASMT I_EXPR END REASMT R_PAREN L_BRACKET B_STMT_LIST R_BRACKET
STMT -> FUNCTION
STMT -> V_FUNC L_PAREN F_CALL_P_LIST R_PAREN END
FUNCTION -> VOID ID L_PAREN PARAMETERS R_PAREN L_BRACKET F_STMT_LIST R_BRACKET
FUNCTION -> I_ASMT ID L_PAREN PARAMETERS R_PAREN L_BRACKET F_STMT_LIST RETURN I_EXPR END R_BRACKET
FUNCTION -> D_ASMT ID L_PAREN PARAMETERS R_PAREN L_BRACKET F_STMT_LIST RETURN D_EXPR END R_BRACKET
FUNCTION -> S_ASMT ID L_PAREN PARAMETERS R_PAREN L_BRACKET F_STMT_LIST RETURN S_EXPR END R_BRACKET
PARAMETERS -> PARAMETERS2
PARAMETERS -> ''
PARAMETERS2 -> I_ASMT ID PARAMETERS3
PARAMETERS2 -> D_ASMT ID PARAMETERS3
PARAMETERS2 -> S_ASMT ID PARAMETERS3
PARAMETERS3 -> COMMA PARAMETERS2
PARAMETERS3 -> ''
F_STMT_LIST -> F_STMT F_STMT_LIST
F_STMT_LIST -> ''
F_STMT -> PRINTSTMT
F_STMT -> ASMT
F_STMT -> REASMT END
F_STMT -> EXPR END
F_STMT -> IF L_PAREN EXPR R_PAREN L_BRACKET B_STMT_LIST R_BRACKET
F_STMT -> IF L_PAREN EXPR R_PAREN L_BRACKET B_STMT_LIST R_BRACKET ELSE L_BRACKET B_STMT_LIST R_BRACKET
F_STMT -> WHILE L_PAREN I_EXPR R_PAREN L_BRACKET B_STMT_LIST R_BRACKET
F_STMT -> FOR L_PAREN ASMT I_EXPR END REASMT R_PAREN L_BRACKET B_STMT_LIST R_BRACKET
F_CALL_P_LIST -> EXPR F_CALL_P_LIST2
F_CALL_P_LIST -> ''
F_CALL_P_LIST2 -> COMMA EXPR F_CALL_P_LIST2
F_CALL_P_LIST2 -> ''
B_STMT_LIST -> B_STMT B_STMT_LIST
B_STMT_LIST -> ''
B_STMT -> PRINTSTMT
B_STMT -> REASMT END
B_STMT -> EXPR END
B_STMT -> IF L_PAREN EXPR R_PAREN L_BRACKET B_STMT_LIST R_BRACKET
B_STMT -> IF L_PAREN EXPR R_PAREN L_BRACKET B_STMT_LIST R_BRACKET ELSE L_BRACKET B_STMT_LIST R_BRACKET
B_STMT -> WHILE L_PAREN I_EXPR R_PAREN L_BRACKET B_STMT_LIST R_BRACKET
B_STMT -> FOR L_PAREN ASMT I_EXPR END REASMT R_PAREN L_BRACKET B_STMT_LIST R_BRACKET
B_STMT -> V_FUNC L_PAREN F_CALL_P_LIST R_PAREN END
PRINTSTMT -> PRINT L_PAREN EXPR R_PAREN END
ASMT -> DOUBLEASMT
ASMT -> INTASMT
ASMT -> STRASMT
DOUBLEASMT -> D_ASMT ID ASSIGN D_EXPR END
INTASMT -> I_ASMT ID ASSIGN I_EXPR END
STRASMT -> S_ASMT ID ASSIGN S_EXPR END
REASMT -> I_VAR ASSIGN I_EXPR
REASMT -> D_VAR ASSIGN D_EXPR
REASMT -> S_VAR ASSIGN S_EXPR
EXPR -> I_EXPR
EXPR -> D_EXPR
EXPR -> S_EXPR
OP -> PLUS
OP -> MINUS
OP -> MULTI
OP -> DIVIDE
OP -> POWER
RELOP -> LESS
RELOP -> LESSEQUAL
RELOP -> GREATER
RELOP -> GREATEREQUAL
RELOP -> EQUAL
RELOP -> NOTEQUAL
SIGN -> PLUS
SIGN -> MINUS
SIGN -> ''
I_EXPR -> B_EXPR I_EXPR3
I_EXPR -> I_EXPR2 I_EXPR3
I_EXPR2 -> SIGN INT
I_EXPR2 -> I_VAR
I_EXPR2 -> I_FUNC L_PAREN F_CALL_P_LIST R_PAREN
I_EXPR2 -> I_EXPR2 RELOP I_EXPR2
I_EXPR3 -> OP I_EXPR2 I_EXPR3
I_EXPR3 -> ''
B_EXPR -> S_EXPR RELOP S_EXPR
B_EXPR -> D_EXPR RELOP D_VAR
B_EXPR -> D_EXPR RELOP SIGN DOUBLE
D_EXPR -> SIGN DOUBLE D_EXPR2
D_EXPR -> D_VAR D_EXPR2
D_EXPR -> D_FUNC L_PAREN F_CALL_P_LIST R_PAREN D_EXPR2
D_EXPR2 -> OP D_EXPR
D_EXPR2 -> ''
S_EXPR -> STRING
S_EXPR -> S_VAR
S_EXPR -> S_FUNC L_PAREN F_CALL_P_LIST R_PAREN
S_EXPR -> CONCAT L_PAREN S_EXPR COMMA S_EXPR R_PAREN
S_EXPR -> CHARAT L_PAREN S_EXPR COMMA I_EXPR R_PAREN