PageRenderTime 63ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/projects/antlr-3.4/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleCParser.m

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Objective C | 1440 lines | 955 code | 306 blank | 179 comment | 102 complexity | edac0b0c528fa71772b3b4978d92007b MD5 | raw file
  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 15:09:17
  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 15:09:17
  15. /* -----------------------------------------
  16. * Include the ANTLR3 generated header file.
  17. */
  18. #import "SimpleCParser.h"
  19. /* ----------------------------------------- */
  20. /* ============================================================================= */
  21. /* =============================================================================
  22. * Start of recognizer
  23. */
  24. #pragma mark Cyclic DFA implementation start DFA2
  25. @implementation DFA2
  26. const static NSInteger dfa2_eot[13] =
  27. {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
  28. const static NSInteger dfa2_eof[13] =
  29. {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
  30. const static unichar dfa2_min[13] =
  31. {9,14,18,9,0,14,17,10,0,0,9,14,10};
  32. const static unichar dfa2_max[13] =
  33. {24,14,23,24,0,14,23,22,0,0,24,14,22};
  34. const static NSInteger dfa2_accept[13] =
  35. {-1,-1,-1,-1,1,-1,-1,-1,2,3,-1,-1,-1};
  36. const static NSInteger dfa2_special[13] =
  37. {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
  38. const static NSInteger dfa2_transition[] = {};
  39. const static NSInteger dfa2_transition0[] = {9, -1, -1, -1, -1, -1, 8};
  40. const static NSInteger dfa2_transition1[] = {10, -1, -1, -1, -1, -1, -1,
  41. -1, -1, -1, -1, -1, 6};
  42. const static NSInteger dfa2_transition2[] = {5, -1, -1, -1, -1, 5, -1, 5,
  43. -1, -1, -1, -1, -1, 6, -1, 5};
  44. const static NSInteger dfa2_transition3[] = {11, -1, -1, -1, -1, 11, -1,
  45. 11, -1, -1, -1, -1, -1, -1, -1, 11};
  46. const static NSInteger dfa2_transition4[] = {3, -1, -1, -1, -1, 4};
  47. const static NSInteger dfa2_transition5[] = {1, -1, -1, -1, -1, 1, -1, 1,
  48. -1, -1, -1, -1, -1, -1, -1, 1};
  49. const static NSInteger dfa2_transition6[] = {7};
  50. const static NSInteger dfa2_transition7[] = {12};
  51. const static NSInteger dfa2_transition8[] = {2};
  52. + (id) newDFA2WithRecognizer:(ANTLRBaseRecognizer *)aRecognizer
  53. {
  54. return [[[DFA2 alloc] initWithRecognizer:aRecognizer] retain];
  55. }
  56. - (id) initWithRecognizer:(ANTLRBaseRecognizer *) theRecognizer
  57. {
  58. self = [super initWithRecognizer:theRecognizer];
  59. if ( self != nil ) {
  60. decisionNumber = 2;
  61. eot = dfa2_eot;
  62. eof = dfa2_eof;
  63. min = dfa2_min;
  64. max = dfa2_max;
  65. accept = dfa2_accept;
  66. special = dfa2_special;
  67. if (!(transition = calloc(13, sizeof(void*)))) {
  68. [self release];
  69. return nil;
  70. }
  71. len = 13;
  72. transition[0] = dfa2_transition5;
  73. transition[1] = dfa2_transition8;
  74. transition[2] = dfa2_transition4;
  75. transition[3] = dfa2_transition2;
  76. transition[4] = dfa2_transition6;
  77. transition[5] = dfa2_transition0;
  78. transition[6] = dfa2_transition1;
  79. transition[7] = dfa2_transition3;
  80. transition[8] = dfa2_transition7;
  81. transition[9] = dfa2_transition1;
  82. }
  83. return self;
  84. }
  85. - (void) dealloc
  86. {
  87. free(transition);
  88. [super dealloc];
  89. }
  90. - (NSString *) description
  91. {
  92. return @"20:1: declaration : ( variable | functionHeader K_SEMICOLON -> ^( FUNC_DECL functionHeader ) | functionHeader block -> ^( FUNC_DEF functionHeader block ) );";
  93. }
  94. @end /* end DFA2 implementation */
  95. #pragma mark Cyclic DFA implementation end DFA2
  96. #pragma mark Bitsets
  97. static ANTLRBitSet *FOLLOW_declaration_in_program85;
  98. static const unsigned long long FOLLOW_declaration_in_program85_data[] = { 0x0000000001014202LL};
  99. static ANTLRBitSet *FOLLOW_variable_in_declaration105;
  100. static const unsigned long long FOLLOW_variable_in_declaration105_data[] = { 0x0000000000000002LL};
  101. static ANTLRBitSet *FOLLOW_functionHeader_in_declaration115;
  102. static const unsigned long long FOLLOW_functionHeader_in_declaration115_data[] = { 0x0000000000800000LL};
  103. static ANTLRBitSet *FOLLOW_K_SEMICOLON_in_declaration117;
  104. static const unsigned long long FOLLOW_K_SEMICOLON_in_declaration117_data[] = { 0x0000000000000002LL};
  105. static ANTLRBitSet *FOLLOW_functionHeader_in_declaration135;
  106. static const unsigned long long FOLLOW_functionHeader_in_declaration135_data[] = { 0x0000000000020000LL};
  107. static ANTLRBitSet *FOLLOW_block_in_declaration137;
  108. static const unsigned long long FOLLOW_block_in_declaration137_data[] = { 0x0000000000000002LL};
  109. static ANTLRBitSet *FOLLOW_type_in_variable166;
  110. static const unsigned long long FOLLOW_type_in_variable166_data[] = { 0x0000000000004000LL};
  111. static ANTLRBitSet *FOLLOW_declarator_in_variable168;
  112. static const unsigned long long FOLLOW_declarator_in_variable168_data[] = { 0x0000000000800000LL};
  113. static ANTLRBitSet *FOLLOW_K_SEMICOLON_in_variable170;
  114. static const unsigned long long FOLLOW_K_SEMICOLON_in_variable170_data[] = { 0x0000000000000002LL};
  115. static ANTLRBitSet *FOLLOW_K_ID_in_declarator199;
  116. static const unsigned long long FOLLOW_K_ID_in_declarator199_data[] = { 0x0000000000000002LL};
  117. static ANTLRBitSet *FOLLOW_type_in_functionHeader219;
  118. static const unsigned long long FOLLOW_type_in_functionHeader219_data[] = { 0x0000000000004000LL};
  119. static ANTLRBitSet *FOLLOW_K_ID_in_functionHeader221;
  120. static const unsigned long long FOLLOW_K_ID_in_functionHeader221_data[] = { 0x0000000000040000LL};
  121. static ANTLRBitSet *FOLLOW_K_LCURVE_in_functionHeader223;
  122. static const unsigned long long FOLLOW_K_LCURVE_in_functionHeader223_data[] = { 0x0000000001414200LL};
  123. static ANTLRBitSet *FOLLOW_formalParameter_in_functionHeader227;
  124. static const unsigned long long FOLLOW_formalParameter_in_functionHeader227_data[] = { 0x0000000000400400LL};
  125. static ANTLRBitSet *FOLLOW_K_COMMA_in_functionHeader231;
  126. static const unsigned long long FOLLOW_K_COMMA_in_functionHeader231_data[] = { 0x0000000001014200LL};
  127. static ANTLRBitSet *FOLLOW_formalParameter_in_functionHeader233;
  128. static const unsigned long long FOLLOW_formalParameter_in_functionHeader233_data[] = { 0x0000000000400400LL};
  129. static ANTLRBitSet *FOLLOW_K_RCURVE_in_functionHeader241;
  130. static const unsigned long long FOLLOW_K_RCURVE_in_functionHeader241_data[] = { 0x0000000000000002LL};
  131. static ANTLRBitSet *FOLLOW_type_in_formalParameter281;
  132. static const unsigned long long FOLLOW_type_in_formalParameter281_data[] = { 0x0000000000004000LL};
  133. static ANTLRBitSet *FOLLOW_declarator_in_formalParameter283;
  134. static const unsigned long long FOLLOW_declarator_in_formalParameter283_data[] = { 0x0000000000000002LL};
  135. static ANTLRBitSet *FOLLOW_K_LCURLY_in_block376;
  136. static const unsigned long long FOLLOW_K_LCURLY_in_block376_data[] = { 0x0000000001A7E200LL};
  137. static ANTLRBitSet *FOLLOW_variable_in_block390;
  138. static const unsigned long long FOLLOW_variable_in_block390_data[] = { 0x0000000001A7E200LL};
  139. static ANTLRBitSet *FOLLOW_stat_in_block405;
  140. static const unsigned long long FOLLOW_stat_in_block405_data[] = { 0x0000000000A6E000LL};
  141. static ANTLRBitSet *FOLLOW_K_RCURLY_in_block416;
  142. static const unsigned long long FOLLOW_K_RCURLY_in_block416_data[] = { 0x0000000000000002LL};
  143. static ANTLRBitSet *FOLLOW_forStat_in_stat449;
  144. static const unsigned long long FOLLOW_forStat_in_stat449_data[] = { 0x0000000000000002LL};
  145. static ANTLRBitSet *FOLLOW_expr_in_stat457;
  146. static const unsigned long long FOLLOW_expr_in_stat457_data[] = { 0x0000000000800000LL};
  147. static ANTLRBitSet *FOLLOW_K_SEMICOLON_in_stat459;
  148. static const unsigned long long FOLLOW_K_SEMICOLON_in_stat459_data[] = { 0x0000000000000002LL};
  149. static ANTLRBitSet *FOLLOW_block_in_stat468;
  150. static const unsigned long long FOLLOW_block_in_stat468_data[] = { 0x0000000000000002LL};
  151. static ANTLRBitSet *FOLLOW_assignStat_in_stat476;
  152. static const unsigned long long FOLLOW_assignStat_in_stat476_data[] = { 0x0000000000800000LL};
  153. static ANTLRBitSet *FOLLOW_K_SEMICOLON_in_stat478;
  154. static const unsigned long long FOLLOW_K_SEMICOLON_in_stat478_data[] = { 0x0000000000000002LL};
  155. static ANTLRBitSet *FOLLOW_K_SEMICOLON_in_stat487;
  156. static const unsigned long long FOLLOW_K_SEMICOLON_in_stat487_data[] = { 0x0000000000000002LL};
  157. static ANTLRBitSet *FOLLOW_K_FOR_in_forStat507;
  158. static const unsigned long long FOLLOW_K_FOR_in_forStat507_data[] = { 0x0000000000040000LL};
  159. static ANTLRBitSet *FOLLOW_K_LCURVE_in_forStat509;
  160. static const unsigned long long FOLLOW_K_LCURVE_in_forStat509_data[] = { 0x0000000000004000LL};
  161. static ANTLRBitSet *FOLLOW_assignStat_in_forStat513;
  162. static const unsigned long long FOLLOW_assignStat_in_forStat513_data[] = { 0x0000000000800000LL};
  163. static ANTLRBitSet *FOLLOW_K_SEMICOLON_in_forStat515;
  164. static const unsigned long long FOLLOW_K_SEMICOLON_in_forStat515_data[] = { 0x000000000004C000LL};
  165. static ANTLRBitSet *FOLLOW_expr_in_forStat517;
  166. static const unsigned long long FOLLOW_expr_in_forStat517_data[] = { 0x0000000000800000LL};
  167. static ANTLRBitSet *FOLLOW_K_SEMICOLON_in_forStat519;
  168. static const unsigned long long FOLLOW_K_SEMICOLON_in_forStat519_data[] = { 0x0000000000004000LL};
  169. static ANTLRBitSet *FOLLOW_assignStat_in_forStat523;
  170. static const unsigned long long FOLLOW_assignStat_in_forStat523_data[] = { 0x0000000000400000LL};
  171. static ANTLRBitSet *FOLLOW_K_RCURVE_in_forStat525;
  172. static const unsigned long long FOLLOW_K_RCURVE_in_forStat525_data[] = { 0x0000000000020000LL};
  173. static ANTLRBitSet *FOLLOW_block_in_forStat527;
  174. static const unsigned long long FOLLOW_block_in_forStat527_data[] = { 0x0000000000000002LL};
  175. static ANTLRBitSet *FOLLOW_K_ID_in_assignStat570;
  176. static const unsigned long long FOLLOW_K_ID_in_assignStat570_data[] = { 0x0000000000000800LL};
  177. static ANTLRBitSet *FOLLOW_K_EQ_in_assignStat572;
  178. static const unsigned long long FOLLOW_K_EQ_in_assignStat572_data[] = { 0x000000000004C000LL};
  179. static ANTLRBitSet *FOLLOW_expr_in_assignStat574;
  180. static const unsigned long long FOLLOW_expr_in_assignStat574_data[] = { 0x0000000000000002LL};
  181. static ANTLRBitSet *FOLLOW_condExpr_in_expr598;
  182. static const unsigned long long FOLLOW_condExpr_in_expr598_data[] = { 0x0000000000000002LL};
  183. static ANTLRBitSet *FOLLOW_aexpr_in_condExpr617;
  184. static const unsigned long long FOLLOW_aexpr_in_condExpr617_data[] = { 0x0000000000081002LL};
  185. static ANTLRBitSet *FOLLOW_K_EQEQ_in_condExpr622;
  186. static const unsigned long long FOLLOW_K_EQEQ_in_condExpr622_data[] = { 0x000000000004C000LL};
  187. static ANTLRBitSet *FOLLOW_K_LT_in_condExpr627;
  188. static const unsigned long long FOLLOW_K_LT_in_condExpr627_data[] = { 0x000000000004C000LL};
  189. static ANTLRBitSet *FOLLOW_aexpr_in_condExpr631;
  190. static const unsigned long long FOLLOW_aexpr_in_condExpr631_data[] = { 0x0000000000000002LL};
  191. static ANTLRBitSet *FOLLOW_atom_in_aexpr653;
  192. static const unsigned long long FOLLOW_atom_in_aexpr653_data[] = { 0x0000000000100002LL};
  193. static ANTLRBitSet *FOLLOW_K_PLUS_in_aexpr657;
  194. static const unsigned long long FOLLOW_K_PLUS_in_aexpr657_data[] = { 0x000000000004C000LL};
  195. static ANTLRBitSet *FOLLOW_atom_in_aexpr660;
  196. static const unsigned long long FOLLOW_atom_in_aexpr660_data[] = { 0x0000000000100002LL};
  197. static ANTLRBitSet *FOLLOW_K_ID_in_atom680;
  198. static const unsigned long long FOLLOW_K_ID_in_atom680_data[] = { 0x0000000000000002LL};
  199. static ANTLRBitSet *FOLLOW_K_INT_in_atom694;
  200. static const unsigned long long FOLLOW_K_INT_in_atom694_data[] = { 0x0000000000000002LL};
  201. static ANTLRBitSet *FOLLOW_K_LCURVE_in_atom708;
  202. static const unsigned long long FOLLOW_K_LCURVE_in_atom708_data[] = { 0x000000000004C000LL};
  203. static ANTLRBitSet *FOLLOW_expr_in_atom710;
  204. static const unsigned long long FOLLOW_expr_in_atom710_data[] = { 0x0000000000400000LL};
  205. static ANTLRBitSet *FOLLOW_K_RCURVE_in_atom712;
  206. static const unsigned long long FOLLOW_K_RCURVE_in_atom712_data[] = { 0x0000000000000002LL};
  207. #pragma mark Dynamic Global Scopes
  208. #pragma mark Dynamic Rule Scopes
  209. #pragma mark Rule Return Scopes start
  210. @implementation SimpleCParser_program_return /* returnScope */
  211. /* AST returnScope.synthesize */
  212. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  213. + (SimpleCParser_program_return *)newSimpleCParser_program_return
  214. {
  215. return [[[SimpleCParser_program_return alloc] init] retain];
  216. }
  217. - (id) init
  218. {
  219. self = [super init];
  220. return self;
  221. }
  222. /* AST returnScope.methods */
  223. - (ANTLRCommonTree *)getTree
  224. {
  225. return tree;
  226. }
  227. - (void) setTree:(ANTLRCommonTree *)aTree
  228. {
  229. if (tree != aTree) {
  230. if (tree != nil) [tree release];
  231. if (aTree != nil) [aTree retain];
  232. tree = aTree;
  233. }
  234. }
  235. - (void) dealloc
  236. {
  237. self.tree = nil;
  238. [super dealloc];
  239. }
  240. @end /* end of returnScope implementation */
  241. @implementation SimpleCParser_declaration_return /* returnScope */
  242. /* AST returnScope.synthesize */
  243. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  244. + (SimpleCParser_declaration_return *)newSimpleCParser_declaration_return
  245. {
  246. return [[[SimpleCParser_declaration_return alloc] init] retain];
  247. }
  248. - (id) init
  249. {
  250. self = [super init];
  251. return self;
  252. }
  253. /* AST returnScope.methods */
  254. - (ANTLRCommonTree *)getTree
  255. {
  256. return tree;
  257. }
  258. - (void) setTree:(ANTLRCommonTree *)aTree
  259. {
  260. if (tree != aTree) {
  261. if (tree != nil) [tree release];
  262. if (aTree != nil) [aTree retain];
  263. tree = aTree;
  264. }
  265. }
  266. - (void) dealloc
  267. {
  268. self.tree = nil;
  269. [super dealloc];
  270. }
  271. @end /* end of returnScope implementation */
  272. @implementation SimpleCParser_variable_return /* returnScope */
  273. /* AST returnScope.synthesize */
  274. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  275. + (SimpleCParser_variable_return *)newSimpleCParser_variable_return
  276. {
  277. return [[[SimpleCParser_variable_return alloc] init] retain];
  278. }
  279. - (id) init
  280. {
  281. self = [super init];
  282. return self;
  283. }
  284. /* AST returnScope.methods */
  285. - (ANTLRCommonTree *)getTree
  286. {
  287. return tree;
  288. }
  289. - (void) setTree:(ANTLRCommonTree *)aTree
  290. {
  291. if (tree != aTree) {
  292. if (tree != nil) [tree release];
  293. if (aTree != nil) [aTree retain];
  294. tree = aTree;
  295. }
  296. }
  297. - (void) dealloc
  298. {
  299. self.tree = nil;
  300. [super dealloc];
  301. }
  302. @end /* end of returnScope implementation */
  303. @implementation SimpleCParser_declarator_return /* returnScope */
  304. /* AST returnScope.synthesize */
  305. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  306. + (SimpleCParser_declarator_return *)newSimpleCParser_declarator_return
  307. {
  308. return [[[SimpleCParser_declarator_return alloc] init] retain];
  309. }
  310. - (id) init
  311. {
  312. self = [super init];
  313. return self;
  314. }
  315. /* AST returnScope.methods */
  316. - (ANTLRCommonTree *)getTree
  317. {
  318. return tree;
  319. }
  320. - (void) setTree:(ANTLRCommonTree *)aTree
  321. {
  322. if (tree != aTree) {
  323. if (tree != nil) [tree release];
  324. if (aTree != nil) [aTree retain];
  325. tree = aTree;
  326. }
  327. }
  328. - (void) dealloc
  329. {
  330. self.tree = nil;
  331. [super dealloc];
  332. }
  333. @end /* end of returnScope implementation */
  334. @implementation SimpleCParser_functionHeader_return /* returnScope */
  335. /* AST returnScope.synthesize */
  336. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  337. + (SimpleCParser_functionHeader_return *)newSimpleCParser_functionHeader_return
  338. {
  339. return [[[SimpleCParser_functionHeader_return alloc] init] retain];
  340. }
  341. - (id) init
  342. {
  343. self = [super init];
  344. return self;
  345. }
  346. /* AST returnScope.methods */
  347. - (ANTLRCommonTree *)getTree
  348. {
  349. return tree;
  350. }
  351. - (void) setTree:(ANTLRCommonTree *)aTree
  352. {
  353. if (tree != aTree) {
  354. if (tree != nil) [tree release];
  355. if (aTree != nil) [aTree retain];
  356. tree = aTree;
  357. }
  358. }
  359. - (void) dealloc
  360. {
  361. self.tree = nil;
  362. [super dealloc];
  363. }
  364. @end /* end of returnScope implementation */
  365. @implementation SimpleCParser_formalParameter_return /* returnScope */
  366. /* AST returnScope.synthesize */
  367. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  368. + (SimpleCParser_formalParameter_return *)newSimpleCParser_formalParameter_return
  369. {
  370. return [[[SimpleCParser_formalParameter_return alloc] init] retain];
  371. }
  372. - (id) init
  373. {
  374. self = [super init];
  375. return self;
  376. }
  377. /* AST returnScope.methods */
  378. - (ANTLRCommonTree *)getTree
  379. {
  380. return tree;
  381. }
  382. - (void) setTree:(ANTLRCommonTree *)aTree
  383. {
  384. if (tree != aTree) {
  385. if (tree != nil) [tree release];
  386. if (aTree != nil) [aTree retain];
  387. tree = aTree;
  388. }
  389. }
  390. - (void) dealloc
  391. {
  392. self.tree = nil;
  393. [super dealloc];
  394. }
  395. @end /* end of returnScope implementation */
  396. @implementation SimpleCParser_type_return /* returnScope */
  397. /* AST returnScope.synthesize */
  398. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  399. + (SimpleCParser_type_return *)newSimpleCParser_type_return
  400. {
  401. return [[[SimpleCParser_type_return alloc] init] retain];
  402. }
  403. - (id) init
  404. {
  405. self = [super init];
  406. return self;
  407. }
  408. /* AST returnScope.methods */
  409. - (ANTLRCommonTree *)getTree
  410. {
  411. return tree;
  412. }
  413. - (void) setTree:(ANTLRCommonTree *)aTree
  414. {
  415. if (tree != aTree) {
  416. if (tree != nil) [tree release];
  417. if (aTree != nil) [aTree retain];
  418. tree = aTree;
  419. }
  420. }
  421. - (void) dealloc
  422. {
  423. self.tree = nil;
  424. [super dealloc];
  425. }
  426. @end /* end of returnScope implementation */
  427. @implementation SimpleCParser_block_return /* returnScope */
  428. /* AST returnScope.synthesize */
  429. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  430. + (SimpleCParser_block_return *)newSimpleCParser_block_return
  431. {
  432. return [[[SimpleCParser_block_return alloc] init] retain];
  433. }
  434. - (id) init
  435. {
  436. self = [super init];
  437. return self;
  438. }
  439. /* AST returnScope.methods */
  440. - (ANTLRCommonTree *)getTree
  441. {
  442. return tree;
  443. }
  444. - (void) setTree:(ANTLRCommonTree *)aTree
  445. {
  446. if (tree != aTree) {
  447. if (tree != nil) [tree release];
  448. if (aTree != nil) [aTree retain];
  449. tree = aTree;
  450. }
  451. }
  452. - (void) dealloc
  453. {
  454. self.tree = nil;
  455. [super dealloc];
  456. }
  457. @end /* end of returnScope implementation */
  458. @implementation SimpleCParser_stat_return /* returnScope */
  459. /* AST returnScope.synthesize */
  460. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  461. + (SimpleCParser_stat_return *)newSimpleCParser_stat_return
  462. {
  463. return [[[SimpleCParser_stat_return alloc] init] retain];
  464. }
  465. - (id) init
  466. {
  467. self = [super init];
  468. return self;
  469. }
  470. /* AST returnScope.methods */
  471. - (ANTLRCommonTree *)getTree
  472. {
  473. return tree;
  474. }
  475. - (void) setTree:(ANTLRCommonTree *)aTree
  476. {
  477. if (tree != aTree) {
  478. if (tree != nil) [tree release];
  479. if (aTree != nil) [aTree retain];
  480. tree = aTree;
  481. }
  482. }
  483. - (void) dealloc
  484. {
  485. self.tree = nil;
  486. [super dealloc];
  487. }
  488. @end /* end of returnScope implementation */
  489. @implementation SimpleCParser_forStat_return /* returnScope */
  490. /* AST returnScope.synthesize */
  491. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  492. + (SimpleCParser_forStat_return *)newSimpleCParser_forStat_return
  493. {
  494. return [[[SimpleCParser_forStat_return alloc] init] retain];
  495. }
  496. - (id) init
  497. {
  498. self = [super init];
  499. return self;
  500. }
  501. /* AST returnScope.methods */
  502. - (ANTLRCommonTree *)getTree
  503. {
  504. return tree;
  505. }
  506. - (void) setTree:(ANTLRCommonTree *)aTree
  507. {
  508. if (tree != aTree) {
  509. if (tree != nil) [tree release];
  510. if (aTree != nil) [aTree retain];
  511. tree = aTree;
  512. }
  513. }
  514. - (void) dealloc
  515. {
  516. self.tree = nil;
  517. [super dealloc];
  518. }
  519. @end /* end of returnScope implementation */
  520. @implementation SimpleCParser_assignStat_return /* returnScope */
  521. /* AST returnScope.synthesize */
  522. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  523. + (SimpleCParser_assignStat_return *)newSimpleCParser_assignStat_return
  524. {
  525. return [[[SimpleCParser_assignStat_return alloc] init] retain];
  526. }
  527. - (id) init
  528. {
  529. self = [super init];
  530. return self;
  531. }
  532. /* AST returnScope.methods */
  533. - (ANTLRCommonTree *)getTree
  534. {
  535. return tree;
  536. }
  537. - (void) setTree:(ANTLRCommonTree *)aTree
  538. {
  539. if (tree != aTree) {
  540. if (tree != nil) [tree release];
  541. if (aTree != nil) [aTree retain];
  542. tree = aTree;
  543. }
  544. }
  545. - (void) dealloc
  546. {
  547. self.tree = nil;
  548. [super dealloc];
  549. }
  550. @end /* end of returnScope implementation */
  551. @implementation SimpleCParser_expr_return /* returnScope */
  552. /* AST returnScope.synthesize */
  553. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  554. + (SimpleCParser_expr_return *)newSimpleCParser_expr_return
  555. {
  556. return [[[SimpleCParser_expr_return alloc] init] retain];
  557. }
  558. - (id) init
  559. {
  560. self = [super init];
  561. return self;
  562. }
  563. /* AST returnScope.methods */
  564. - (ANTLRCommonTree *)getTree
  565. {
  566. return tree;
  567. }
  568. - (void) setTree:(ANTLRCommonTree *)aTree
  569. {
  570. if (tree != aTree) {
  571. if (tree != nil) [tree release];
  572. if (aTree != nil) [aTree retain];
  573. tree = aTree;
  574. }
  575. }
  576. - (void) dealloc
  577. {
  578. self.tree = nil;
  579. [super dealloc];
  580. }
  581. @end /* end of returnScope implementation */
  582. @implementation SimpleCParser_condExpr_return /* returnScope */
  583. /* AST returnScope.synthesize */
  584. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  585. + (SimpleCParser_condExpr_return *)newSimpleCParser_condExpr_return
  586. {
  587. return [[[SimpleCParser_condExpr_return alloc] init] retain];
  588. }
  589. - (id) init
  590. {
  591. self = [super init];
  592. return self;
  593. }
  594. /* AST returnScope.methods */
  595. - (ANTLRCommonTree *)getTree
  596. {
  597. return tree;
  598. }
  599. - (void) setTree:(ANTLRCommonTree *)aTree
  600. {
  601. if (tree != aTree) {
  602. if (tree != nil) [tree release];
  603. if (aTree != nil) [aTree retain];
  604. tree = aTree;
  605. }
  606. }
  607. - (void) dealloc
  608. {
  609. self.tree = nil;
  610. [super dealloc];
  611. }
  612. @end /* end of returnScope implementation */
  613. @implementation SimpleCParser_aexpr_return /* returnScope */
  614. /* AST returnScope.synthesize */
  615. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  616. + (SimpleCParser_aexpr_return *)newSimpleCParser_aexpr_return
  617. {
  618. return [[[SimpleCParser_aexpr_return alloc] init] retain];
  619. }
  620. - (id) init
  621. {
  622. self = [super init];
  623. return self;
  624. }
  625. /* AST returnScope.methods */
  626. - (ANTLRCommonTree *)getTree
  627. {
  628. return tree;
  629. }
  630. - (void) setTree:(ANTLRCommonTree *)aTree
  631. {
  632. if (tree != aTree) {
  633. if (tree != nil) [tree release];
  634. if (aTree != nil) [aTree retain];
  635. tree = aTree;
  636. }
  637. }
  638. - (void) dealloc
  639. {
  640. self.tree = nil;
  641. [super dealloc];
  642. }
  643. @end /* end of returnScope implementation */
  644. @implementation SimpleCParser_atom_return /* returnScope */
  645. /* AST returnScope.synthesize */
  646. @synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
  647. + (SimpleCParser_atom_return *)newSimpleCParser_atom_return
  648. {
  649. return [[[SimpleCParser_atom_return alloc] init] retain];
  650. }
  651. - (id) init
  652. {
  653. self = [super init];
  654. return self;
  655. }
  656. /* AST returnScope.methods */
  657. - (ANTLRCommonTree *)getTree
  658. {
  659. return tree;
  660. }
  661. - (void) setTree:(ANTLRCommonTree *)aTree
  662. {
  663. if (tree != aTree) {
  664. if (tree != nil) [tree release];
  665. if (aTree != nil) [aTree retain];
  666. tree = aTree;
  667. }
  668. }
  669. - (void) dealloc
  670. {
  671. self.tree = nil;
  672. [super dealloc];
  673. }
  674. @end /* end of returnScope implementation */
  675. //#pragma mark Rule return scopes start
  676. //
  677. #pragma mark Rule return scopes start
  678. @implementation SimpleCParser // line 637
  679. /* ObjC start of ruleAttributeScope */
  680. #pragma mark Dynamic Rule Scopes
  681. /* ObjC end of ruleAttributeScope */
  682. #pragma mark global Attribute Scopes
  683. /* ObjC start globalAttributeScope */
  684. /* ObjC end globalAttributeScope */
  685. /* ObjC start actions.(actionScope).synthesize */
  686. /* ObjC end actions.(actionScope).synthesize */
  687. /* ObjC start synthesize() */
  688. /* AST genericParser.synthesize */
  689. /* AST parserProperties */
  690. @synthesize treeAdaptor;
  691. /* ObjC end synthesize() */
  692. + (void) initialize
  693. {
  694. #pragma mark Bitsets
  695. FOLLOW_declaration_in_program85 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_declaration_in_program85_data Count:(NSUInteger)1] retain];
  696. FOLLOW_variable_in_declaration105 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_variable_in_declaration105_data Count:(NSUInteger)1] retain];
  697. FOLLOW_functionHeader_in_declaration115 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_functionHeader_in_declaration115_data Count:(NSUInteger)1] retain];
  698. FOLLOW_K_SEMICOLON_in_declaration117 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_SEMICOLON_in_declaration117_data Count:(NSUInteger)1] retain];
  699. FOLLOW_functionHeader_in_declaration135 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_functionHeader_in_declaration135_data Count:(NSUInteger)1] retain];
  700. FOLLOW_block_in_declaration137 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_declaration137_data Count:(NSUInteger)1] retain];
  701. FOLLOW_type_in_variable166 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_type_in_variable166_data Count:(NSUInteger)1] retain];
  702. FOLLOW_declarator_in_variable168 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_declarator_in_variable168_data Count:(NSUInteger)1] retain];
  703. FOLLOW_K_SEMICOLON_in_variable170 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_SEMICOLON_in_variable170_data Count:(NSUInteger)1] retain];
  704. FOLLOW_K_ID_in_declarator199 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_ID_in_declarator199_data Count:(NSUInteger)1] retain];
  705. FOLLOW_type_in_functionHeader219 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_type_in_functionHeader219_data Count:(NSUInteger)1] retain];
  706. FOLLOW_K_ID_in_functionHeader221 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_ID_in_functionHeader221_data Count:(NSUInteger)1] retain];
  707. FOLLOW_K_LCURVE_in_functionHeader223 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_LCURVE_in_functionHeader223_data Count:(NSUInteger)1] retain];
  708. FOLLOW_formalParameter_in_functionHeader227 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_formalParameter_in_functionHeader227_data Count:(NSUInteger)1] retain];
  709. FOLLOW_K_COMMA_in_functionHeader231 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_COMMA_in_functionHeader231_data Count:(NSUInteger)1] retain];
  710. FOLLOW_formalParameter_in_functionHeader233 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_formalParameter_in_functionHeader233_data Count:(NSUInteger)1] retain];
  711. FOLLOW_K_RCURVE_in_functionHeader241 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_RCURVE_in_functionHeader241_data Count:(NSUInteger)1] retain];
  712. FOLLOW_type_in_formalParameter281 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_type_in_formalParameter281_data Count:(NSUInteger)1] retain];
  713. FOLLOW_declarator_in_formalParameter283 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_declarator_in_formalParameter283_data Count:(NSUInteger)1] retain];
  714. FOLLOW_K_LCURLY_in_block376 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_LCURLY_in_block376_data Count:(NSUInteger)1] retain];
  715. FOLLOW_variable_in_block390 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_variable_in_block390_data Count:(NSUInteger)1] retain];
  716. FOLLOW_stat_in_block405 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_stat_in_block405_data Count:(NSUInteger)1] retain];
  717. FOLLOW_K_RCURLY_in_block416 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_RCURLY_in_block416_data Count:(NSUInteger)1] retain];
  718. FOLLOW_forStat_in_stat449 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_forStat_in_stat449_data Count:(NSUInteger)1] retain];
  719. FOLLOW_expr_in_stat457 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_stat457_data Count:(NSUInteger)1] retain];
  720. FOLLOW_K_SEMICOLON_in_stat459 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_SEMICOLON_in_stat459_data Count:(NSUInteger)1] retain];
  721. FOLLOW_block_in_stat468 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_stat468_data Count:(NSUInteger)1] retain];
  722. FOLLOW_assignStat_in_stat476 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_assignStat_in_stat476_data Count:(NSUInteger)1] retain];
  723. FOLLOW_K_SEMICOLON_in_stat478 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_SEMICOLON_in_stat478_data Count:(NSUInteger)1] retain];
  724. FOLLOW_K_SEMICOLON_in_stat487 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_SEMICOLON_in_stat487_data Count:(NSUInteger)1] retain];
  725. FOLLOW_K_FOR_in_forStat507 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_FOR_in_forStat507_data Count:(NSUInteger)1] retain];
  726. FOLLOW_K_LCURVE_in_forStat509 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_LCURVE_in_forStat509_data Count:(NSUInteger)1] retain];
  727. FOLLOW_assignStat_in_forStat513 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_assignStat_in_forStat513_data Count:(NSUInteger)1] retain];
  728. FOLLOW_K_SEMICOLON_in_forStat515 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_SEMICOLON_in_forStat515_data Count:(NSUInteger)1] retain];
  729. FOLLOW_expr_in_forStat517 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_forStat517_data Count:(NSUInteger)1] retain];
  730. FOLLOW_K_SEMICOLON_in_forStat519 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_SEMICOLON_in_forStat519_data Count:(NSUInteger)1] retain];
  731. FOLLOW_assignStat_in_forStat523 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_assignStat_in_forStat523_data Count:(NSUInteger)1] retain];
  732. FOLLOW_K_RCURVE_in_forStat525 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_RCURVE_in_forStat525_data Count:(NSUInteger)1] retain];
  733. FOLLOW_block_in_forStat527 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_forStat527_data Count:(NSUInteger)1] retain];
  734. FOLLOW_K_ID_in_assignStat570 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_ID_in_assignStat570_data Count:(NSUInteger)1] retain];
  735. FOLLOW_K_EQ_in_assignStat572 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_EQ_in_assignStat572_data Count:(NSUInteger)1] retain];
  736. FOLLOW_expr_in_assignStat574 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_assignStat574_data Count:(NSUInteger)1] retain];
  737. FOLLOW_condExpr_in_expr598 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_condExpr_in_expr598_data Count:(NSUInteger)1] retain];
  738. FOLLOW_aexpr_in_condExpr617 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_aexpr_in_condExpr617_data Count:(NSUInteger)1] retain];
  739. FOLLOW_K_EQEQ_in_condExpr622 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_EQEQ_in_condExpr622_data Count:(NSUInteger)1] retain];
  740. FOLLOW_K_LT_in_condExpr627 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_LT_in_condExpr627_data Count:(NSUInteger)1] retain];
  741. FOLLOW_aexpr_in_condExpr631 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_aexpr_in_condExpr631_data Count:(NSUInteger)1] retain];
  742. FOLLOW_atom_in_aexpr653 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_atom_in_aexpr653_data Count:(NSUInteger)1] retain];
  743. FOLLOW_K_PLUS_in_aexpr657 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_PLUS_in_aexpr657_data Count:(NSUInteger)1] retain];
  744. FOLLOW_atom_in_aexpr660 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_atom_in_aexpr660_data Count:(NSUInteger)1] retain];
  745. FOLLOW_K_ID_in_atom680 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_ID_in_atom680_data Count:(NSUInteger)1] retain];
  746. FOLLOW_K_INT_in_atom694 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_INT_in_atom694_data Count:(NSUInteger)1] retain];
  747. FOLLOW_K_LCURVE_in_atom708 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_LCURVE_in_atom708_data Count:(NSUInteger)1] retain];
  748. FOLLOW_expr_in_atom710 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_atom710_data Count:(NSUInteger)1] retain];
  749. FOLLOW_K_RCURVE_in_atom712 = [[ANTLRBitSet newANTLRBitSetWithBits:(const unsigned long long *)FOLLOW_K_RCURVE_in_atom712_data Count:(NSUInteger)1] retain];
  750. [ANTLRBaseRecognizer setTokenNames:[[AMutableArray arrayWithObjects:@"<invalid>", @"<EOR>", @"<DOWN>", @"<UP>",
  751. @"ARG_DEF", @"BLOCK", @"FUNC_DECL", @"FUNC_DEF", @"FUNC_HDR", @"K_CHAR",
  752. @"K_COMMA", @"K_EQ", @"K_EQEQ", @"K_FOR", @"K_ID", @"K_INT", @"K_INT_TYPE",
  753. @"K_LCURLY", @"K_LCURVE", @"K_LT", @"K_PLUS", @"K_RCURLY", @"K_RCURVE",
  754. @"K_SEMICOLON", @"K_VOID", @"VAR_DEF", @"WS", nil] retain]];
  755. [ANTLRBaseRecognizer setGrammarFileName:@"SimpleC.g"];
  756. }
  757. + (SimpleCParser *)newSimpleCParser:(id<ANTLRTokenStream>)aStream
  758. {
  759. return [[SimpleCParser alloc] initWithTokenStream:aStream];
  760. }
  761. - (id) initWithTokenStream:(id<ANTLRTokenStream>)aStream
  762. {
  763. self = [super initWithTokenStream:aStream State:[[ANTLRRecognizerSharedState newANTLRRecognizerSharedStateWithRuleLen:15+1] retain]];
  764. if ( self != nil ) {
  765. dfa2 = [DFA2 newDFA2WithRecognizer:self];
  766. /* start of actions-actionScope-init */
  767. /* start of init */
  768. /* AST genericParser.init */
  769. [self setTreeAdaptor:[[ANTLRCommonTreeAdaptor newTreeAdaptor] retain]];
  770. }
  771. return self;
  772. }
  773. - (void) dealloc
  774. {
  775. [dfa2 release];
  776. /* AST genericParser.dealloc */
  777. [self setTreeAdaptor:nil];
  778. [super dealloc];
  779. }
  780. /* ObjC start members */
  781. /* ObjC end members */
  782. /* ObjC start actions.(actionScope).methods */
  783. /* ObjC end actions.(actionScope).methods */
  784. /* ObjC start methods() */
  785. /* AST genericParser.methods */
  786. /* AST parserMethods */
  787. - (id<ANTLRTreeAdaptor>) getTreeAdaptor
  788. {
  789. return treeAdaptor;
  790. }
  791. - (void) setTreeAdaptor:(id<ANTLRTreeAdaptor>)aTreeAdaptor
  792. {
  793. if (aTreeAdaptor != treeAdaptor) {
  794. treeAdaptor = aTreeAdaptor;
  795. }
  796. }
  797. /* ObjC end methods() */
  798. /* ObjC start rules */
  799. /*
  800. * $ANTLR start program
  801. * SimpleC.g:16:1: program : ( declaration )+ ;
  802. */
  803. - (SimpleCParser_program_return *) program
  804. {
  805. /* my ruleScopeSetUp */
  806. /* Terence's stuff */
  807. /* AST ruleDeclarations */
  808. SimpleCParser_program_return * retval = [SimpleCParser_program_return newSimpleCParser_program_return];
  809. [retval setStart:[input LT:1]];
  810. ANTLRCommonTree *root_0 = nil;
  811. @try {
  812. /* AST ruleLabelDefs */
  813. SimpleCParser_declaration_return * declaration1 = nil ;
  814. // SimpleC.g:17:5: ( ( declaration )+ ) // ruleBlockSingleAlt
  815. // SimpleC.g:17:9: ( declaration )+ // alt
  816. {
  817. root_0 = (ANTLRCommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
  818. // SimpleC.g:17:9: ( declaration )+ // positiveClosureBlock
  819. NSInteger cnt1 = 0;
  820. do {
  821. NSInteger alt1 = 2;
  822. NSInteger LA1_0 = [input LA:1];
  823. if ( (LA1_0==K_CHAR||LA1_0==K_ID||LA1_0==K_INT_TYPE||LA1_0==K_VOID) ) {
  824. alt1=1;
  825. }
  826. switch (alt1) {
  827. case 1 : ;
  828. // SimpleC.g:17:9: declaration // alt
  829. {
  830. /* ASTParser ruleRef */
  831. /* ruleRef */
  832. [self pushFollow:FOLLOW_declaration_in_program85];
  833. declaration1 = [self declaration];
  834. [self popFollow];
  835. [treeAdaptor addChild:[declaration1 getTree] toTree:root_0];
  836. }
  837. break;
  838. default :
  839. if ( cnt1 >= 1 )
  840. goto loop1;
  841. ANTLREarlyExitException *eee =
  842. [ANTLREarlyExitException newException:input decisionNumber:1];
  843. @throw eee;
  844. }
  845. cnt1++;
  846. } while (YES);
  847. loop1: ;
  848. }
  849. /* ASTParser ruleCleanUp */
  850. /* AST ruleCleanUp */
  851. // token+rule list labels
  852. [retval setStop:[input LT:-1]];
  853. retval.tree = (ANTLRCommonTree *)[treeAdaptor rulePostProcessing:root_0];
  854. [treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
  855. }
  856. @catch (ANTLRRecognitionException *re) {
  857. [self reportError:re];
  858. [self recover:input Exception:re];
  859. /* ASTParser rule.setErrorReturnValue */
  860. retval.tree = (ANTLRCommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
  861. }
  862. @finally {
  863. /* Terence's stuff */
  864. }
  865. return retval;
  866. }
  867. /* $ANTLR end program */
  868. /*
  869. * $ANTLR start declaration
  870. * SimpleC.g:20:1: declaration : ( variable | functionHeader K_SEMICOLON -> ^( FUNC_DECL functionHeader ) | functionHeader block -> ^( FUNC_DEF functionHeader block ) );
  871. */
  872. - (SimpleCParser_declaration_return *) declaration
  873. {
  874. /* my ruleScopeSetUp */
  875. /* Terence's stuff */
  876. /* AST ruleDeclarations */
  877. SimpleCParser_declaration_return * retval = [SimpleCParser_declaration_return newSimpleCParser_declaration_return];
  878. [retval setStart:[input LT:1]];
  879. ANTLRCommonTree *root_0 = nil;
  880. @try {
  881. /* AST ruleLabelDefs */
  882. ANTLRCommonToken *K_SEMICOLON4 = nil;
  883. SimpleCParser_variable_return * variable2 = nil ;
  884. SimpleCParser_functionHeader_return * functionHeader3 = nil ;
  885. SimpleCParser_functionHeader_return * functionHeader5 = nil ;
  886. SimpleCParser_block_return * block6 = nil ;
  887. ANTLRCommonTree *K_SEMICOLON4_tree=nil;
  888. ANTLRRewriteRuleTokenStream *stream_K_SEMICOLON =
  889. [[ANTLRRewriteRuleTokenStream newANTLRRewriteRuleTokenStream:treeAdaptor
  890. description:@"token K_SEMICOLON"] retain];
  891. ANTLRRewriteRuleSubtreeStream *stream_functionHeader =
  892. [[ANTLRRewriteRuleSubtreeStream newANTLRRewriteRuleSubtreeStream:treeAdaptor
  893. description:@"rule functionHeader"] retain];
  894. ANTLRRewriteRuleSubtreeStream *stream_block =
  895. [[ANTLRRewriteRuleSubtreeStream newANTLRRewriteRuleSubtreeStream:treeAdaptor
  896. description:@"rule block"] retain];
  897. // SimpleC.g:21:5: ( variable | functionHeader K_SEMICOLON -> ^( FUNC_DECL functionHeader ) | functionHeader block -> ^( FUNC_DEF functionHeader block ) ) //ruleblock
  898. NSInteger alt2=3;
  899. alt2 = [dfa2 predict:input];
  900. switch (alt2) {
  901. case 1 : ;
  902. // SimpleC.g:21:9: variable // alt
  903. {
  904. root_0 = (ANTLRCommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
  905. /* ASTParser ruleRef */
  906. /* ruleRef */
  907. [self pushFollow:FOLLOW_variable_in_declaration105];
  908. variable2 = [self variable];
  909. [self popFollow];
  910. [treeAdaptor addChild:[variable2 getTree] toTree:root_0];
  911. }
  912. break;
  913. case 2 : ;
  914. // SimpleC.g:22:9: functionHeader K_SEMICOLON // alt
  915. {
  916. /* ruleRef */
  917. [self pushFollow:FOLLOW_functionHeader_in_declaration115];
  918. functionHeader3 = [self functionHeader];
  919. [self popFollow];
  920. [stream_functionHeader addElement:[functionHeader3 getTree]];
  921. K_SEMICOLON4=(ANTLRCommonToken *)[self match:input TokenType:K_SEMICOLON Follow:FOLLOW_K_SEMICOLON_in_declaration117];
  922. [stream_K_SEMICOLON addElement:K_SEMICOLON4];
  923. // AST REWRITE
  924. // elements: functionHeader
  925. // token labels:
  926. // rule labels: retval
  927. // token list labels:
  928. // rule list labels:
  929. // wildcard labels:
  930. retval.tree = root_0;
  931. ANTLRRewriteRuleSubtreeStream *stream_retval =
  932. [[ANTLRRewriteRuleSubtreeStream newANTLRRewriteRuleSubtreeStream:treeAdaptor
  933. description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
  934. root_0 = (ANTLRCommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
  935. // 22:36: -> ^( FUNC_DECL functionHeader )
  936. {
  937. // SimpleC.g:22:39: ^( FUNC_DECL functionHeader )
  938. {
  939. ANTLRCommonTree *root_1 = (ANTLRCommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
  940. root_1 = (ANTLRCommonTree *)[treeAdaptor becomeRoot:
  941. [treeAdaptor createTree:FUNC_DECL Text:@"FUNC_DECL"]
  942. old:root_1];
  943. [treeAdaptor addChild:[stream_functionHeader nextTree] toTree:root_1];
  944. [treeAdaptor addChild:root_1 toTree:root_0];
  945. }
  946. }
  947. retval.tree = root_0;
  948. }
  949. break;
  950. case 3 : ;
  951. // SimpleC.g:23:9: functionHeader block // alt
  952. {
  953. /* ruleRef */
  954. [self pushFollow:FOLLOW_functionHeader_in_declaration135];
  955. functionHeader5 = [self functionHeader];
  956. [self popFollow];
  957. [stream_functionHeader addElement:[functionHeader5 getTree]];
  958. /* ruleRef */
  959. [self pushFollow:FOLLOW_block_in_declaration137];
  960. block6 = [self block];
  961. [self popFollow];
  962. [stream_block addElement:[block6 getTree]];
  963. // AST REWRITE
  964. // elements: functionHeader, block
  965. // token labels:
  966. // rule labels: retval
  967. // token list labels:
  968. // rule list labels:
  969. // wildcard labels:
  970. retval.tree = root_0;
  971. ANTLRRewriteRuleSubtreeStream *stream_retval =
  972. [[ANTLRRewriteRuleSubtreeStream newANTLRRewriteRuleSubtreeStream:treeAdaptor
  973. description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
  974. root_0 = (ANTLRCommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
  975. // 23:30: -> ^( FUNC_DEF functionHeader block )
  976. {
  977. // SimpleC.g:23:33: ^( FUNC_DEF functionHeader block )
  978. {
  979. ANTLRCommonTree *root_1 = (ANTLRCommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
  980. root_1 = (ANTLRCommonTree *)[treeAdaptor becomeRoot:
  981. [treeAdaptor createTree:FUNC_DEF Text:@"FUNC_DEF"]
  982. old:root_1];
  983. [treeAdaptor addChild:[stream_functionHeader nextTree] toTree:root_1];
  984. [treeAdaptor addChild:[stream_block nextTree] toTree:root_1];
  985. [treeAdaptor addChild:root_1 toTree:root_0];
  986. }
  987. }
  988. retval.tree = root_0;
  989. }
  990. break;
  991. }
  992. /* ASTParser ruleCleanUp */
  993. /* AST ruleCleanUp */
  994. // token+rule list labels
  995. [retval setStop:[input LT:-1]];
  996. [stream_K_SEMICOLON release];
  997. [stream_functionHeader release];
  998. [stream_block release];
  999. retval.tree = (ANTLRCommonTree *)[treeAdaptor rulePostProcessing:root_0];
  1000. [treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
  1001. }
  1002. @catch (ANTLRRecognitionException *re) {
  1003. [self reportError:re];
  1004. [self recover:input Exception:re];
  1005. /* ASTParser rule.setErrorReturnValue */
  1006. retval.tree = (ANTLRCommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
  1007. }
  1008. @finally {
  1009. /* Terence's stuff */
  1010. }
  1011. return retval;
  1012. }
  1013. /* $ANTLR end declaration */
  1014. /*
  1015. * $ANTLR start variable
  1016. * SimpleC.g:26:1: variable : type declarator K_SEMICOLON -> ^( VAR_DEF type declarator ) ;
  1017. */
  1018. - (SimpleCParser_variable_return *) variable
  1019. {
  1020. /* my ruleScopeSetUp */
  1021. /* Terence's stuff */
  1022. /* AST ruleDeclarations */
  1023. SimpleCParser_variable_return * retval = [SimpleCParser_variable_return newSimpleCParser_variable_return];
  1024. [retval setStart:[input LT:1]];
  1025. ANTLRCommonTree *root_0 = nil;
  1026. @try {
  1027. /* AST ruleLabelDefs */
  1028. ANTLRCommonToken *K_SEMICOLON9 = nil;
  1029. SimpleCParser_type_return * type7 = nil ;
  1030. SimpleCParser_declarator_return * declarator8 = nil ;
  1031. ANTLRCommonTree *K_SEMICOLON9_tree=nil;
  1032. ANTLRRewriteRuleTokenStream *stream_K_SEMICOLON =
  1033. [[ANTLRRewriteRuleTokenStream newANTLRRewriteRuleTokenStream:treeAdaptor
  1034. description:@"token K_SEMICOLON"] retain];
  1035. ANTLRRewriteRuleSubtreeStream *stream_declarator =
  1036. [[ANTLRRewriteRuleSubtreeStream newANTLRRewriteRuleSubtreeStream:treeAdaptor
  1037. description:@"rule declarator"] retain];
  1038. ANTLRRewriteRuleSubtreeStream *stream_type =
  1039. [[ANTLRRewriteRuleSubtreeStream newANTLRRewriteRuleSubtreeStream:treeAdaptor
  1040. description:@"rule type"] retain];
  1041. // SimpleC.g:27:5: ( type declarator K_SEMICOLON -> ^( VAR_DEF type declarator ) ) // ruleBlockSingleAlt
  1042. // SimpleC.g:27:9: type declarator K_SEMICOLON // alt
  1043. {
  1044. /* ruleRef */
  1045. [self pushFollow:FOLLOW_type_in_variable166];
  1046. type7 = [self type];
  1047. [self popFollow];
  1048. [stream_type addElement:[type7 getTree]];
  1049. /* ruleRef */
  1050. [self pushFollow:FOLLOW_declarator_in_variable168];
  1051. declarator8 = [self declarator];
  1052. [self popFollow];
  1053. [stream_declarator addElement:[declarator8 getTree]];
  1054. K_SEMICOLON9=(ANTLRCommonToken *)[self match:input TokenType:K_SEMICOLON Follow:FOLLOW_K_SEMICOLON_in_variable170];
  1055. [stream_K_SEMICOLON addElement:K_SEMICOLON9];
  1056. // AST REWRITE
  1057. // elements: declarator, type
  1058. // token labels:
  1059. // rule labels: retval
  1060. // token list labels:
  1061. // rule list labels:
  1062. // wildcard labels:
  1063. retval.tree = root_0;
  1064. ANTLRRewriteRuleSubtreeStream *stream_retval =
  1065. [[ANTLRRewriteRuleSubtreeStream newANTLRRewriteRuleSubtreeStream:treeAdaptor
  1066. description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
  1067. root_0 = (ANTLRCommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
  1068. // 27:37: -> ^( VAR_DEF type declarator )
  1069. {
  1070. // SimpleC.g:27:40: ^( VAR_DEF type declarator )
  1071. {
  1072. ANTLRCommonTree *root_1 = (ANTLRCommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
  1073. root_1 = (ANTLRCommonTree *)[treeAdaptor becomeRoot:
  1074. [treeAdaptor createTree:VAR_DEF Text:@"VAR_DEF"]
  1075. old:root_1];
  1076. [treeAdaptor addChild:[stream_type nextTree] toTree:root_1];
  1077. [treeAdaptor addChild:[stream_declarator nextTree] toTree:root_1];
  1078. [treeAdaptor addChild:root_1 toTree:root_0];
  1079. }
  1080. }
  1081. retval.tree = root_0;
  1082. }
  1083. /* ASTParser ruleCleanUp */
  1084. /* AST ruleCleanUp */
  1085. // token+rule list labels
  1086. [retval setStop:[input LT:-1]];
  1087. [stream_K_SEMICOLON release];
  1088. [stream_declarator release];
  1089. [stream_type release];
  1090. retval.tree = (ANTLRCommonTree *)[treeAdaptor rulePostProcessing:root_0];
  1091. [treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
  1092. }
  1093. @catch (ANTLRRecognitionException *re) {
  1094. [self reportError:re];
  1095. [self recover:input Exception:re];
  1096. /* ASTParser rule.setErrorReturnValue */
  1097. retval.tree = (ANTLRCommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
  1098. }
  1099. @finally {
  1100. /* Terence's stuff */
  1101. }
  1102. return retval;
  1103. }
  1104. /* $ANTLR end variable */
  1105. /*
  1106. * $ANTLR start declarator
  1107. * SimpleC.g:30:1: declarator : K_ID ;
  1108. */
  1109. - (SimpleCParser_declarator_return *) declarator
  1110. {
  1111. /* my ruleScopeSetUp */
  1112. /* Terence's stuff */
  1113. /* AST ruleDeclarations */
  1114. SimpleCParser_declarator_return * retval = [SimpleCParser_declarator_return newSimpleCParser_declarator_return];
  1115. [retval setStart:[input LT:1]];
  1116. ANTLRCommonTree *root_0 = nil;
  1117. @try {
  1118. /* AST ruleLabelDefs */
  1119. ANTLRCommonToken *K_ID10 = nil;
  1120. ANTLRCommonTree *K_ID10_tree=nil;
  1121. // SimpleC.g:31:5: ( K_ID ) // ruleBlockSingleAlt
  1122. // SimpleC.g:31:9: K_ID // alt
  1123. {
  1124. root_0 = (ANTLRCommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
  1125. /* ASTParser tokenRef */
  1126. K_ID10=(ANTLRCommonToken *)[self match:input TokenType:K_ID Follow:FOLLOW_K_ID_in_declarator199];
  1127. K_ID10_tree = /* ASTParser createNodeFromToken */
  1128. (ANTLRCommonTree *)[[treeAdaptor create:K_ID10] retain]
  1129. ;
  1130. [treeAdaptor addChild:K_ID10_tree toTree:root_0];
  1131. }
  1132. /* ASTParser ruleCleanUp */
  1133. /* AST ruleCleanUp */
  1134. // token+rule list