-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrammar
110 lines (110 loc) · 2.5 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
98
99
100
101
102
103
104
105
106
107
108
109
110
P -> P'
P' -> common commons
commons -> common commons
commons -> ε
common -> type ID after_part
common -> STRUCT ID struct_body ;
struct_body -> { struct_define struct_defines }
struct_defines -> struct_define struct_defines
struct_defines -> ε
struct_define -> type ID array_part ;
array_part -> [ const ]
array_part -> ε
after_part -> ( args ) func_body
after_part -> init vars ;
type -> INT
type -> SHORT
type -> LONG
type -> FLOAT
type -> DOUBLE
type -> VOID
type -> CHAR
type -> UNSIGNED type
args -> type ID arg
args -> ε
arg -> , type ID arg
arg -> ε
func_body -> ;
func_body -> block
block -> { define_stmts stmts }
define_stmts -> define_stmt define_stmts
define_stmts -> ε
define_stmt -> type ID init vars ;
define_stmt -> STRUCT ID ID ;
init -> = expression
init -> array_part
init -> ε
vars -> , ID init vars
vars -> ε
stmts -> stmt stmts
stmts -> ε
stmt -> assign_stmt
stmt -> jump_stmt
stmt -> iteration_stmt
stmt -> if_stmt
stmt -> switch_stmt
assign_stmt -> expression ;
jump_stmt -> CONTINUE ;
jump_stmt -> BREAK ;
jump_stmt -> RETURN isnull_expr ;
iteration_stmt -> WHILE ( logical_expression ) block
iteration_stmt -> FOR ( isnull_expr ; isnull_expr ; isnull_expr ) block
iteration_stmt -> DO block WHILE ( logical_expression ) ;
if_stmt -> IF ( logical_expression ) block result
result -> ELSE after_else
result -> ε
after_else -> block
after_else -> if_stmt
switch_stmt -> SWITCH ( value ) { case_stmt case_stmts default_stmt }
case_stmts -> case_stmt case_stmts
case_stmts -> ε
case_stmt -> CASE const : stmts
default_stmt -> DEFAULT : stmts
default_stmt -> ε
logical_expression -> ! expression bool_expression
logical_expression -> expression bool_expression
bool_expression -> lop expression bool_expression
bool_expression -> ε
lop -> &&
lop -> ||
isnull_expr -> expression
isnull_expr -> ε
expression -> value operation
operation -> compare_op value
operation -> equal_op value
operation -> ++
operation -> --
operation -> ε
compare_op -> >
compare_op -> >=
compare_op -> <
compare_op -> <=
compare_op -> ==
compare_op -> !=
equal_op -> =
value -> item value'
value' -> + item value'
value' -> - item value'
value' -> ε
item -> factor item'
item' -> * factor item'
item' -> / factor item'
item' -> % factor item'
item' -> ε
factor -> ( value )
factor -> ID factor'
factor -> const
factor' -> array_part
factor' -> call_func
factor' -> DOT ID
factor' -> ε
call_func -> ( es )
es -> expression eps
es -> ε
eps -> , expression eps
eps -> ε
const -> OCT
const -> DECIMAL
const -> HEX
const -> STRING
const -> CHARACTER