-
Notifications
You must be signed in to change notification settings - Fork 45
/
grammer.txt
129 lines (129 loc) · 3.05 KB
/
grammer.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
*terminals
ID
VOID
INT
CHAR
FLOAT
LONG
DOUBLE
SHORT
STRING_LITERAL
(
)
[
]
,
;
{
}
=
:
>
<
>=
<=
!=
==
=
+=
-=
*=
/=
%=
+
-
*
/
%
&
~
++
--
!
#
int
float
double
short
long
while
if
else
*productions
<s> ::= <translation_unit>
<translation_unit> ::= <external_declaration> <translation_unit>
<translation_unit> ::=
<external_declaration> ::= <func_declaration>
<declaration> ::= <declaration_specifiers> P21 ;
<init_declarator> ::=
<init_declarator> ::= <initializer>
<initializer> ::= <assignment_expression>
<initializer> ::= { <initializer_list> }
<initializer_list> ::= <initializer> , <initializer_list>
<func_declaration>::= <declaration_specifiers> <declarator> <declaration_list> <compound_stmt>
<declaration_list> ::=
<declaration_list> ::= <declaration> P22 <declaration_list>
<declaration_specifiers> ::= <type_specifier> ID P31
<declarator> ::= ( <parameter_type_list> )
<declarator> ::=
<parameter_type_list> ::= <parameter_list>
<parameter_type_list> ::=
<parameter_list> ::= <parameter_declaration>
<parameter_declaration> ::= <declaration_specifiers> <declarator>
<parameter_declaration> ::= <declaration_specifiers>
<stmt> ::= <compound_stmt>
<stmt> ::= <iter_stmt>
<stmt> ::= <selection_stmt>
<stmt> ::= <expression_stmt>
<expression_stmt> ::= ;
<expression_stmt> ::= <expression> ;
<compound_stmt> ::= { <stmt_list> }
<compound_stmt> ::= { <declaration_list> <stmt_list> }
<stmt_list> ::=
<stmt_list> ::= <stmt> <stmt_list>
<iter_stmt> ::= while ( <primary_expression> ) P91 <stmt> P92
<selection_stmt>::= if ( <primary_expression> ) P81 <stmt> P82
<type_specifier> ::= int P11
<type_specifier> ::= float P12
<type_specifier> ::= double P13
<type_specifier> ::= short P14
<type_specifier> ::= long P15
<constant> ::= INT P41
<constant> ::= FLOAT P42
<constant> ::= SHORT P43
<constant> ::= LONG P44
<compare_op> ::= >
<compare_op> ::= <
<compare_op> ::= ==
<compare_op> ::= >=
<compare_op> ::= <=
<compare_op> ::= ==
<compare_op> ::= !=
<unary_op> ::= &
<unary_op> ::= *
<unary_op> ::= +
<unary_op> ::= -
<unary_op> ::= ~
<unary_op> ::= !
<assignment_op> ::= =
<assignment_op> ::= -=
<assignment_op> ::= +=
<assignment_op> ::= *=
<assignment_op> ::= /=
<assignment_op> ::= %=
<expression> ::= ID = <unary_expression> P62 <factor_expression> P61
<factor_expression> ::=
<factor_expression> ::= + <unary_expression> P101
<factor_expression> ::= * <unary_expression> P102
<compare_expression> ::= <primary_expression> <compare_op> <primary_expression>
<assignment_expression>::= += <unary_expression>
<assignment_expression>::= -= <unary_expression>
<primary_expression> ::= ID P51
<primary_expression> ::= <constant> P52
<primary_expression> ::= STRING_LITERAL
<primary_expression> ::= ( <expression> )
<unary_expression> ::= <primary_expression> P71
<unary_expression> ::= ++ <unary_expression> P72
<unary_expression> ::= -- <unary_expression> P73
<unary_expression> ::= <unary_op> <unary_expression>
*end