-
Notifications
You must be signed in to change notification settings - Fork 25
/
C.cf
331 lines (255 loc) · 16.2 KB
/
C.cf
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
-- Copyright 2020 United States Government as represented by the Administrator
-- of the National Aeronautics and Space Administration. All Rights Reserved.
--
-- Disclaimers
--
-- No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY
-- OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
-- LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
-- SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-- PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE
-- SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF
-- PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN
-- ANY MANNER, CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR
-- RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR
-- ANY OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE. FURTHER,
-- GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING
-- THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES
-- IT "AS IS."
--
-- Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST
-- THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS
-- ANY PRIOR RECIPIENT. IF RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN
-- ANY LIABILITIES, DEMANDS, DAMAGES, EXPENSES OR LOSSES ARISING FROM SUCH USE,
-- INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S
-- USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS THE
-- UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY
-- PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE REMEDY
-- FOR ANY SUCH MATTER SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS
-- AGREEMENT.
--
entrypoints TranslationUnit;
token Identifier ( ( letter | '_' ) (letter | digit | '_' )* ) ;
token IntegerConstant ( ( ["123456789"] digit*)
| ('0' ["01234567"]+)
| ('0' ('x' | 'X') ["01234567"]+)
)
( ('u' | 'U' | 'l' | 'L')? ) ;
MkTranslationUnit . TranslationUnit ::= [ExternalDeclaration] ;
(:[]) . [ExternalDeclaration] ::= ExternalDeclaration ;
(:) . [ExternalDeclaration] ::= ExternalDeclaration [ExternalDeclaration] ;
MkExternalDeclarationFunctionDefinition . ExternalDeclaration ::= FunctionDefinition ;
MkExternalDeclarationDeclaration . ExternalDeclaration ::= Declaration ;
MkFunctionDefinition . FunctionDefinition ::= [DeclarationSpecifier] Declarator [Declaration] CompoundStatement ;
MkDeclaration . Declaration ::= DeclarationSpecifiers InitDeclarationListOpt ";" ;
[] . [Declaration] ::= ;
(:) . [Declaration] ::= Declaration [Declaration];
[] . [DeclarationSpecifier] ::= ;
(:) . [DeclarationSpecifier] ::= DeclarationSpecifier [DeclarationSpecifier] ;
DeclarationSpecifiers . DeclarationSpecifiers ::= DeclarationSpecifier [DeclarationSpecifier] ;
MkDeclarationSpecifierStorageClass . DeclarationSpecifier ::= StorageClassSpecifier ;
MkDeclarationSpecifierTypeSpecifier . DeclarationSpecifier ::= TypeSpecifier ;
MkDeclarationSpecifierTypeQualifier . DeclarationSpecifier ::= TypeQualifier ;
MkStorageClassSpecifierAuto . StorageClassSpecifier ::= "auto" ;
MkStorageClassSpecifierRegister . StorageClassSpecifier ::= "register" ;
MkStorageClassSpecifierStatic . StorageClassSpecifier ::= "static" ;
MkStorageClassSpecifierExtern . StorageClassSpecifier ::= "extern" ;
MkStorageClassSpecifierTypedef . StorageClassSpecifier ::= "typedef" ;
MkTypeSpecifierVoid . TypeSpecifier ::= "void" ;
MkTypeSpecifierChar . TypeSpecifier ::= "char" ;
MkTypeSpecifierShort . TypeSpecifier ::= "short" ;
MkTypeSpecifierInt . TypeSpecifier ::= "int" ;
MkTypeSpecifierInt8 . TypeSpecifier ::= "int8_t" ;
MkTypeSpecifierInt16 . TypeSpecifier ::= "int16_t" ;
MkTypeSpecifierInt32 . TypeSpecifier ::= "int32_t" ;
MkTypeSpecifierInt64 . TypeSpecifier ::= "int64_t" ;
MkTypeSpecifierUInt8 . TypeSpecifier ::= "uint8_t" ;
MkTypeSpecifierUInt16 . TypeSpecifier ::= "uint16_t" ;
MkTypeSpecifierUInt32 . TypeSpecifier ::= "uint32_t" ;
MkTypeSpecifierUInt64 . TypeSpecifier ::= "uint64_t" ;
MkTypeSpecifierLong . TypeSpecifier ::= "long" ;
MkTypeSpecifierFloat . TypeSpecifier ::= "float" ;
MkTypeSpecifierDouble . TypeSpecifier ::= "double" ;
MkTypeSpecifierSigned . TypeSpecifier ::= "signed" ;
MkTypeSpecifierUnsigned . TypeSpecifier ::= "unsigned" ;
MkTypeSpecifierStructOrUnion . TypeSpecifier ::= StructOrUnionSpecifier ;
MkTypeSpecifierEnumSpecifier . TypeSpecifier ::= EnumSpecifier ;
-- MkTypeSpecifierTypedefName . TypeSpecifier ::= TypedefName ;
MkTypeQualifierConst . TypeQualifier ::= "const" ;
MkTypeQualifierVolatile . TypeQualifier ::= "volatile" ;
MkStructOrUnionSpecifierWithFields . StructOrUnionSpecifier ::= StructOrUnion IdentifierOpt "{" [StructDeclaration] "}" ;
MkStructOrUnionSpecifierEmpty . StructOrUnionSpecifier ::= StructOrUnion Identifier ;
MkStructOrUnionStruct . StructOrUnion ::= "struct" ;
MkStructOrUnionUnion . StructOrUnion ::= "union" ;
(:[]) . [StructDeclaration] ::= StructDeclaration ;
(:) . [StructDeclaration] ::= StructDeclaration [StructDeclaration];
MkInitDeclarationListOptNothing . InitDeclarationListOpt ::= ;
MkInitDeclarationListOptJust . InitDeclarationListOpt ::= [InitDeclarator] ;
(:[]) . [InitDeclarator] ::= InitDeclarator ;
(:) . [InitDeclarator] ::= InitDeclarator "," [InitDeclarator];
MkInitDeclaratorUninitialized . InitDeclarator ::= Declarator ;
MkInitDeclaratorInitialized . InitDeclarator ::= Declarator "=" Initializer ;
MkStructDeclaration . StructDeclaration ::= [SpecifierQualifier] [StructDeclarator] ";" ;
(:[]) . [SpecifierQualifier] ::= SpecifierQualifier ;
(:) . [SpecifierQualifier] ::= SpecifierQualifier [SpecifierQualifier] ;
MkSpecifierQualifierTypeSpecifier . SpecifierQualifier ::= TypeSpecifier ;
MkSpecifierQualifierTypeQualifier . SpecifierQualifier ::= TypeQualifier ;
(:[]) . [StructDeclarator] ::= StructDeclarator ;
(:) . [StructDeclarator] ::= StructDeclarator "," [StructDeclarator] ;
MkStructDeclaratorDeclarator . StructDeclarator ::= Declarator ;
MkStructDeclaratorConstant . StructDeclarator ::= DeclaratorOpt ":" ConstantExpression ;
MkEnumSpecifierWithCases . EnumSpecifier ::= "enum" IdentifierOpt "{" EnumeratorList "}" ;
MkEnumSpecifierEmpty . EnumSpecifier ::= "enum" Identifier ;
MkEnumeratorList1 . EnumeratorList ::= Enumerator ;
MkEnumeratorListN . EnumeratorList ::= EnumeratorList "," Enumerator ;
MkEnumeratorUninitialized . Enumerator ::= Identifier ;
MkEnumeratorInitialized . Enumerator ::= Identifier "=" ConstantExpression ;
MkDeclaratorOptNothing . DeclaratorOpt ::= ;
MkDeclaratorOptJust . DeclaratorOpt ::= Declarator ;
MkDeclarator . Declarator ::= PointerOpt DirectDeclarator ;
MkDirectDeclaratorIdentifier . DirectDeclarator ::= Identifier ;
MkDirectDeclaratorParDeclarator . DirectDeclarator ::= "(" Declarator ")" ;
MkDirectDeclaratorConstantExpressionOpt . DirectDeclarator ::= DirectDeclarator "[" ConstantExpressionOpt "]" ;
MkDirectDeclaratorParameterTypeList . DirectDeclarator ::= DirectDeclarator "(" ParameterTypeList ")" ;
MkDirectDeclaratorIdentifierListOpt . DirectDeclarator ::= DirectDeclarator "(" IdentifierListOpt ")" ;
MkPointerOptNothing . PointerOpt ::= ;
MkPointerOptJust . PointerOpt ::= Pointer ;
MkPointer1 . Pointer ::= "*" TypeQualifierListOpt ;
MkPointerN . Pointer ::= "*" TypeQualifierListOpt Pointer ;
MkTypeQualifierListOptNothing . TypeQualifierListOpt ::= ;
MkTypeQualifierListOptJust . TypeQualifierListOpt ::= TypeQualifierList ;
MkTypeQualifierList1 . TypeQualifierList ::= TypeQualifier ;
MkTypeQualifierListN . TypeQualifierList ::= TypeQualifierList TypeQualifier ;
MkParameterTypeList . ParameterTypeList ::= ParameterList ;
MkParameterTypeListEllipsis . ParameterTypeList ::= ParameterList "," "..." ;
MkParameterList1 . ParameterList ::= ParameterDeclaration ;
MkParameterListN . ParameterList ::= ParameterList "," ParameterDeclaration ;
MkParameterDeclarationDeclarator . ParameterDeclaration ::= DeclarationSpecifiers Declarator ;
MkParameterDeclarationAbstractDeclaratorOpt . ParameterDeclaration ::= DeclarationSpecifiers AbstractDeclaratorOpt ;
MkIdentifierListOptNothing . IdentifierListOpt ::= ;
MkIdentifierListOptJust . IdentifierListOpt ::= IdentifierList ;
MkIdentifierList1 . IdentifierList ::= Identifier ;
MkIdentifierListN . IdentifierList ::= IdentifierList "," Identifier ;
MkInitializerAssignment . Initializer ::= Expression ;
MkInitializerIniutializerList . Initializer ::= "{" InitializerList "}" ;
MkInitializerIniutializerListC . Initializer ::= "{" InitializerList "," "}" ;
MkInitializerList1 . InitializerList ::= Initializer ;
MkInitializerListN . InitializerList ::= InitializerList "," Initializer ;
MkTypeName . TypeName ::= [SpecifierQualifier] AbstractDeclaratorOpt ;
MkAbstractDeclaratorOptNothing . AbstractDeclaratorOpt ::= ;
MkAbstractDeclaratorOptJust . AbstractDeclaratorOpt ::= AbstractDeclarator ;
MkAbstractDeclaratorPointer . AbstractDeclarator ::= Pointer ;
MkAbstractDeclaratorDirect . AbstractDeclarator ::= PointerOpt DirectAbstractDeclarator ;
MkDirectAbstractDeclaratorOptNothing . DirectAbstractDeclaratorOpt ::= ;
MkDirectAbstractDeclaratorOptJust . DirectAbstractDeclaratorOpt ::= DirectAbstractDeclarator ;
MkDirectAbstractDeclaratorPar . DirectAbstractDeclarator ::= "(" AbstractDeclarator ")" ;
MkDirectAbstractDeclaratorConstantExpressionOpt . DirectAbstractDeclarator ::= DirectAbstractDeclaratorOpt "[" ConstantExpressionOpt "]" ;
MkDirectAbstractDeclaratorParameterTypeList . DirectAbstractDeclarator ::= DirectAbstractDeclaratorOpt "(" ParameterTypeList ")" ;
-- MkTypedefName . TypedefName ::= Identifier ;
MkStatementLabeled . Statement ::= LabeledStatement ;
MkStatementExpression . Statement ::= ExpressionStatement ;
MkStatementCompound . Statement ::= CompoundStatement ;
MkStatementSelection . Statement ::= SelectionStatement ;
MkStatementIteration . Statement ::= IterationStatement ;
MkStatementJump . Statement ::= JumpStatement ;
MkLabeledStatementIdentifier . LabeledStatement ::= Identifier ":" Statement ;
MkLabeledStatementCase . LabeledStatement ::= "case" ConstantExpression ":" Statement ;
MkLabeledStatementDefault . LabeledStatement ::= "default" ":" Statement ;
MkExpressionStatement . ExpressionStatement ::= ExpressionOpt ";" ;
MkCompoundStatement . CompoundStatement ::= "{" [Declaration] [Statement] "}" ;
[] . [Statement] ::= ;
(:) . [Statement] ::= Statement [Statement] ;
MkSelectionStatementIfThen . SelectionStatement ::= "if" "(" Expression ")" Statement ;
MkSelectionStatementIfThenElse . SelectionStatement ::= "if" "(" Expression ")" Statement "else" Statement ;
MkSelectionStatementSwitch . SelectionStatement ::= "switch" "(" Expression ")" Statement ;
MkIterationStatementWhile . IterationStatement ::= "while" "(" Expression ")" Statement ;
MkIterationStatementDo . IterationStatement ::= "do" Statement "while" "(" Expression ")" ";" ;
MkIterationStatementFor . IterationStatement ::= "for" "(" ExpressionOpt ";" ExpressionOpt ";" ExpressionOpt ")" Statement ;
MkJumpStatementGoto . JumpStatement ::= "goto" Identifier ";" ;
MkJumpStatementContinue . JumpStatement ::= "continue" ";" ;
MkJumpStatementBreak . JumpStatement ::= "break" ";" ;
MkJumpStatementReturn . JumpStatement ::= "return" ExpressionOpt ";" ;
MkExpressionOptNothing . ExpressionOpt ::= ;
MkExpressionOptJust . ExpressionOpt ::= Expression ;
coercions Expression 12 ;
Expression12 . Expression12 ::= CastExpression ;
Expression11 . Expression11 ::= Expression11 MultOp Expression12 ;
Expression10 . Expression10 ::= Expression10 AddOp Expression11 ;
Expression9 . Expression9 ::= Expression9 ShiftOp Expression10 ;
Expression8 . Expression8 ::= Expression8 RelOp Expression9 ;
Expression7 . Expression7 ::= Expression7 EqOp Expression8 ;
Expression6 . Expression6 ::= Expression6 "^" Expression7 ;
Expression5 . Expression5 ::= Expression5 "|" Expression6 ;
Expression4 . Expression4 ::= Expression4 "&&" Expression5 ;
Expression3 . Expression3 ::= Expression3 "||" Expression4 ;
Expression2 . Expression2 ::= Expression3 "?" Expression ":" Expression2 ;
Expression1 . Expression1 ::= UnaryExpression AssignmentOperator Expression2 ;
Expression . Expression ::= Expression "," Expression1;
(:[]) . [Expression1] ::= Expression1 ;
(:) . [Expression1] ::= Expression1 "," [Expression1] ;
MkAssignmentOperatorAssign . AssignmentOperator ::= "=" ;
MkAssignmentOperatorTimes . AssignmentOperator ::= "*=" ;
MkAssignmentOperatorDiv . AssignmentOperator ::= "/=" ;
MkAssignmentOperatorMod . AssignmentOperator ::= "%=" ;
MkAssignmentOperatorPlus . AssignmentOperator ::= "+=" ;
MkAssignmentOperatorMinus . AssignmentOperator ::= "-=" ;
MkAssignmentOperatorShiftL . AssignmentOperator ::= "<<=" ;
MkAssignmentOperatorShiftR . AssignmentOperator ::= ">>=" ;
MkAssignmentOperatorAnd . AssignmentOperator ::= "&=" ;
MkAssignmentOperatorXOr . AssignmentOperator ::= "^=" ;
MkAssignmentOperatorOr . AssignmentOperator ::= "|=" ;
MkConditionalExpressionNothing . ConstantExpressionOpt ::= ;
MkConditionalExpressionJust . ConstantExpressionOpt ::= ConstantExpression ;
-- Should be Expression2
MkConstantExpression . ConstantExpression ::= Expression2 ;
EqOpEq . EqOp ::= "==" ;
EqOpNeq . EqOp ::= "!=" ;
RelOpLT . RelOp ::= "<" ;
RelOpGT . RelOp ::= ">" ;
RelOpLE . RelOp ::= "<=" ;
RelOpGE . RelOp ::= ">=" ;
ShiftOpLeft . ShiftOp ::= "<<" ;
ShiftOpRight . ShiftOp ::= ">>" ;
AddOpPlus . AddOp ::= "+" ;
AddOpMinus . AddOp ::= "-" ;
MultOpTimes . MultOp ::= "*" ;
MultOpDiv . MultOp ::= "/" ;
MultOpMod . MultOp ::= "%" ;
MkCastExpression1 . CastExpression ::= UnaryExpression ;
MkCastExpressionN . CastExpression ::= "(" TypeName ")" CastExpression ;
MkUnaryExpressionPostfix . UnaryExpression ::= PostfixExpression ;
MkUnaryExpressionPlus2 . UnaryExpression ::= "++" UnaryExpression ;
MkUnaryExpressionMinus2 . UnaryExpression ::= "--" UnaryExpression ;
MkUnaryExpressionUnaryOp . UnaryExpression ::= UnaryOperator CastExpression ;
MkUnaryExpressionSizeof1 . UnaryExpression ::= "sizeof" UnaryExpression ;
MkUnaryExpressionSizeofPar . UnaryExpression ::= "sizeof" "(" TypeName ")" ;
MkUnaryOperatorAnd . UnaryOperator ::= "&" ;
MkUnaryOperatorTimes . UnaryOperator ::= "*" ;
MkUnaryOperatorPlus . UnaryOperator ::= "+" ;
MkUnaryOperatorMinus . UnaryOperator ::= "-" ;
MkUnaryOperatorTilde . UnaryOperator ::= "~" ;
MkUnaryOperatorBang . UnaryOperator ::= "!" ;
MkPostfixExpression1 . PostfixExpression ::= PrimaryExpression ;
MkPostfixExpressionBrackets . PostfixExpression ::= PostfixExpression "[" Expression "]" ;
MkPostfixExpressionArgumentExpressionListOpt . PostfixExpression ::= PostfixExpression "(" ArgumentExpressionListOpt ")" ;
MkPostfixExpressionDot . PostfixExpression ::= PostfixExpression "." Identifier ;
MkPostfixExpressionArrow . PostfixExpression ::= PostfixExpression "->" Identifier ;
MkPostfixExpressionPlus2 . PostfixExpression ::= PostfixExpression "++" ;
MkPostfixExpressionMinus2 . PostfixExpression ::= PostfixExpression "--" ;
MkPrimaryExpressionIdentifier . PrimaryExpression ::= Identifier ;
MkPrimaryExpressionConstant . PrimaryExpression ::= Constant ;
MkPrimaryExpressionString . PrimaryExpression ::= String ;
MkPrimaryExpressionParExpression . PrimaryExpression ::= "(" Expression ")" ;
MkArgumentExpressionListOptNothing . ArgumentExpressionListOpt ::= ;
MkArgumentExpressionListOptJust . ArgumentExpressionListOpt ::= [Expression1] ;
MkConstantInteger . Constant ::= IntegerConstant ;
MkConstantCharacter . Constant ::= CharacterConstant ;
MkConstantFloating . Constant ::= FloatingConstant ;
-- MkConstantEnumeration . Constant ::= EnumerationConstant ;
MkIdentifierOptNothing . IdentifierOpt ::= ;
MkIdentifierOptJust . IdentifierOpt ::= Identifier ;
MkCharacterConstant . CharacterConstant ::= Char ;
MkFloatingConstant . FloatingConstant ::= Double ;
comment "/*" "*/" ;
comment "//" ;
comment "#" ;