1/** \file 2 * This OBJC source file was generated by $ANTLR version ${project.version} ${buildNumber} 3 * 4 * - From the grammar source file : SimpleC.g 5 * - On : 2011-05-06 13:53:12 6 * - for the parser : SimpleCParserParser 7 * 8 * Editing it, at least manually, is not wise. 9 * 10 * ObjC language generator and runtime by Alan Condit, acondit|hereisanat|ipns|dotgoeshere|com. 11 * 12 * 13*/ 14// $ANTLR ${project.version} ${buildNumber} SimpleC.g 2011-05-06 13:53:12 15 16 17/* ----------------------------------------- 18 * Include the ANTLR3 generated header file. 19 */ 20#import "SimpleCParser.h" 21/* ----------------------------------------- */ 22 23 24/* ============================================================================= */ 25/* ============================================================================= 26 * Start of recognizer 27 */ 28#pragma mark Cyclic DFA implementation start DFA2 29@implementation DFA2 30const static NSInteger dfa2_eot[13] = 31 {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; 32const static NSInteger dfa2_eof[13] = 33 {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; 34const static unichar dfa2_min[13] = 35 {4,4,7,4,0,4,11,8,0,0,4,4,8}; 36const static unichar dfa2_max[13] = 37 {18,4,11,18,0,4,19,10,0,0,18,4,10}; 38const static NSInteger dfa2_accept[13] = 39 {-1,-1,-1,-1,1,-1,-1,-1,2,3,-1,-1,-1}; 40const static NSInteger dfa2_special[13] = 41 {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; 42const static NSInteger dfa2_transition[] = {}; 43const static NSInteger dfa2_transition0[] = {3, -1, -1, -1, 4}; 44const static NSInteger dfa2_transition1[] = {6, -1, 10}; 45const static NSInteger dfa2_transition2[] = {8, -1, -1, -1, -1, -1, -1, 46 -1, 9}; 47const static NSInteger dfa2_transition3[] = {2}; 48const static NSInteger dfa2_transition4[] = {1, -1, -1, -1, -1, -1, -1, 49 -1, -1, -1, -1, 1, -1, 1, 1}; 50const static NSInteger dfa2_transition5[] = {7}; 51const static NSInteger dfa2_transition6[] = {11, -1, -1, -1, -1, -1, -1, 52 -1, -1, -1, -1, 11, -1, 11, 11}; 53const static NSInteger dfa2_transition7[] = {12}; 54const static NSInteger dfa2_transition8[] = {5, -1, -1, -1, 6, -1, -1, -1, 55 -1, -1, -1, 5, -1, 5, 5}; 56 57 58+ (id) newDFA2WithRecognizer:(ANTLRBaseRecognizer *)aRecognizer 59{ 60 return [[[DFA2 alloc] initWithRecognizer:aRecognizer] retain]; 61} 62 63- (id) initWithRecognizer:(ANTLRBaseRecognizer *) theRecognizer 64{ 65 self = [super initWithRecognizer:theRecognizer]; 66 if ( self != nil ) { 67 decisionNumber = 2; 68 eot = dfa2_eot; 69 eof = dfa2_eof; 70 min = dfa2_min; 71 max = dfa2_max; 72 accept = dfa2_accept; 73 special = dfa2_special; 74 if (!(transition = calloc(13, sizeof(void*)))) { 75 [self release]; 76 return nil; 77 } 78 len = 13; 79 transition[0] = dfa2_transition4; 80 transition[1] = dfa2_transition3; 81 transition[2] = dfa2_transition0; 82 transition[3] = dfa2_transition8; 83 84 transition[4] = dfa2_transition5; 85 transition[5] = dfa2_transition2; 86 transition[6] = dfa2_transition1; 87 88 89 transition[7] = dfa2_transition6; 90 transition[8] = dfa2_transition7; 91 transition[9] = dfa2_transition1; 92 } 93 return self; 94} 95 96- (void) dealloc 97{ 98 free(transition); 99 [super dealloc]; 100} 101 102- (NSString *) description 103{ 104 return @"20:1: declaration : ( variable | functionHeader ';' | functionHeader block );"; 105} 106 107 108@end /* end DFA2 implementation */ 109 110#pragma mark Cyclic DFA implementation end DFA2 111 112 113 114#pragma mark Bitsets 115static ANTLRBitSet *FOLLOW_declaration_in_program28; 116static const unsigned long long FOLLOW_declaration_in_program28_data[] = { 0x0000000000068012LL}; 117static ANTLRBitSet *FOLLOW_variable_in_declaration50; 118static const unsigned long long FOLLOW_variable_in_declaration50_data[] = { 0x0000000000000002LL}; 119static ANTLRBitSet *FOLLOW_functionHeader_in_declaration60; 120static const unsigned long long FOLLOW_functionHeader_in_declaration60_data[] = { 0x0000000000000800LL}; 121static ANTLRBitSet *FOLLOW_11_in_declaration62; 122static const unsigned long long FOLLOW_11_in_declaration62_data[] = { 0x0000000000000002LL}; 123static ANTLRBitSet *FOLLOW_functionHeader_in_declaration75; 124static const unsigned long long FOLLOW_functionHeader_in_declaration75_data[] = { 0x0000000000080000LL}; 125static ANTLRBitSet *FOLLOW_block_in_declaration77; 126static const unsigned long long FOLLOW_block_in_declaration77_data[] = { 0x0000000000000002LL}; 127static ANTLRBitSet *FOLLOW_type_in_variable99; 128static const unsigned long long FOLLOW_type_in_variable99_data[] = { 0x0000000000000010LL}; 129static ANTLRBitSet *FOLLOW_declarator_in_variable101; 130static const unsigned long long FOLLOW_declarator_in_variable101_data[] = { 0x0000000000000800LL}; 131static ANTLRBitSet *FOLLOW_11_in_variable103; 132static const unsigned long long FOLLOW_11_in_variable103_data[] = { 0x0000000000000002LL}; 133static ANTLRBitSet *FOLLOW_ID_in_declarator122; 134static const unsigned long long FOLLOW_ID_in_declarator122_data[] = { 0x0000000000000002LL}; 135static ANTLRBitSet *FOLLOW_type_in_functionHeader151; 136static const unsigned long long FOLLOW_type_in_functionHeader151_data[] = { 0x0000000000000010LL}; 137static ANTLRBitSet *FOLLOW_ID_in_functionHeader153; 138static const unsigned long long FOLLOW_ID_in_functionHeader153_data[] = { 0x0000000000000080LL}; 139static ANTLRBitSet *FOLLOW_7_in_functionHeader155; 140static const unsigned long long FOLLOW_7_in_functionHeader155_data[] = { 0x0000000000068110LL}; 141static ANTLRBitSet *FOLLOW_formalParameter_in_functionHeader159; 142static const unsigned long long FOLLOW_formalParameter_in_functionHeader159_data[] = { 0x0000000000000500LL}; 143static ANTLRBitSet *FOLLOW_10_in_functionHeader163; 144static const unsigned long long FOLLOW_10_in_functionHeader163_data[] = { 0x0000000000068010LL}; 145static ANTLRBitSet *FOLLOW_formalParameter_in_functionHeader165; 146static const unsigned long long FOLLOW_formalParameter_in_functionHeader165_data[] = { 0x0000000000000500LL}; 147static ANTLRBitSet *FOLLOW_8_in_functionHeader173; 148static const unsigned long long FOLLOW_8_in_functionHeader173_data[] = { 0x0000000000000002LL}; 149static ANTLRBitSet *FOLLOW_type_in_formalParameter195; 150static const unsigned long long FOLLOW_type_in_formalParameter195_data[] = { 0x0000000000000010LL}; 151static ANTLRBitSet *FOLLOW_declarator_in_formalParameter197; 152static const unsigned long long FOLLOW_declarator_in_formalParameter197_data[] = { 0x0000000000000002LL}; 153static ANTLRBitSet *FOLLOW_19_in_block286; 154static const unsigned long long FOLLOW_19_in_block286_data[] = { 0x00000000001F88B0LL}; 155static ANTLRBitSet *FOLLOW_variable_in_block300; 156static const unsigned long long FOLLOW_variable_in_block300_data[] = { 0x00000000001F88B0LL}; 157static ANTLRBitSet *FOLLOW_stat_in_block315; 158static const unsigned long long FOLLOW_stat_in_block315_data[] = { 0x00000000001908B0LL}; 159static ANTLRBitSet *FOLLOW_20_in_block326; 160static const unsigned long long FOLLOW_20_in_block326_data[] = { 0x0000000000000002LL}; 161static ANTLRBitSet *FOLLOW_forStat_in_stat338; 162static const unsigned long long FOLLOW_forStat_in_stat338_data[] = { 0x0000000000000002LL}; 163static ANTLRBitSet *FOLLOW_expr_in_stat346; 164static const unsigned long long FOLLOW_expr_in_stat346_data[] = { 0x0000000000000800LL}; 165static ANTLRBitSet *FOLLOW_11_in_stat348; 166static const unsigned long long FOLLOW_11_in_stat348_data[] = { 0x0000000000000002LL}; 167static ANTLRBitSet *FOLLOW_block_in_stat362; 168static const unsigned long long FOLLOW_block_in_stat362_data[] = { 0x0000000000000002LL}; 169static ANTLRBitSet *FOLLOW_assignStat_in_stat370; 170static const unsigned long long FOLLOW_assignStat_in_stat370_data[] = { 0x0000000000000800LL}; 171static ANTLRBitSet *FOLLOW_11_in_stat372; 172static const unsigned long long FOLLOW_11_in_stat372_data[] = { 0x0000000000000002LL}; 173static ANTLRBitSet *FOLLOW_11_in_stat380; 174static const unsigned long long FOLLOW_11_in_stat380_data[] = { 0x0000000000000002LL}; 175static ANTLRBitSet *FOLLOW_16_in_forStat399; 176static const unsigned long long FOLLOW_16_in_forStat399_data[] = { 0x0000000000000080LL}; 177static ANTLRBitSet *FOLLOW_7_in_forStat401; 178static const unsigned long long FOLLOW_7_in_forStat401_data[] = { 0x0000000000000010LL}; 179static ANTLRBitSet *FOLLOW_assignStat_in_forStat403; 180static const unsigned long long FOLLOW_assignStat_in_forStat403_data[] = { 0x0000000000000800LL}; 181static ANTLRBitSet *FOLLOW_11_in_forStat405; 182static const unsigned long long FOLLOW_11_in_forStat405_data[] = { 0x00000000000000B0LL}; 183static ANTLRBitSet *FOLLOW_expr_in_forStat407; 184static const unsigned long long FOLLOW_expr_in_forStat407_data[] = { 0x0000000000000800LL}; 185static ANTLRBitSet *FOLLOW_11_in_forStat409; 186static const unsigned long long FOLLOW_11_in_forStat409_data[] = { 0x0000000000000010LL}; 187static ANTLRBitSet *FOLLOW_assignStat_in_forStat411; 188static const unsigned long long FOLLOW_assignStat_in_forStat411_data[] = { 0x0000000000000100LL}; 189static ANTLRBitSet *FOLLOW_8_in_forStat413; 190static const unsigned long long FOLLOW_8_in_forStat413_data[] = { 0x0000000000080000LL}; 191static ANTLRBitSet *FOLLOW_block_in_forStat415; 192static const unsigned long long FOLLOW_block_in_forStat415_data[] = { 0x0000000000000002LL}; 193static ANTLRBitSet *FOLLOW_ID_in_assignStat442; 194static const unsigned long long FOLLOW_ID_in_assignStat442_data[] = { 0x0000000000002000LL}; 195static ANTLRBitSet *FOLLOW_13_in_assignStat444; 196static const unsigned long long FOLLOW_13_in_assignStat444_data[] = { 0x00000000000000B0LL}; 197static ANTLRBitSet *FOLLOW_expr_in_assignStat446; 198static const unsigned long long FOLLOW_expr_in_assignStat446_data[] = { 0x0000000000000002LL}; 199static ANTLRBitSet *FOLLOW_condExpr_in_expr468; 200static const unsigned long long FOLLOW_condExpr_in_expr468_data[] = { 0x0000000000000002LL}; 201static ANTLRBitSet *FOLLOW_aexpr_in_condExpr487; 202static const unsigned long long FOLLOW_aexpr_in_condExpr487_data[] = { 0x0000000000005002LL}; 203static ANTLRBitSet *FOLLOW_set_in_condExpr491; 204static const unsigned long long FOLLOW_set_in_condExpr491_data[] = { 0x00000000000000B0LL}; 205static ANTLRBitSet *FOLLOW_aexpr_in_condExpr499; 206static const unsigned long long FOLLOW_aexpr_in_condExpr499_data[] = { 0x0000000000000002LL}; 207static ANTLRBitSet *FOLLOW_atom_in_aexpr521; 208static const unsigned long long FOLLOW_atom_in_aexpr521_data[] = { 0x0000000000000202LL}; 209static ANTLRBitSet *FOLLOW_9_in_aexpr525; 210static const unsigned long long FOLLOW_9_in_aexpr525_data[] = { 0x00000000000000B0LL}; 211static ANTLRBitSet *FOLLOW_atom_in_aexpr527; 212static const unsigned long long FOLLOW_atom_in_aexpr527_data[] = { 0x0000000000000202LL}; 213static ANTLRBitSet *FOLLOW_ID_in_atom547; 214static const unsigned long long FOLLOW_ID_in_atom547_data[] = { 0x0000000000000002LL}; 215static ANTLRBitSet *FOLLOW_INT_in_atom561; 216static const unsigned long long FOLLOW_INT_in_atom561_data[] = { 0x0000000000000002LL}; 217static ANTLRBitSet *FOLLOW_7_in_atom575; 218static const unsigned long long FOLLOW_7_in_atom575_data[] = { 0x00000000000000B0LL}; 219static ANTLRBitSet *FOLLOW_expr_in_atom577; 220static const unsigned long long FOLLOW_expr_in_atom577_data[] = { 0x0000000000000100LL}; 221static ANTLRBitSet *FOLLOW_8_in_atom579; 222static const unsigned long long FOLLOW_8_in_atom579_data[] = { 0x0000000000000002LL}; 223 224 225#pragma mark Dynamic Global Scopes 226 227#pragma mark Dynamic Rule Scopes 228 229#pragma mark Rule Return Scopes start 230//#pragma mark Rule return scopes start 231// 232 233#pragma mark Rule return scopes start 234 235@implementation SimpleCParser // line 637 236 237/* ObjC start of ruleAttributeScope */ 238#pragma mark Dynamic Rule Scopes 239/* ObjC end of ruleAttributeScope */ 240#pragma mark global Attribute Scopes 241/* ObjC start globalAttributeScope */ 242/* ObjC end globalAttributeScope */ 243/* ObjC start actions.(actionScope).synthesize */ 244/* ObjC end actions.(actionScope).synthesize */ 245/* ObjC start synthesize() */ 246/* ObjC end synthesize() */ 247 248+ (void) initialize 249{ 250 #pragma mark Bitsets 251 FOLLOW_declaration_in_program28 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_declaration_in_program28_data Count:(NSUInteger)1] retain]; 252 FOLLOW_variable_in_declaration50 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_variable_in_declaration50_data Count:(NSUInteger)1] retain]; 253 FOLLOW_functionHeader_in_declaration60 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_functionHeader_in_declaration60_data Count:(NSUInteger)1] retain]; 254 FOLLOW_11_in_declaration62 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_11_in_declaration62_data Count:(NSUInteger)1] retain]; 255 FOLLOW_functionHeader_in_declaration75 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_functionHeader_in_declaration75_data Count:(NSUInteger)1] retain]; 256 FOLLOW_block_in_declaration77 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_declaration77_data Count:(NSUInteger)1] retain]; 257 FOLLOW_type_in_variable99 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_type_in_variable99_data Count:(NSUInteger)1] retain]; 258 FOLLOW_declarator_in_variable101 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_declarator_in_variable101_data Count:(NSUInteger)1] retain]; 259 FOLLOW_11_in_variable103 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_11_in_variable103_data Count:(NSUInteger)1] retain]; 260 FOLLOW_ID_in_declarator122 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_declarator122_data Count:(NSUInteger)1] retain]; 261 FOLLOW_type_in_functionHeader151 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_type_in_functionHeader151_data Count:(NSUInteger)1] retain]; 262 FOLLOW_ID_in_functionHeader153 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_functionHeader153_data Count:(NSUInteger)1] retain]; 263 FOLLOW_7_in_functionHeader155 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_7_in_functionHeader155_data Count:(NSUInteger)1] retain]; 264 FOLLOW_formalParameter_in_functionHeader159 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_formalParameter_in_functionHeader159_data Count:(NSUInteger)1] retain]; 265 FOLLOW_10_in_functionHeader163 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_10_in_functionHeader163_data Count:(NSUInteger)1] retain]; 266 FOLLOW_formalParameter_in_functionHeader165 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_formalParameter_in_functionHeader165_data Count:(NSUInteger)1] retain]; 267 FOLLOW_8_in_functionHeader173 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_functionHeader173_data Count:(NSUInteger)1] retain]; 268 FOLLOW_type_in_formalParameter195 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_type_in_formalParameter195_data Count:(NSUInteger)1] retain]; 269 FOLLOW_declarator_in_formalParameter197 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_declarator_in_formalParameter197_data Count:(NSUInteger)1] retain]; 270 FOLLOW_19_in_block286 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_19_in_block286_data Count:(NSUInteger)1] retain]; 271 FOLLOW_variable_in_block300 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_variable_in_block300_data Count:(NSUInteger)1] retain]; 272 FOLLOW_stat_in_block315 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_stat_in_block315_data Count:(NSUInteger)1] retain]; 273 FOLLOW_20_in_block326 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_20_in_block326_data Count:(NSUInteger)1] retain]; 274 FOLLOW_forStat_in_stat338 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_forStat_in_stat338_data Count:(NSUInteger)1] retain]; 275 FOLLOW_expr_in_stat346 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_stat346_data Count:(NSUInteger)1] retain]; 276 FOLLOW_11_in_stat348 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_11_in_stat348_data Count:(NSUInteger)1] retain]; 277 FOLLOW_block_in_stat362 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_stat362_data Count:(NSUInteger)1] retain]; 278 FOLLOW_assignStat_in_stat370 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_assignStat_in_stat370_data Count:(NSUInteger)1] retain]; 279 FOLLOW_11_in_stat372 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_11_in_stat372_data Count:(NSUInteger)1] retain]; 280 FOLLOW_11_in_stat380 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_11_in_stat380_data Count:(NSUInteger)1] retain]; 281 FOLLOW_16_in_forStat399 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_16_in_forStat399_data Count:(NSUInteger)1] retain]; 282 FOLLOW_7_in_forStat401 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_7_in_forStat401_data Count:(NSUInteger)1] retain]; 283 FOLLOW_assignStat_in_forStat403 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_assignStat_in_forStat403_data Count:(NSUInteger)1] retain]; 284 FOLLOW_11_in_forStat405 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_11_in_forStat405_data Count:(NSUInteger)1] retain]; 285 FOLLOW_expr_in_forStat407 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_forStat407_data Count:(NSUInteger)1] retain]; 286 FOLLOW_11_in_forStat409 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_11_in_forStat409_data Count:(NSUInteger)1] retain]; 287 FOLLOW_assignStat_in_forStat411 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_assignStat_in_forStat411_data Count:(NSUInteger)1] retain]; 288 FOLLOW_8_in_forStat413 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_forStat413_data Count:(NSUInteger)1] retain]; 289 FOLLOW_block_in_forStat415 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_forStat415_data Count:(NSUInteger)1] retain]; 290 FOLLOW_ID_in_assignStat442 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_assignStat442_data Count:(NSUInteger)1] retain]; 291 FOLLOW_13_in_assignStat444 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_13_in_assignStat444_data Count:(NSUInteger)1] retain]; 292 FOLLOW_expr_in_assignStat446 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_assignStat446_data Count:(NSUInteger)1] retain]; 293 FOLLOW_condExpr_in_expr468 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_condExpr_in_expr468_data Count:(NSUInteger)1] retain]; 294 FOLLOW_aexpr_in_condExpr487 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_aexpr_in_condExpr487_data Count:(NSUInteger)1] retain]; 295 FOLLOW_set_in_condExpr491 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_set_in_condExpr491_data Count:(NSUInteger)1] retain]; 296 FOLLOW_aexpr_in_condExpr499 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_aexpr_in_condExpr499_data Count:(NSUInteger)1] retain]; 297 FOLLOW_atom_in_aexpr521 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_atom_in_aexpr521_data Count:(NSUInteger)1] retain]; 298 FOLLOW_9_in_aexpr525 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_9_in_aexpr525_data Count:(NSUInteger)1] retain]; 299 FOLLOW_atom_in_aexpr527 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_atom_in_aexpr527_data Count:(NSUInteger)1] retain]; 300 FOLLOW_ID_in_atom547 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_ID_in_atom547_data Count:(NSUInteger)1] retain]; 301 FOLLOW_INT_in_atom561 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_INT_in_atom561_data Count:(NSUInteger)1] retain]; 302 FOLLOW_7_in_atom575 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_7_in_atom575_data Count:(NSUInteger)1] retain]; 303 FOLLOW_expr_in_atom577 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_atom577_data Count:(NSUInteger)1] retain]; 304 FOLLOW_8_in_atom579 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_8_in_atom579_data Count:(NSUInteger)1] retain]; 305 306 [ANTLRBaseRecognizer setTokenNames:[[AMutableArray arrayWithObjects:@"<invalid>", @"<EOR>", @"<DOWN>", @"<UP>", 307 @"ID", @"INT", @"WS", @"'('", @"')'", @"'+'", @"','", @"';'", @"'<'", @"'='", 308 @"'=='", @"'char'", @"'for'", @"'int'", @"'void'", @"'{'", @"'}'", nil] retain]]; 309 [ANTLRBaseRecognizer setGrammarFileName:@"SimpleC.g"]; 310} 311 312+ (SimpleCParser *)newSimpleCParser:(id<ANTLRTokenStream>)aStream 313{ 314 return [[SimpleCParser alloc] initWithTokenStream:aStream]; 315 316 317} 318 319- (id) initWithTokenStream:(id<ANTLRTokenStream>)aStream 320{ 321 self = [super initWithTokenStream:aStream State:[[ANTLRRecognizerSharedState newANTLRRecognizerSharedStateWithRuleLen:15+1] retain]]; 322 if ( self != nil ) { 323 324 325 dfa2 = [DFA2 newDFA2WithRecognizer:self]; 326 /* start of actions-actionScope-init */ 327 /* start of init */ 328 } 329 return self; 330} 331 332- (void) dealloc 333{ 334 [dfa2 release]; 335 [super dealloc]; 336} 337 338/* ObjC start members */ 339/* ObjC end members */ 340/* ObjC start actions.(actionScope).methods */ 341/* ObjC end actions.(actionScope).methods */ 342/* ObjC start methods() */ 343/* ObjC end methods() */ 344/* ObjC start rules */ 345/* 346 * $ANTLR start program 347 * SimpleC.g:7:1: program : ( declaration )+ ; 348 */ 349- (void) program 350{ 351 /* my ruleScopeSetUp */ 352 /* Terence's stuff */ 353 354 @try { 355 // SimpleC.g:8:5: ( ( declaration )+ ) // ruleBlockSingleAlt 356 // SimpleC.g:8:9: ( declaration )+ // alt 357 { 358 // SimpleC.g:8:9: ( declaration )+ // positiveClosureBlock 359 NSInteger cnt1 = 0; 360 do { 361 NSInteger alt1 = 2; 362 NSInteger LA1_0 = [input LA:1]; 363 if ( (LA1_0==ID||LA1_0==15||(LA1_0 >= 17 && LA1_0 <= 18)) ) { 364 alt1=1; 365 } 366 367 368 switch (alt1) { 369 case 1 : ; 370 // SimpleC.g:8:9: declaration // alt 371 { 372 /* ruleRef */ 373 [self pushFollow:FOLLOW_declaration_in_program28]; 374 [self declaration]; 375 376 [self popFollow]; 377 378 379 380 } 381 break; 382 383 default : 384 if ( cnt1 >= 1 ) 385 goto loop1; 386 ANTLREarlyExitException *eee = 387 [ANTLREarlyExitException newException:input decisionNumber:1]; 388 @throw eee; 389 } 390 cnt1++; 391 } while (YES); 392 loop1: ; 393 394 395 } 396 397 // token+rule list labels 398 399 } 400 @catch (ANTLRRecognitionException *re) { 401 [self reportError:re]; 402 [self recover:input Exception:re]; 403 } 404 405 @finally { 406 /* my stuff */ 407 /* Terence's stuff */ 408 409 } 410 return ; 411} 412/* $ANTLR end program */ 413 414/* 415 * $ANTLR start declaration 416 * SimpleC.g:20:1: declaration : ( variable | functionHeader ';' | functionHeader block ); 417 */ 418- (void) declaration 419{ 420 /* my ruleScopeSetUp */ 421 /* Terence's stuff */ 422 423 @try { 424 NSString * functionHeader1 = nil ; 425 426 NSString * functionHeader2 = nil ; 427 428 429 // SimpleC.g:21:5: ( variable | functionHeader ';' | functionHeader block ) //ruleblock 430 NSInteger alt2=3; 431 alt2 = [dfa2 predict:input]; 432 switch (alt2) { 433 case 1 : ; 434 // SimpleC.g:21:9: variable // alt 435 { 436 /* ruleRef */ 437 [self pushFollow:FOLLOW_variable_in_declaration50]; 438 [self variable]; 439 440 [self popFollow]; 441 442 443 444 } 445 break; 446 case 2 : ; 447 // SimpleC.g:22:9: functionHeader ';' // alt 448 { 449 /* ruleRef */ 450 [self pushFollow:FOLLOW_functionHeader_in_declaration60]; 451 functionHeader1 = [self functionHeader]; 452 453 [self popFollow]; 454 455 456 457 [self match:input TokenType:11 Follow:FOLLOW_11_in_declaration62]; 458 459 NSLog(@"%@ is a declaration\n", functionHeader1 460 ); 461 462 463 } 464 break; 465 case 3 : ; 466 // SimpleC.g:24:9: functionHeader block // alt 467 { 468 /* ruleRef */ 469 [self pushFollow:FOLLOW_functionHeader_in_declaration75]; 470 functionHeader2 = [self functionHeader]; 471 472 [self popFollow]; 473 474 475 476 /* ruleRef */ 477 [self pushFollow:FOLLOW_block_in_declaration77]; 478 [self block]; 479 480 [self popFollow]; 481 482 483 484 NSLog(@"%@ is a definition\n", functionHeader2 485 ); 486 487 488 } 489 break; 490 491 } 492 // token+rule list labels 493 494 } 495 @catch (ANTLRRecognitionException *re) { 496 [self reportError:re]; 497 [self recover:input Exception:re]; 498 } 499 500 @finally { 501 /* my stuff */ 502 /* Terence's stuff */ 503 504 } 505 return ; 506} 507/* $ANTLR end declaration */ 508 509/* 510 * $ANTLR start variable 511 * SimpleC.g:28:1: variable : type declarator ';' ; 512 */ 513- (void) variable 514{ 515 /* my ruleScopeSetUp */ 516 /* Terence's stuff */ 517 518 @try { 519 // SimpleC.g:29:5: ( type declarator ';' ) // ruleBlockSingleAlt 520 // SimpleC.g:29:9: type declarator ';' // alt 521 { 522 /* ruleRef */ 523 [self pushFollow:FOLLOW_type_in_variable99]; 524 [self type]; 525 526 [self popFollow]; 527 528 529 530 /* ruleRef */ 531 [self pushFollow:FOLLOW_declarator_in_variable101]; 532 [self declarator]; 533 534 [self popFollow]; 535 536 537 538 [self match:input TokenType:11 Follow:FOLLOW_11_in_variable103]; 539 540 } 541 542 // token+rule list labels 543 544 } 545 @catch (ANTLRRecognitionException *re) { 546 [self reportError:re]; 547 [self recover:input Exception:re]; 548 } 549 550 @finally { 551 /* my stuff */ 552 /* Terence's stuff */ 553 554 } 555 return ; 556} 557/* $ANTLR end variable */ 558 559/* 560 * $ANTLR start declarator 561 * SimpleC.g:32:1: declarator : ID ; 562 */ 563- (void) declarator 564{ 565 /* my ruleScopeSetUp */ 566 /* Terence's stuff */ 567 568 @try { 569 // SimpleC.g:33:5: ( ID ) // ruleBlockSingleAlt 570 // SimpleC.g:33:9: ID // alt 571 { 572 [self match:input TokenType:ID Follow:FOLLOW_ID_in_declarator122]; 573 574 } 575 576 // token+rule list labels 577 578 } 579 @catch (ANTLRRecognitionException *re) { 580 [self reportError:re]; 581 [self recover:input Exception:re]; 582 } 583 584 @finally { 585 /* my stuff */ 586 /* Terence's stuff */ 587 588 } 589 return ; 590} 591/* $ANTLR end declarator */ 592 593/* 594 * $ANTLR start functionHeader 595 * SimpleC.g:36:1: functionHeader returns [NSString *name] : type ID '(' ( formalParameter ( ',' formalParameter )* )? ')' ; 596 */ 597- (NSString *) functionHeader 598{ 599 /* my ruleScopeSetUp */ 600 /* Terence's stuff */ 601 602 NSString * name = nil ; 603 604 605 606 name=nil; // for now you must init here rather than in 'returns' 607 608 @try { 609 ANTLRCommonToken *ID3 = nil; 610 611 // SimpleC.g:40:5: ( type ID '(' ( formalParameter ( ',' formalParameter )* )? ')' ) // ruleBlockSingleAlt 612 // SimpleC.g:40:9: type ID '(' ( formalParameter ( ',' formalParameter )* )? ')' // alt 613 { 614 /* ruleRef */ 615 [self pushFollow:FOLLOW_type_in_functionHeader151]; 616 [self type]; 617 618 [self popFollow]; 619 620 621 622 ID3=(ANTLRCommonToken *)[self match:input TokenType:ID Follow:FOLLOW_ID_in_functionHeader153]; 623 624 [self match:input TokenType:7 Follow:FOLLOW_7_in_functionHeader155]; 625 626 // SimpleC.g:40:21: ( formalParameter ( ',' formalParameter )* )? // block 627 NSInteger alt4=2; 628 NSInteger LA4_0 = [input LA:1]; 629 630 if ( (LA4_0==ID||LA4_0==15||(LA4_0 >= 17 && LA4_0 <= 18)) ) { 631 alt4=1; 632 } 633 switch (alt4) { 634 case 1 : ; 635 // SimpleC.g:40:23: formalParameter ( ',' formalParameter )* // alt 636 { 637 /* ruleRef */ 638 [self pushFollow:FOLLOW_formalParameter_in_functionHeader159]; 639 [self formalParameter]; 640 641 [self popFollow]; 642 643 644 645 do { 646 NSInteger alt3=2; 647 NSInteger LA3_0 = [input LA:1]; 648 if ( (LA3_0==10) ) { 649 alt3=1; 650 } 651 652 653 switch (alt3) { 654 case 1 : ; 655 // SimpleC.g:40:41: ',' formalParameter // alt 656 { 657 [self match:input TokenType:10 Follow:FOLLOW_10_in_functionHeader163]; 658 659 /* ruleRef */ 660 [self pushFollow:FOLLOW_formalParameter_in_functionHeader165]; 661 [self formalParameter]; 662 663 [self popFollow]; 664 665 666 667 } 668 break; 669 670 default : 671 goto loop3; 672 } 673 } while (YES); 674 loop3: ; 675 676 677 } 678 break; 679 680 } 681 682 683 [self match:input TokenType:8 Follow:FOLLOW_8_in_functionHeader173]; 684 685 name = (ID3!=nil?ID3.text:nil); 686 687 688 689 } 690 691 // token+rule list labels 692 693 } 694 @catch (ANTLRRecognitionException *re) { 695 [self reportError:re]; 696 [self recover:input Exception:re]; 697 } 698 699 @finally { 700 /* my stuff */ 701 /* Terence's stuff */ 702 703 } 704 return name; 705} 706/* $ANTLR end functionHeader */ 707 708/* 709 * $ANTLR start formalParameter 710 * SimpleC.g:44:1: formalParameter : type declarator ; 711 */ 712- (void) formalParameter 713{ 714 /* my ruleScopeSetUp */ 715 /* Terence's stuff */ 716 717 @try { 718 // SimpleC.g:45:5: ( type declarator ) // ruleBlockSingleAlt 719 // SimpleC.g:45:9: type declarator // alt 720 { 721 /* ruleRef */ 722 [self pushFollow:FOLLOW_type_in_formalParameter195]; 723 [self type]; 724 725 [self popFollow]; 726 727 728 729 /* ruleRef */ 730 [self pushFollow:FOLLOW_declarator_in_formalParameter197]; 731 [self declarator]; 732 733 [self popFollow]; 734 735 736 737 } 738 739 // token+rule list labels 740 741 } 742 @catch (ANTLRRecognitionException *re) { 743 [self reportError:re]; 744 [self recover:input Exception:re]; 745 } 746 747 @finally { 748 /* my stuff */ 749 /* Terence's stuff */ 750 751 } 752 return ; 753} 754/* $ANTLR end formalParameter */ 755 756/* 757 * $ANTLR start type 758 * SimpleC.g:48:1: type : ( 'int' | 'char' | 'void' | ID ); 759 */ 760- (void) type 761{ 762 /* my ruleScopeSetUp */ 763 /* Terence's stuff */ 764 765 @try { 766 // SimpleC.g:49:5: ( 'int' | 'char' | 'void' | ID ) // ruleBlockSingleAlt 767 // SimpleC.g: // alt 768 { 769 if ([input LA:1] == ID||[input LA:1] == 15||(([input LA:1] >= 17) && ([input LA:1] <= 18))) { 770 [input consume]; 771 [state setIsErrorRecovery:NO]; 772 } else { 773 ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException newException:nil stream:input]; 774 @throw mse; 775 } 776 777 778 } 779 780 // token+rule list labels 781 782 } 783 @catch (ANTLRRecognitionException *re) { 784 [self reportError:re]; 785 [self recover:input Exception:re]; 786 } 787 788 @finally { 789 /* my stuff */ 790 /* Terence's stuff */ 791 792 } 793 return ; 794} 795/* $ANTLR end type */ 796 797/* 798 * $ANTLR start block 799 * SimpleC.g:55:1: block : '{' ( variable )* ( stat )* '}' ; 800 */ 801- (void) block 802{ 803 /* my ruleScopeSetUp */ 804 /* Terence's stuff */ 805 806 @try { 807 // SimpleC.g:56:5: ( '{' ( variable )* ( stat )* '}' ) // ruleBlockSingleAlt 808 // SimpleC.g:56:9: '{' ( variable )* ( stat )* '}' // alt 809 { 810 [self match:input TokenType:19 Follow:FOLLOW_19_in_block286]; 811 812 do { 813 NSInteger alt5=2; 814 NSInteger LA5_0 = [input LA:1]; 815 if ( (LA5_0==ID) ) { 816 NSInteger LA5_2 = [input LA:2]; 817 if ( (LA5_2==ID) ) { 818 alt5=1; 819 } 820 821 822 } 823 else if ( (LA5_0==15||(LA5_0 >= 17 && LA5_0 <= 18)) ) { 824 alt5=1; 825 } 826 827 828 switch (alt5) { 829 case 1 : ; 830 // SimpleC.g:57:13: variable // alt 831 { 832 /* ruleRef */ 833 [self pushFollow:FOLLOW_variable_in_block300]; 834 [self variable]; 835 836 [self popFollow]; 837 838 839 840 } 841 break; 842 843 default : 844 goto loop5; 845 } 846 } while (YES); 847 loop5: ; 848 849 850 do { 851 NSInteger alt6=2; 852 NSInteger LA6_0 = [input LA:1]; 853 if ( ((LA6_0 >= ID && LA6_0 <= INT)||LA6_0==7||LA6_0==11||LA6_0==16||LA6_0==19) ) { 854 alt6=1; 855 } 856 857 858 switch (alt6) { 859 case 1 : ; 860 // SimpleC.g:58:13: stat // alt 861 { 862 /* ruleRef */ 863 [self pushFollow:FOLLOW_stat_in_block315]; 864 [self stat]; 865 866 [self popFollow]; 867 868 869 870 } 871 break; 872 873 default : 874 goto loop6; 875 } 876 } while (YES); 877 loop6: ; 878 879 880 [self match:input TokenType:20 Follow:FOLLOW_20_in_block326]; 881 882 } 883 884 // token+rule list labels 885 886 } 887 @catch (ANTLRRecognitionException *re) { 888 [self reportError:re]; 889 [self recover:input Exception:re]; 890 } 891 892 @finally { 893 /* my stuff */ 894 /* Terence's stuff */ 895 896 } 897 return ; 898} 899/* $ANTLR end block */ 900 901/* 902 * $ANTLR start stat 903 * SimpleC.g:62:1: stat : ( forStat | expr ';' | block | assignStat ';' | ';' ); 904 */ 905- (void) stat 906{ 907 /* my ruleScopeSetUp */ 908 /* Terence's stuff */ 909 910 @try { 911 // SimpleC.g:62:5: ( forStat | expr ';' | block | assignStat ';' | ';' ) //ruleblock 912 NSInteger alt7=5; 913 unichar charLA7 = [input LA:1]; 914 switch (charLA7) { 915 case 16: ; 916 { 917 alt7=1; 918 } 919 break; 920 case ID: ; 921 { 922 NSInteger LA7_2 = [input LA:2]; 923 924 if ( (LA7_2==13) ) { 925 alt7=4; 926 } 927 else if ( (LA7_2==9||(LA7_2 >= 11 && LA7_2 <= 12)||LA7_2==14) ) { 928 alt7=2; 929 } 930 else { 931 ANTLRNoViableAltException *nvae = [ANTLRNoViableAltException newException:7 state:2 stream:input]; 932 nvae.c = LA7_2; 933 @throw nvae; 934 935 } 936 } 937 break; 938 case INT: ; 939 case 7: ; 940 { 941 alt7=2; 942 } 943 break; 944 case 19: ; 945 { 946 alt7=3; 947 } 948 break; 949 case 11: ; 950 { 951 alt7=5; 952 } 953 break; 954 955 default: ; 956 ANTLRNoViableAltException *nvae = [ANTLRNoViableAltException newException:7 state:0 stream:input]; 957 nvae.c = charLA7; 958 @throw nvae; 959 960 } 961 962 switch (alt7) { 963 case 1 : ; 964 // SimpleC.g:62:7: forStat // alt 965 { 966 /* ruleRef */ 967 [self pushFollow:FOLLOW_forStat_in_stat338]; 968 [self forStat]; 969 970 [self popFollow]; 971 972 973 974 } 975 break; 976 case 2 : ; 977 // SimpleC.g:63:7: expr ';' // alt 978 { 979 /* ruleRef */ 980 [self pushFollow:FOLLOW_expr_in_stat346]; 981 [self expr]; 982 983 [self popFollow]; 984 985 986 987 [self match:input TokenType:11 Follow:FOLLOW_11_in_stat348]; 988 989 } 990 break; 991 case 3 : ; 992 // SimpleC.g:64:7: block // alt 993 { 994 /* ruleRef */ 995 [self pushFollow:FOLLOW_block_in_stat362]; 996 [self block]; 997 998 [self popFollow]; 999 1000 1001 1002 } 1003 break; 1004 case 4 : ; 1005 // SimpleC.g:65:7: assignStat ';' // alt 1006 { 1007 /* ruleRef */ 1008 [self pushFollow:FOLLOW_assignStat_in_stat370]; 1009 [self assignStat]; 1010 1011 [self popFollow]; 1012 1013 1014 1015 [self match:input TokenType:11 Follow:FOLLOW_11_in_stat372]; 1016 1017 } 1018 break; 1019 case 5 : ; 1020 // SimpleC.g:66:7: ';' // alt 1021 { 1022 [self match:input TokenType:11 Follow:FOLLOW_11_in_stat380]; 1023 1024 } 1025 break; 1026 1027 } 1028 // token+rule list labels 1029 1030 } 1031 @catch (ANTLRRecognitionException *re) { 1032 [self reportError:re]; 1033 [self recover:input Exception:re]; 1034 } 1035 1036 @finally { 1037 /* my stuff */ 1038 /* Terence's stuff */ 1039 1040 } 1041 return ; 1042} 1043/* $ANTLR end stat */ 1044 1045/* 1046 * $ANTLR start forStat 1047 * SimpleC.g:69:1: forStat : 'for' '(' assignStat ';' expr ';' assignStat ')' block ; 1048 */ 1049- (void) forStat 1050{ 1051 /* my ruleScopeSetUp */ 1052 /* Terence's stuff */ 1053 1054 @try { 1055 // SimpleC.g:70:5: ( 'for' '(' assignStat ';' expr ';' assignStat ')' block ) // ruleBlockSingleAlt 1056 // SimpleC.g:70:9: 'for' '(' assignStat ';' expr ';' assignStat ')' block // alt 1057 { 1058 [self match:input TokenType:16 Follow:FOLLOW_16_in_forStat399]; 1059 1060 [self match:input TokenType:7 Follow:FOLLOW_7_in_forStat401]; 1061 1062 /* ruleRef */ 1063 [self pushFollow:FOLLOW_assignStat_in_forStat403]; 1064 [self assignStat]; 1065 1066 [self popFollow]; 1067 1068 1069 1070 [self match:input TokenType:11 Follow:FOLLOW_11_in_forStat405]; 1071 1072 /* ruleRef */ 1073 [self pushFollow:FOLLOW_expr_in_forStat407]; 1074 [self expr]; 1075 1076 [self popFollow]; 1077 1078 1079 1080 [self match:input TokenType:11 Follow:FOLLOW_11_in_forStat409]; 1081 1082 /* ruleRef */ 1083 [self pushFollow:FOLLOW_assignStat_in_forStat411]; 1084 [self assignStat]; 1085 1086 [self popFollow]; 1087 1088 1089 1090 [self match:input TokenType:8 Follow:FOLLOW_8_in_forStat413]; 1091 1092 /* ruleRef */ 1093 [self pushFollow:FOLLOW_block_in_forStat415]; 1094 [self block]; 1095 1096 [self popFollow]; 1097 1098 1099 1100 } 1101 1102 // token+rule list labels 1103 1104 } 1105 @catch (ANTLRRecognitionException *re) { 1106 [self reportError:re]; 1107 [self recover:input Exception:re]; 1108 } 1109 1110 @finally { 1111 /* my stuff */ 1112 /* Terence's stuff */ 1113 1114 } 1115 return ; 1116} 1117/* $ANTLR end forStat */ 1118 1119/* 1120 * $ANTLR start assignStat 1121 * SimpleC.g:73:1: assignStat : ID '=' expr ; 1122 */ 1123- (void) assignStat 1124{ 1125 /* my ruleScopeSetUp */ 1126 /* Terence's stuff */ 1127 1128 @try { 1129 // SimpleC.g:74:5: ( ID '=' expr ) // ruleBlockSingleAlt 1130 // SimpleC.g:74:9: ID '=' expr // alt 1131 { 1132 [self match:input TokenType:ID Follow:FOLLOW_ID_in_assignStat442]; 1133 1134 [self match:input TokenType:13 Follow:FOLLOW_13_in_assignStat444]; 1135 1136 /* ruleRef */ 1137 [self pushFollow:FOLLOW_expr_in_assignStat446]; 1138 [self expr]; 1139 1140 [self popFollow]; 1141 1142 1143 1144 } 1145 1146 // token+rule list labels 1147 1148 } 1149 @catch (ANTLRRecognitionException *re) { 1150 [self reportError:re]; 1151 [self recover:input Exception:re]; 1152 } 1153 1154 @finally { 1155 /* my stuff */ 1156 /* Terence's stuff */ 1157 1158 } 1159 return ; 1160} 1161/* $ANTLR end assignStat */ 1162 1163/* 1164 * $ANTLR start expr 1165 * SimpleC.g:77:1: expr : condExpr ; 1166 */ 1167- (void) expr 1168{ 1169 /* my ruleScopeSetUp */ 1170 /* Terence's stuff */ 1171 1172 @try { 1173 // SimpleC.g:77:5: ( condExpr ) // ruleBlockSingleAlt 1174 // SimpleC.g:77:9: condExpr // alt 1175 { 1176 /* ruleRef */ 1177 [self pushFollow:FOLLOW_condExpr_in_expr468]; 1178 [self condExpr]; 1179 1180 [self popFollow]; 1181 1182 1183 1184 } 1185 1186 // token+rule list labels 1187 1188 } 1189 @catch (ANTLRRecognitionException *re) { 1190 [self reportError:re]; 1191 [self recover:input Exception:re]; 1192 } 1193 1194 @finally { 1195 /* my stuff */ 1196 /* Terence's stuff */ 1197 1198 } 1199 return ; 1200} 1201/* $ANTLR end expr */ 1202 1203/* 1204 * $ANTLR start condExpr 1205 * SimpleC.g:80:1: condExpr : aexpr ( ( '==' | '<' ) aexpr )? ; 1206 */ 1207- (void) condExpr 1208{ 1209 /* my ruleScopeSetUp */ 1210 /* Terence's stuff */ 1211 1212 @try { 1213 // SimpleC.g:81:5: ( aexpr ( ( '==' | '<' ) aexpr )? ) // ruleBlockSingleAlt 1214 // SimpleC.g:81:9: aexpr ( ( '==' | '<' ) aexpr )? // alt 1215 { 1216 /* ruleRef */ 1217 [self pushFollow:FOLLOW_aexpr_in_condExpr487]; 1218 [self aexpr]; 1219 1220 [self popFollow]; 1221 1222 1223 1224 // SimpleC.g:81:15: ( ( '==' | '<' ) aexpr )? // block 1225 NSInteger alt8=2; 1226 NSInteger LA8_0 = [input LA:1]; 1227 1228 if ( (LA8_0==12||LA8_0==14) ) { 1229 alt8=1; 1230 } 1231 switch (alt8) { 1232 case 1 : ; 1233 // SimpleC.g:81:17: ( '==' | '<' ) aexpr // alt 1234 { 1235 if ([input LA:1] == 12||[input LA:1] == 14) { 1236 [input consume]; 1237 [state setIsErrorRecovery:NO]; 1238 } else { 1239 ANTLRMismatchedSetException *mse = [ANTLRMismatchedSetException newException:nil stream:input]; 1240 @throw mse; 1241 } 1242 1243 1244 /* ruleRef */ 1245 [self pushFollow:FOLLOW_aexpr_in_condExpr499]; 1246 [self aexpr]; 1247 1248 [self popFollow]; 1249 1250 1251 1252 } 1253 break; 1254 1255 } 1256 1257 1258 } 1259 1260 // token+rule list labels 1261 1262 } 1263 @catch (ANTLRRecognitionException *re) { 1264 [self reportError:re]; 1265 [self recover:input Exception:re]; 1266 } 1267 1268 @finally { 1269 /* my stuff */ 1270 /* Terence's stuff */ 1271 1272 } 1273 return ; 1274} 1275/* $ANTLR end condExpr */ 1276 1277/* 1278 * $ANTLR start aexpr 1279 * SimpleC.g:84:1: aexpr : atom ( '+' atom )* ; 1280 */ 1281- (void) aexpr 1282{ 1283 /* my ruleScopeSetUp */ 1284 /* Terence's stuff */ 1285 1286 @try { 1287 // SimpleC.g:85:5: ( atom ( '+' atom )* ) // ruleBlockSingleAlt 1288 // SimpleC.g:85:9: atom ( '+' atom )* // alt 1289 { 1290 /* ruleRef */ 1291 [self pushFollow:FOLLOW_atom_in_aexpr521]; 1292 [self atom]; 1293 1294 [self popFollow]; 1295 1296 1297 1298 do { 1299 NSInteger alt9=2; 1300 NSInteger LA9_0 = [input LA:1]; 1301 if ( (LA9_0==9) ) { 1302 alt9=1; 1303 } 1304 1305 1306 switch (alt9) { 1307 case 1 : ; 1308 // SimpleC.g:85:16: '+' atom // alt 1309 { 1310 [self match:input TokenType:9 Follow:FOLLOW_9_in_aexpr525]; 1311 1312 /* ruleRef */ 1313 [self pushFollow:FOLLOW_atom_in_aexpr527]; 1314 [self atom]; 1315 1316 [self popFollow]; 1317 1318 1319 1320 } 1321 break; 1322 1323 default : 1324 goto loop9; 1325 } 1326 } while (YES); 1327 loop9: ; 1328 1329 1330 } 1331 1332 // token+rule list labels 1333 1334 } 1335 @catch (ANTLRRecognitionException *re) { 1336 [self reportError:re]; 1337 [self recover:input Exception:re]; 1338 } 1339 1340 @finally { 1341 /* my stuff */ 1342 /* Terence's stuff */ 1343 1344 } 1345 return ; 1346} 1347/* $ANTLR end aexpr */ 1348 1349/* 1350 * $ANTLR start atom 1351 * SimpleC.g:88:1: atom : ( ID | INT | '(' expr ')' ); 1352 */ 1353- (void) atom 1354{ 1355 /* my ruleScopeSetUp */ 1356 /* Terence's stuff */ 1357 1358 @try { 1359 // SimpleC.g:89:5: ( ID | INT | '(' expr ')' ) //ruleblock 1360 NSInteger alt10=3; 1361 unichar charLA10 = [input LA:1]; 1362 switch (charLA10) { 1363 case ID: ; 1364 { 1365 alt10=1; 1366 } 1367 break; 1368 case INT: ; 1369 { 1370 alt10=2; 1371 } 1372 break; 1373 case 7: ; 1374 { 1375 alt10=3; 1376 } 1377 break; 1378 1379 default: ; 1380 ANTLRNoViableAltException *nvae = [ANTLRNoViableAltException newException:10 state:0 stream:input]; 1381 nvae.c = charLA10; 1382 @throw nvae; 1383 1384 } 1385 1386 switch (alt10) { 1387 case 1 : ; 1388 // SimpleC.g:89:7: ID // alt 1389 { 1390 [self match:input TokenType:ID Follow:FOLLOW_ID_in_atom547]; 1391 1392 } 1393 break; 1394 case 2 : ; 1395 // SimpleC.g:90:7: INT // alt 1396 { 1397 [self match:input TokenType:INT Follow:FOLLOW_INT_in_atom561]; 1398 1399 } 1400 break; 1401 case 3 : ; 1402 // SimpleC.g:91:7: '(' expr ')' // alt 1403 { 1404 [self match:input TokenType:7 Follow:FOLLOW_7_in_atom575]; 1405 1406 /* ruleRef */ 1407 [self pushFollow:FOLLOW_expr_in_atom577]; 1408 [self expr]; 1409 1410 [self popFollow]; 1411 1412 1413 1414 [self match:input TokenType:8 Follow:FOLLOW_8_in_atom579]; 1415 1416 } 1417 break; 1418 1419 } 1420 // token+rule list labels 1421 1422 } 1423 @catch (ANTLRRecognitionException *re) { 1424 [self reportError:re]; 1425 [self recover:input Exception:re]; 1426 } 1427 1428 @finally { 1429 /* my stuff */ 1430 /* Terence's stuff */ 1431 1432 } 1433 return ; 1434} 1435/* $ANTLR end atom */ 1436/* ObjC end rules */ 1437 1438@end /* end of SimpleCParser implementation line 692 */ 1439