b66ac2d8d5450f857cd069f34cebec9d7161274c
[mirror_edk2.git] / BaseTools / Source / Python / Ecc / CParser.py
1 # $ANTLR 3.0.1 C.g 2010-02-23 09:58:53
2
3 from __future__ import print_function
4 from antlr3 import *
5 from antlr3.compat import set, frozenset
6
7 ## @file
8 # The file defines the parser for C source files.
9 #
10 # THIS FILE IS AUTO-GENENERATED. PLEASE DON NOT MODIFY THIS FILE.
11 # This file is generated by running:
12 # java org.antlr.Tool C.g
13 #
14 # Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
15 #
16 # This program and the accompanying materials are licensed and made available
17 # under the terms and conditions of the BSD License which accompanies this
18 # distribution. The full text of the license may be found at:
19 # http://opensource.org/licenses/bsd-license.php
20 #
21 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
22 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
23 #
24 ##
25
26 import CodeFragment
27 import FileProfile
28
29
30
31 # for convenience in actions
32 HIDDEN = BaseRecognizer.HIDDEN
33
34 # token types
35 BS=20
36 LINE_COMMENT=23
37 FloatTypeSuffix=16
38 IntegerTypeSuffix=14
39 LETTER=11
40 OCTAL_LITERAL=6
41 CHARACTER_LITERAL=8
42 Exponent=15
43 EOF=-1
44 HexDigit=13
45 STRING_LITERAL=9
46 WS=19
47 FLOATING_POINT_LITERAL=10
48 IDENTIFIER=4
49 UnicodeEscape=18
50 LINE_COMMAND=24
51 UnicodeVocabulary=21
52 HEX_LITERAL=5
53 COMMENT=22
54 DECIMAL_LITERAL=7
55 EscapeSequence=12
56 OctalEscape=17
57
58 # token names
59 tokenNames = [
60 "<invalid>", "<EOR>", "<DOWN>", "<UP>",
61 "IDENTIFIER", "HEX_LITERAL", "OCTAL_LITERAL", "DECIMAL_LITERAL", "CHARACTER_LITERAL",
62 "STRING_LITERAL", "FLOATING_POINT_LITERAL", "LETTER", "EscapeSequence",
63 "HexDigit", "IntegerTypeSuffix", "Exponent", "FloatTypeSuffix", "OctalEscape",
64 "UnicodeEscape", "WS", "BS", "UnicodeVocabulary", "COMMENT", "LINE_COMMENT",
65 "LINE_COMMAND", "';'", "'typedef'", "','", "'='", "'extern'", "'static'",
66 "'auto'", "'register'", "'STATIC'", "'void'", "'char'", "'short'", "'int'",
67 "'long'", "'float'", "'double'", "'signed'", "'unsigned'", "'{'", "'}'",
68 "'struct'", "'union'", "':'", "'enum'", "'const'", "'volatile'", "'IN'",
69 "'OUT'", "'OPTIONAL'", "'CONST'", "'UNALIGNED'", "'VOLATILE'", "'GLOBAL_REMOVE_IF_UNREFERENCED'",
70 "'EFIAPI'", "'EFI_BOOTSERVICE'", "'EFI_RUNTIMESERVICE'", "'PACKED'",
71 "'('", "')'", "'['", "']'", "'*'", "'...'", "'+'", "'-'", "'/'", "'%'",
72 "'++'", "'--'", "'sizeof'", "'.'", "'->'", "'&'", "'~'", "'!'", "'*='",
73 "'/='", "'%='", "'+='", "'-='", "'<<='", "'>>='", "'&='", "'^='", "'|='",
74 "'?'", "'||'", "'&&'", "'|'", "'^'", "'=='", "'!='", "'<'", "'>'", "'<='",
75 "'>='", "'<<'", "'>>'", "'__asm__'", "'_asm'", "'__asm'", "'case'",
76 "'default'", "'if'", "'else'", "'switch'", "'while'", "'do'", "'for'",
77 "'goto'", "'continue'", "'break'", "'return'"
78 ]
79
80
81 class function_definition_scope(object):
82 def __init__(self):
83 self.ModifierText = None
84 self.DeclText = None
85 self.LBLine = None
86 self.LBOffset = None
87 self.DeclLine = None
88 self.DeclOffset = None
89 class postfix_expression_scope(object):
90 def __init__(self):
91 self.FuncCallText = None
92
93
94 class CParser(Parser):
95 grammarFileName = "C.g"
96 tokenNames = tokenNames
97
98 def __init__(self, input):
99 Parser.__init__(self, input)
100 self.ruleMemo = {}
101
102 self.function_definition_stack = []
103 self.postfix_expression_stack = []
104
105 def printTokenInfo(self, line, offset, tokenText):
106 print(str(line)+ ',' + str(offset) + ':' + str(tokenText))
107
108 def StorePredicateExpression(self, StartLine, StartOffset, EndLine, EndOffset, Text):
109 PredExp = CodeFragment.PredicateExpression(Text, (StartLine, StartOffset), (EndLine, EndOffset))
110 FileProfile.PredicateExpressionList.append(PredExp)
111
112 def StoreEnumerationDefinition(self, StartLine, StartOffset, EndLine, EndOffset, Text):
113 EnumDef = CodeFragment.EnumerationDefinition(Text, (StartLine, StartOffset), (EndLine, EndOffset))
114 FileProfile.EnumerationDefinitionList.append(EnumDef)
115
116 def StoreStructUnionDefinition(self, StartLine, StartOffset, EndLine, EndOffset, Text):
117 SUDef = CodeFragment.StructUnionDefinition(Text, (StartLine, StartOffset), (EndLine, EndOffset))
118 FileProfile.StructUnionDefinitionList.append(SUDef)
119
120 def StoreTypedefDefinition(self, StartLine, StartOffset, EndLine, EndOffset, FromText, ToText):
121 Tdef = CodeFragment.TypedefDefinition(FromText, ToText, (StartLine, StartOffset), (EndLine, EndOffset))
122 FileProfile.TypedefDefinitionList.append(Tdef)
123
124 def StoreFunctionDefinition(self, StartLine, StartOffset, EndLine, EndOffset, ModifierText, DeclText, LeftBraceLine, LeftBraceOffset, DeclLine, DeclOffset):
125 FuncDef = CodeFragment.FunctionDefinition(ModifierText, DeclText, (StartLine, StartOffset), (EndLine, EndOffset), (LeftBraceLine, LeftBraceOffset), (DeclLine, DeclOffset))
126 FileProfile.FunctionDefinitionList.append(FuncDef)
127
128 def StoreVariableDeclaration(self, StartLine, StartOffset, EndLine, EndOffset, ModifierText, DeclText):
129 VarDecl = CodeFragment.VariableDeclaration(ModifierText, DeclText, (StartLine, StartOffset), (EndLine, EndOffset))
130 FileProfile.VariableDeclarationList.append(VarDecl)
131
132 def StoreFunctionCalling(self, StartLine, StartOffset, EndLine, EndOffset, FuncName, ParamList):
133 FuncCall = CodeFragment.FunctionCalling(FuncName, ParamList, (StartLine, StartOffset), (EndLine, EndOffset))
134 FileProfile.FunctionCallingList.append(FuncCall)
135
136
137
138
139 # $ANTLR start translation_unit
140 # C.g:102:1: translation_unit : ( external_declaration )* ;
141 def translation_unit(self, ):
142
143 translation_unit_StartIndex = self.input.index()
144 try:
145 try:
146 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 1):
147 return
148
149 # C.g:103:2: ( ( external_declaration )* )
150 # C.g:103:4: ( external_declaration )*
151 # C.g:103:4: ( external_declaration )*
152 while True: #loop1
153 alt1 = 2
154 LA1_0 = self.input.LA(1)
155
156 if (LA1_0 == IDENTIFIER or LA1_0 == 26 or (29 <= LA1_0 <= 42) or (45 <= LA1_0 <= 46) or (48 <= LA1_0 <= 62) or LA1_0 == 66) :
157 alt1 = 1
158
159
160 if alt1 == 1:
161 # C.g:0:0: external_declaration
162 self.following.append(self.FOLLOW_external_declaration_in_translation_unit74)
163 self.external_declaration()
164 self.following.pop()
165 if self.failed:
166 return
167
168
169 else:
170 break #loop1
171
172
173
174
175
176
177 except RecognitionException as re:
178 self.reportError(re)
179 self.recover(self.input, re)
180 finally:
181 if self.backtracking > 0:
182 self.memoize(self.input, 1, translation_unit_StartIndex)
183
184 pass
185
186 return
187
188 # $ANTLR end translation_unit
189
190
191 # $ANTLR start external_declaration
192 # C.g:114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );
193 def external_declaration(self, ):
194
195 external_declaration_StartIndex = self.input.index()
196 try:
197 try:
198 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 2):
199 return
200
201 # C.g:119:2: ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? )
202 alt3 = 3
203 LA3_0 = self.input.LA(1)
204
205 if ((29 <= LA3_0 <= 33)) :
206 LA3_1 = self.input.LA(2)
207
208 if (self.synpred4()) :
209 alt3 = 1
210 elif (self.synpred5()) :
211 alt3 = 2
212 else:
213 if self.backtracking > 0:
214 self.failed = True
215 return
216
217 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 1, self.input)
218
219 raise nvae
220
221 elif (LA3_0 == 34) :
222 LA3_2 = self.input.LA(2)
223
224 if (self.synpred4()) :
225 alt3 = 1
226 elif (self.synpred5()) :
227 alt3 = 2
228 else:
229 if self.backtracking > 0:
230 self.failed = True
231 return
232
233 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 2, self.input)
234
235 raise nvae
236
237 elif (LA3_0 == 35) :
238 LA3_3 = self.input.LA(2)
239
240 if (self.synpred4()) :
241 alt3 = 1
242 elif (self.synpred5()) :
243 alt3 = 2
244 else:
245 if self.backtracking > 0:
246 self.failed = True
247 return
248
249 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 3, self.input)
250
251 raise nvae
252
253 elif (LA3_0 == 36) :
254 LA3_4 = self.input.LA(2)
255
256 if (self.synpred4()) :
257 alt3 = 1
258 elif (self.synpred5()) :
259 alt3 = 2
260 else:
261 if self.backtracking > 0:
262 self.failed = True
263 return
264
265 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 4, self.input)
266
267 raise nvae
268
269 elif (LA3_0 == 37) :
270 LA3_5 = self.input.LA(2)
271
272 if (self.synpred4()) :
273 alt3 = 1
274 elif (self.synpred5()) :
275 alt3 = 2
276 else:
277 if self.backtracking > 0:
278 self.failed = True
279 return
280
281 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 5, self.input)
282
283 raise nvae
284
285 elif (LA3_0 == 38) :
286 LA3_6 = self.input.LA(2)
287
288 if (self.synpred4()) :
289 alt3 = 1
290 elif (self.synpred5()) :
291 alt3 = 2
292 else:
293 if self.backtracking > 0:
294 self.failed = True
295 return
296
297 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 6, self.input)
298
299 raise nvae
300
301 elif (LA3_0 == 39) :
302 LA3_7 = self.input.LA(2)
303
304 if (self.synpred4()) :
305 alt3 = 1
306 elif (self.synpred5()) :
307 alt3 = 2
308 else:
309 if self.backtracking > 0:
310 self.failed = True
311 return
312
313 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 7, self.input)
314
315 raise nvae
316
317 elif (LA3_0 == 40) :
318 LA3_8 = self.input.LA(2)
319
320 if (self.synpred4()) :
321 alt3 = 1
322 elif (self.synpred5()) :
323 alt3 = 2
324 else:
325 if self.backtracking > 0:
326 self.failed = True
327 return
328
329 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 8, self.input)
330
331 raise nvae
332
333 elif (LA3_0 == 41) :
334 LA3_9 = self.input.LA(2)
335
336 if (self.synpred4()) :
337 alt3 = 1
338 elif (self.synpred5()) :
339 alt3 = 2
340 else:
341 if self.backtracking > 0:
342 self.failed = True
343 return
344
345 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 9, self.input)
346
347 raise nvae
348
349 elif (LA3_0 == 42) :
350 LA3_10 = self.input.LA(2)
351
352 if (self.synpred4()) :
353 alt3 = 1
354 elif (self.synpred5()) :
355 alt3 = 2
356 else:
357 if self.backtracking > 0:
358 self.failed = True
359 return
360
361 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 10, self.input)
362
363 raise nvae
364
365 elif ((45 <= LA3_0 <= 46)) :
366 LA3_11 = self.input.LA(2)
367
368 if (self.synpred4()) :
369 alt3 = 1
370 elif (self.synpred5()) :
371 alt3 = 2
372 else:
373 if self.backtracking > 0:
374 self.failed = True
375 return
376
377 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 11, self.input)
378
379 raise nvae
380
381 elif (LA3_0 == 48) :
382 LA3_12 = self.input.LA(2)
383
384 if (self.synpred4()) :
385 alt3 = 1
386 elif (self.synpred5()) :
387 alt3 = 2
388 else:
389 if self.backtracking > 0:
390 self.failed = True
391 return
392
393 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 12, self.input)
394
395 raise nvae
396
397 elif (LA3_0 == IDENTIFIER) :
398 LA3_13 = self.input.LA(2)
399
400 if (self.synpred4()) :
401 alt3 = 1
402 elif (self.synpred5()) :
403 alt3 = 2
404 elif (True) :
405 alt3 = 3
406 else:
407 if self.backtracking > 0:
408 self.failed = True
409 return
410
411 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 13, self.input)
412
413 raise nvae
414
415 elif (LA3_0 == 58) :
416 LA3_14 = self.input.LA(2)
417
418 if (self.synpred4()) :
419 alt3 = 1
420 elif (self.synpred5()) :
421 alt3 = 2
422 else:
423 if self.backtracking > 0:
424 self.failed = True
425 return
426
427 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 14, self.input)
428
429 raise nvae
430
431 elif (LA3_0 == 66) and (self.synpred4()):
432 alt3 = 1
433 elif (LA3_0 == 59) :
434 LA3_16 = self.input.LA(2)
435
436 if (self.synpred4()) :
437 alt3 = 1
438 elif (self.synpred5()) :
439 alt3 = 2
440 else:
441 if self.backtracking > 0:
442 self.failed = True
443 return
444
445 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 16, self.input)
446
447 raise nvae
448
449 elif (LA3_0 == 60) :
450 LA3_17 = self.input.LA(2)
451
452 if (self.synpred4()) :
453 alt3 = 1
454 elif (self.synpred5()) :
455 alt3 = 2
456 else:
457 if self.backtracking > 0:
458 self.failed = True
459 return
460
461 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 17, self.input)
462
463 raise nvae
464
465 elif ((49 <= LA3_0 <= 57) or LA3_0 == 61) :
466 LA3_18 = self.input.LA(2)
467
468 if (self.synpred4()) :
469 alt3 = 1
470 elif (self.synpred5()) :
471 alt3 = 2
472 else:
473 if self.backtracking > 0:
474 self.failed = True
475 return
476
477 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 18, self.input)
478
479 raise nvae
480
481 elif (LA3_0 == 62) and (self.synpred4()):
482 alt3 = 1
483 elif (LA3_0 == 26) :
484 alt3 = 2
485 else:
486 if self.backtracking > 0:
487 self.failed = True
488 return
489
490 nvae = NoViableAltException("114:1: external_declaration options {k=1; } : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition | declaration | macro_statement ( ';' )? );", 3, 0, self.input)
491
492 raise nvae
493
494 if alt3 == 1:
495 # C.g:119:4: ( ( declaration_specifiers )? declarator ( declaration )* '{' )=> function_definition
496 self.following.append(self.FOLLOW_function_definition_in_external_declaration113)
497 self.function_definition()
498 self.following.pop()
499 if self.failed:
500 return
501
502
503 elif alt3 == 2:
504 # C.g:120:4: declaration
505 self.following.append(self.FOLLOW_declaration_in_external_declaration118)
506 self.declaration()
507 self.following.pop()
508 if self.failed:
509 return
510
511
512 elif alt3 == 3:
513 # C.g:121:4: macro_statement ( ';' )?
514 self.following.append(self.FOLLOW_macro_statement_in_external_declaration123)
515 self.macro_statement()
516 self.following.pop()
517 if self.failed:
518 return
519 # C.g:121:20: ( ';' )?
520 alt2 = 2
521 LA2_0 = self.input.LA(1)
522
523 if (LA2_0 == 25) :
524 alt2 = 1
525 if alt2 == 1:
526 # C.g:121:21: ';'
527 self.match(self.input, 25, self.FOLLOW_25_in_external_declaration126)
528 if self.failed:
529 return
530
531
532
533
534
535
536 except RecognitionException as re:
537 self.reportError(re)
538 self.recover(self.input, re)
539 finally:
540 if self.backtracking > 0:
541 self.memoize(self.input, 2, external_declaration_StartIndex)
542
543 pass
544
545 return
546
547 # $ANTLR end external_declaration
548
549 class function_definition_return(object):
550 def __init__(self):
551 self.start = None
552 self.stop = None
553
554
555
556 # $ANTLR start function_definition
557 # C.g:126:1: function_definition : (d= declaration_specifiers )? declarator ( ( declaration )+ a= compound_statement | b= compound_statement ) ;
558 def function_definition(self, ):
559 self.function_definition_stack.append(function_definition_scope())
560 retval = self.function_definition_return()
561 retval.start = self.input.LT(1)
562 function_definition_StartIndex = self.input.index()
563 d = None
564
565 a = None
566
567 b = None
568
569 declarator1 = None
570
571
572
573 self.function_definition_stack[-1].ModifierText = ''
574 self.function_definition_stack[-1].DeclText = ''
575 self.function_definition_stack[-1].LBLine = 0
576 self.function_definition_stack[-1].LBOffset = 0
577 self.function_definition_stack[-1].DeclLine = 0
578 self.function_definition_stack[-1].DeclOffset = 0
579
580 try:
581 try:
582 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 3):
583 return retval
584
585 # C.g:146:2: ( (d= declaration_specifiers )? declarator ( ( declaration )+ a= compound_statement | b= compound_statement ) )
586 # C.g:146:4: (d= declaration_specifiers )? declarator ( ( declaration )+ a= compound_statement | b= compound_statement )
587 # C.g:146:5: (d= declaration_specifiers )?
588 alt4 = 2
589 LA4 = self.input.LA(1)
590 if LA4 == 29 or LA4 == 30 or LA4 == 31 or LA4 == 32 or LA4 == 33 or LA4 == 34 or LA4 == 35 or LA4 == 36 or LA4 == 37 or LA4 == 38 or LA4 == 39 or LA4 == 40 or LA4 == 41 or LA4 == 42 or LA4 == 45 or LA4 == 46 or LA4 == 48 or LA4 == 49 or LA4 == 50 or LA4 == 51 or LA4 == 52 or LA4 == 53 or LA4 == 54 or LA4 == 55 or LA4 == 56 or LA4 == 57 or LA4 == 61:
591 alt4 = 1
592 elif LA4 == IDENTIFIER:
593 LA4 = self.input.LA(2)
594 if LA4 == 66:
595 alt4 = 1
596 elif LA4 == 58:
597 LA4_21 = self.input.LA(3)
598
599 if (self.synpred7()) :
600 alt4 = 1
601 elif LA4 == 59:
602 LA4_22 = self.input.LA(3)
603
604 if (self.synpred7()) :
605 alt4 = 1
606 elif LA4 == 60:
607 LA4_23 = self.input.LA(3)
608
609 if (self.synpred7()) :
610 alt4 = 1
611 elif LA4 == IDENTIFIER:
612 LA4_24 = self.input.LA(3)
613
614 if (self.synpred7()) :
615 alt4 = 1
616 elif LA4 == 62:
617 LA4_25 = self.input.LA(3)
618
619 if (self.synpred7()) :
620 alt4 = 1
621 elif LA4 == 29 or LA4 == 30 or LA4 == 31 or LA4 == 32 or LA4 == 33:
622 LA4_26 = self.input.LA(3)
623
624 if (self.synpred7()) :
625 alt4 = 1
626 elif LA4 == 34:
627 LA4_27 = self.input.LA(3)
628
629 if (self.synpred7()) :
630 alt4 = 1
631 elif LA4 == 35:
632 LA4_28 = self.input.LA(3)
633
634 if (self.synpred7()) :
635 alt4 = 1
636 elif LA4 == 36:
637 LA4_29 = self.input.LA(3)
638
639 if (self.synpred7()) :
640 alt4 = 1
641 elif LA4 == 37:
642 LA4_30 = self.input.LA(3)
643
644 if (self.synpred7()) :
645 alt4 = 1
646 elif LA4 == 38:
647 LA4_31 = self.input.LA(3)
648
649 if (self.synpred7()) :
650 alt4 = 1
651 elif LA4 == 39:
652 LA4_32 = self.input.LA(3)
653
654 if (self.synpred7()) :
655 alt4 = 1
656 elif LA4 == 40:
657 LA4_33 = self.input.LA(3)
658
659 if (self.synpred7()) :
660 alt4 = 1
661 elif LA4 == 41:
662 LA4_34 = self.input.LA(3)
663
664 if (self.synpred7()) :
665 alt4 = 1
666 elif LA4 == 42:
667 LA4_35 = self.input.LA(3)
668
669 if (self.synpred7()) :
670 alt4 = 1
671 elif LA4 == 45 or LA4 == 46:
672 LA4_36 = self.input.LA(3)
673
674 if (self.synpred7()) :
675 alt4 = 1
676 elif LA4 == 48:
677 LA4_37 = self.input.LA(3)
678
679 if (self.synpred7()) :
680 alt4 = 1
681 elif LA4 == 49 or LA4 == 50 or LA4 == 51 or LA4 == 52 or LA4 == 53 or LA4 == 54 or LA4 == 55 or LA4 == 56 or LA4 == 57 or LA4 == 61:
682 LA4_38 = self.input.LA(3)
683
684 if (self.synpred7()) :
685 alt4 = 1
686 elif LA4 == 58:
687 LA4_14 = self.input.LA(2)
688
689 if (self.synpred7()) :
690 alt4 = 1
691 elif LA4 == 59:
692 LA4_16 = self.input.LA(2)
693
694 if (self.synpred7()) :
695 alt4 = 1
696 elif LA4 == 60:
697 LA4_17 = self.input.LA(2)
698
699 if (self.synpred7()) :
700 alt4 = 1
701 if alt4 == 1:
702 # C.g:0:0: d= declaration_specifiers
703 self.following.append(self.FOLLOW_declaration_specifiers_in_function_definition157)
704 d = self.declaration_specifiers()
705 self.following.pop()
706 if self.failed:
707 return retval
708
709
710
711 self.following.append(self.FOLLOW_declarator_in_function_definition160)
712 declarator1 = self.declarator()
713 self.following.pop()
714 if self.failed:
715 return retval
716 # C.g:147:3: ( ( declaration )+ a= compound_statement | b= compound_statement )
717 alt6 = 2
718 LA6_0 = self.input.LA(1)
719
720 if (LA6_0 == IDENTIFIER or LA6_0 == 26 or (29 <= LA6_0 <= 42) or (45 <= LA6_0 <= 46) or (48 <= LA6_0 <= 61)) :
721 alt6 = 1
722 elif (LA6_0 == 43) :
723 alt6 = 2
724 else:
725 if self.backtracking > 0:
726 self.failed = True
727 return retval
728
729 nvae = NoViableAltException("147:3: ( ( declaration )+ a= compound_statement | b= compound_statement )", 6, 0, self.input)
730
731 raise nvae
732
733 if alt6 == 1:
734 # C.g:147:5: ( declaration )+ a= compound_statement
735 # C.g:147:5: ( declaration )+
736 cnt5 = 0
737 while True: #loop5
738 alt5 = 2
739 LA5_0 = self.input.LA(1)
740
741 if (LA5_0 == IDENTIFIER or LA5_0 == 26 or (29 <= LA5_0 <= 42) or (45 <= LA5_0 <= 46) or (48 <= LA5_0 <= 61)) :
742 alt5 = 1
743
744
745 if alt5 == 1:
746 # C.g:0:0: declaration
747 self.following.append(self.FOLLOW_declaration_in_function_definition166)
748 self.declaration()
749 self.following.pop()
750 if self.failed:
751 return retval
752
753
754 else:
755 if cnt5 >= 1:
756 break #loop5
757
758 if self.backtracking > 0:
759 self.failed = True
760 return retval
761
762 eee = EarlyExitException(5, self.input)
763 raise eee
764
765 cnt5 += 1
766
767
768 self.following.append(self.FOLLOW_compound_statement_in_function_definition171)
769 a = self.compound_statement()
770 self.following.pop()
771 if self.failed:
772 return retval
773
774
775 elif alt6 == 2:
776 # C.g:148:5: b= compound_statement
777 self.following.append(self.FOLLOW_compound_statement_in_function_definition180)
778 b = self.compound_statement()
779 self.following.pop()
780 if self.failed:
781 return retval
782
783
784
785 if self.backtracking == 0:
786
787 if d is not None:
788 self.function_definition_stack[-1].ModifierText = self.input.toString(d.start, d.stop)
789 else:
790 self.function_definition_stack[-1].ModifierText = ''
791 self.function_definition_stack[-1].DeclText = self.input.toString(declarator1.start, declarator1.stop)
792 self.function_definition_stack[-1].DeclLine = declarator1.start.line
793 self.function_definition_stack[-1].DeclOffset = declarator1.start.charPositionInLine
794 if a is not None:
795 self.function_definition_stack[-1].LBLine = a.start.line
796 self.function_definition_stack[-1].LBOffset = a.start.charPositionInLine
797 else:
798 self.function_definition_stack[-1].LBLine = b.start.line
799 self.function_definition_stack[-1].LBOffset = b.start.charPositionInLine
800
801
802
803
804
805 retval.stop = self.input.LT(-1)
806
807 if self.backtracking == 0:
808
809 self.StoreFunctionDefinition(retval.start.line, retval.start.charPositionInLine, retval.stop.line, retval.stop.charPositionInLine, self.function_definition_stack[-1].ModifierText, self.function_definition_stack[-1].DeclText, self.function_definition_stack[-1].LBLine, self.function_definition_stack[-1].LBOffset, self.function_definition_stack[-1].DeclLine, self.function_definition_stack[-1].DeclOffset)
810
811
812
813 except RecognitionException as re:
814 self.reportError(re)
815 self.recover(self.input, re)
816 finally:
817 if self.backtracking > 0:
818 self.memoize(self.input, 3, function_definition_StartIndex)
819
820 self.function_definition_stack.pop()
821 pass
822
823 return retval
824
825 # $ANTLR end function_definition
826
827
828 # $ANTLR start declaration
829 # C.g:166:1: declaration : (a= 'typedef' (b= declaration_specifiers )? c= init_declarator_list d= ';' | s= declaration_specifiers (t= init_declarator_list )? e= ';' );
830 def declaration(self, ):
831
832 declaration_StartIndex = self.input.index()
833 a = None
834 d = None
835 e = None
836 b = None
837
838 c = None
839
840 s = None
841
842 t = None
843
844
845 try:
846 try:
847 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 4):
848 return
849
850 # C.g:167:2: (a= 'typedef' (b= declaration_specifiers )? c= init_declarator_list d= ';' | s= declaration_specifiers (t= init_declarator_list )? e= ';' )
851 alt9 = 2
852 LA9_0 = self.input.LA(1)
853
854 if (LA9_0 == 26) :
855 alt9 = 1
856 elif (LA9_0 == IDENTIFIER or (29 <= LA9_0 <= 42) or (45 <= LA9_0 <= 46) or (48 <= LA9_0 <= 61)) :
857 alt9 = 2
858 else:
859 if self.backtracking > 0:
860 self.failed = True
861 return
862
863 nvae = NoViableAltException("166:1: declaration : (a= 'typedef' (b= declaration_specifiers )? c= init_declarator_list d= ';' | s= declaration_specifiers (t= init_declarator_list )? e= ';' );", 9, 0, self.input)
864
865 raise nvae
866
867 if alt9 == 1:
868 # C.g:167:4: a= 'typedef' (b= declaration_specifiers )? c= init_declarator_list d= ';'
869 a = self.input.LT(1)
870 self.match(self.input, 26, self.FOLLOW_26_in_declaration203)
871 if self.failed:
872 return
873 # C.g:167:17: (b= declaration_specifiers )?
874 alt7 = 2
875 LA7 = self.input.LA(1)
876 if LA7 == 29 or LA7 == 30 or LA7 == 31 or LA7 == 32 or LA7 == 33 or LA7 == 34 or LA7 == 35 or LA7 == 36 or LA7 == 37 or LA7 == 38 or LA7 == 39 or LA7 == 40 or LA7 == 41 or LA7 == 42 or LA7 == 45 or LA7 == 46 or LA7 == 48 or LA7 == 49 or LA7 == 50 or LA7 == 51 or LA7 == 52 or LA7 == 53 or LA7 == 54 or LA7 == 55 or LA7 == 56 or LA7 == 57 or LA7 == 61:
877 alt7 = 1
878 elif LA7 == IDENTIFIER:
879 LA7_13 = self.input.LA(2)
880
881 if (LA7_13 == 62) :
882 LA7_21 = self.input.LA(3)
883
884 if (self.synpred10()) :
885 alt7 = 1
886 elif (LA7_13 == IDENTIFIER or (29 <= LA7_13 <= 42) or (45 <= LA7_13 <= 46) or (48 <= LA7_13 <= 61) or LA7_13 == 66) :
887 alt7 = 1
888 elif LA7 == 58:
889 LA7_14 = self.input.LA(2)
890
891 if (self.synpred10()) :
892 alt7 = 1
893 elif LA7 == 59:
894 LA7_16 = self.input.LA(2)
895
896 if (self.synpred10()) :
897 alt7 = 1
898 elif LA7 == 60:
899 LA7_17 = self.input.LA(2)
900
901 if (self.synpred10()) :
902 alt7 = 1
903 if alt7 == 1:
904 # C.g:0:0: b= declaration_specifiers
905 self.following.append(self.FOLLOW_declaration_specifiers_in_declaration207)
906 b = self.declaration_specifiers()
907 self.following.pop()
908 if self.failed:
909 return
910
911
912
913 self.following.append(self.FOLLOW_init_declarator_list_in_declaration216)
914 c = self.init_declarator_list()
915 self.following.pop()
916 if self.failed:
917 return
918 d = self.input.LT(1)
919 self.match(self.input, 25, self.FOLLOW_25_in_declaration220)
920 if self.failed:
921 return
922 if self.backtracking == 0:
923
924 if b is not None:
925 self.StoreTypedefDefinition(a.line, a.charPositionInLine, d.line, d.charPositionInLine, self.input.toString(b.start, b.stop), self.input.toString(c.start, c.stop))
926 else:
927 self.StoreTypedefDefinition(a.line, a.charPositionInLine, d.line, d.charPositionInLine, '', self.input.toString(c.start, c.stop))
928
929
930
931
932 elif alt9 == 2:
933 # C.g:175:4: s= declaration_specifiers (t= init_declarator_list )? e= ';'
934 self.following.append(self.FOLLOW_declaration_specifiers_in_declaration234)
935 s = self.declaration_specifiers()
936 self.following.pop()
937 if self.failed:
938 return
939 # C.g:175:30: (t= init_declarator_list )?
940 alt8 = 2
941 LA8_0 = self.input.LA(1)
942
943 if (LA8_0 == IDENTIFIER or (58 <= LA8_0 <= 60) or LA8_0 == 62 or LA8_0 == 66) :
944 alt8 = 1
945 if alt8 == 1:
946 # C.g:0:0: t= init_declarator_list
947 self.following.append(self.FOLLOW_init_declarator_list_in_declaration238)
948 t = self.init_declarator_list()
949 self.following.pop()
950 if self.failed:
951 return
952
953
954
955 e = self.input.LT(1)
956 self.match(self.input, 25, self.FOLLOW_25_in_declaration243)
957 if self.failed:
958 return
959 if self.backtracking == 0:
960
961 if t is not None:
962 self.StoreVariableDeclaration(s.start.line, s.start.charPositionInLine, t.start.line, t.start.charPositionInLine, self.input.toString(s.start, s.stop), self.input.toString(t.start, t.stop))
963
964
965
966
967
968 except RecognitionException as re:
969 self.reportError(re)
970 self.recover(self.input, re)
971 finally:
972 if self.backtracking > 0:
973 self.memoize(self.input, 4, declaration_StartIndex)
974
975 pass
976
977 return
978
979 # $ANTLR end declaration
980
981 class declaration_specifiers_return(object):
982 def __init__(self):
983 self.start = None
984 self.stop = None
985
986
987
988 # $ANTLR start declaration_specifiers
989 # C.g:182:1: declaration_specifiers : ( storage_class_specifier | type_specifier | type_qualifier )+ ;
990 def declaration_specifiers(self, ):
991
992 retval = self.declaration_specifiers_return()
993 retval.start = self.input.LT(1)
994 declaration_specifiers_StartIndex = self.input.index()
995 try:
996 try:
997 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 5):
998 return retval
999
1000 # C.g:183:2: ( ( storage_class_specifier | type_specifier | type_qualifier )+ )
1001 # C.g:183:6: ( storage_class_specifier | type_specifier | type_qualifier )+
1002 # C.g:183:6: ( storage_class_specifier | type_specifier | type_qualifier )+
1003 cnt10 = 0
1004 while True: #loop10
1005 alt10 = 4
1006 LA10 = self.input.LA(1)
1007 if LA10 == 58:
1008 LA10_2 = self.input.LA(2)
1009
1010 if (self.synpred15()) :
1011 alt10 = 3
1012
1013
1014 elif LA10 == 59:
1015 LA10_3 = self.input.LA(2)
1016
1017 if (self.synpred15()) :
1018 alt10 = 3
1019
1020
1021 elif LA10 == 60:
1022 LA10_4 = self.input.LA(2)
1023
1024 if (self.synpred15()) :
1025 alt10 = 3
1026
1027
1028 elif LA10 == IDENTIFIER:
1029 LA10_5 = self.input.LA(2)
1030
1031 if (self.synpred14()) :
1032 alt10 = 2
1033
1034
1035 elif LA10 == 53:
1036 LA10_9 = self.input.LA(2)
1037
1038 if (self.synpred15()) :
1039 alt10 = 3
1040
1041
1042 elif LA10 == 29 or LA10 == 30 or LA10 == 31 or LA10 == 32 or LA10 == 33:
1043 alt10 = 1
1044 elif LA10 == 34 or LA10 == 35 or LA10 == 36 or LA10 == 37 or LA10 == 38 or LA10 == 39 or LA10 == 40 or LA10 == 41 or LA10 == 42 or LA10 == 45 or LA10 == 46 or LA10 == 48:
1045 alt10 = 2
1046 elif LA10 == 49 or LA10 == 50 or LA10 == 51 or LA10 == 52 or LA10 == 54 or LA10 == 55 or LA10 == 56 or LA10 == 57 or LA10 == 61:
1047 alt10 = 3
1048
1049 if alt10 == 1:
1050 # C.g:183:10: storage_class_specifier
1051 self.following.append(self.FOLLOW_storage_class_specifier_in_declaration_specifiers264)
1052 self.storage_class_specifier()
1053 self.following.pop()
1054 if self.failed:
1055 return retval
1056
1057
1058 elif alt10 == 2:
1059 # C.g:184:7: type_specifier
1060 self.following.append(self.FOLLOW_type_specifier_in_declaration_specifiers272)
1061 self.type_specifier()
1062 self.following.pop()
1063 if self.failed:
1064 return retval
1065
1066
1067 elif alt10 == 3:
1068 # C.g:185:13: type_qualifier
1069 self.following.append(self.FOLLOW_type_qualifier_in_declaration_specifiers286)
1070 self.type_qualifier()
1071 self.following.pop()
1072 if self.failed:
1073 return retval
1074
1075
1076 else:
1077 if cnt10 >= 1:
1078 break #loop10
1079
1080 if self.backtracking > 0:
1081 self.failed = True
1082 return retval
1083
1084 eee = EarlyExitException(10, self.input)
1085 raise eee
1086
1087 cnt10 += 1
1088
1089
1090
1091
1092
1093 retval.stop = self.input.LT(-1)
1094
1095
1096 except RecognitionException as re:
1097 self.reportError(re)
1098 self.recover(self.input, re)
1099 finally:
1100 if self.backtracking > 0:
1101 self.memoize(self.input, 5, declaration_specifiers_StartIndex)
1102
1103 pass
1104
1105 return retval
1106
1107 # $ANTLR end declaration_specifiers
1108
1109 class init_declarator_list_return(object):
1110 def __init__(self):
1111 self.start = None
1112 self.stop = None
1113
1114
1115
1116 # $ANTLR start init_declarator_list
1117 # C.g:189:1: init_declarator_list : init_declarator ( ',' init_declarator )* ;
1118 def init_declarator_list(self, ):
1119
1120 retval = self.init_declarator_list_return()
1121 retval.start = self.input.LT(1)
1122 init_declarator_list_StartIndex = self.input.index()
1123 try:
1124 try:
1125 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 6):
1126 return retval
1127
1128 # C.g:190:2: ( init_declarator ( ',' init_declarator )* )
1129 # C.g:190:4: init_declarator ( ',' init_declarator )*
1130 self.following.append(self.FOLLOW_init_declarator_in_init_declarator_list308)
1131 self.init_declarator()
1132 self.following.pop()
1133 if self.failed:
1134 return retval
1135 # C.g:190:20: ( ',' init_declarator )*
1136 while True: #loop11
1137 alt11 = 2
1138 LA11_0 = self.input.LA(1)
1139
1140 if (LA11_0 == 27) :
1141 alt11 = 1
1142
1143
1144 if alt11 == 1:
1145 # C.g:190:21: ',' init_declarator
1146 self.match(self.input, 27, self.FOLLOW_27_in_init_declarator_list311)
1147 if self.failed:
1148 return retval
1149 self.following.append(self.FOLLOW_init_declarator_in_init_declarator_list313)
1150 self.init_declarator()
1151 self.following.pop()
1152 if self.failed:
1153 return retval
1154
1155
1156 else:
1157 break #loop11
1158
1159
1160
1161
1162
1163 retval.stop = self.input.LT(-1)
1164
1165
1166 except RecognitionException as re:
1167 self.reportError(re)
1168 self.recover(self.input, re)
1169 finally:
1170 if self.backtracking > 0:
1171 self.memoize(self.input, 6, init_declarator_list_StartIndex)
1172
1173 pass
1174
1175 return retval
1176
1177 # $ANTLR end init_declarator_list
1178
1179
1180 # $ANTLR start init_declarator
1181 # C.g:193:1: init_declarator : declarator ( '=' initializer )? ;
1182 def init_declarator(self, ):
1183
1184 init_declarator_StartIndex = self.input.index()
1185 try:
1186 try:
1187 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 7):
1188 return
1189
1190 # C.g:194:2: ( declarator ( '=' initializer )? )
1191 # C.g:194:4: declarator ( '=' initializer )?
1192 self.following.append(self.FOLLOW_declarator_in_init_declarator326)
1193 self.declarator()
1194 self.following.pop()
1195 if self.failed:
1196 return
1197 # C.g:194:15: ( '=' initializer )?
1198 alt12 = 2
1199 LA12_0 = self.input.LA(1)
1200
1201 if (LA12_0 == 28) :
1202 alt12 = 1
1203 if alt12 == 1:
1204 # C.g:194:16: '=' initializer
1205 self.match(self.input, 28, self.FOLLOW_28_in_init_declarator329)
1206 if self.failed:
1207 return
1208 self.following.append(self.FOLLOW_initializer_in_init_declarator331)
1209 self.initializer()
1210 self.following.pop()
1211 if self.failed:
1212 return
1213
1214
1215
1216
1217
1218
1219
1220 except RecognitionException as re:
1221 self.reportError(re)
1222 self.recover(self.input, re)
1223 finally:
1224 if self.backtracking > 0:
1225 self.memoize(self.input, 7, init_declarator_StartIndex)
1226
1227 pass
1228
1229 return
1230
1231 # $ANTLR end init_declarator
1232
1233
1234 # $ANTLR start storage_class_specifier
1235 # C.g:197:1: storage_class_specifier : ( 'extern' | 'static' | 'auto' | 'register' | 'STATIC' );
1236 def storage_class_specifier(self, ):
1237
1238 storage_class_specifier_StartIndex = self.input.index()
1239 try:
1240 try:
1241 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 8):
1242 return
1243
1244 # C.g:198:2: ( 'extern' | 'static' | 'auto' | 'register' | 'STATIC' )
1245 # C.g:
1246 if (29 <= self.input.LA(1) <= 33):
1247 self.input.consume();
1248 self.errorRecovery = False
1249 self.failed = False
1250
1251 else:
1252 if self.backtracking > 0:
1253 self.failed = True
1254 return
1255
1256 mse = MismatchedSetException(None, self.input)
1257 self.recoverFromMismatchedSet(
1258 self.input, mse, self.FOLLOW_set_in_storage_class_specifier0
1259 )
1260 raise mse
1261
1262
1263
1264
1265
1266
1267 except RecognitionException as re:
1268 self.reportError(re)
1269 self.recover(self.input, re)
1270 finally:
1271 if self.backtracking > 0:
1272 self.memoize(self.input, 8, storage_class_specifier_StartIndex)
1273
1274 pass
1275
1276 return
1277
1278 # $ANTLR end storage_class_specifier
1279
1280
1281 # $ANTLR start type_specifier
1282 # C.g:205:1: type_specifier : ( 'void' | 'char' | 'short' | 'int' | 'long' | 'float' | 'double' | 'signed' | 'unsigned' | s= struct_or_union_specifier | e= enum_specifier | ( IDENTIFIER ( type_qualifier )* declarator )=> type_id );
1283 def type_specifier(self, ):
1284
1285 type_specifier_StartIndex = self.input.index()
1286 s = None
1287
1288 e = None
1289
1290
1291 try:
1292 try:
1293 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 9):
1294 return
1295
1296 # C.g:206:2: ( 'void' | 'char' | 'short' | 'int' | 'long' | 'float' | 'double' | 'signed' | 'unsigned' | s= struct_or_union_specifier | e= enum_specifier | ( IDENTIFIER ( type_qualifier )* declarator )=> type_id )
1297 alt13 = 12
1298 LA13_0 = self.input.LA(1)
1299
1300 if (LA13_0 == 34) :
1301 alt13 = 1
1302 elif (LA13_0 == 35) :
1303 alt13 = 2
1304 elif (LA13_0 == 36) :
1305 alt13 = 3
1306 elif (LA13_0 == 37) :
1307 alt13 = 4
1308 elif (LA13_0 == 38) :
1309 alt13 = 5
1310 elif (LA13_0 == 39) :
1311 alt13 = 6
1312 elif (LA13_0 == 40) :
1313 alt13 = 7
1314 elif (LA13_0 == 41) :
1315 alt13 = 8
1316 elif (LA13_0 == 42) :
1317 alt13 = 9
1318 elif ((45 <= LA13_0 <= 46)) :
1319 alt13 = 10
1320 elif (LA13_0 == 48) :
1321 alt13 = 11
1322 elif (LA13_0 == IDENTIFIER) and (self.synpred34()):
1323 alt13 = 12
1324 else:
1325 if self.backtracking > 0:
1326 self.failed = True
1327 return
1328
1329 nvae = NoViableAltException("205:1: type_specifier : ( 'void' | 'char' | 'short' | 'int' | 'long' | 'float' | 'double' | 'signed' | 'unsigned' | s= struct_or_union_specifier | e= enum_specifier | ( IDENTIFIER ( type_qualifier )* declarator )=> type_id );", 13, 0, self.input)
1330
1331 raise nvae
1332
1333 if alt13 == 1:
1334 # C.g:206:4: 'void'
1335 self.match(self.input, 34, self.FOLLOW_34_in_type_specifier376)
1336 if self.failed:
1337 return
1338
1339
1340 elif alt13 == 2:
1341 # C.g:207:4: 'char'
1342 self.match(self.input, 35, self.FOLLOW_35_in_type_specifier381)
1343 if self.failed:
1344 return
1345
1346
1347 elif alt13 == 3:
1348 # C.g:208:4: 'short'
1349 self.match(self.input, 36, self.FOLLOW_36_in_type_specifier386)
1350 if self.failed:
1351 return
1352
1353
1354 elif alt13 == 4:
1355 # C.g:209:4: 'int'
1356 self.match(self.input, 37, self.FOLLOW_37_in_type_specifier391)
1357 if self.failed:
1358 return
1359
1360
1361 elif alt13 == 5:
1362 # C.g:210:4: 'long'
1363 self.match(self.input, 38, self.FOLLOW_38_in_type_specifier396)
1364 if self.failed:
1365 return
1366
1367
1368 elif alt13 == 6:
1369 # C.g:211:4: 'float'
1370 self.match(self.input, 39, self.FOLLOW_39_in_type_specifier401)
1371 if self.failed:
1372 return
1373
1374
1375 elif alt13 == 7:
1376 # C.g:212:4: 'double'
1377 self.match(self.input, 40, self.FOLLOW_40_in_type_specifier406)
1378 if self.failed:
1379 return
1380
1381
1382 elif alt13 == 8:
1383 # C.g:213:4: 'signed'
1384 self.match(self.input, 41, self.FOLLOW_41_in_type_specifier411)
1385 if self.failed:
1386 return
1387
1388
1389 elif alt13 == 9:
1390 # C.g:214:4: 'unsigned'
1391 self.match(self.input, 42, self.FOLLOW_42_in_type_specifier416)
1392 if self.failed:
1393 return
1394
1395
1396 elif alt13 == 10:
1397 # C.g:215:4: s= struct_or_union_specifier
1398 self.following.append(self.FOLLOW_struct_or_union_specifier_in_type_specifier423)
1399 s = self.struct_or_union_specifier()
1400 self.following.pop()
1401 if self.failed:
1402 return
1403 if self.backtracking == 0:
1404
1405 if s.stop is not None:
1406 self.StoreStructUnionDefinition(s.start.line, s.start.charPositionInLine, s.stop.line, s.stop.charPositionInLine, self.input.toString(s.start, s.stop))
1407
1408
1409
1410
1411 elif alt13 == 11:
1412 # C.g:220:4: e= enum_specifier
1413 self.following.append(self.FOLLOW_enum_specifier_in_type_specifier433)
1414 e = self.enum_specifier()
1415 self.following.pop()
1416 if self.failed:
1417 return
1418 if self.backtracking == 0:
1419
1420 if e.stop is not None:
1421 self.StoreEnumerationDefinition(e.start.line, e.start.charPositionInLine, e.stop.line, e.stop.charPositionInLine, self.input.toString(e.start, e.stop))
1422
1423
1424
1425
1426 elif alt13 == 12:
1427 # C.g:225:4: ( IDENTIFIER ( type_qualifier )* declarator )=> type_id
1428 self.following.append(self.FOLLOW_type_id_in_type_specifier451)
1429 self.type_id()
1430 self.following.pop()
1431 if self.failed:
1432 return
1433
1434
1435
1436 except RecognitionException as re:
1437 self.reportError(re)
1438 self.recover(self.input, re)
1439 finally:
1440 if self.backtracking > 0:
1441 self.memoize(self.input, 9, type_specifier_StartIndex)
1442
1443 pass
1444
1445 return
1446
1447 # $ANTLR end type_specifier
1448
1449
1450 # $ANTLR start type_id
1451 # C.g:228:1: type_id : IDENTIFIER ;
1452 def type_id(self, ):
1453
1454 type_id_StartIndex = self.input.index()
1455 try:
1456 try:
1457 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 10):
1458 return
1459
1460 # C.g:229:5: ( IDENTIFIER )
1461 # C.g:229:9: IDENTIFIER
1462 self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_in_type_id467)
1463 if self.failed:
1464 return
1465
1466
1467
1468
1469 except RecognitionException as re:
1470 self.reportError(re)
1471 self.recover(self.input, re)
1472 finally:
1473 if self.backtracking > 0:
1474 self.memoize(self.input, 10, type_id_StartIndex)
1475
1476 pass
1477
1478 return
1479
1480 # $ANTLR end type_id
1481
1482 class struct_or_union_specifier_return(object):
1483 def __init__(self):
1484 self.start = None
1485 self.stop = None
1486
1487
1488
1489 # $ANTLR start struct_or_union_specifier
1490 # C.g:233:1: struct_or_union_specifier options {k=3; } : ( struct_or_union ( IDENTIFIER )? '{' struct_declaration_list '}' | struct_or_union IDENTIFIER );
1491 def struct_or_union_specifier(self, ):
1492
1493 retval = self.struct_or_union_specifier_return()
1494 retval.start = self.input.LT(1)
1495 struct_or_union_specifier_StartIndex = self.input.index()
1496 try:
1497 try:
1498 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 11):
1499 return retval
1500
1501 # C.g:235:2: ( struct_or_union ( IDENTIFIER )? '{' struct_declaration_list '}' | struct_or_union IDENTIFIER )
1502 alt15 = 2
1503 LA15_0 = self.input.LA(1)
1504
1505 if ((45 <= LA15_0 <= 46)) :
1506 LA15_1 = self.input.LA(2)
1507
1508 if (LA15_1 == IDENTIFIER) :
1509 LA15_2 = self.input.LA(3)
1510
1511 if (LA15_2 == 43) :
1512 alt15 = 1
1513 elif (LA15_2 == EOF or LA15_2 == IDENTIFIER or LA15_2 == 25 or LA15_2 == 27 or (29 <= LA15_2 <= 42) or (45 <= LA15_2 <= 64) or LA15_2 == 66) :
1514 alt15 = 2
1515 else:
1516 if self.backtracking > 0:
1517 self.failed = True
1518 return retval
1519
1520 nvae = NoViableAltException("233:1: struct_or_union_specifier options {k=3; } : ( struct_or_union ( IDENTIFIER )? '{' struct_declaration_list '}' | struct_or_union IDENTIFIER );", 15, 2, self.input)
1521
1522 raise nvae
1523
1524 elif (LA15_1 == 43) :
1525 alt15 = 1
1526 else:
1527 if self.backtracking > 0:
1528 self.failed = True
1529 return retval
1530
1531 nvae = NoViableAltException("233:1: struct_or_union_specifier options {k=3; } : ( struct_or_union ( IDENTIFIER )? '{' struct_declaration_list '}' | struct_or_union IDENTIFIER );", 15, 1, self.input)
1532
1533 raise nvae
1534
1535 else:
1536 if self.backtracking > 0:
1537 self.failed = True
1538 return retval
1539
1540 nvae = NoViableAltException("233:1: struct_or_union_specifier options {k=3; } : ( struct_or_union ( IDENTIFIER )? '{' struct_declaration_list '}' | struct_or_union IDENTIFIER );", 15, 0, self.input)
1541
1542 raise nvae
1543
1544 if alt15 == 1:
1545 # C.g:235:4: struct_or_union ( IDENTIFIER )? '{' struct_declaration_list '}'
1546 self.following.append(self.FOLLOW_struct_or_union_in_struct_or_union_specifier494)
1547 self.struct_or_union()
1548 self.following.pop()
1549 if self.failed:
1550 return retval
1551 # C.g:235:20: ( IDENTIFIER )?
1552 alt14 = 2
1553 LA14_0 = self.input.LA(1)
1554
1555 if (LA14_0 == IDENTIFIER) :
1556 alt14 = 1
1557 if alt14 == 1:
1558 # C.g:0:0: IDENTIFIER
1559 self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_in_struct_or_union_specifier496)
1560 if self.failed:
1561 return retval
1562
1563
1564
1565 self.match(self.input, 43, self.FOLLOW_43_in_struct_or_union_specifier499)
1566 if self.failed:
1567 return retval
1568 self.following.append(self.FOLLOW_struct_declaration_list_in_struct_or_union_specifier501)
1569 self.struct_declaration_list()
1570 self.following.pop()
1571 if self.failed:
1572 return retval
1573 self.match(self.input, 44, self.FOLLOW_44_in_struct_or_union_specifier503)
1574 if self.failed:
1575 return retval
1576
1577
1578 elif alt15 == 2:
1579 # C.g:236:4: struct_or_union IDENTIFIER
1580 self.following.append(self.FOLLOW_struct_or_union_in_struct_or_union_specifier508)
1581 self.struct_or_union()
1582 self.following.pop()
1583 if self.failed:
1584 return retval
1585 self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_in_struct_or_union_specifier510)
1586 if self.failed:
1587 return retval
1588
1589
1590 retval.stop = self.input.LT(-1)
1591
1592
1593 except RecognitionException as re:
1594 self.reportError(re)
1595 self.recover(self.input, re)
1596 finally:
1597 if self.backtracking > 0:
1598 self.memoize(self.input, 11, struct_or_union_specifier_StartIndex)
1599
1600 pass
1601
1602 return retval
1603
1604 # $ANTLR end struct_or_union_specifier
1605
1606
1607 # $ANTLR start struct_or_union
1608 # C.g:239:1: struct_or_union : ( 'struct' | 'union' );
1609 def struct_or_union(self, ):
1610
1611 struct_or_union_StartIndex = self.input.index()
1612 try:
1613 try:
1614 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 12):
1615 return
1616
1617 # C.g:240:2: ( 'struct' | 'union' )
1618 # C.g:
1619 if (45 <= self.input.LA(1) <= 46):
1620 self.input.consume();
1621 self.errorRecovery = False
1622 self.failed = False
1623
1624 else:
1625 if self.backtracking > 0:
1626 self.failed = True
1627 return
1628
1629 mse = MismatchedSetException(None, self.input)
1630 self.recoverFromMismatchedSet(
1631 self.input, mse, self.FOLLOW_set_in_struct_or_union0
1632 )
1633 raise mse
1634
1635
1636
1637
1638
1639
1640 except RecognitionException as re:
1641 self.reportError(re)
1642 self.recover(self.input, re)
1643 finally:
1644 if self.backtracking > 0:
1645 self.memoize(self.input, 12, struct_or_union_StartIndex)
1646
1647 pass
1648
1649 return
1650
1651 # $ANTLR end struct_or_union
1652
1653
1654 # $ANTLR start struct_declaration_list
1655 # C.g:244:1: struct_declaration_list : ( struct_declaration )+ ;
1656 def struct_declaration_list(self, ):
1657
1658 struct_declaration_list_StartIndex = self.input.index()
1659 try:
1660 try:
1661 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 13):
1662 return
1663
1664 # C.g:245:2: ( ( struct_declaration )+ )
1665 # C.g:245:4: ( struct_declaration )+
1666 # C.g:245:4: ( struct_declaration )+
1667 cnt16 = 0
1668 while True: #loop16
1669 alt16 = 2
1670 LA16_0 = self.input.LA(1)
1671
1672 if (LA16_0 == IDENTIFIER or (34 <= LA16_0 <= 42) or (45 <= LA16_0 <= 46) or (48 <= LA16_0 <= 61)) :
1673 alt16 = 1
1674
1675
1676 if alt16 == 1:
1677 # C.g:0:0: struct_declaration
1678 self.following.append(self.FOLLOW_struct_declaration_in_struct_declaration_list537)
1679 self.struct_declaration()
1680 self.following.pop()
1681 if self.failed:
1682 return
1683
1684
1685 else:
1686 if cnt16 >= 1:
1687 break #loop16
1688
1689 if self.backtracking > 0:
1690 self.failed = True
1691 return
1692
1693 eee = EarlyExitException(16, self.input)
1694 raise eee
1695
1696 cnt16 += 1
1697
1698
1699
1700
1701
1702
1703 except RecognitionException as re:
1704 self.reportError(re)
1705 self.recover(self.input, re)
1706 finally:
1707 if self.backtracking > 0:
1708 self.memoize(self.input, 13, struct_declaration_list_StartIndex)
1709
1710 pass
1711
1712 return
1713
1714 # $ANTLR end struct_declaration_list
1715
1716
1717 # $ANTLR start struct_declaration
1718 # C.g:248:1: struct_declaration : specifier_qualifier_list struct_declarator_list ';' ;
1719 def struct_declaration(self, ):
1720
1721 struct_declaration_StartIndex = self.input.index()
1722 try:
1723 try:
1724 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 14):
1725 return
1726
1727 # C.g:249:2: ( specifier_qualifier_list struct_declarator_list ';' )
1728 # C.g:249:4: specifier_qualifier_list struct_declarator_list ';'
1729 self.following.append(self.FOLLOW_specifier_qualifier_list_in_struct_declaration549)
1730 self.specifier_qualifier_list()
1731 self.following.pop()
1732 if self.failed:
1733 return
1734 self.following.append(self.FOLLOW_struct_declarator_list_in_struct_declaration551)
1735 self.struct_declarator_list()
1736 self.following.pop()
1737 if self.failed:
1738 return
1739 self.match(self.input, 25, self.FOLLOW_25_in_struct_declaration553)
1740 if self.failed:
1741 return
1742
1743
1744
1745
1746 except RecognitionException as re:
1747 self.reportError(re)
1748 self.recover(self.input, re)
1749 finally:
1750 if self.backtracking > 0:
1751 self.memoize(self.input, 14, struct_declaration_StartIndex)
1752
1753 pass
1754
1755 return
1756
1757 # $ANTLR end struct_declaration
1758
1759
1760 # $ANTLR start specifier_qualifier_list
1761 # C.g:252:1: specifier_qualifier_list : ( type_qualifier | type_specifier )+ ;
1762 def specifier_qualifier_list(self, ):
1763
1764 specifier_qualifier_list_StartIndex = self.input.index()
1765 try:
1766 try:
1767 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 15):
1768 return
1769
1770 # C.g:253:2: ( ( type_qualifier | type_specifier )+ )
1771 # C.g:253:4: ( type_qualifier | type_specifier )+
1772 # C.g:253:4: ( type_qualifier | type_specifier )+
1773 cnt17 = 0
1774 while True: #loop17
1775 alt17 = 3
1776 LA17 = self.input.LA(1)
1777 if LA17 == 58:
1778 LA17_2 = self.input.LA(2)
1779
1780 if (self.synpred39()) :
1781 alt17 = 1
1782
1783
1784 elif LA17 == 59:
1785 LA17_3 = self.input.LA(2)
1786
1787 if (self.synpred39()) :
1788 alt17 = 1
1789
1790
1791 elif LA17 == 60:
1792 LA17_4 = self.input.LA(2)
1793
1794 if (self.synpred39()) :
1795 alt17 = 1
1796
1797
1798 elif LA17 == IDENTIFIER:
1799 LA17 = self.input.LA(2)
1800 if LA17 == EOF or LA17 == IDENTIFIER or LA17 == 34 or LA17 == 35 or LA17 == 36 or LA17 == 37 or LA17 == 38 or LA17 == 39 or LA17 == 40 or LA17 == 41 or LA17 == 42 or LA17 == 45 or LA17 == 46 or LA17 == 48 or LA17 == 49 or LA17 == 50 or LA17 == 51 or LA17 == 52 or LA17 == 53 or LA17 == 54 or LA17 == 55 or LA17 == 56 or LA17 == 57 or LA17 == 58 or LA17 == 59 or LA17 == 60 or LA17 == 61 or LA17 == 63 or LA17 == 66:
1801 alt17 = 2
1802 elif LA17 == 62:
1803 LA17_94 = self.input.LA(3)
1804
1805 if (self.synpred40()) :
1806 alt17 = 2
1807
1808
1809 elif LA17 == 47:
1810 LA17_95 = self.input.LA(3)
1811
1812 if (self.synpred40()) :
1813 alt17 = 2
1814
1815
1816 elif LA17 == 64:
1817 LA17_96 = self.input.LA(3)
1818
1819 if (self.synpred40()) :
1820 alt17 = 2
1821
1822
1823
1824 elif LA17 == 49 or LA17 == 50 or LA17 == 51 or LA17 == 52 or LA17 == 53 or LA17 == 54 or LA17 == 55 or LA17 == 56 or LA17 == 57 or LA17 == 61:
1825 alt17 = 1
1826 elif LA17 == 34 or LA17 == 35 or LA17 == 36 or LA17 == 37 or LA17 == 38 or LA17 == 39 or LA17 == 40 or LA17 == 41 or LA17 == 42 or LA17 == 45 or LA17 == 46 or LA17 == 48:
1827 alt17 = 2
1828
1829 if alt17 == 1:
1830 # C.g:253:6: type_qualifier
1831 self.following.append(self.FOLLOW_type_qualifier_in_specifier_qualifier_list566)
1832 self.type_qualifier()
1833 self.following.pop()
1834 if self.failed:
1835 return
1836
1837
1838 elif alt17 == 2:
1839 # C.g:253:23: type_specifier
1840 self.following.append(self.FOLLOW_type_specifier_in_specifier_qualifier_list570)
1841 self.type_specifier()
1842 self.following.pop()
1843 if self.failed:
1844 return
1845
1846
1847 else:
1848 if cnt17 >= 1:
1849 break #loop17
1850
1851 if self.backtracking > 0:
1852 self.failed = True
1853 return
1854
1855 eee = EarlyExitException(17, self.input)
1856 raise eee
1857
1858 cnt17 += 1
1859
1860
1861
1862
1863
1864
1865 except RecognitionException as re:
1866 self.reportError(re)
1867 self.recover(self.input, re)
1868 finally:
1869 if self.backtracking > 0:
1870 self.memoize(self.input, 15, specifier_qualifier_list_StartIndex)
1871
1872 pass
1873
1874 return
1875
1876 # $ANTLR end specifier_qualifier_list
1877
1878
1879 # $ANTLR start struct_declarator_list
1880 # C.g:256:1: struct_declarator_list : struct_declarator ( ',' struct_declarator )* ;
1881 def struct_declarator_list(self, ):
1882
1883 struct_declarator_list_StartIndex = self.input.index()
1884 try:
1885 try:
1886 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 16):
1887 return
1888
1889 # C.g:257:2: ( struct_declarator ( ',' struct_declarator )* )
1890 # C.g:257:4: struct_declarator ( ',' struct_declarator )*
1891 self.following.append(self.FOLLOW_struct_declarator_in_struct_declarator_list584)
1892 self.struct_declarator()
1893 self.following.pop()
1894 if self.failed:
1895 return
1896 # C.g:257:22: ( ',' struct_declarator )*
1897 while True: #loop18
1898 alt18 = 2
1899 LA18_0 = self.input.LA(1)
1900
1901 if (LA18_0 == 27) :
1902 alt18 = 1
1903
1904
1905 if alt18 == 1:
1906 # C.g:257:23: ',' struct_declarator
1907 self.match(self.input, 27, self.FOLLOW_27_in_struct_declarator_list587)
1908 if self.failed:
1909 return
1910 self.following.append(self.FOLLOW_struct_declarator_in_struct_declarator_list589)
1911 self.struct_declarator()
1912 self.following.pop()
1913 if self.failed:
1914 return
1915
1916
1917 else:
1918 break #loop18
1919
1920
1921
1922
1923
1924
1925 except RecognitionException as re:
1926 self.reportError(re)
1927 self.recover(self.input, re)
1928 finally:
1929 if self.backtracking > 0:
1930 self.memoize(self.input, 16, struct_declarator_list_StartIndex)
1931
1932 pass
1933
1934 return
1935
1936 # $ANTLR end struct_declarator_list
1937
1938
1939 # $ANTLR start struct_declarator
1940 # C.g:260:1: struct_declarator : ( declarator ( ':' constant_expression )? | ':' constant_expression );
1941 def struct_declarator(self, ):
1942
1943 struct_declarator_StartIndex = self.input.index()
1944 try:
1945 try:
1946 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 17):
1947 return
1948
1949 # C.g:261:2: ( declarator ( ':' constant_expression )? | ':' constant_expression )
1950 alt20 = 2
1951 LA20_0 = self.input.LA(1)
1952
1953 if (LA20_0 == IDENTIFIER or (58 <= LA20_0 <= 60) or LA20_0 == 62 or LA20_0 == 66) :
1954 alt20 = 1
1955 elif (LA20_0 == 47) :
1956 alt20 = 2
1957 else:
1958 if self.backtracking > 0:
1959 self.failed = True
1960 return
1961
1962 nvae = NoViableAltException("260:1: struct_declarator : ( declarator ( ':' constant_expression )? | ':' constant_expression );", 20, 0, self.input)
1963
1964 raise nvae
1965
1966 if alt20 == 1:
1967 # C.g:261:4: declarator ( ':' constant_expression )?
1968 self.following.append(self.FOLLOW_declarator_in_struct_declarator602)
1969 self.declarator()
1970 self.following.pop()
1971 if self.failed:
1972 return
1973 # C.g:261:15: ( ':' constant_expression )?
1974 alt19 = 2
1975 LA19_0 = self.input.LA(1)
1976
1977 if (LA19_0 == 47) :
1978 alt19 = 1
1979 if alt19 == 1:
1980 # C.g:261:16: ':' constant_expression
1981 self.match(self.input, 47, self.FOLLOW_47_in_struct_declarator605)
1982 if self.failed:
1983 return
1984 self.following.append(self.FOLLOW_constant_expression_in_struct_declarator607)
1985 self.constant_expression()
1986 self.following.pop()
1987 if self.failed:
1988 return
1989
1990
1991
1992
1993
1994 elif alt20 == 2:
1995 # C.g:262:4: ':' constant_expression
1996 self.match(self.input, 47, self.FOLLOW_47_in_struct_declarator614)
1997 if self.failed:
1998 return
1999 self.following.append(self.FOLLOW_constant_expression_in_struct_declarator616)
2000 self.constant_expression()
2001 self.following.pop()
2002 if self.failed:
2003 return
2004
2005
2006
2007 except RecognitionException as re:
2008 self.reportError(re)
2009 self.recover(self.input, re)
2010 finally:
2011 if self.backtracking > 0:
2012 self.memoize(self.input, 17, struct_declarator_StartIndex)
2013
2014 pass
2015
2016 return
2017
2018 # $ANTLR end struct_declarator
2019
2020 class enum_specifier_return(object):
2021 def __init__(self):
2022 self.start = None
2023 self.stop = None
2024
2025
2026
2027 # $ANTLR start enum_specifier
2028 # C.g:265:1: enum_specifier options {k=3; } : ( 'enum' '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER );
2029 def enum_specifier(self, ):
2030
2031 retval = self.enum_specifier_return()
2032 retval.start = self.input.LT(1)
2033 enum_specifier_StartIndex = self.input.index()
2034 try:
2035 try:
2036 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 18):
2037 return retval
2038
2039 # C.g:267:2: ( 'enum' '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER )
2040 alt23 = 3
2041 LA23_0 = self.input.LA(1)
2042
2043 if (LA23_0 == 48) :
2044 LA23_1 = self.input.LA(2)
2045
2046 if (LA23_1 == IDENTIFIER) :
2047 LA23_2 = self.input.LA(3)
2048
2049 if (LA23_2 == 43) :
2050 alt23 = 2
2051 elif (LA23_2 == EOF or LA23_2 == IDENTIFIER or LA23_2 == 25 or LA23_2 == 27 or (29 <= LA23_2 <= 42) or (45 <= LA23_2 <= 64) or LA23_2 == 66) :
2052 alt23 = 3
2053 else:
2054 if self.backtracking > 0:
2055 self.failed = True
2056 return retval
2057
2058 nvae = NoViableAltException("265:1: enum_specifier options {k=3; } : ( 'enum' '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER );", 23, 2, self.input)
2059
2060 raise nvae
2061
2062 elif (LA23_1 == 43) :
2063 alt23 = 1
2064 else:
2065 if self.backtracking > 0:
2066 self.failed = True
2067 return retval
2068
2069 nvae = NoViableAltException("265:1: enum_specifier options {k=3; } : ( 'enum' '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER );", 23, 1, self.input)
2070
2071 raise nvae
2072
2073 else:
2074 if self.backtracking > 0:
2075 self.failed = True
2076 return retval
2077
2078 nvae = NoViableAltException("265:1: enum_specifier options {k=3; } : ( 'enum' '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER );", 23, 0, self.input)
2079
2080 raise nvae
2081
2082 if alt23 == 1:
2083 # C.g:267:4: 'enum' '{' enumerator_list ( ',' )? '}'
2084 self.match(self.input, 48, self.FOLLOW_48_in_enum_specifier634)
2085 if self.failed:
2086 return retval
2087 self.match(self.input, 43, self.FOLLOW_43_in_enum_specifier636)
2088 if self.failed:
2089 return retval
2090 self.following.append(self.FOLLOW_enumerator_list_in_enum_specifier638)
2091 self.enumerator_list()
2092 self.following.pop()
2093 if self.failed:
2094 return retval
2095 # C.g:267:31: ( ',' )?
2096 alt21 = 2
2097 LA21_0 = self.input.LA(1)
2098
2099 if (LA21_0 == 27) :
2100 alt21 = 1
2101 if alt21 == 1:
2102 # C.g:0:0: ','
2103 self.match(self.input, 27, self.FOLLOW_27_in_enum_specifier640)
2104 if self.failed:
2105 return retval
2106
2107
2108
2109 self.match(self.input, 44, self.FOLLOW_44_in_enum_specifier643)
2110 if self.failed:
2111 return retval
2112
2113
2114 elif alt23 == 2:
2115 # C.g:268:4: 'enum' IDENTIFIER '{' enumerator_list ( ',' )? '}'
2116 self.match(self.input, 48, self.FOLLOW_48_in_enum_specifier648)
2117 if self.failed:
2118 return retval
2119 self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_in_enum_specifier650)
2120 if self.failed:
2121 return retval
2122 self.match(self.input, 43, self.FOLLOW_43_in_enum_specifier652)
2123 if self.failed:
2124 return retval
2125 self.following.append(self.FOLLOW_enumerator_list_in_enum_specifier654)
2126 self.enumerator_list()
2127 self.following.pop()
2128 if self.failed:
2129 return retval
2130 # C.g:268:42: ( ',' )?
2131 alt22 = 2
2132 LA22_0 = self.input.LA(1)
2133
2134 if (LA22_0 == 27) :
2135 alt22 = 1
2136 if alt22 == 1:
2137 # C.g:0:0: ','
2138 self.match(self.input, 27, self.FOLLOW_27_in_enum_specifier656)
2139 if self.failed:
2140 return retval
2141
2142
2143
2144 self.match(self.input, 44, self.FOLLOW_44_in_enum_specifier659)
2145 if self.failed:
2146 return retval
2147
2148
2149 elif alt23 == 3:
2150 # C.g:269:4: 'enum' IDENTIFIER
2151 self.match(self.input, 48, self.FOLLOW_48_in_enum_specifier664)
2152 if self.failed:
2153 return retval
2154 self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_in_enum_specifier666)
2155 if self.failed:
2156 return retval
2157
2158
2159 retval.stop = self.input.LT(-1)
2160
2161
2162 except RecognitionException as re:
2163 self.reportError(re)
2164 self.recover(self.input, re)
2165 finally:
2166 if self.backtracking > 0:
2167 self.memoize(self.input, 18, enum_specifier_StartIndex)
2168
2169 pass
2170
2171 return retval
2172
2173 # $ANTLR end enum_specifier
2174
2175
2176 # $ANTLR start enumerator_list
2177 # C.g:272:1: enumerator_list : enumerator ( ',' enumerator )* ;
2178 def enumerator_list(self, ):
2179
2180 enumerator_list_StartIndex = self.input.index()
2181 try:
2182 try:
2183 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 19):
2184 return
2185
2186 # C.g:273:2: ( enumerator ( ',' enumerator )* )
2187 # C.g:273:4: enumerator ( ',' enumerator )*
2188 self.following.append(self.FOLLOW_enumerator_in_enumerator_list677)
2189 self.enumerator()
2190 self.following.pop()
2191 if self.failed:
2192 return
2193 # C.g:273:15: ( ',' enumerator )*
2194 while True: #loop24
2195 alt24 = 2
2196 LA24_0 = self.input.LA(1)
2197
2198 if (LA24_0 == 27) :
2199 LA24_1 = self.input.LA(2)
2200
2201 if (LA24_1 == IDENTIFIER) :
2202 alt24 = 1
2203
2204
2205
2206
2207 if alt24 == 1:
2208 # C.g:273:16: ',' enumerator
2209 self.match(self.input, 27, self.FOLLOW_27_in_enumerator_list680)
2210 if self.failed:
2211 return
2212 self.following.append(self.FOLLOW_enumerator_in_enumerator_list682)
2213 self.enumerator()
2214 self.following.pop()
2215 if self.failed:
2216 return
2217
2218
2219 else:
2220 break #loop24
2221
2222
2223
2224
2225
2226
2227 except RecognitionException as re:
2228 self.reportError(re)
2229 self.recover(self.input, re)
2230 finally:
2231 if self.backtracking > 0:
2232 self.memoize(self.input, 19, enumerator_list_StartIndex)
2233
2234 pass
2235
2236 return
2237
2238 # $ANTLR end enumerator_list
2239
2240
2241 # $ANTLR start enumerator
2242 # C.g:276:1: enumerator : IDENTIFIER ( '=' constant_expression )? ;
2243 def enumerator(self, ):
2244
2245 enumerator_StartIndex = self.input.index()
2246 try:
2247 try:
2248 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 20):
2249 return
2250
2251 # C.g:277:2: ( IDENTIFIER ( '=' constant_expression )? )
2252 # C.g:277:4: IDENTIFIER ( '=' constant_expression )?
2253 self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_in_enumerator695)
2254 if self.failed:
2255 return
2256 # C.g:277:15: ( '=' constant_expression )?
2257 alt25 = 2
2258 LA25_0 = self.input.LA(1)
2259
2260 if (LA25_0 == 28) :
2261 alt25 = 1
2262 if alt25 == 1:
2263 # C.g:277:16: '=' constant_expression
2264 self.match(self.input, 28, self.FOLLOW_28_in_enumerator698)
2265 if self.failed:
2266 return
2267 self.following.append(self.FOLLOW_constant_expression_in_enumerator700)
2268 self.constant_expression()
2269 self.following.pop()
2270 if self.failed:
2271 return
2272
2273
2274
2275
2276
2277
2278
2279 except RecognitionException as re:
2280 self.reportError(re)
2281 self.recover(self.input, re)
2282 finally:
2283 if self.backtracking > 0:
2284 self.memoize(self.input, 20, enumerator_StartIndex)
2285
2286 pass
2287
2288 return
2289
2290 # $ANTLR end enumerator
2291
2292
2293 # $ANTLR start type_qualifier
2294 # C.g:280:1: type_qualifier : ( 'const' | 'volatile' | 'IN' | 'OUT' | 'OPTIONAL' | 'CONST' | 'UNALIGNED' | 'VOLATILE' | 'GLOBAL_REMOVE_IF_UNREFERENCED' | 'EFIAPI' | 'EFI_BOOTSERVICE' | 'EFI_RUNTIMESERVICE' | 'PACKED' );
2295 def type_qualifier(self, ):
2296
2297 type_qualifier_StartIndex = self.input.index()
2298 try:
2299 try:
2300 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 21):
2301 return
2302
2303 # C.g:281:2: ( 'const' | 'volatile' | 'IN' | 'OUT' | 'OPTIONAL' | 'CONST' | 'UNALIGNED' | 'VOLATILE' | 'GLOBAL_REMOVE_IF_UNREFERENCED' | 'EFIAPI' | 'EFI_BOOTSERVICE' | 'EFI_RUNTIMESERVICE' | 'PACKED' )
2304 # C.g:
2305 if (49 <= self.input.LA(1) <= 61):
2306 self.input.consume();
2307 self.errorRecovery = False
2308 self.failed = False
2309
2310 else:
2311 if self.backtracking > 0:
2312 self.failed = True
2313 return
2314
2315 mse = MismatchedSetException(None, self.input)
2316 self.recoverFromMismatchedSet(
2317 self.input, mse, self.FOLLOW_set_in_type_qualifier0
2318 )
2319 raise mse
2320
2321
2322
2323
2324
2325
2326 except RecognitionException as re:
2327 self.reportError(re)
2328 self.recover(self.input, re)
2329 finally:
2330 if self.backtracking > 0:
2331 self.memoize(self.input, 21, type_qualifier_StartIndex)
2332
2333 pass
2334
2335 return
2336
2337 # $ANTLR end type_qualifier
2338
2339 class declarator_return(object):
2340 def __init__(self):
2341 self.start = None
2342 self.stop = None
2343
2344
2345
2346 # $ANTLR start declarator
2347 # C.g:296:1: declarator : ( ( pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERVICE' )? ( 'EFI_RUNTIMESERVICE' )? direct_declarator | pointer );
2348 def declarator(self, ):
2349
2350 retval = self.declarator_return()
2351 retval.start = self.input.LT(1)
2352 declarator_StartIndex = self.input.index()
2353 try:
2354 try:
2355 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 22):
2356 return retval
2357
2358 # C.g:297:2: ( ( pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERVICE' )? ( 'EFI_RUNTIMESERVICE' )? direct_declarator | pointer )
2359 alt30 = 2
2360 LA30_0 = self.input.LA(1)
2361
2362 if (LA30_0 == 66) :
2363 LA30_1 = self.input.LA(2)
2364
2365 if (self.synpred66()) :
2366 alt30 = 1
2367 elif (True) :
2368 alt30 = 2
2369 else:
2370 if self.backtracking > 0:
2371 self.failed = True
2372 return retval
2373
2374 nvae = NoViableAltException("296:1: declarator : ( ( pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERVICE' )? ( 'EFI_RUNTIMESERVICE' )? direct_declarator | pointer );", 30, 1, self.input)
2375
2376 raise nvae
2377
2378 elif (LA30_0 == IDENTIFIER or (58 <= LA30_0 <= 60) or LA30_0 == 62) :
2379 alt30 = 1
2380 else:
2381 if self.backtracking > 0:
2382 self.failed = True
2383 return retval
2384
2385 nvae = NoViableAltException("296:1: declarator : ( ( pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERVICE' )? ( 'EFI_RUNTIMESERVICE' )? direct_declarator | pointer );", 30, 0, self.input)
2386
2387 raise nvae
2388
2389 if alt30 == 1:
2390 # C.g:297:4: ( pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERVICE' )? ( 'EFI_RUNTIMESERVICE' )? direct_declarator
2391 # C.g:297:4: ( pointer )?
2392 alt26 = 2
2393 LA26_0 = self.input.LA(1)
2394
2395 if (LA26_0 == 66) :
2396 alt26 = 1
2397 if alt26 == 1:
2398 # C.g:0:0: pointer
2399 self.following.append(self.FOLLOW_pointer_in_declarator784)
2400 self.pointer()
2401 self.following.pop()
2402 if self.failed:
2403 return retval
2404
2405
2406
2407 # C.g:297:13: ( 'EFIAPI' )?
2408 alt27 = 2
2409 LA27_0 = self.input.LA(1)
2410
2411 if (LA27_0 == 58) :
2412 alt27 = 1
2413 if alt27 == 1:
2414 # C.g:297:14: 'EFIAPI'
2415 self.match(self.input, 58, self.FOLLOW_58_in_declarator788)
2416 if self.failed:
2417 return retval
2418
2419
2420
2421 # C.g:297:25: ( 'EFI_BOOTSERVICE' )?
2422 alt28 = 2
2423 LA28_0 = self.input.LA(1)
2424
2425 if (LA28_0 == 59) :
2426 alt28 = 1
2427 if alt28 == 1:
2428 # C.g:297:26: 'EFI_BOOTSERVICE'
2429 self.match(self.input, 59, self.FOLLOW_59_in_declarator793)
2430 if self.failed:
2431 return retval
2432
2433
2434
2435 # C.g:297:46: ( 'EFI_RUNTIMESERVICE' )?
2436 alt29 = 2
2437 LA29_0 = self.input.LA(1)
2438
2439 if (LA29_0 == 60) :
2440 alt29 = 1
2441 if alt29 == 1:
2442 # C.g:297:47: 'EFI_RUNTIMESERVICE'
2443 self.match(self.input, 60, self.FOLLOW_60_in_declarator798)
2444 if self.failed:
2445 return retval
2446
2447
2448
2449 self.following.append(self.FOLLOW_direct_declarator_in_declarator802)
2450 self.direct_declarator()
2451 self.following.pop()
2452 if self.failed:
2453 return retval
2454
2455
2456 elif alt30 == 2:
2457 # C.g:299:4: pointer
2458 self.following.append(self.FOLLOW_pointer_in_declarator808)
2459 self.pointer()
2460 self.following.pop()
2461 if self.failed:
2462 return retval
2463
2464
2465 retval.stop = self.input.LT(-1)
2466
2467
2468 except RecognitionException as re:
2469 self.reportError(re)
2470 self.recover(self.input, re)
2471 finally:
2472 if self.backtracking > 0:
2473 self.memoize(self.input, 22, declarator_StartIndex)
2474
2475 pass
2476
2477 return retval
2478
2479 # $ANTLR end declarator
2480
2481
2482 # $ANTLR start direct_declarator
2483 # C.g:302:1: direct_declarator : ( IDENTIFIER ( declarator_suffix )* | '(' ( 'EFIAPI' )? declarator ')' ( declarator_suffix )+ );
2484 def direct_declarator(self, ):
2485
2486 direct_declarator_StartIndex = self.input.index()
2487 try:
2488 try:
2489 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 23):
2490 return
2491
2492 # C.g:303:2: ( IDENTIFIER ( declarator_suffix )* | '(' ( 'EFIAPI' )? declarator ')' ( declarator_suffix )+ )
2493 alt34 = 2
2494 LA34_0 = self.input.LA(1)
2495
2496 if (LA34_0 == IDENTIFIER) :
2497 alt34 = 1
2498 elif (LA34_0 == 62) :
2499 alt34 = 2
2500 else:
2501 if self.backtracking > 0:
2502 self.failed = True
2503 return
2504
2505 nvae = NoViableAltException("302:1: direct_declarator : ( IDENTIFIER ( declarator_suffix )* | '(' ( 'EFIAPI' )? declarator ')' ( declarator_suffix )+ );", 34, 0, self.input)
2506
2507 raise nvae
2508
2509 if alt34 == 1:
2510 # C.g:303:4: IDENTIFIER ( declarator_suffix )*
2511 self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_in_direct_declarator819)
2512 if self.failed:
2513 return
2514 # C.g:303:15: ( declarator_suffix )*
2515 while True: #loop31
2516 alt31 = 2
2517 LA31_0 = self.input.LA(1)
2518
2519 if (LA31_0 == 62) :
2520 LA31 = self.input.LA(2)
2521 if LA31 == 63:
2522 LA31_30 = self.input.LA(3)
2523
2524 if (self.synpred67()) :
2525 alt31 = 1
2526
2527
2528 elif LA31 == 58:
2529 LA31_31 = self.input.LA(3)
2530
2531 if (self.synpred67()) :
2532 alt31 = 1
2533
2534
2535 elif LA31 == 66:
2536 LA31_32 = self.input.LA(3)
2537
2538 if (self.synpred67()) :
2539 alt31 = 1
2540
2541
2542 elif LA31 == 59:
2543 LA31_33 = self.input.LA(3)
2544
2545 if (self.synpred67()) :
2546 alt31 = 1
2547
2548
2549 elif LA31 == 60:
2550 LA31_34 = self.input.LA(3)
2551
2552 if (self.synpred67()) :
2553 alt31 = 1
2554
2555
2556 elif LA31 == IDENTIFIER:
2557 LA31_35 = self.input.LA(3)
2558
2559 if (self.synpred67()) :
2560 alt31 = 1
2561
2562
2563 elif LA31 == 29 or LA31 == 30 or LA31 == 31 or LA31 == 32 or LA31 == 33:
2564 LA31_37 = self.input.LA(3)
2565
2566 if (self.synpred67()) :
2567 alt31 = 1
2568
2569
2570 elif LA31 == 34:
2571 LA31_38 = self.input.LA(3)
2572
2573 if (self.synpred67()) :
2574 alt31 = 1
2575
2576
2577 elif LA31 == 35:
2578 LA31_39 = self.input.LA(3)
2579
2580 if (self.synpred67()) :
2581 alt31 = 1
2582
2583
2584 elif LA31 == 36:
2585 LA31_40 = self.input.LA(3)
2586
2587 if (self.synpred67()) :
2588 alt31 = 1
2589
2590
2591 elif LA31 == 37:
2592 LA31_41 = self.input.LA(3)
2593
2594 if (self.synpred67()) :
2595 alt31 = 1
2596
2597
2598 elif LA31 == 38:
2599 LA31_42 = self.input.LA(3)
2600
2601 if (self.synpred67()) :
2602 alt31 = 1
2603
2604
2605 elif LA31 == 39:
2606 LA31_43 = self.input.LA(3)
2607
2608 if (self.synpred67()) :
2609 alt31 = 1
2610
2611
2612 elif LA31 == 40:
2613 LA31_44 = self.input.LA(3)
2614
2615 if (self.synpred67()) :
2616 alt31 = 1
2617
2618
2619 elif LA31 == 41:
2620 LA31_45 = self.input.LA(3)
2621
2622 if (self.synpred67()) :
2623 alt31 = 1
2624
2625
2626 elif LA31 == 42:
2627 LA31_46 = self.input.LA(3)
2628
2629 if (self.synpred67()) :
2630 alt31 = 1
2631
2632
2633 elif LA31 == 45 or LA31 == 46:
2634 LA31_47 = self.input.LA(3)
2635
2636 if (self.synpred67()) :
2637 alt31 = 1
2638
2639
2640 elif LA31 == 48:
2641 LA31_48 = self.input.LA(3)
2642
2643 if (self.synpred67()) :
2644 alt31 = 1
2645
2646
2647 elif LA31 == 49 or LA31 == 50 or LA31 == 51 or LA31 == 52 or LA31 == 53 or LA31 == 54 or LA31 == 55 or LA31 == 56 or LA31 == 57 or LA31 == 61:
2648 LA31_49 = self.input.LA(3)
2649
2650 if (self.synpred67()) :
2651 alt31 = 1
2652
2653
2654
2655 elif (LA31_0 == 64) :
2656 LA31 = self.input.LA(2)
2657 if LA31 == 65:
2658 LA31_51 = self.input.LA(3)
2659
2660 if (self.synpred67()) :
2661 alt31 = 1
2662
2663
2664 elif LA31 == 62:
2665 LA31_52 = self.input.LA(3)
2666
2667 if (self.synpred67()) :
2668 alt31 = 1
2669
2670
2671 elif LA31 == IDENTIFIER:
2672 LA31_53 = self.input.LA(3)
2673
2674 if (self.synpred67()) :
2675 alt31 = 1
2676
2677
2678 elif LA31 == HEX_LITERAL:
2679 LA31_54 = self.input.LA(3)
2680
2681 if (self.synpred67()) :
2682 alt31 = 1
2683
2684
2685 elif LA31 == OCTAL_LITERAL:
2686 LA31_55 = self.input.LA(3)
2687
2688 if (self.synpred67()) :
2689 alt31 = 1
2690
2691
2692 elif LA31 == DECIMAL_LITERAL:
2693 LA31_56 = self.input.LA(3)
2694
2695 if (self.synpred67()) :
2696 alt31 = 1
2697
2698
2699 elif LA31 == CHARACTER_LITERAL:
2700 LA31_57 = self.input.LA(3)
2701
2702 if (self.synpred67()) :
2703 alt31 = 1
2704
2705
2706 elif LA31 == STRING_LITERAL:
2707 LA31_58 = self.input.LA(3)
2708
2709 if (self.synpred67()) :
2710 alt31 = 1
2711
2712
2713 elif LA31 == FLOATING_POINT_LITERAL:
2714 LA31_59 = self.input.LA(3)
2715
2716 if (self.synpred67()) :
2717 alt31 = 1
2718
2719
2720 elif LA31 == 72:
2721 LA31_60 = self.input.LA(3)
2722
2723 if (self.synpred67()) :
2724 alt31 = 1
2725
2726
2727 elif LA31 == 73:
2728 LA31_61 = self.input.LA(3)
2729
2730 if (self.synpred67()) :
2731 alt31 = 1
2732
2733
2734 elif LA31 == 66 or LA31 == 68 or LA31 == 69 or LA31 == 77 or LA31 == 78 or LA31 == 79:
2735 LA31_62 = self.input.LA(3)
2736
2737 if (self.synpred67()) :
2738 alt31 = 1
2739
2740
2741 elif LA31 == 74:
2742 LA31_63 = self.input.LA(3)
2743
2744 if (self.synpred67()) :
2745 alt31 = 1
2746
2747
2748
2749
2750
2751 if alt31 == 1:
2752 # C.g:0:0: declarator_suffix
2753 self.following.append(self.FOLLOW_declarator_suffix_in_direct_declarator821)
2754 self.declarator_suffix()
2755 self.following.pop()
2756 if self.failed:
2757 return
2758
2759
2760 else:
2761 break #loop31
2762
2763
2764
2765
2766 elif alt34 == 2:
2767 # C.g:304:4: '(' ( 'EFIAPI' )? declarator ')' ( declarator_suffix )+
2768 self.match(self.input, 62, self.FOLLOW_62_in_direct_declarator827)
2769 if self.failed:
2770 return
2771 # C.g:304:8: ( 'EFIAPI' )?
2772 alt32 = 2
2773 LA32_0 = self.input.LA(1)
2774
2775 if (LA32_0 == 58) :
2776 LA32_1 = self.input.LA(2)
2777
2778 if (self.synpred69()) :
2779 alt32 = 1
2780 if alt32 == 1:
2781 # C.g:304:9: 'EFIAPI'
2782 self.match(self.input, 58, self.FOLLOW_58_in_direct_declarator830)
2783 if self.failed:
2784 return
2785
2786
2787
2788 self.following.append(self.FOLLOW_declarator_in_direct_declarator834)
2789 self.declarator()
2790 self.following.pop()
2791 if self.failed:
2792 return
2793 self.match(self.input, 63, self.FOLLOW_63_in_direct_declarator836)
2794 if self.failed:
2795 return
2796 # C.g:304:35: ( declarator_suffix )+
2797 cnt33 = 0
2798 while True: #loop33
2799 alt33 = 2
2800 LA33_0 = self.input.LA(1)
2801
2802 if (LA33_0 == 62) :
2803 LA33 = self.input.LA(2)
2804 if LA33 == 63:
2805 LA33_30 = self.input.LA(3)
2806
2807 if (self.synpred70()) :
2808 alt33 = 1
2809
2810
2811 elif LA33 == 58:
2812 LA33_31 = self.input.LA(3)
2813
2814 if (self.synpred70()) :
2815 alt33 = 1
2816
2817
2818 elif LA33 == 66:
2819 LA33_32 = self.input.LA(3)
2820
2821 if (self.synpred70()) :
2822 alt33 = 1
2823
2824
2825 elif LA33 == 59:
2826 LA33_33 = self.input.LA(3)
2827
2828 if (self.synpred70()) :
2829 alt33 = 1
2830
2831
2832 elif LA33 == 60:
2833 LA33_34 = self.input.LA(3)
2834
2835 if (self.synpred70()) :
2836 alt33 = 1
2837
2838
2839 elif LA33 == IDENTIFIER:
2840 LA33_35 = self.input.LA(3)
2841
2842 if (self.synpred70()) :
2843 alt33 = 1
2844
2845
2846 elif LA33 == 29 or LA33 == 30 or LA33 == 31 or LA33 == 32 or LA33 == 33:
2847 LA33_37 = self.input.LA(3)
2848
2849 if (self.synpred70()) :
2850 alt33 = 1
2851
2852
2853 elif LA33 == 34:
2854 LA33_38 = self.input.LA(3)
2855
2856 if (self.synpred70()) :
2857 alt33 = 1
2858
2859
2860 elif LA33 == 35:
2861 LA33_39 = self.input.LA(3)
2862
2863 if (self.synpred70()) :
2864 alt33 = 1
2865
2866
2867 elif LA33 == 36:
2868 LA33_40 = self.input.LA(3)
2869
2870 if (self.synpred70()) :
2871 alt33 = 1
2872
2873
2874 elif LA33 == 37:
2875 LA33_41 = self.input.LA(3)
2876
2877 if (self.synpred70()) :
2878 alt33 = 1
2879
2880
2881 elif LA33 == 38:
2882 LA33_42 = self.input.LA(3)
2883
2884 if (self.synpred70()) :
2885 alt33 = 1
2886
2887
2888 elif LA33 == 39:
2889 LA33_43 = self.input.LA(3)
2890
2891 if (self.synpred70()) :
2892 alt33 = 1
2893
2894
2895 elif LA33 == 40:
2896 LA33_44 = self.input.LA(3)
2897
2898 if (self.synpred70()) :
2899 alt33 = 1
2900
2901
2902 elif LA33 == 41:
2903 LA33_45 = self.input.LA(3)
2904
2905 if (self.synpred70()) :
2906 alt33 = 1
2907
2908
2909 elif LA33 == 42:
2910 LA33_46 = self.input.LA(3)
2911
2912 if (self.synpred70()) :
2913 alt33 = 1
2914
2915
2916 elif LA33 == 45 or LA33 == 46:
2917 LA33_47 = self.input.LA(3)
2918
2919 if (self.synpred70()) :
2920 alt33 = 1
2921
2922
2923 elif LA33 == 48:
2924 LA33_48 = self.input.LA(3)
2925
2926 if (self.synpred70()) :
2927 alt33 = 1
2928
2929
2930 elif LA33 == 49 or LA33 == 50 or LA33 == 51 or LA33 == 52 or LA33 == 53 or LA33 == 54 or LA33 == 55 or LA33 == 56 or LA33 == 57 or LA33 == 61:
2931 LA33_49 = self.input.LA(3)
2932
2933 if (self.synpred70()) :
2934 alt33 = 1
2935
2936
2937
2938 elif (LA33_0 == 64) :
2939 LA33 = self.input.LA(2)
2940 if LA33 == 65:
2941 LA33_51 = self.input.LA(3)
2942
2943 if (self.synpred70()) :
2944 alt33 = 1
2945
2946
2947 elif LA33 == 62:
2948 LA33_52 = self.input.LA(3)
2949
2950 if (self.synpred70()) :
2951 alt33 = 1
2952
2953
2954 elif LA33 == IDENTIFIER:
2955 LA33_53 = self.input.LA(3)
2956
2957 if (self.synpred70()) :
2958 alt33 = 1
2959
2960
2961 elif LA33 == HEX_LITERAL:
2962 LA33_54 = self.input.LA(3)
2963
2964 if (self.synpred70()) :
2965 alt33 = 1
2966
2967
2968 elif LA33 == OCTAL_LITERAL:
2969 LA33_55 = self.input.LA(3)
2970
2971 if (self.synpred70()) :
2972 alt33 = 1
2973
2974
2975 elif LA33 == DECIMAL_LITERAL:
2976 LA33_56 = self.input.LA(3)
2977
2978 if (self.synpred70()) :
2979 alt33 = 1
2980
2981
2982 elif LA33 == CHARACTER_LITERAL:
2983 LA33_57 = self.input.LA(3)
2984
2985 if (self.synpred70()) :
2986 alt33 = 1
2987
2988
2989 elif LA33 == STRING_LITERAL:
2990 LA33_58 = self.input.LA(3)
2991
2992 if (self.synpred70()) :
2993 alt33 = 1
2994
2995
2996 elif LA33 == FLOATING_POINT_LITERAL:
2997 LA33_59 = self.input.LA(3)
2998
2999 if (self.synpred70()) :
3000 alt33 = 1
3001
3002
3003 elif LA33 == 72:
3004 LA33_60 = self.input.LA(3)
3005
3006 if (self.synpred70()) :
3007 alt33 = 1
3008
3009
3010 elif LA33 == 73:
3011 LA33_61 = self.input.LA(3)
3012
3013 if (self.synpred70()) :
3014 alt33 = 1
3015
3016
3017 elif LA33 == 66 or LA33 == 68 or LA33 == 69 or LA33 == 77 or LA33 == 78 or LA33 == 79:
3018 LA33_62 = self.input.LA(3)
3019
3020 if (self.synpred70()) :
3021 alt33 = 1
3022
3023
3024 elif LA33 == 74:
3025 LA33_63 = self.input.LA(3)
3026
3027 if (self.synpred70()) :
3028 alt33 = 1
3029
3030
3031
3032
3033
3034 if alt33 == 1:
3035 # C.g:0:0: declarator_suffix
3036 self.following.append(self.FOLLOW_declarator_suffix_in_direct_declarator838)
3037 self.declarator_suffix()
3038 self.following.pop()
3039 if self.failed:
3040 return
3041
3042
3043 else:
3044 if cnt33 >= 1:
3045 break #loop33
3046
3047 if self.backtracking > 0:
3048 self.failed = True
3049 return
3050
3051 eee = EarlyExitException(33, self.input)
3052 raise eee
3053
3054 cnt33 += 1
3055
3056
3057
3058
3059
3060 except RecognitionException as re:
3061 self.reportError(re)
3062 self.recover(self.input, re)
3063 finally:
3064 if self.backtracking > 0:
3065 self.memoize(self.input, 23, direct_declarator_StartIndex)
3066
3067 pass
3068
3069 return
3070
3071 # $ANTLR end direct_declarator
3072
3073
3074 # $ANTLR start declarator_suffix
3075 # C.g:307:1: declarator_suffix : ( '[' constant_expression ']' | '[' ']' | '(' parameter_type_list ')' | '(' identifier_list ')' | '(' ')' );
3076 def declarator_suffix(self, ):
3077
3078 declarator_suffix_StartIndex = self.input.index()
3079 try:
3080 try:
3081 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 24):
3082 return
3083
3084 # C.g:308:2: ( '[' constant_expression ']' | '[' ']' | '(' parameter_type_list ')' | '(' identifier_list ')' | '(' ')' )
3085 alt35 = 5
3086 LA35_0 = self.input.LA(1)
3087
3088 if (LA35_0 == 64) :
3089 LA35_1 = self.input.LA(2)
3090
3091 if (LA35_1 == 65) :
3092 alt35 = 2
3093 elif ((IDENTIFIER <= LA35_1 <= FLOATING_POINT_LITERAL) or LA35_1 == 62 or LA35_1 == 66 or (68 <= LA35_1 <= 69) or (72 <= LA35_1 <= 74) or (77 <= LA35_1 <= 79)) :
3094 alt35 = 1
3095 else:
3096 if self.backtracking > 0:
3097 self.failed = True
3098 return
3099
3100 nvae = NoViableAltException("307:1: declarator_suffix : ( '[' constant_expression ']' | '[' ']' | '(' parameter_type_list ')' | '(' identifier_list ')' | '(' ')' );", 35, 1, self.input)
3101
3102 raise nvae
3103
3104 elif (LA35_0 == 62) :
3105 LA35 = self.input.LA(2)
3106 if LA35 == 63:
3107 alt35 = 5
3108 elif LA35 == 29 or LA35 == 30 or LA35 == 31 or LA35 == 32 or LA35 == 33 or LA35 == 34 or LA35 == 35 or LA35 == 36 or LA35 == 37 or LA35 == 38 or LA35 == 39 or LA35 == 40 or LA35 == 41 or LA35 == 42 or LA35 == 45 or LA35 == 46 or LA35 == 48 or LA35 == 49 or LA35 == 50 or LA35 == 51 or LA35 == 52 or LA35 == 53 or LA35 == 54 or LA35 == 55 or LA35 == 56 or LA35 == 57 or LA35 == 58 or LA35 == 59 or LA35 == 60 or LA35 == 61 or LA35 == 66:
3109 alt35 = 3
3110 elif LA35 == IDENTIFIER:
3111 LA35_29 = self.input.LA(3)
3112
3113 if (self.synpred73()) :
3114 alt35 = 3
3115 elif (self.synpred74()) :
3116 alt35 = 4
3117 else:
3118 if self.backtracking > 0:
3119 self.failed = True
3120 return
3121
3122 nvae = NoViableAltException("307:1: declarator_suffix : ( '[' constant_expression ']' | '[' ']' | '(' parameter_type_list ')' | '(' identifier_list ')' | '(' ')' );", 35, 29, self.input)
3123
3124 raise nvae
3125
3126 else:
3127 if self.backtracking > 0:
3128 self.failed = True
3129 return
3130
3131 nvae = NoViableAltException("307:1: declarator_suffix : ( '[' constant_expression ']' | '[' ']' | '(' parameter_type_list ')' | '(' identifier_list ')' | '(' ')' );", 35, 2, self.input)
3132
3133 raise nvae
3134
3135 else:
3136 if self.backtracking > 0:
3137 self.failed = True
3138 return
3139
3140 nvae = NoViableAltException("307:1: declarator_suffix : ( '[' constant_expression ']' | '[' ']' | '(' parameter_type_list ')' | '(' identifier_list ')' | '(' ')' );", 35, 0, self.input)
3141
3142 raise nvae
3143
3144 if alt35 == 1:
3145 # C.g:308:6: '[' constant_expression ']'
3146 self.match(self.input, 64, self.FOLLOW_64_in_declarator_suffix852)
3147 if self.failed:
3148 return
3149 self.following.append(self.FOLLOW_constant_expression_in_declarator_suffix854)
3150 self.constant_expression()
3151 self.following.pop()
3152 if self.failed:
3153 return
3154 self.match(self.input, 65, self.FOLLOW_65_in_declarator_suffix856)
3155 if self.failed:
3156 return
3157
3158
3159 elif alt35 == 2:
3160 # C.g:309:9: '[' ']'
3161 self.match(self.input, 64, self.FOLLOW_64_in_declarator_suffix866)
3162 if self.failed:
3163 return
3164 self.match(self.input, 65, self.FOLLOW_65_in_declarator_suffix868)
3165 if self.failed:
3166 return
3167
3168
3169 elif alt35 == 3:
3170 # C.g:310:9: '(' parameter_type_list ')'
3171 self.match(self.input, 62, self.FOLLOW_62_in_declarator_suffix878)
3172 if self.failed:
3173 return
3174 self.following.append(self.FOLLOW_parameter_type_list_in_declarator_suffix880)
3175 self.parameter_type_list()
3176 self.following.pop()
3177 if self.failed:
3178 return
3179 self.match(self.input, 63, self.FOLLOW_63_in_declarator_suffix882)
3180 if self.failed:
3181 return
3182
3183
3184 elif alt35 == 4:
3185 # C.g:311:9: '(' identifier_list ')'
3186 self.match(self.input, 62, self.FOLLOW_62_in_declarator_suffix892)
3187 if self.failed:
3188 return
3189 self.following.append(self.FOLLOW_identifier_list_in_declarator_suffix894)
3190 self.identifier_list()
3191 self.following.pop()
3192 if self.failed:
3193 return
3194 self.match(self.input, 63, self.FOLLOW_63_in_declarator_suffix896)
3195 if self.failed:
3196 return
3197
3198
3199 elif alt35 == 5:
3200 # C.g:312:9: '(' ')'
3201 self.match(self.input, 62, self.FOLLOW_62_in_declarator_suffix906)
3202 if self.failed:
3203 return
3204 self.match(self.input, 63, self.FOLLOW_63_in_declarator_suffix908)
3205 if self.failed:
3206 return
3207
3208
3209
3210 except RecognitionException as re:
3211 self.reportError(re)
3212 self.recover(self.input, re)
3213 finally:
3214 if self.backtracking > 0:
3215 self.memoize(self.input, 24, declarator_suffix_StartIndex)
3216
3217 pass
3218
3219 return
3220
3221 # $ANTLR end declarator_suffix
3222
3223
3224 # $ANTLR start pointer
3225 # C.g:315:1: pointer : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );
3226 def pointer(self, ):
3227
3228 pointer_StartIndex = self.input.index()
3229 try:
3230 try:
3231 if self.backtracking > 0 and self.alreadyParsedRule(self.input, 25):
3232 return
3233
3234 # C.g:316:2: ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' )
3235 alt38 = 3
3236 LA38_0 = self.input.LA(1)
3237
3238 if (LA38_0 == 66) :
3239 LA38 = self.input.LA(2)
3240 if LA38 == 66:
3241 LA38_2 = self.input.LA(3)
3242
3243 if (self.synpred78()) :
3244 alt38 = 2
3245 elif (True) :
3246 alt38 = 3
3247 else:
3248 if self.backtracking > 0:
3249 self.failed = True
3250 return
3251
3252 nvae = NoViableAltException("315:1: pointer : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 2, self.input)
3253
3254 raise nvae
3255
3256 elif LA38 == 58:
3257 LA38_3 = self.input.LA(3)
3258
3259 if (self.synpred77()) :
3260 alt38 = 1
3261 elif (True) :
3262 alt38 = 3
3263 else:
3264 if self.backtracking > 0:
3265 self.failed = True
3266 return
3267
3268 nvae = NoViableAltException("315:1: pointer : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 3, self.input)
3269
3270 raise nvae
3271
3272 elif LA38 == 59:
3273 LA38_4 = self.input.LA(3)
3274
3275 if (self.synpred77()) :
3276 alt38 = 1
3277 elif (True) :
3278 alt38 = 3
3279 else:
3280 if self.backtracking > 0:
3281 self.failed = True
3282 return
3283
3284 nvae = NoViableAltException("315:1: pointer : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 4, self.input)
3285
3286 raise nvae
3287
3288 elif LA38 == 60:
3289 LA38_5 = self.input.LA(3)
3290
3291 if (self.synpred77()) :
3292 alt38 = 1
3293 elif (True) :
3294 alt38 = 3
3295 else:
3296 if self.backtracking > 0:
3297 self.failed = True
3298 return
3299
3300 nvae = NoViableAltException("315:1: pointer : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 5, self.input)
3301
3302 raise nvae
3303
3304 elif LA38 == EOF or LA38 == IDENTIFIER or LA38 == 25 or LA38 == 26 or LA38 == 27 or LA38 == 28 or LA38 == 29 or LA38 == 30 or LA38 == 31 or LA38 == 32 or LA38 == 33 or LA38 == 34 or LA38 == 35 or LA38 == 36 or LA38 == 37 or LA38 == 38 or LA38 == 39 or LA38 == 40 or LA38 == 41 or LA38 == 42 or LA38 == 43 or LA38 == 45 or LA38 == 46 or LA38 == 47 or LA38 == 48 or LA38 == 62 or LA38 == 63 or LA38 == 64:
3305 alt38 = 3
3306 elif LA38 == 53:
3307 LA38_21 = self.input.LA(3)
3308
3309 if (self.synpred77()) :
3310 alt38 = 1
3311 elif (True) :
3312 alt38 = 3
3313 else:
3314 if self.backtracking > 0:
3315 self.failed = True
3316 return
3317
3318 nvae = NoViableAltException("315:1: pointer : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 21, self.input)
3319
3320 raise nvae
3321
3322 elif LA38 == 49 or LA38 == 50 or LA38 == 51 or LA38 == 52 or LA38 == 54 or LA38 == 55 or LA38 == 56 or LA38 == 57 or LA38 == 61:
3323 LA38_29 = self.input.LA(3)
3324
3325 if (self.synpred77()) :
3326 alt38 = 1
3327 elif (True) :
3328 alt38 = 3
3329 else:
3330 if self.backtracking > 0:
3331 self.failed = True
3332 return
3333
3334 nvae = NoViableAltException("315:1: pointer : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 29, self.input)
3335
3336 raise nvae
3337
3338 else:
3339 if self.backtracking > 0:
3340 self.failed = True
3341 return
3342
3343 nvae = NoViableAltException("315:1: pointer : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 1, self.input)
3344
3345 raise nvae
3346
3347 else:
3348 if self.backtracking > 0: