-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.txt
92 lines (92 loc) · 3.02 KB
/
grammar.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
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
Program -> DeclarationList $
DeclarationList -> Declaration DeclarationList
DeclarationList -> ε
Declaration -> DeclarationInitial DeclarationPrime
DeclarationInitial -> TypeSpecifier ID
DeclarationPrime -> FunDeclarationPrime
DeclarationPrime -> VarDeclarationPrime
VarDeclarationPrime -> #id_declaration ;
VarDeclarationPrime -> [ #pnum NUM ] #arr_declaration ;
FunDeclarationPrime -> #activation_record ( Params ) CompoundStmt #function
TypeSpecifier -> int
TypeSpecifier -> void
Params -> int ID ParamPrime #parameter_declaration ParamList
Params -> void ParamListVoidAbtar
ParamListVoidAbtar -> ID ParamPrime ParamList
ParamListVoidAbtar -> ε
ParamList -> , Param ParamList #parameter_declaration
ParamList -> ε
Param -> DeclarationInitial ParamPrime
ParamPrime -> [ ]
ParamPrime -> ε
CompoundStmt -> { DeclarationList StatementList }
StatementList -> Statement StatementList
StatementList -> ε
Statement -> ExpressionStmt
Statement -> CompoundStmt
Statement -> SelectionStmt
Statement -> IterationStmt
Statement -> ReturnStmt
Statement -> SwitchStmt
ExpressionStmt -> Expression #correct_assign ;
ExpressionStmt -> break #jp_break ;
ExpressionStmt -> ;
SelectionStmt -> if ( Expression ) #save Statement else #else Statement #if
IterationStmt -> while #label ( Expression ) #save Statement #while
ReturnStmt -> return ReturnStmtPrime #return
ReturnStmtPrime -> ;
ReturnStmtPrime -> Expression ;
SwitchStmt -> switch #tmp_save ( Expression ) { CaseStmts DefaultStmt #jp_switch }
CaseStmts -> CaseStmt CaseStmts
CaseStmts -> ε
CaseStmt -> case #pnum NUM #cmp_save : StatementList #jpf
DefaultStmt -> default : StatementList
DefaultStmt -> ε
Expression -> SimpleExpressionZegond
Expression -> #pid ID B
B -> = Expression #assign
B -> [ Expression ] #arr_index H
B -> SimpleExpressionPrime
H -> = Expression #assign
H -> G D C
SimpleExpressionZegond -> AdditiveExpressionZegond C
SimpleExpressionPrime -> AdditiveExpressionPrime C
C -> #save_addop Relop AdditiveExpression #relop
C -> ε
Relop -> <
Relop -> ==
AdditiveExpression -> Term D
AdditiveExpressionPrime -> TermPrime D
AdditiveExpressionZegond -> TermZegond D
D -> #save_addop Addop Term #addop D
D -> ε
Addop -> +
Addop -> -
Term -> SignedFactor G
TermPrime -> SignedFactorPrime G
TermZegond -> SignedFactorZegond G
G -> #save_addop * SignedFactor #mult G
G -> ε
SignedFactor -> #psign + Factor #correct_signed_factor
SignedFactor -> #psign - Factor #correct_signed_factor
SignedFactor -> Factor
SignedFactorPrime -> FactorPrime
SignedFactorZegond -> #psign + Factor #correct_signed_factor
SignedFactorZegond -> #psign - Factor #correct_signed_factor
SignedFactorZegond -> FactorZegond
Factor -> ( Expression )
Factor -> #pid ID VarCallPrime
Factor -> #pnum NUM
VarCallPrime -> ( Args ) #call_function
VarCallPrime -> VarPrime
VarPrime -> [ Expression ] #arr_index
VarPrime -> ε
FactorPrime -> ( Args ) #call_function
FactorPrime -> ε
FactorZegond -> ( Expression )
FactorZegond -> #pnum NUM
Args -> ArgList
Args -> ε
ArgList -> Expression ArgListPrime
ArgListPrime -> , Expression ArgListPrime
ArgListPrime -> ε