3145 lines
108 KiB
Objective-C
3145 lines
108 KiB
Objective-C
/** \file
|
|
* This OBJC source file was generated by $ANTLR version 3.4
|
|
*
|
|
* - From the grammar source file : /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g
|
|
* - On : 2012-02-16 17:40:52
|
|
* - for the parser : SimpleCParserParser
|
|
*
|
|
* Editing it, at least manually, is not wise.
|
|
*
|
|
* ObjC language generator and runtime by Alan Condit, acondit|hereisanat|ipns|dotgoeshere|com.
|
|
*
|
|
*
|
|
*/
|
|
// $ANTLR 3.4 /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g 2012-02-16 17:40:52
|
|
|
|
|
|
/* -----------------------------------------
|
|
* Include the ANTLR3 generated header file.
|
|
*/
|
|
#import "SimpleCParser.h"
|
|
/* ----------------------------------------- */
|
|
|
|
|
|
/* ============================================================================= */
|
|
/* =============================================================================
|
|
* Start of recognizer
|
|
*/
|
|
#pragma mark Cyclic DFA implementation start DFA2
|
|
|
|
@implementation DFA2
|
|
const static NSInteger dfa2_eot[13] =
|
|
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
|
|
const static NSInteger dfa2_eof[13] =
|
|
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
|
|
const static unichar dfa2_min[13] =
|
|
{9,14,18,9,-1,14,17,10,-1,-1,9,14,10};
|
|
const static unichar dfa2_max[13] =
|
|
{24,14,23,24,-1,14,23,22,-1,-1,24,14,22};
|
|
const static NSInteger dfa2_accept[13] =
|
|
{-1,-1,-1,-1,1,-1,-1,-1,2,3,-1,-1,-1};
|
|
const static NSInteger dfa2_special[13] =
|
|
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
|
|
|
|
/** Used when there is no transition table entry for a particular state */
|
|
#define dfa2_T_empty nil
|
|
|
|
const static NSInteger dfa2_T0[] =
|
|
{
|
|
9, -1, -1, -1, -1, -1, 8
|
|
};
|
|
const static NSInteger dfa2_T1[] =
|
|
{
|
|
10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6
|
|
};
|
|
const static NSInteger dfa2_T2[] =
|
|
{
|
|
5, -1, -1, -1, -1, 5, -1, 5, -1, -1, -1, -1, -1, 6, -1, 5
|
|
};
|
|
const static NSInteger dfa2_T3[] =
|
|
{
|
|
11, -1, -1, -1, -1, 11, -1, 11, -1, -1, -1, -1, -1, -1, -1, 11
|
|
};
|
|
const static NSInteger dfa2_T4[] =
|
|
{
|
|
3, -1, -1, -1, -1, 4
|
|
};
|
|
const static NSInteger dfa2_T5[] =
|
|
{
|
|
1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1
|
|
};
|
|
const static NSInteger dfa2_T6[] =
|
|
{
|
|
7
|
|
};
|
|
const static NSInteger dfa2_T7[] =
|
|
{
|
|
12
|
|
};
|
|
const static NSInteger dfa2_T8[] =
|
|
{
|
|
2
|
|
};
|
|
|
|
|
|
const static NSInteger *dfa2_transition[] =
|
|
{
|
|
dfa2_T5, dfa2_T8, dfa2_T4, dfa2_T2, nil, dfa2_T6, dfa2_T0, dfa2_T1,
|
|
nil, nil, dfa2_T3, dfa2_T7, dfa2_T1
|
|
};
|
|
|
|
//const static NSInteger dfa2_transition[] = {};
|
|
|
|
+ (DFA2 *) newDFA2WithRecognizer:(BaseRecognizer *)aRecognizer
|
|
{
|
|
return [[[DFA2 alloc] initWithRecognizer:aRecognizer] retain];
|
|
}
|
|
|
|
- (id) initWithRecognizer:(BaseRecognizer *) theRecognizer
|
|
{
|
|
self = [super initWithRecognizer:theRecognizer];
|
|
if ( self != nil ) {
|
|
decisionNumber = 2;
|
|
eot = dfa2_eot;
|
|
eof = dfa2_eof;
|
|
min = dfa2_min;
|
|
max = dfa2_max;
|
|
accept = dfa2_accept;
|
|
special = dfa2_special;
|
|
transition = dfa2_transition;
|
|
/*
|
|
if (!(transition = calloc(13, sizeof(void*)))) {
|
|
[self release];
|
|
return nil;
|
|
}
|
|
len = 13;
|
|
transition[0] = dfa2_transition5;
|
|
transition[1] = dfa2_transition8;
|
|
transition[2] = dfa2_transition4;
|
|
transition[3] = dfa2_transition2;
|
|
|
|
transition[4] = dfa2_transition6;
|
|
transition[5] = dfa2_transition0;
|
|
transition[6] = dfa2_transition1;
|
|
|
|
|
|
transition[7] = dfa2_transition3;
|
|
transition[8] = dfa2_transition7;
|
|
transition[9] = dfa2_transition1;
|
|
*/
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
free(transition);
|
|
[super dealloc];
|
|
}
|
|
|
|
- (NSString *) description
|
|
{
|
|
return @"20:1: declaration : ( variable | functionHeader K_SEMICOLON -> ^( FUNC_DECL functionHeader ) | functionHeader block -> ^( FUNC_DEF functionHeader block ) );";
|
|
}
|
|
|
|
|
|
@end /* end DFA2 implementation */
|
|
|
|
#pragma mark Cyclic DFA implementation end DFA2
|
|
|
|
|
|
|
|
#pragma mark Bitsets
|
|
static ANTLRBitSet *FOLLOW_declaration_in_program85;
|
|
static const unsigned long long FOLLOW_declaration_in_program85_data[] = { 0x0000000001014202LL};
|
|
static ANTLRBitSet *FOLLOW_variable_in_declaration105;
|
|
static const unsigned long long FOLLOW_variable_in_declaration105_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_functionHeader_in_declaration115;
|
|
static const unsigned long long FOLLOW_functionHeader_in_declaration115_data[] = { 0x0000000000800000LL};
|
|
static ANTLRBitSet *FOLLOW_K_SEMICOLON_in_declaration117;
|
|
static const unsigned long long FOLLOW_K_SEMICOLON_in_declaration117_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_functionHeader_in_declaration135;
|
|
static const unsigned long long FOLLOW_functionHeader_in_declaration135_data[] = { 0x0000000000020000LL};
|
|
static ANTLRBitSet *FOLLOW_block_in_declaration137;
|
|
static const unsigned long long FOLLOW_block_in_declaration137_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_type_in_variable166;
|
|
static const unsigned long long FOLLOW_type_in_variable166_data[] = { 0x0000000000004000LL};
|
|
static ANTLRBitSet *FOLLOW_declarator_in_variable168;
|
|
static const unsigned long long FOLLOW_declarator_in_variable168_data[] = { 0x0000000000800000LL};
|
|
static ANTLRBitSet *FOLLOW_K_SEMICOLON_in_variable170;
|
|
static const unsigned long long FOLLOW_K_SEMICOLON_in_variable170_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_K_ID_in_declarator199;
|
|
static const unsigned long long FOLLOW_K_ID_in_declarator199_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_type_in_functionHeader219;
|
|
static const unsigned long long FOLLOW_type_in_functionHeader219_data[] = { 0x0000000000004000LL};
|
|
static ANTLRBitSet *FOLLOW_K_ID_in_functionHeader221;
|
|
static const unsigned long long FOLLOW_K_ID_in_functionHeader221_data[] = { 0x0000000000040000LL};
|
|
static ANTLRBitSet *FOLLOW_K_LCURVE_in_functionHeader223;
|
|
static const unsigned long long FOLLOW_K_LCURVE_in_functionHeader223_data[] = { 0x0000000001414200LL};
|
|
static ANTLRBitSet *FOLLOW_formalParameter_in_functionHeader227;
|
|
static const unsigned long long FOLLOW_formalParameter_in_functionHeader227_data[] = { 0x0000000000400400LL};
|
|
static ANTLRBitSet *FOLLOW_K_COMMA_in_functionHeader231;
|
|
static const unsigned long long FOLLOW_K_COMMA_in_functionHeader231_data[] = { 0x0000000001014200LL};
|
|
static ANTLRBitSet *FOLLOW_formalParameter_in_functionHeader233;
|
|
static const unsigned long long FOLLOW_formalParameter_in_functionHeader233_data[] = { 0x0000000000400400LL};
|
|
static ANTLRBitSet *FOLLOW_K_RCURVE_in_functionHeader241;
|
|
static const unsigned long long FOLLOW_K_RCURVE_in_functionHeader241_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_type_in_formalParameter281;
|
|
static const unsigned long long FOLLOW_type_in_formalParameter281_data[] = { 0x0000000000004000LL};
|
|
static ANTLRBitSet *FOLLOW_declarator_in_formalParameter283;
|
|
static const unsigned long long FOLLOW_declarator_in_formalParameter283_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_K_LCURLY_in_block376;
|
|
static const unsigned long long FOLLOW_K_LCURLY_in_block376_data[] = { 0x0000000001A7E200LL};
|
|
static ANTLRBitSet *FOLLOW_variable_in_block390;
|
|
static const unsigned long long FOLLOW_variable_in_block390_data[] = { 0x0000000001A7E200LL};
|
|
static ANTLRBitSet *FOLLOW_stat_in_block405;
|
|
static const unsigned long long FOLLOW_stat_in_block405_data[] = { 0x0000000000A6E000LL};
|
|
static ANTLRBitSet *FOLLOW_K_RCURLY_in_block416;
|
|
static const unsigned long long FOLLOW_K_RCURLY_in_block416_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_forStat_in_stat449;
|
|
static const unsigned long long FOLLOW_forStat_in_stat449_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_expr_in_stat457;
|
|
static const unsigned long long FOLLOW_expr_in_stat457_data[] = { 0x0000000000800000LL};
|
|
static ANTLRBitSet *FOLLOW_K_SEMICOLON_in_stat459;
|
|
static const unsigned long long FOLLOW_K_SEMICOLON_in_stat459_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_block_in_stat468;
|
|
static const unsigned long long FOLLOW_block_in_stat468_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_assignStat_in_stat476;
|
|
static const unsigned long long FOLLOW_assignStat_in_stat476_data[] = { 0x0000000000800000LL};
|
|
static ANTLRBitSet *FOLLOW_K_SEMICOLON_in_stat478;
|
|
static const unsigned long long FOLLOW_K_SEMICOLON_in_stat478_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_K_SEMICOLON_in_stat487;
|
|
static const unsigned long long FOLLOW_K_SEMICOLON_in_stat487_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_K_FOR_in_forStat507;
|
|
static const unsigned long long FOLLOW_K_FOR_in_forStat507_data[] = { 0x0000000000040000LL};
|
|
static ANTLRBitSet *FOLLOW_K_LCURVE_in_forStat509;
|
|
static const unsigned long long FOLLOW_K_LCURVE_in_forStat509_data[] = { 0x0000000000004000LL};
|
|
static ANTLRBitSet *FOLLOW_assignStat_in_forStat513;
|
|
static const unsigned long long FOLLOW_assignStat_in_forStat513_data[] = { 0x0000000000800000LL};
|
|
static ANTLRBitSet *FOLLOW_K_SEMICOLON_in_forStat515;
|
|
static const unsigned long long FOLLOW_K_SEMICOLON_in_forStat515_data[] = { 0x000000000004C000LL};
|
|
static ANTLRBitSet *FOLLOW_expr_in_forStat517;
|
|
static const unsigned long long FOLLOW_expr_in_forStat517_data[] = { 0x0000000000800000LL};
|
|
static ANTLRBitSet *FOLLOW_K_SEMICOLON_in_forStat519;
|
|
static const unsigned long long FOLLOW_K_SEMICOLON_in_forStat519_data[] = { 0x0000000000004000LL};
|
|
static ANTLRBitSet *FOLLOW_assignStat_in_forStat523;
|
|
static const unsigned long long FOLLOW_assignStat_in_forStat523_data[] = { 0x0000000000400000LL};
|
|
static ANTLRBitSet *FOLLOW_K_RCURVE_in_forStat525;
|
|
static const unsigned long long FOLLOW_K_RCURVE_in_forStat525_data[] = { 0x0000000000020000LL};
|
|
static ANTLRBitSet *FOLLOW_block_in_forStat527;
|
|
static const unsigned long long FOLLOW_block_in_forStat527_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_K_ID_in_assignStat570;
|
|
static const unsigned long long FOLLOW_K_ID_in_assignStat570_data[] = { 0x0000000000000800LL};
|
|
static ANTLRBitSet *FOLLOW_K_EQ_in_assignStat572;
|
|
static const unsigned long long FOLLOW_K_EQ_in_assignStat572_data[] = { 0x000000000004C000LL};
|
|
static ANTLRBitSet *FOLLOW_expr_in_assignStat574;
|
|
static const unsigned long long FOLLOW_expr_in_assignStat574_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_condExpr_in_expr598;
|
|
static const unsigned long long FOLLOW_condExpr_in_expr598_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_aexpr_in_condExpr617;
|
|
static const unsigned long long FOLLOW_aexpr_in_condExpr617_data[] = { 0x0000000000081002LL};
|
|
static ANTLRBitSet *FOLLOW_K_EQEQ_in_condExpr622;
|
|
static const unsigned long long FOLLOW_K_EQEQ_in_condExpr622_data[] = { 0x000000000004C000LL};
|
|
static ANTLRBitSet *FOLLOW_K_LT_in_condExpr627;
|
|
static const unsigned long long FOLLOW_K_LT_in_condExpr627_data[] = { 0x000000000004C000LL};
|
|
static ANTLRBitSet *FOLLOW_aexpr_in_condExpr631;
|
|
static const unsigned long long FOLLOW_aexpr_in_condExpr631_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_atom_in_aexpr653;
|
|
static const unsigned long long FOLLOW_atom_in_aexpr653_data[] = { 0x0000000000100002LL};
|
|
static ANTLRBitSet *FOLLOW_K_PLUS_in_aexpr657;
|
|
static const unsigned long long FOLLOW_K_PLUS_in_aexpr657_data[] = { 0x000000000004C000LL};
|
|
static ANTLRBitSet *FOLLOW_atom_in_aexpr660;
|
|
static const unsigned long long FOLLOW_atom_in_aexpr660_data[] = { 0x0000000000100002LL};
|
|
static ANTLRBitSet *FOLLOW_K_ID_in_atom680;
|
|
static const unsigned long long FOLLOW_K_ID_in_atom680_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_K_INT_in_atom694;
|
|
static const unsigned long long FOLLOW_K_INT_in_atom694_data[] = { 0x0000000000000002LL};
|
|
static ANTLRBitSet *FOLLOW_K_LCURVE_in_atom708;
|
|
static const unsigned long long FOLLOW_K_LCURVE_in_atom708_data[] = { 0x000000000004C000LL};
|
|
static ANTLRBitSet *FOLLOW_expr_in_atom710;
|
|
static const unsigned long long FOLLOW_expr_in_atom710_data[] = { 0x0000000000400000LL};
|
|
static ANTLRBitSet *FOLLOW_K_RCURVE_in_atom712;
|
|
static const unsigned long long FOLLOW_K_RCURVE_in_atom712_data[] = { 0x0000000000000002LL};
|
|
|
|
|
|
#pragma mark Dynamic Global globalAttributeScopeImplementation
|
|
|
|
#pragma mark Dynamic Rule Scopes ruleAttributeScopeImplementation
|
|
|
|
#pragma mark Rule Return Scopes returnScopeImplementation
|
|
@implementation SimpleCParser_program_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_program_return *)newSimpleCParser_program_return
|
|
{
|
|
return [[[SimpleCParser_program_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
@implementation SimpleCParser_declaration_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_declaration_return *)newSimpleCParser_declaration_return
|
|
{
|
|
return [[[SimpleCParser_declaration_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
@implementation SimpleCParser_variable_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_variable_return *)newSimpleCParser_variable_return
|
|
{
|
|
return [[[SimpleCParser_variable_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
@implementation SimpleCParser_declarator_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_declarator_return *)newSimpleCParser_declarator_return
|
|
{
|
|
return [[[SimpleCParser_declarator_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
@implementation SimpleCParser_functionHeader_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_functionHeader_return *)newSimpleCParser_functionHeader_return
|
|
{
|
|
return [[[SimpleCParser_functionHeader_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
@implementation SimpleCParser_formalParameter_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_formalParameter_return *)newSimpleCParser_formalParameter_return
|
|
{
|
|
return [[[SimpleCParser_formalParameter_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
@implementation SimpleCParser_type_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_type_return *)newSimpleCParser_type_return
|
|
{
|
|
return [[[SimpleCParser_type_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
@implementation SimpleCParser_block_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_block_return *)newSimpleCParser_block_return
|
|
{
|
|
return [[[SimpleCParser_block_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
@implementation SimpleCParser_stat_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_stat_return *)newSimpleCParser_stat_return
|
|
{
|
|
return [[[SimpleCParser_stat_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
@implementation SimpleCParser_forStat_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_forStat_return *)newSimpleCParser_forStat_return
|
|
{
|
|
return [[[SimpleCParser_forStat_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
@implementation SimpleCParser_assignStat_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_assignStat_return *)newSimpleCParser_assignStat_return
|
|
{
|
|
return [[[SimpleCParser_assignStat_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
@implementation SimpleCParser_expr_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_expr_return *)newSimpleCParser_expr_return
|
|
{
|
|
return [[[SimpleCParser_expr_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
@implementation SimpleCParser_condExpr_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_condExpr_return *)newSimpleCParser_condExpr_return
|
|
{
|
|
return [[[SimpleCParser_condExpr_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
@implementation SimpleCParser_aexpr_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_aexpr_return *)newSimpleCParser_aexpr_return
|
|
{
|
|
return [[[SimpleCParser_aexpr_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
@implementation SimpleCParser_atom_return /* returnScopeImplementation */
|
|
/* AST returnScope.synthesize */
|
|
@synthesize tree; /* start of synthesize -- OBJC-Line 1837 */
|
|
+ (SimpleCParser_atom_return *)newSimpleCParser_atom_return
|
|
{
|
|
return [[[SimpleCParser_atom_return alloc] init] retain];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
return self;
|
|
}
|
|
|
|
/* AST returnScope.methods */
|
|
- (CommonTree *)getTree
|
|
{
|
|
return tree;
|
|
}
|
|
|
|
- (void) setTree:(CommonTree *)aTree
|
|
{
|
|
if (tree != aTree) {
|
|
if (tree != nil) [tree release];
|
|
if (aTree != nil) [aTree retain];
|
|
tree = aTree;
|
|
}
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
self.tree = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
@end /* end of returnScope implementation */
|
|
|
|
|
|
|
|
@implementation SimpleCParser // line 637
|
|
|
|
/* ObjC start of ruleAttributeScope */
|
|
#pragma mark Dynamic Rule Scopes ruleAttributeScope
|
|
/* ObjC end of ruleAttributeScope */
|
|
#pragma mark global Attribute Scopes globalAttributeScope
|
|
/* ObjC start globalAttributeScope */
|
|
/* ObjC end globalAttributeScope */
|
|
/* ObjC start actions.(actionScope).synthesize */
|
|
/* ObjC start synthesize() */
|
|
/* AST genericParser.synthesize */
|
|
/* AST parserProperties */
|
|
@synthesize treeAdaptor;
|
|
|
|
+ (void) initialize
|
|
{
|
|
#pragma mark Bitsets
|
|
FOLLOW_declaration_in_program85 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_declaration_in_program85_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_variable_in_declaration105 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_variable_in_declaration105_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_functionHeader_in_declaration115 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_functionHeader_in_declaration115_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_SEMICOLON_in_declaration117 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_SEMICOLON_in_declaration117_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_functionHeader_in_declaration135 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_functionHeader_in_declaration135_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_block_in_declaration137 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_declaration137_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_type_in_variable166 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_type_in_variable166_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_declarator_in_variable168 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_declarator_in_variable168_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_SEMICOLON_in_variable170 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_SEMICOLON_in_variable170_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_ID_in_declarator199 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_ID_in_declarator199_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_type_in_functionHeader219 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_type_in_functionHeader219_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_ID_in_functionHeader221 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_ID_in_functionHeader221_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_LCURVE_in_functionHeader223 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_LCURVE_in_functionHeader223_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_formalParameter_in_functionHeader227 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_formalParameter_in_functionHeader227_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_COMMA_in_functionHeader231 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_COMMA_in_functionHeader231_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_formalParameter_in_functionHeader233 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_formalParameter_in_functionHeader233_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_RCURVE_in_functionHeader241 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_RCURVE_in_functionHeader241_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_type_in_formalParameter281 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_type_in_formalParameter281_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_declarator_in_formalParameter283 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_declarator_in_formalParameter283_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_LCURLY_in_block376 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_LCURLY_in_block376_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_variable_in_block390 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_variable_in_block390_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_stat_in_block405 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_stat_in_block405_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_RCURLY_in_block416 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_RCURLY_in_block416_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_forStat_in_stat449 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_forStat_in_stat449_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_expr_in_stat457 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_stat457_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_SEMICOLON_in_stat459 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_SEMICOLON_in_stat459_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_block_in_stat468 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_stat468_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_assignStat_in_stat476 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_assignStat_in_stat476_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_SEMICOLON_in_stat478 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_SEMICOLON_in_stat478_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_SEMICOLON_in_stat487 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_SEMICOLON_in_stat487_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_FOR_in_forStat507 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_FOR_in_forStat507_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_LCURVE_in_forStat509 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_LCURVE_in_forStat509_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_assignStat_in_forStat513 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_assignStat_in_forStat513_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_SEMICOLON_in_forStat515 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_SEMICOLON_in_forStat515_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_expr_in_forStat517 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_forStat517_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_SEMICOLON_in_forStat519 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_SEMICOLON_in_forStat519_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_assignStat_in_forStat523 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_assignStat_in_forStat523_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_RCURVE_in_forStat525 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_RCURVE_in_forStat525_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_block_in_forStat527 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_block_in_forStat527_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_ID_in_assignStat570 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_ID_in_assignStat570_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_EQ_in_assignStat572 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_EQ_in_assignStat572_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_expr_in_assignStat574 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_assignStat574_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_condExpr_in_expr598 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_condExpr_in_expr598_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_aexpr_in_condExpr617 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_aexpr_in_condExpr617_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_EQEQ_in_condExpr622 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_EQEQ_in_condExpr622_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_LT_in_condExpr627 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_LT_in_condExpr627_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_aexpr_in_condExpr631 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_aexpr_in_condExpr631_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_atom_in_aexpr653 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_atom_in_aexpr653_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_PLUS_in_aexpr657 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_PLUS_in_aexpr657_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_atom_in_aexpr660 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_atom_in_aexpr660_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_ID_in_atom680 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_ID_in_atom680_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_INT_in_atom694 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_INT_in_atom694_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_LCURVE_in_atom708 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_LCURVE_in_atom708_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_expr_in_atom710 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_expr_in_atom710_data Count:(NSUInteger)1] retain];
|
|
FOLLOW_K_RCURVE_in_atom712 = [[ANTLRBitSet newBitSetWithBits:(const unsigned long long *)FOLLOW_K_RCURVE_in_atom712_data Count:(NSUInteger)1] retain];
|
|
|
|
[BaseRecognizer setTokenNames:[[AMutableArray arrayWithObjects:@"<invalid>", @"<EOR>", @"<DOWN>", @"<UP>",
|
|
@"ARG_DEF", @"BLOCK", @"FUNC_DECL", @"FUNC_DEF", @"FUNC_HDR", @"K_CHAR",
|
|
@"K_COMMA", @"K_EQ", @"K_EQEQ", @"K_FOR", @"K_ID", @"K_INT", @"K_INT_TYPE",
|
|
@"K_LCURLY", @"K_LCURVE", @"K_LT", @"K_PLUS", @"K_RCURLY", @"K_RCURVE",
|
|
@"K_SEMICOLON", @"K_VOID", @"VAR_DEF", @"WS", nil] retain]];
|
|
[BaseRecognizer setGrammarFileName:@"/Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g"];
|
|
}
|
|
|
|
+ (SimpleCParser *)newSimpleCParser:(id<TokenStream>)aStream
|
|
{
|
|
return [[SimpleCParser alloc] initWithTokenStream:aStream];
|
|
}
|
|
|
|
- (id) initWithTokenStream:(id<TokenStream>)aStream
|
|
{
|
|
self = [super initWithTokenStream:aStream State:[[RecognizerSharedState newRecognizerSharedStateWithRuleLen:15+1] retain]];
|
|
if ( self != nil ) {
|
|
dfa2 = [DFA2 newDFA2WithRecognizer:self];
|
|
/* start of actions-actionScope-init */
|
|
/* start of init */
|
|
/* AST genericParser.init */
|
|
[self setTreeAdaptor:[[CommonTreeAdaptor newTreeAdaptor] retain]];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
[dfa2 release];
|
|
/* AST genericParser.dealloc */
|
|
[self setTreeAdaptor:nil];
|
|
|
|
[super dealloc];
|
|
}
|
|
|
|
/* ObjC start actions.(actionScope).methods */
|
|
/* ObjC end actions.(actionScope).methods */
|
|
/* ObjC start methods() */
|
|
/* AST genericParser.methods */
|
|
/* AST parserMethods */
|
|
- (id<TreeAdaptor>) getTreeAdaptor
|
|
{
|
|
return treeAdaptor;
|
|
}
|
|
|
|
- (void) setTreeAdaptor:(id<TreeAdaptor>)aTreeAdaptor
|
|
{
|
|
if (aTreeAdaptor != treeAdaptor) {
|
|
treeAdaptor = aTreeAdaptor;
|
|
}
|
|
}
|
|
/* ObjC end methods() */
|
|
/* ObjC start rules */
|
|
/*
|
|
* $ANTLR start program
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:16:1: program : ( declaration )+ ;
|
|
*/
|
|
- (SimpleCParser_program_return *) program
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_program_return * retval = [SimpleCParser_program_return newSimpleCParser_program_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
SimpleCParser_declaration_return * declaration1 = nil ;
|
|
|
|
|
|
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:17:5: ( ( declaration )+ ) // ruleBlockSingleAlt
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:17:9: ( declaration )+ // alt
|
|
{
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
|
|
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:17:9: ( declaration )+ // positiveClosureBlock
|
|
NSInteger cnt1 = 0;
|
|
do {
|
|
NSInteger alt1 = 2;
|
|
NSInteger LA1_0 = [input LA:1];
|
|
if ( (LA1_0==K_CHAR||LA1_0==K_ID||LA1_0==K_INT_TYPE||LA1_0==K_VOID) ) {
|
|
alt1=1;
|
|
}
|
|
|
|
|
|
switch (alt1) {
|
|
case 1 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:17:9: declaration // alt
|
|
{
|
|
|
|
/* ASTParser ruleRef */
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_declaration_in_program85];
|
|
declaration1 = [self declaration];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[treeAdaptor addChild:[declaration1 getTree] toTree:root_0];
|
|
|
|
}
|
|
break;
|
|
|
|
default :
|
|
if ( cnt1 >= 1 )
|
|
goto loop1;
|
|
EarlyExitException *eee =
|
|
[EarlyExitException newException:input decisionNumber:1];
|
|
@throw eee;
|
|
}
|
|
cnt1++;
|
|
} while (YES);
|
|
loop1: ;
|
|
|
|
|
|
}
|
|
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end program */
|
|
|
|
/*
|
|
* $ANTLR start declaration
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:20:1: declaration : ( variable | functionHeader K_SEMICOLON -> ^( FUNC_DECL functionHeader ) | functionHeader block -> ^( FUNC_DEF functionHeader block ) );
|
|
*/
|
|
- (SimpleCParser_declaration_return *) declaration
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_declaration_return * retval = [SimpleCParser_declaration_return newSimpleCParser_declaration_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
CommonToken *K_SEMICOLON4 = nil;SimpleCParser_variable_return * variable2 = nil ;
|
|
|
|
SimpleCParser_functionHeader_return * functionHeader3 = nil ;
|
|
|
|
SimpleCParser_functionHeader_return * functionHeader5 = nil ;
|
|
|
|
SimpleCParser_block_return * block6 = nil ;
|
|
|
|
|
|
CommonTree *K_SEMICOLON4_tree=nil;
|
|
RewriteRuleTokenStream *stream_K_SEMICOLON =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_SEMICOLON"] retain];
|
|
RewriteRuleSubtreeStream *stream_functionHeader =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule functionHeader"] retain];
|
|
RewriteRuleSubtreeStream *stream_block =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule block"] retain];
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:21:5: ( variable | functionHeader K_SEMICOLON -> ^( FUNC_DECL functionHeader ) | functionHeader block -> ^( FUNC_DEF functionHeader block ) ) //ruleblock
|
|
NSInteger alt2=3;
|
|
alt2 = [dfa2 predict:input];
|
|
switch (alt2) {
|
|
case 1 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:21:9: variable // alt
|
|
{
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
|
|
|
|
/* ASTParser ruleRef */
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_variable_in_declaration105];
|
|
variable2 = [self variable];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[treeAdaptor addChild:[variable2 getTree] toTree:root_0];
|
|
|
|
}
|
|
break;
|
|
case 2 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:22:9: functionHeader K_SEMICOLON // alt
|
|
{
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_functionHeader_in_declaration115];
|
|
functionHeader3 = [self functionHeader];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_functionHeader addElement:[functionHeader3 getTree]];
|
|
|
|
K_SEMICOLON4=(CommonToken *)[self match:input TokenType:K_SEMICOLON Follow:FOLLOW_K_SEMICOLON_in_declaration117];
|
|
[stream_K_SEMICOLON addElement:K_SEMICOLON4];
|
|
|
|
|
|
// AST REWRITE
|
|
// elements: functionHeader
|
|
// token labels:
|
|
// rule labels: retval
|
|
// token list labels:
|
|
// rule list labels:
|
|
// wildcard labels:
|
|
retval.tree = root_0;
|
|
|
|
RewriteRuleSubtreeStream *stream_retval =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
|
|
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
// 22:36: -> ^( FUNC_DECL functionHeader )
|
|
{
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:22:39: ^( FUNC_DECL functionHeader )
|
|
{
|
|
CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
root_1 = (CommonTree *)[treeAdaptor becomeRoot:
|
|
[[treeAdaptor createTree:FUNC_DECL Text:@"FUNC_DECL"] retain]
|
|
old:root_1];
|
|
|
|
[treeAdaptor addChild:[stream_functionHeader nextTree] toTree:root_1];
|
|
|
|
[treeAdaptor addChild:root_1 toTree:root_0];
|
|
}
|
|
|
|
}
|
|
|
|
|
|
retval.tree = root_0;
|
|
|
|
|
|
}
|
|
break;
|
|
case 3 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:23:9: functionHeader block // alt
|
|
{
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_functionHeader_in_declaration135];
|
|
functionHeader5 = [self functionHeader];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_functionHeader addElement:[functionHeader5 getTree]];
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_block_in_declaration137];
|
|
block6 = [self block];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_block addElement:[block6 getTree]];
|
|
|
|
// AST REWRITE
|
|
// elements: functionHeader, block
|
|
// token labels:
|
|
// rule labels: retval
|
|
// token list labels:
|
|
// rule list labels:
|
|
// wildcard labels:
|
|
retval.tree = root_0;
|
|
|
|
RewriteRuleSubtreeStream *stream_retval =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
|
|
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
// 23:30: -> ^( FUNC_DEF functionHeader block )
|
|
{
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:23:33: ^( FUNC_DEF functionHeader block )
|
|
{
|
|
CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
root_1 = (CommonTree *)[treeAdaptor becomeRoot:
|
|
[[treeAdaptor createTree:FUNC_DEF Text:@"FUNC_DEF"] retain]
|
|
old:root_1];
|
|
|
|
[treeAdaptor addChild:[stream_functionHeader nextTree] toTree:root_1];
|
|
|
|
[treeAdaptor addChild:[stream_block nextTree] toTree:root_1];
|
|
|
|
[treeAdaptor addChild:root_1 toTree:root_0];
|
|
}
|
|
|
|
}
|
|
|
|
|
|
retval.tree = root_0;
|
|
|
|
|
|
}
|
|
break;
|
|
|
|
}
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
[stream_K_SEMICOLON release];
|
|
[stream_functionHeader release];
|
|
[stream_block release];
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end declaration */
|
|
|
|
/*
|
|
* $ANTLR start variable
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:26:1: variable : type declarator K_SEMICOLON -> ^( VAR_DEF type declarator ) ;
|
|
*/
|
|
- (SimpleCParser_variable_return *) variable
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_variable_return * retval = [SimpleCParser_variable_return newSimpleCParser_variable_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
CommonToken *K_SEMICOLON9 = nil;SimpleCParser_type_return * type7 = nil ;
|
|
|
|
SimpleCParser_declarator_return * declarator8 = nil ;
|
|
|
|
|
|
CommonTree *K_SEMICOLON9_tree=nil;
|
|
RewriteRuleTokenStream *stream_K_SEMICOLON =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_SEMICOLON"] retain];
|
|
RewriteRuleSubtreeStream *stream_declarator =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule declarator"] retain];
|
|
RewriteRuleSubtreeStream *stream_type =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule type"] retain];
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:27:5: ( type declarator K_SEMICOLON -> ^( VAR_DEF type declarator ) ) // ruleBlockSingleAlt
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:27:9: type declarator K_SEMICOLON // alt
|
|
{
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_type_in_variable166];
|
|
type7 = [self type];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_type addElement:[type7 getTree]];
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_declarator_in_variable168];
|
|
declarator8 = [self declarator];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_declarator addElement:[declarator8 getTree]];
|
|
|
|
K_SEMICOLON9=(CommonToken *)[self match:input TokenType:K_SEMICOLON Follow:FOLLOW_K_SEMICOLON_in_variable170];
|
|
[stream_K_SEMICOLON addElement:K_SEMICOLON9];
|
|
|
|
|
|
// AST REWRITE
|
|
// elements: declarator, type
|
|
// token labels:
|
|
// rule labels: retval
|
|
// token list labels:
|
|
// rule list labels:
|
|
// wildcard labels:
|
|
retval.tree = root_0;
|
|
|
|
RewriteRuleSubtreeStream *stream_retval =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
|
|
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
// 27:37: -> ^( VAR_DEF type declarator )
|
|
{
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:27:40: ^( VAR_DEF type declarator )
|
|
{
|
|
CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
root_1 = (CommonTree *)[treeAdaptor becomeRoot:
|
|
[[treeAdaptor createTree:VAR_DEF Text:@"VAR_DEF"] retain]
|
|
old:root_1];
|
|
|
|
[treeAdaptor addChild:[stream_type nextTree] toTree:root_1];
|
|
|
|
[treeAdaptor addChild:[stream_declarator nextTree] toTree:root_1];
|
|
|
|
[treeAdaptor addChild:root_1 toTree:root_0];
|
|
}
|
|
|
|
}
|
|
|
|
|
|
retval.tree = root_0;
|
|
|
|
|
|
}
|
|
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
[stream_K_SEMICOLON release];
|
|
[stream_declarator release];
|
|
[stream_type release];
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end variable */
|
|
|
|
/*
|
|
* $ANTLR start declarator
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:30:1: declarator : K_ID ;
|
|
*/
|
|
- (SimpleCParser_declarator_return *) declarator
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_declarator_return * retval = [SimpleCParser_declarator_return newSimpleCParser_declarator_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
CommonToken *K_ID10 = nil;
|
|
|
|
CommonTree *K_ID10_tree=nil;
|
|
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:31:5: ( K_ID ) // ruleBlockSingleAlt
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:31:9: K_ID // alt
|
|
{
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
|
|
|
|
/* ASTParser tokenRef */
|
|
K_ID10=(CommonToken *)[self match:input TokenType:K_ID Follow:FOLLOW_K_ID_in_declarator199];
|
|
K_ID10_tree = /* ASTParser createNodeFromToken */
|
|
(CommonTree *)[[treeAdaptor create:K_ID10] retain]
|
|
;
|
|
[treeAdaptor addChild:K_ID10_tree toTree:root_0];
|
|
|
|
|
|
}
|
|
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end declarator */
|
|
|
|
/*
|
|
* $ANTLR start functionHeader
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:34:1: functionHeader : type K_ID K_LCURVE ( formalParameter ( K_COMMA formalParameter )* )? K_RCURVE -> ^( FUNC_HDR type K_ID ( formalParameter )+ ) ;
|
|
*/
|
|
- (SimpleCParser_functionHeader_return *) functionHeader
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_functionHeader_return * retval = [SimpleCParser_functionHeader_return newSimpleCParser_functionHeader_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
CommonToken *K_ID12 = nil;
|
|
CommonToken *K_LCURVE13 = nil;
|
|
CommonToken *K_COMMA15 = nil;
|
|
CommonToken *K_RCURVE17 = nil;SimpleCParser_type_return * type11 = nil ;
|
|
|
|
SimpleCParser_formalParameter_return * formalParameter14 = nil ;
|
|
|
|
SimpleCParser_formalParameter_return * formalParameter16 = nil ;
|
|
|
|
|
|
CommonTree *K_ID12_tree=nil;
|
|
CommonTree *K_LCURVE13_tree=nil;
|
|
CommonTree *K_COMMA15_tree=nil;
|
|
CommonTree *K_RCURVE17_tree=nil;
|
|
RewriteRuleTokenStream *stream_K_ID =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_ID"] retain];
|
|
RewriteRuleTokenStream *stream_K_LCURVE =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_LCURVE"] retain];
|
|
RewriteRuleTokenStream *stream_K_RCURVE =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_RCURVE"] retain];
|
|
RewriteRuleTokenStream *stream_K_COMMA =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_COMMA"] retain];
|
|
RewriteRuleSubtreeStream *stream_formalParameter =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule formalParameter"] retain];
|
|
RewriteRuleSubtreeStream *stream_type =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule type"] retain];
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:35:5: ( type K_ID K_LCURVE ( formalParameter ( K_COMMA formalParameter )* )? K_RCURVE -> ^( FUNC_HDR type K_ID ( formalParameter )+ ) ) // ruleBlockSingleAlt
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:35:9: type K_ID K_LCURVE ( formalParameter ( K_COMMA formalParameter )* )? K_RCURVE // alt
|
|
{
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_type_in_functionHeader219];
|
|
type11 = [self type];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_type addElement:[type11 getTree]];
|
|
|
|
K_ID12=(CommonToken *)[self match:input TokenType:K_ID Follow:FOLLOW_K_ID_in_functionHeader221];
|
|
[stream_K_ID addElement:K_ID12];
|
|
|
|
|
|
K_LCURVE13=(CommonToken *)[self match:input TokenType:K_LCURVE Follow:FOLLOW_K_LCURVE_in_functionHeader223];
|
|
[stream_K_LCURVE addElement:K_LCURVE13];
|
|
|
|
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:35:28: ( formalParameter ( K_COMMA formalParameter )* )? // block
|
|
NSInteger alt4=2;
|
|
NSInteger LA4_0 = [input LA:1];
|
|
|
|
if ( (LA4_0==K_CHAR||LA4_0==K_ID||LA4_0==K_INT_TYPE||LA4_0==K_VOID) ) {
|
|
alt4=1;
|
|
}
|
|
switch (alt4) {
|
|
case 1 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:35:30: formalParameter ( K_COMMA formalParameter )* // alt
|
|
{
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_formalParameter_in_functionHeader227];
|
|
formalParameter14 = [self formalParameter];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_formalParameter addElement:[formalParameter14 getTree]];
|
|
|
|
|
|
do {
|
|
NSInteger alt3=2;
|
|
NSInteger LA3_0 = [input LA:1];
|
|
if ( (LA3_0==K_COMMA) ) {
|
|
alt3=1;
|
|
}
|
|
|
|
|
|
switch (alt3) {
|
|
case 1 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:35:48: K_COMMA formalParameter // alt
|
|
{
|
|
|
|
K_COMMA15=(CommonToken *)[self match:input TokenType:K_COMMA Follow:FOLLOW_K_COMMA_in_functionHeader231];
|
|
[stream_K_COMMA addElement:K_COMMA15];
|
|
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_formalParameter_in_functionHeader233];
|
|
formalParameter16 = [self formalParameter];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_formalParameter addElement:[formalParameter16 getTree]];
|
|
|
|
}
|
|
break;
|
|
|
|
default :
|
|
goto loop3;
|
|
}
|
|
} while (YES);
|
|
loop3: ;
|
|
|
|
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
K_RCURVE17=(CommonToken *)[self match:input TokenType:K_RCURVE Follow:FOLLOW_K_RCURVE_in_functionHeader241];
|
|
[stream_K_RCURVE addElement:K_RCURVE17];
|
|
|
|
|
|
// AST REWRITE
|
|
// elements: K_ID, type, formalParameter
|
|
// token labels:
|
|
// rule labels: retval
|
|
// token list labels:
|
|
// rule list labels:
|
|
// wildcard labels:
|
|
retval.tree = root_0;
|
|
|
|
RewriteRuleSubtreeStream *stream_retval =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
|
|
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
// 36:9: -> ^( FUNC_HDR type K_ID ( formalParameter )+ )
|
|
{
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:36:12: ^( FUNC_HDR type K_ID ( formalParameter )+ )
|
|
{
|
|
CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
root_1 = (CommonTree *)[treeAdaptor becomeRoot:
|
|
[[treeAdaptor createTree:FUNC_HDR Text:@"FUNC_HDR"] retain]
|
|
old:root_1];
|
|
|
|
[treeAdaptor addChild:[stream_type nextTree] toTree:root_1];
|
|
|
|
// TODO: args:
|
|
[treeAdaptor addChild:
|
|
[stream_K_ID nextNode]
|
|
toTree:root_1];
|
|
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:36:33: ( formalParameter )+
|
|
{
|
|
if ( !([stream_formalParameter hasNext]) ) {
|
|
@throw [RewriteEarlyExitException newException];
|
|
}
|
|
while ( [stream_formalParameter hasNext] ) {
|
|
[treeAdaptor addChild:[stream_formalParameter nextTree] toTree:root_1];
|
|
|
|
}
|
|
[stream_formalParameter reset];
|
|
|
|
}
|
|
[treeAdaptor addChild:root_1 toTree:root_0];
|
|
}
|
|
|
|
}
|
|
|
|
|
|
retval.tree = root_0;
|
|
|
|
|
|
}
|
|
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
[stream_K_ID release];
|
|
[stream_K_LCURVE release];
|
|
[stream_K_RCURVE release];
|
|
[stream_K_COMMA release];
|
|
[stream_formalParameter release];
|
|
[stream_type release];
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end functionHeader */
|
|
|
|
/*
|
|
* $ANTLR start formalParameter
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:39:1: formalParameter : type declarator -> ^( ARG_DEF type declarator ) ;
|
|
*/
|
|
- (SimpleCParser_formalParameter_return *) formalParameter
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_formalParameter_return * retval = [SimpleCParser_formalParameter_return newSimpleCParser_formalParameter_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
SimpleCParser_type_return * type18 = nil ;
|
|
|
|
SimpleCParser_declarator_return * declarator19 = nil ;
|
|
|
|
|
|
RewriteRuleSubtreeStream *stream_declarator =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule declarator"] retain];
|
|
RewriteRuleSubtreeStream *stream_type =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule type"] retain];
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:40:5: ( type declarator -> ^( ARG_DEF type declarator ) ) // ruleBlockSingleAlt
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:40:9: type declarator // alt
|
|
{
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_type_in_formalParameter281];
|
|
type18 = [self type];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_type addElement:[type18 getTree]];
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_declarator_in_formalParameter283];
|
|
declarator19 = [self declarator];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_declarator addElement:[declarator19 getTree]];
|
|
|
|
// AST REWRITE
|
|
// elements: type, declarator
|
|
// token labels:
|
|
// rule labels: retval
|
|
// token list labels:
|
|
// rule list labels:
|
|
// wildcard labels:
|
|
retval.tree = root_0;
|
|
|
|
RewriteRuleSubtreeStream *stream_retval =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
|
|
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
// 40:25: -> ^( ARG_DEF type declarator )
|
|
{
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:40:28: ^( ARG_DEF type declarator )
|
|
{
|
|
CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
root_1 = (CommonTree *)[treeAdaptor becomeRoot:
|
|
[[treeAdaptor createTree:ARG_DEF Text:@"ARG_DEF"] retain]
|
|
old:root_1];
|
|
|
|
[treeAdaptor addChild:[stream_type nextTree] toTree:root_1];
|
|
|
|
[treeAdaptor addChild:[stream_declarator nextTree] toTree:root_1];
|
|
|
|
[treeAdaptor addChild:root_1 toTree:root_0];
|
|
}
|
|
|
|
}
|
|
|
|
|
|
retval.tree = root_0;
|
|
|
|
|
|
}
|
|
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
[stream_declarator release];
|
|
[stream_type release];
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end formalParameter */
|
|
|
|
/*
|
|
* $ANTLR start type
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:43:1: type : ( K_INT_TYPE | K_CHAR | K_VOID | K_ID );
|
|
*/
|
|
- (SimpleCParser_type_return *) type
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_type_return * retval = [SimpleCParser_type_return newSimpleCParser_type_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
CommonToken *set20 = nil;
|
|
|
|
CommonTree *set20_tree=nil;
|
|
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:44:5: ( K_INT_TYPE | K_CHAR | K_VOID | K_ID ) // ruleBlockSingleAlt
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g: // alt
|
|
{
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
|
|
|
|
/* ASTParser matchRuleBlockSet */
|
|
/* ASTParser matchSet */
|
|
set20 = (CommonToken *)[input LT:1]; /* matchSet */
|
|
|
|
if ([input LA:1] == K_CHAR||[input LA:1] == K_ID||[input LA:1] == K_INT_TYPE||[input LA:1] == K_VOID) {
|
|
[input consume];
|
|
[treeAdaptor addChild:/* ASTParser createNodeFromToken */
|
|
(CommonTree *)[[treeAdaptor create:set20] retain]
|
|
toTree:root_0 ];
|
|
[state setIsErrorRecovery:NO];
|
|
} else {
|
|
MismatchedSetException *mse = [MismatchedSetException newException:nil stream:input];
|
|
@throw mse;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end type */
|
|
|
|
/*
|
|
* $ANTLR start block
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:50:1: block : lc= K_LCURLY ( variable )* ( stat )* K_RCURLY -> ^( BLOCK[$lc,@\"BLOCK\"] ( variable )* ( stat )* ) ;
|
|
*/
|
|
- (SimpleCParser_block_return *) block
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_block_return * retval = [SimpleCParser_block_return newSimpleCParser_block_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
CommonToken *lc = nil;
|
|
CommonToken *K_RCURLY23 = nil;SimpleCParser_variable_return * variable21 = nil ;
|
|
|
|
SimpleCParser_stat_return * stat22 = nil ;
|
|
|
|
|
|
CommonTree *lc_tree=nil;
|
|
CommonTree *K_RCURLY23_tree=nil;
|
|
RewriteRuleTokenStream *stream_K_LCURLY =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_LCURLY"] retain];
|
|
RewriteRuleTokenStream *stream_K_RCURLY =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_RCURLY"] retain];
|
|
RewriteRuleSubtreeStream *stream_variable =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule variable"] retain];
|
|
RewriteRuleSubtreeStream *stream_stat =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule stat"] retain];
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:51:5: (lc= K_LCURLY ( variable )* ( stat )* K_RCURLY -> ^( BLOCK[$lc,@\"BLOCK\"] ( variable )* ( stat )* ) ) // ruleBlockSingleAlt
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:51:9: lc= K_LCURLY ( variable )* ( stat )* K_RCURLY // alt
|
|
{
|
|
|
|
lc=(CommonToken *)[self match:input TokenType:K_LCURLY Follow:FOLLOW_K_LCURLY_in_block376];
|
|
[stream_K_LCURLY addElement:lc];
|
|
|
|
|
|
|
|
do {
|
|
NSInteger alt5=2;
|
|
NSInteger LA5_0 = [input LA:1];
|
|
if ( (LA5_0==K_ID) ) {
|
|
NSInteger LA5_2 = [input LA:2];
|
|
if ( (LA5_2==K_ID) ) {
|
|
alt5=1;
|
|
}
|
|
|
|
|
|
}
|
|
else if ( (LA5_0==K_CHAR||LA5_0==K_INT_TYPE||LA5_0==K_VOID) ) {
|
|
alt5=1;
|
|
}
|
|
|
|
|
|
switch (alt5) {
|
|
case 1 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:52:13: variable // alt
|
|
{
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_variable_in_block390];
|
|
variable21 = [self variable];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_variable addElement:[variable21 getTree]];
|
|
|
|
}
|
|
break;
|
|
|
|
default :
|
|
goto loop5;
|
|
}
|
|
} while (YES);
|
|
loop5: ;
|
|
|
|
|
|
|
|
do {
|
|
NSInteger alt6=2;
|
|
NSInteger LA6_0 = [input LA:1];
|
|
if ( ((LA6_0 >= K_FOR && LA6_0 <= K_INT)||(LA6_0 >= K_LCURLY && LA6_0 <= K_LCURVE)||LA6_0==K_SEMICOLON) ) {
|
|
alt6=1;
|
|
}
|
|
|
|
|
|
switch (alt6) {
|
|
case 1 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:53:13: stat // alt
|
|
{
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_stat_in_block405];
|
|
stat22 = [self stat];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_stat addElement:[stat22 getTree]];
|
|
|
|
}
|
|
break;
|
|
|
|
default :
|
|
goto loop6;
|
|
}
|
|
} while (YES);
|
|
loop6: ;
|
|
|
|
|
|
K_RCURLY23=(CommonToken *)[self match:input TokenType:K_RCURLY Follow:FOLLOW_K_RCURLY_in_block416];
|
|
[stream_K_RCURLY addElement:K_RCURLY23];
|
|
|
|
|
|
// AST REWRITE
|
|
// elements: stat, variable
|
|
// token labels:
|
|
// rule labels: retval
|
|
// token list labels:
|
|
// rule list labels:
|
|
// wildcard labels:
|
|
retval.tree = root_0;
|
|
|
|
RewriteRuleSubtreeStream *stream_retval =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
|
|
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
// 55:9: -> ^( BLOCK[$lc,@\"BLOCK\"] ( variable )* ( stat )* )
|
|
{
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:55:12: ^( BLOCK[$lc,@\"BLOCK\"] ( variable )* ( stat )* )
|
|
{
|
|
CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
root_1 = (CommonTree *)[treeAdaptor becomeRoot:
|
|
[[treeAdaptor createTree:BLOCK FromToken:lc Text:@"BLOCK"] retain]
|
|
old:root_1];
|
|
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:55:34: ( variable )*
|
|
while ( [stream_variable hasNext] ) {
|
|
[treeAdaptor addChild:[stream_variable nextTree] toTree:root_1];
|
|
|
|
}
|
|
[stream_variable reset];
|
|
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:55:44: ( stat )*
|
|
while ( [stream_stat hasNext] ) {
|
|
[treeAdaptor addChild:[stream_stat nextTree] toTree:root_1];
|
|
|
|
}
|
|
[stream_stat reset];
|
|
|
|
[treeAdaptor addChild:root_1 toTree:root_0];
|
|
}
|
|
|
|
}
|
|
|
|
|
|
retval.tree = root_0;
|
|
|
|
|
|
}
|
|
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
[stream_K_LCURLY release];
|
|
[stream_K_RCURLY release];
|
|
[stream_variable release];
|
|
[stream_stat release];
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end block */
|
|
|
|
/*
|
|
* $ANTLR start stat
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:58:1: stat : ( forStat | expr K_SEMICOLON !| block | assignStat K_SEMICOLON !| K_SEMICOLON !);
|
|
*/
|
|
- (SimpleCParser_stat_return *) stat
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_stat_return * retval = [SimpleCParser_stat_return newSimpleCParser_stat_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
CommonToken *K_SEMICOLON26 = nil;
|
|
CommonToken *K_SEMICOLON29 = nil;
|
|
CommonToken *K_SEMICOLON30 = nil;SimpleCParser_forStat_return * forStat24 = nil ;
|
|
|
|
SimpleCParser_expr_return * expr25 = nil ;
|
|
|
|
SimpleCParser_block_return * block27 = nil ;
|
|
|
|
SimpleCParser_assignStat_return * assignStat28 = nil ;
|
|
|
|
|
|
CommonTree *K_SEMICOLON26_tree=nil;
|
|
CommonTree *K_SEMICOLON29_tree=nil;
|
|
CommonTree *K_SEMICOLON30_tree=nil;
|
|
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:58:5: ( forStat | expr K_SEMICOLON !| block | assignStat K_SEMICOLON !| K_SEMICOLON !) //ruleblock
|
|
NSInteger alt7=5;
|
|
unichar charLA7 = [input LA:1];
|
|
switch (charLA7) {
|
|
case K_FOR: ;
|
|
{
|
|
alt7=1;
|
|
}
|
|
break;
|
|
case K_ID: ;
|
|
{
|
|
NSInteger LA7_2 = [input LA:2];
|
|
|
|
if ( (LA7_2==K_EQ) ) {
|
|
alt7=4;
|
|
}
|
|
else if ( (LA7_2==K_EQEQ||(LA7_2 >= K_LT && LA7_2 <= K_PLUS)||LA7_2==K_SEMICOLON) ) {
|
|
alt7=2;
|
|
}
|
|
else {
|
|
NoViableAltException *nvae = [NoViableAltException newException:7 state:2 stream:input];
|
|
nvae.c = LA7_2;
|
|
@throw nvae;
|
|
|
|
}
|
|
}
|
|
break;
|
|
case K_INT: ;
|
|
case K_LCURVE: ;
|
|
{
|
|
alt7=2;
|
|
}
|
|
break;
|
|
case K_LCURLY: ;
|
|
{
|
|
alt7=3;
|
|
}
|
|
break;
|
|
case K_SEMICOLON: ;
|
|
{
|
|
alt7=5;
|
|
}
|
|
break;
|
|
|
|
default: ;
|
|
NoViableAltException *nvae = [NoViableAltException newException:7 state:0 stream:input];
|
|
nvae.c = charLA7;
|
|
@throw nvae;
|
|
|
|
}
|
|
|
|
switch (alt7) {
|
|
case 1 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:58:7: forStat // alt
|
|
{
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
|
|
|
|
/* ASTParser ruleRef */
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_forStat_in_stat449];
|
|
forStat24 = [self forStat];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[treeAdaptor addChild:[forStat24 getTree] toTree:root_0];
|
|
|
|
}
|
|
break;
|
|
case 2 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:59:7: expr K_SEMICOLON ! // alt
|
|
{
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
|
|
|
|
/* ASTParser ruleRef */
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_expr_in_stat457];
|
|
expr25 = [self expr];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[treeAdaptor addChild:[expr25 getTree] toTree:root_0];
|
|
|
|
K_SEMICOLON26=(CommonToken *)[self match:input TokenType:K_SEMICOLON Follow:FOLLOW_K_SEMICOLON_in_stat459];
|
|
|
|
}
|
|
break;
|
|
case 3 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:60:7: block // alt
|
|
{
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
|
|
|
|
/* ASTParser ruleRef */
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_block_in_stat468];
|
|
block27 = [self block];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[treeAdaptor addChild:[block27 getTree] toTree:root_0];
|
|
|
|
}
|
|
break;
|
|
case 4 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:61:7: assignStat K_SEMICOLON ! // alt
|
|
{
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
|
|
|
|
/* ASTParser ruleRef */
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_assignStat_in_stat476];
|
|
assignStat28 = [self assignStat];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[treeAdaptor addChild:[assignStat28 getTree] toTree:root_0];
|
|
|
|
K_SEMICOLON29=(CommonToken *)[self match:input TokenType:K_SEMICOLON Follow:FOLLOW_K_SEMICOLON_in_stat478];
|
|
|
|
}
|
|
break;
|
|
case 5 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:62:7: K_SEMICOLON ! // alt
|
|
{
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
|
|
|
|
K_SEMICOLON30=(CommonToken *)[self match:input TokenType:K_SEMICOLON Follow:FOLLOW_K_SEMICOLON_in_stat487];
|
|
|
|
}
|
|
break;
|
|
|
|
}
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end stat */
|
|
|
|
/*
|
|
* $ANTLR start forStat
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:65:1: forStat : K_FOR K_LCURVE start= assignStat K_SEMICOLON expr K_SEMICOLON next= assignStat K_RCURVE block -> ^( K_FOR $start expr $next block ) ;
|
|
*/
|
|
- (SimpleCParser_forStat_return *) forStat
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_forStat_return * retval = [SimpleCParser_forStat_return newSimpleCParser_forStat_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
CommonToken *K_FOR31 = nil;
|
|
CommonToken *K_LCURVE32 = nil;
|
|
CommonToken *K_SEMICOLON33 = nil;
|
|
CommonToken *K_SEMICOLON35 = nil;
|
|
CommonToken *K_RCURVE36 = nil;SimpleCParser_assignStat_return * start = nil ;
|
|
|
|
SimpleCParser_assignStat_return * next = nil ;
|
|
|
|
SimpleCParser_expr_return * expr34 = nil ;
|
|
|
|
SimpleCParser_block_return * block37 = nil ;
|
|
|
|
|
|
CommonTree *K_FOR31_tree=nil;
|
|
CommonTree *K_LCURVE32_tree=nil;
|
|
CommonTree *K_SEMICOLON33_tree=nil;
|
|
CommonTree *K_SEMICOLON35_tree=nil;
|
|
CommonTree *K_RCURVE36_tree=nil;
|
|
RewriteRuleTokenStream *stream_K_LCURVE =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_LCURVE"] retain];
|
|
RewriteRuleTokenStream *stream_K_RCURVE =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_RCURVE"] retain];
|
|
RewriteRuleTokenStream *stream_K_SEMICOLON =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_SEMICOLON"] retain];
|
|
RewriteRuleTokenStream *stream_K_FOR =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_FOR"] retain];
|
|
RewriteRuleSubtreeStream *stream_assignStat =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule assignStat"] retain];
|
|
RewriteRuleSubtreeStream *stream_block =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule block"] retain];
|
|
RewriteRuleSubtreeStream *stream_expr =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule expr"] retain];
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:66:5: ( K_FOR K_LCURVE start= assignStat K_SEMICOLON expr K_SEMICOLON next= assignStat K_RCURVE block -> ^( K_FOR $start expr $next block ) ) // ruleBlockSingleAlt
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:66:9: K_FOR K_LCURVE start= assignStat K_SEMICOLON expr K_SEMICOLON next= assignStat K_RCURVE block // alt
|
|
{
|
|
|
|
K_FOR31=(CommonToken *)[self match:input TokenType:K_FOR Follow:FOLLOW_K_FOR_in_forStat507];
|
|
[stream_K_FOR addElement:K_FOR31];
|
|
|
|
|
|
K_LCURVE32=(CommonToken *)[self match:input TokenType:K_LCURVE Follow:FOLLOW_K_LCURVE_in_forStat509];
|
|
[stream_K_LCURVE addElement:K_LCURVE32];
|
|
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_assignStat_in_forStat513];
|
|
start = [self assignStat];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_assignStat addElement:[start getTree]];
|
|
|
|
K_SEMICOLON33=(CommonToken *)[self match:input TokenType:K_SEMICOLON Follow:FOLLOW_K_SEMICOLON_in_forStat515];
|
|
[stream_K_SEMICOLON addElement:K_SEMICOLON33];
|
|
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_expr_in_forStat517];
|
|
expr34 = [self expr];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_expr addElement:[expr34 getTree]];
|
|
|
|
K_SEMICOLON35=(CommonToken *)[self match:input TokenType:K_SEMICOLON Follow:FOLLOW_K_SEMICOLON_in_forStat519];
|
|
[stream_K_SEMICOLON addElement:K_SEMICOLON35];
|
|
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_assignStat_in_forStat523];
|
|
next = [self assignStat];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_assignStat addElement:[next getTree]];
|
|
|
|
K_RCURVE36=(CommonToken *)[self match:input TokenType:K_RCURVE Follow:FOLLOW_K_RCURVE_in_forStat525];
|
|
[stream_K_RCURVE addElement:K_RCURVE36];
|
|
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_block_in_forStat527];
|
|
block37 = [self block];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_block addElement:[block37 getTree]];
|
|
|
|
// AST REWRITE
|
|
// elements: block, start, K_FOR, next, expr
|
|
// token labels:
|
|
// rule labels: retval, start, next
|
|
// token list labels:
|
|
// rule list labels:
|
|
// wildcard labels:
|
|
retval.tree = root_0;
|
|
|
|
RewriteRuleSubtreeStream *stream_retval =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
|
|
RewriteRuleSubtreeStream *stream_start =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"token start" element:start!=nil?[start getTree]:nil] retain];
|
|
RewriteRuleSubtreeStream *stream_next =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"token next" element:next!=nil?[next getTree]:nil] retain];
|
|
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
// 67:9: -> ^( K_FOR $start expr $next block )
|
|
{
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:67:12: ^( K_FOR $start expr $next block )
|
|
{
|
|
CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
root_1 = (CommonTree *)[treeAdaptor becomeRoot:
|
|
[stream_K_FOR nextNode]
|
|
old:root_1];
|
|
|
|
[treeAdaptor addChild:[stream_start nextTree] toTree:root_1];
|
|
|
|
[treeAdaptor addChild:[stream_expr nextTree] toTree:root_1];
|
|
|
|
[treeAdaptor addChild:[stream_next nextTree] toTree:root_1];
|
|
|
|
[treeAdaptor addChild:[stream_block nextTree] toTree:root_1];
|
|
|
|
[treeAdaptor addChild:root_1 toTree:root_0];
|
|
}
|
|
|
|
}
|
|
|
|
|
|
retval.tree = root_0;
|
|
|
|
|
|
}
|
|
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
[stream_K_LCURVE release];
|
|
[stream_K_RCURVE release];
|
|
[stream_K_SEMICOLON release];
|
|
[stream_K_FOR release];
|
|
[stream_assignStat release];
|
|
[stream_block release];
|
|
[stream_expr release];
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end forStat */
|
|
|
|
/*
|
|
* $ANTLR start assignStat
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:70:1: assignStat : K_ID K_EQ expr -> ^( K_EQ K_ID expr ) ;
|
|
*/
|
|
- (SimpleCParser_assignStat_return *) assignStat
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_assignStat_return * retval = [SimpleCParser_assignStat_return newSimpleCParser_assignStat_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
CommonToken *K_ID38 = nil;
|
|
CommonToken *K_EQ39 = nil;SimpleCParser_expr_return * expr40 = nil ;
|
|
|
|
|
|
CommonTree *K_ID38_tree=nil;
|
|
CommonTree *K_EQ39_tree=nil;
|
|
RewriteRuleTokenStream *stream_K_ID =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_ID"] retain];
|
|
RewriteRuleTokenStream *stream_K_EQ =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_EQ"] retain];
|
|
RewriteRuleSubtreeStream *stream_expr =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule expr"] retain];
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:71:5: ( K_ID K_EQ expr -> ^( K_EQ K_ID expr ) ) // ruleBlockSingleAlt
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:71:9: K_ID K_EQ expr // alt
|
|
{
|
|
|
|
K_ID38=(CommonToken *)[self match:input TokenType:K_ID Follow:FOLLOW_K_ID_in_assignStat570];
|
|
[stream_K_ID addElement:K_ID38];
|
|
|
|
|
|
K_EQ39=(CommonToken *)[self match:input TokenType:K_EQ Follow:FOLLOW_K_EQ_in_assignStat572];
|
|
[stream_K_EQ addElement:K_EQ39];
|
|
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_expr_in_assignStat574];
|
|
expr40 = [self expr];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_expr addElement:[expr40 getTree]];
|
|
|
|
// AST REWRITE
|
|
// elements: expr, K_ID, K_EQ
|
|
// token labels:
|
|
// rule labels: retval
|
|
// token list labels:
|
|
// rule list labels:
|
|
// wildcard labels:
|
|
retval.tree = root_0;
|
|
|
|
RewriteRuleSubtreeStream *stream_retval =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
|
|
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
// 71:24: -> ^( K_EQ K_ID expr )
|
|
{
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:71:27: ^( K_EQ K_ID expr )
|
|
{
|
|
CommonTree *root_1 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
root_1 = (CommonTree *)[treeAdaptor becomeRoot:
|
|
[stream_K_EQ nextNode]
|
|
old:root_1];
|
|
|
|
// TODO: args:
|
|
[treeAdaptor addChild:
|
|
[stream_K_ID nextNode]
|
|
toTree:root_1];
|
|
|
|
[treeAdaptor addChild:[stream_expr nextTree] toTree:root_1];
|
|
|
|
[treeAdaptor addChild:root_1 toTree:root_0];
|
|
}
|
|
|
|
}
|
|
|
|
|
|
retval.tree = root_0;
|
|
|
|
|
|
}
|
|
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
[stream_K_ID release];
|
|
[stream_K_EQ release];
|
|
[stream_expr release];
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end assignStat */
|
|
|
|
/*
|
|
* $ANTLR start expr
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:74:1: expr : condExpr ;
|
|
*/
|
|
- (SimpleCParser_expr_return *) expr
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_expr_return * retval = [SimpleCParser_expr_return newSimpleCParser_expr_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
SimpleCParser_condExpr_return * condExpr41 = nil ;
|
|
|
|
|
|
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:74:5: ( condExpr ) // ruleBlockSingleAlt
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:74:9: condExpr // alt
|
|
{
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
|
|
|
|
/* ASTParser ruleRef */
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_condExpr_in_expr598];
|
|
condExpr41 = [self condExpr];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[treeAdaptor addChild:[condExpr41 getTree] toTree:root_0];
|
|
|
|
}
|
|
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end expr */
|
|
|
|
/*
|
|
* $ANTLR start condExpr
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:77:1: condExpr : aexpr ( ( K_EQEQ ^| K_LT ^) aexpr )? ;
|
|
*/
|
|
- (SimpleCParser_condExpr_return *) condExpr
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_condExpr_return * retval = [SimpleCParser_condExpr_return newSimpleCParser_condExpr_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
CommonToken *K_EQEQ43 = nil;
|
|
CommonToken *K_LT44 = nil;SimpleCParser_aexpr_return * aexpr42 = nil ;
|
|
|
|
SimpleCParser_aexpr_return * aexpr45 = nil ;
|
|
|
|
|
|
CommonTree *K_EQEQ43_tree=nil;
|
|
CommonTree *K_LT44_tree=nil;
|
|
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:78:5: ( aexpr ( ( K_EQEQ ^| K_LT ^) aexpr )? ) // ruleBlockSingleAlt
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:78:9: aexpr ( ( K_EQEQ ^| K_LT ^) aexpr )? // alt
|
|
{
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
|
|
|
|
/* ASTParser ruleRef */
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_aexpr_in_condExpr617];
|
|
aexpr42 = [self aexpr];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[treeAdaptor addChild:[aexpr42 getTree] toTree:root_0];
|
|
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:78:15: ( ( K_EQEQ ^| K_LT ^) aexpr )? // block
|
|
NSInteger alt9=2;
|
|
NSInteger LA9_0 = [input LA:1];
|
|
|
|
if ( (LA9_0==K_EQEQ||LA9_0==K_LT) ) {
|
|
alt9=1;
|
|
}
|
|
switch (alt9) {
|
|
case 1 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:78:17: ( K_EQEQ ^| K_LT ^) aexpr // alt
|
|
{
|
|
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:78:17: ( K_EQEQ ^| K_LT ^) // block
|
|
NSInteger alt8=2;
|
|
NSInteger LA8_0 = [input LA:1];
|
|
|
|
if ( (LA8_0==K_EQEQ) ) {
|
|
alt8=1;
|
|
}
|
|
else if ( (LA8_0==K_LT) ) {
|
|
alt8=2;
|
|
}
|
|
else {
|
|
NoViableAltException *nvae = [NoViableAltException newException:8 state:0 stream:input];
|
|
nvae.c = LA8_0;
|
|
@throw nvae;
|
|
|
|
}
|
|
switch (alt8) {
|
|
case 1 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:78:18: K_EQEQ ^ // alt
|
|
{
|
|
|
|
K_EQEQ43=(CommonToken *)[self match:input TokenType:K_EQEQ Follow:FOLLOW_K_EQEQ_in_condExpr622];
|
|
K_EQEQ43_tree = /* ASTParser createNodeFromToken */
|
|
(CommonTree *)[[treeAdaptor create:K_EQEQ43] retain]
|
|
;
|
|
root_0 = (CommonTree *)[treeAdaptor becomeRoot:K_EQEQ43_tree old:root_0];
|
|
|
|
|
|
}
|
|
break;
|
|
case 2 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:78:28: K_LT ^ // alt
|
|
{
|
|
|
|
K_LT44=(CommonToken *)[self match:input TokenType:K_LT Follow:FOLLOW_K_LT_in_condExpr627];
|
|
K_LT44_tree = /* ASTParser createNodeFromToken */
|
|
(CommonTree *)[[treeAdaptor create:K_LT44] retain]
|
|
;
|
|
root_0 = (CommonTree *)[treeAdaptor becomeRoot:K_LT44_tree old:root_0];
|
|
|
|
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
/* ASTParser ruleRef */
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_aexpr_in_condExpr631];
|
|
aexpr45 = [self aexpr];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[treeAdaptor addChild:[aexpr45 getTree] toTree:root_0];
|
|
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end condExpr */
|
|
|
|
/*
|
|
* $ANTLR start aexpr
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:81:1: aexpr : atom ( K_PLUS ^ atom )* ;
|
|
*/
|
|
- (SimpleCParser_aexpr_return *) aexpr
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_aexpr_return * retval = [SimpleCParser_aexpr_return newSimpleCParser_aexpr_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
CommonToken *K_PLUS47 = nil;SimpleCParser_atom_return * atom46 = nil ;
|
|
|
|
SimpleCParser_atom_return * atom48 = nil ;
|
|
|
|
|
|
CommonTree *K_PLUS47_tree=nil;
|
|
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:82:5: ( atom ( K_PLUS ^ atom )* ) // ruleBlockSingleAlt
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:82:9: atom ( K_PLUS ^ atom )* // alt
|
|
{
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
|
|
|
|
/* ASTParser ruleRef */
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_atom_in_aexpr653];
|
|
atom46 = [self atom];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[treeAdaptor addChild:[atom46 getTree] toTree:root_0];
|
|
|
|
|
|
do {
|
|
NSInteger alt10=2;
|
|
NSInteger LA10_0 = [input LA:1];
|
|
if ( (LA10_0==K_PLUS) ) {
|
|
alt10=1;
|
|
}
|
|
|
|
|
|
switch (alt10) {
|
|
case 1 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:82:16: K_PLUS ^ atom // alt
|
|
{
|
|
|
|
K_PLUS47=(CommonToken *)[self match:input TokenType:K_PLUS Follow:FOLLOW_K_PLUS_in_aexpr657];
|
|
K_PLUS47_tree = /* ASTParser createNodeFromToken */
|
|
(CommonTree *)[[treeAdaptor create:K_PLUS47] retain]
|
|
;
|
|
root_0 = (CommonTree *)[treeAdaptor becomeRoot:K_PLUS47_tree old:root_0];
|
|
|
|
|
|
/* ASTParser ruleRef */
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_atom_in_aexpr660];
|
|
atom48 = [self atom];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[treeAdaptor addChild:[atom48 getTree] toTree:root_0];
|
|
|
|
}
|
|
break;
|
|
|
|
default :
|
|
goto loop10;
|
|
}
|
|
} while (YES);
|
|
loop10: ;
|
|
|
|
|
|
}
|
|
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end aexpr */
|
|
|
|
/*
|
|
* $ANTLR start atom
|
|
* /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:85:1: atom : ( K_ID | K_INT | K_LCURVE expr K_RCURVE -> expr );
|
|
*/
|
|
- (SimpleCParser_atom_return *) atom
|
|
{
|
|
/* ruleScopeSetUp */
|
|
|
|
/* AST ruleDeclarations */
|
|
/* ruleDeclarations */
|
|
SimpleCParser_atom_return * retval = [SimpleCParser_atom_return newSimpleCParser_atom_return];
|
|
[retval setStart:[input LT:1]];
|
|
|
|
|
|
CommonTree *root_0 = nil;
|
|
|
|
@try {
|
|
/* AST ruleLabelDefs */
|
|
/* ruleLabelDefs entry */
|
|
CommonToken *K_ID49 = nil;
|
|
CommonToken *K_INT50 = nil;
|
|
CommonToken *K_LCURVE51 = nil;
|
|
CommonToken *K_RCURVE53 = nil;SimpleCParser_expr_return * expr52 = nil ;
|
|
|
|
|
|
CommonTree *K_ID49_tree=nil;
|
|
CommonTree *K_INT50_tree=nil;
|
|
CommonTree *K_LCURVE51_tree=nil;
|
|
CommonTree *K_RCURVE53_tree=nil;
|
|
RewriteRuleTokenStream *stream_K_LCURVE =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_LCURVE"] retain];
|
|
RewriteRuleTokenStream *stream_K_RCURVE =
|
|
[[RewriteRuleTokenStream newRewriteRuleTokenStream:treeAdaptor
|
|
description:@"token K_RCURVE"] retain];
|
|
RewriteRuleSubtreeStream *stream_expr =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"rule expr"] retain];
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:86:5: ( K_ID | K_INT | K_LCURVE expr K_RCURVE -> expr ) //ruleblock
|
|
NSInteger alt11=3;
|
|
unichar charLA11 = [input LA:1];
|
|
switch (charLA11) {
|
|
case K_ID: ;
|
|
{
|
|
alt11=1;
|
|
}
|
|
break;
|
|
case K_INT: ;
|
|
{
|
|
alt11=2;
|
|
}
|
|
break;
|
|
case K_LCURVE: ;
|
|
{
|
|
alt11=3;
|
|
}
|
|
break;
|
|
|
|
default: ;
|
|
NoViableAltException *nvae = [NoViableAltException newException:11 state:0 stream:input];
|
|
nvae.c = charLA11;
|
|
@throw nvae;
|
|
|
|
}
|
|
|
|
switch (alt11) {
|
|
case 1 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:86:7: K_ID // alt
|
|
{
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
|
|
|
|
/* ASTParser tokenRef */
|
|
K_ID49=(CommonToken *)[self match:input TokenType:K_ID Follow:FOLLOW_K_ID_in_atom680];
|
|
K_ID49_tree = /* ASTParser createNodeFromToken */
|
|
(CommonTree *)[[treeAdaptor create:K_ID49] retain]
|
|
;
|
|
[treeAdaptor addChild:K_ID49_tree toTree:root_0];
|
|
|
|
|
|
}
|
|
break;
|
|
case 2 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:87:7: K_INT // alt
|
|
{
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
|
|
|
|
/* ASTParser tokenRef */
|
|
K_INT50=(CommonToken *)[self match:input TokenType:K_INT Follow:FOLLOW_K_INT_in_atom694];
|
|
K_INT50_tree = /* ASTParser createNodeFromToken */
|
|
(CommonTree *)[[treeAdaptor create:K_INT50] retain]
|
|
;
|
|
[treeAdaptor addChild:K_INT50_tree toTree:root_0];
|
|
|
|
|
|
}
|
|
break;
|
|
case 3 : ;
|
|
// /Users/acondit/source/antlr/code/antlr3/runtime/ObjC/Framework/examples/simplecTreeParser/SimpleC.g:88:7: K_LCURVE expr K_RCURVE // alt
|
|
{
|
|
|
|
K_LCURVE51=(CommonToken *)[self match:input TokenType:K_LCURVE Follow:FOLLOW_K_LCURVE_in_atom708];
|
|
[stream_K_LCURVE addElement:K_LCURVE51];
|
|
|
|
|
|
/* ruleRef */
|
|
[self pushFollow:FOLLOW_expr_in_atom710];
|
|
expr52 = [self expr];
|
|
|
|
[self popFollow];
|
|
|
|
|
|
[stream_expr addElement:[expr52 getTree]];
|
|
|
|
K_RCURVE53=(CommonToken *)[self match:input TokenType:K_RCURVE Follow:FOLLOW_K_RCURVE_in_atom712];
|
|
[stream_K_RCURVE addElement:K_RCURVE53];
|
|
|
|
|
|
// AST REWRITE
|
|
// elements: expr
|
|
// token labels:
|
|
// rule labels: retval
|
|
// token list labels:
|
|
// rule list labels:
|
|
// wildcard labels:
|
|
retval.tree = root_0;
|
|
|
|
RewriteRuleSubtreeStream *stream_retval =
|
|
[[RewriteRuleSubtreeStream newRewriteRuleSubtreeStream:treeAdaptor
|
|
description:@"token retval" element:retval!=nil?[retval getTree]:nil] retain];
|
|
|
|
root_0 = (CommonTree *)[[[treeAdaptor class] newEmptyTree] retain];
|
|
|
|
// 88:30: -> expr
|
|
{
|
|
[treeAdaptor addChild:[stream_expr nextTree] toTree:root_0];
|
|
|
|
}
|
|
|
|
|
|
retval.tree = root_0;
|
|
|
|
|
|
}
|
|
break;
|
|
|
|
}
|
|
/* ASTParser ruleCleanUp */
|
|
/* AST ruleCleanUp */
|
|
/* token+rule list labels */
|
|
[retval setStop:[input LT:-1]];
|
|
|
|
|
|
[stream_K_LCURVE release];
|
|
[stream_K_RCURVE release];
|
|
[stream_expr release];
|
|
|
|
retval.tree = (CommonTree *)[treeAdaptor rulePostProcessing:root_0];
|
|
[treeAdaptor setTokenBoundaries:retval.tree From:retval.start To:retval.stopToken];
|
|
|
|
}
|
|
@catch (RecognitionException *re) {
|
|
[self reportError:re];
|
|
[self recover:input Exception:re];
|
|
/* ASTParser rule.setErrorReturnValue */
|
|
retval.tree = (CommonTree *)[treeAdaptor errorNode:input From:retval.start To:[input LT:-1] Exception:re];
|
|
|
|
}
|
|
|
|
@finally {
|
|
/* ruleScopeCleanUp */
|
|
|
|
}
|
|
return retval;
|
|
}
|
|
/* $ANTLR end atom */
|
|
/* ObjC end rules */
|
|
|
|
@end /* end of SimpleCParser implementation line 692 */
|