use of org.antlr.runtime.tree.RewriteRuleSubtreeStream in project freud by LMAX-Exchange.
the class JavaParser method forCondition.
// $ANTLR start "forCondition"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:908:1: forCondition : ( expression )? -> ^( FOR_CONDITION ( expression )? ) ;
public final JavaParser.forCondition_return forCondition() throws RecognitionException {
JavaParser.forCondition_return retval = new JavaParser.forCondition_return();
retval.start = input.LT(1);
int forCondition_StartIndex = input.index();
CommonTree root_0 = null;
JavaParser.expression_return expression357 = null;
RewriteRuleSubtreeStream stream_expression = new RewriteRuleSubtreeStream(adaptor, "rule expression");
try {
if (state.backtracking > 0 && alreadyParsedRule(input, 84)) {
return retval;
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:909:5: ( ( expression )? -> ^( FOR_CONDITION ( expression )? ) )
// /home/langera/dev/freud/trunk/src/grammar/Java.g:909:9: ( expression )?
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:909:9: ( expression )?
int alt105 = 2;
int LA105_0 = input.LA(1);
if ((LA105_0 == DEC || LA105_0 == INC || LA105_0 == LESS_THAN || LA105_0 == LOGICAL_NOT || (LA105_0 >= LPAREN && LA105_0 <= MINUS) || LA105_0 == NOT || LA105_0 == PLUS || LA105_0 == BOOLEAN || LA105_0 == BYTE || LA105_0 == CHAR || LA105_0 == DOUBLE || LA105_0 == FALSE || LA105_0 == FLOAT || (LA105_0 >= INT && LA105_0 <= LONG) || (LA105_0 >= NEW && LA105_0 <= NULL) || LA105_0 == SHORT || LA105_0 == SUPER || LA105_0 == THIS || LA105_0 == TRUE || LA105_0 == VOID || (LA105_0 >= IDENT && LA105_0 <= STRING_LITERAL))) {
alt105 = 1;
}
switch(alt105) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: expression
{
pushFollow(FOLLOW_expression_in_forCondition10070);
expression357 = expression();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_expression.add(expression357.getTree());
}
}
break;
}
// wildcard labels:
if (state.backtracking == 0) {
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
root_0 = (CommonTree) adaptor.nil();
// 910:9: -> ^( FOR_CONDITION ( expression )? )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:910:13: ^( FOR_CONDITION ( expression )? )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(FOR_CONDITION, "FOR_CONDITION"), root_1);
// /home/langera/dev/freud/trunk/src/grammar/Java.g:910:29: ( expression )?
if (stream_expression.hasNext()) {
adaptor.addChild(root_1, stream_expression.nextTree());
}
stream_expression.reset();
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
}
retval.stop = input.LT(-1);
if (state.backtracking == 0) {
retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
if (state.backtracking > 0) {
memoize(input, 84, forCondition_StartIndex);
}
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleSubtreeStream in project freud by LMAX-Exchange.
the class JavaParser method finallyClause.
// $ANTLR start "finallyClause"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:880:1: finallyClause : FINALLY block -> block ;
public final JavaParser.finallyClause_return finallyClause() throws RecognitionException {
JavaParser.finallyClause_return retval = new JavaParser.finallyClause_return();
retval.start = input.LT(1);
int finallyClause_StartIndex = input.index();
CommonTree root_0 = null;
Token FINALLY344 = null;
JavaParser.block_return block345 = null;
CommonTree FINALLY344_tree = null;
RewriteRuleTokenStream stream_FINALLY = new RewriteRuleTokenStream(adaptor, "token FINALLY");
RewriteRuleSubtreeStream stream_block = new RewriteRuleSubtreeStream(adaptor, "rule block");
try {
if (state.backtracking > 0 && alreadyParsedRule(input, 78)) {
return retval;
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:881:5: ( FINALLY block -> block )
// /home/langera/dev/freud/trunk/src/grammar/Java.g:881:9: FINALLY block
{
FINALLY344 = (Token) match(input, FINALLY, FOLLOW_FINALLY_in_finallyClause9802);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_FINALLY.add(FINALLY344);
}
pushFollow(FOLLOW_block_in_finallyClause9804);
block345 = block();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_block.add(block345.getTree());
}
// wildcard labels:
if (state.backtracking == 0) {
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
root_0 = (CommonTree) adaptor.nil();
// 882:9: -> block
{
adaptor.addChild(root_0, stream_block.nextTree());
}
retval.tree = root_0;
}
}
retval.stop = input.LT(-1);
if (state.backtracking == 0) {
retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
if (state.backtracking > 0) {
memoize(input, 78, finallyClause_StartIndex);
}
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleSubtreeStream in project freud by LMAX-Exchange.
the class JavaParser method genericTypeParameterList.
// $ANTLR start "genericTypeParameterList"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:464:1: genericTypeParameterList : LESS_THAN genericTypeParameter ( COMMA genericTypeParameter )* genericTypeListClosing -> ^( GENERIC_TYPE_PARAM_LIST[$LESS_THAN, \"GENERIC_TYPE_PARAM_LIST\"] ( genericTypeParameter )+ ) ;
public final JavaParser.genericTypeParameterList_return genericTypeParameterList() throws RecognitionException {
JavaParser.genericTypeParameterList_return retval = new JavaParser.genericTypeParameterList_return();
retval.start = input.LT(1);
int genericTypeParameterList_StartIndex = input.index();
CommonTree root_0 = null;
Token LESS_THAN33 = null;
Token COMMA35 = null;
JavaParser.genericTypeParameter_return genericTypeParameter34 = null;
JavaParser.genericTypeParameter_return genericTypeParameter36 = null;
JavaParser.genericTypeListClosing_return genericTypeListClosing37 = null;
CommonTree LESS_THAN33_tree = null;
CommonTree COMMA35_tree = null;
RewriteRuleTokenStream stream_COMMA = new RewriteRuleTokenStream(adaptor, "token COMMA");
RewriteRuleTokenStream stream_LESS_THAN = new RewriteRuleTokenStream(adaptor, "token LESS_THAN");
RewriteRuleSubtreeStream stream_genericTypeParameter = new RewriteRuleSubtreeStream(adaptor, "rule genericTypeParameter");
RewriteRuleSubtreeStream stream_genericTypeListClosing = new RewriteRuleSubtreeStream(adaptor, "rule genericTypeListClosing");
try {
if (state.backtracking > 0 && alreadyParsedRule(input, 11)) {
return retval;
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:465:5: ( LESS_THAN genericTypeParameter ( COMMA genericTypeParameter )* genericTypeListClosing -> ^( GENERIC_TYPE_PARAM_LIST[$LESS_THAN, \"GENERIC_TYPE_PARAM_LIST\"] ( genericTypeParameter )+ ) )
// /home/langera/dev/freud/trunk/src/grammar/Java.g:465:9: LESS_THAN genericTypeParameter ( COMMA genericTypeParameter )* genericTypeListClosing
{
LESS_THAN33 = (Token) match(input, LESS_THAN, FOLLOW_LESS_THAN_in_genericTypeParameterList4934);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_LESS_THAN.add(LESS_THAN33);
}
pushFollow(FOLLOW_genericTypeParameter_in_genericTypeParameterList4936);
genericTypeParameter34 = genericTypeParameter();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_genericTypeParameter.add(genericTypeParameter34.getTree());
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:465:40: ( COMMA genericTypeParameter )*
loop11: do {
int alt11 = 2;
int LA11_0 = input.LA(1);
if ((LA11_0 == COMMA)) {
alt11 = 1;
}
switch(alt11) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:465:41: COMMA genericTypeParameter
{
COMMA35 = (Token) match(input, COMMA, FOLLOW_COMMA_in_genericTypeParameterList4939);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_COMMA.add(COMMA35);
}
pushFollow(FOLLOW_genericTypeParameter_in_genericTypeParameterList4941);
genericTypeParameter36 = genericTypeParameter();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_genericTypeParameter.add(genericTypeParameter36.getTree());
}
}
break;
default:
break loop11;
}
} while (true);
pushFollow(FOLLOW_genericTypeListClosing_in_genericTypeParameterList4945);
genericTypeListClosing37 = genericTypeListClosing();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_genericTypeListClosing.add(genericTypeListClosing37.getTree());
}
// wildcard labels:
if (state.backtracking == 0) {
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
root_0 = (CommonTree) adaptor.nil();
// 466:9: -> ^( GENERIC_TYPE_PARAM_LIST[$LESS_THAN, \"GENERIC_TYPE_PARAM_LIST\"] ( genericTypeParameter )+ )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:466:13: ^( GENERIC_TYPE_PARAM_LIST[$LESS_THAN, \"GENERIC_TYPE_PARAM_LIST\"] ( genericTypeParameter )+ )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(GENERIC_TYPE_PARAM_LIST, LESS_THAN33, "GENERIC_TYPE_PARAM_LIST"), root_1);
if (!(stream_genericTypeParameter.hasNext())) {
throw new RewriteEarlyExitException();
}
while (stream_genericTypeParameter.hasNext()) {
adaptor.addChild(root_1, stream_genericTypeParameter.nextTree());
}
stream_genericTypeParameter.reset();
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
}
retval.stop = input.LT(-1);
if (state.backtracking == 0) {
retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
if (state.backtracking > 0) {
memoize(input, 11, genericTypeParameterList_StartIndex);
}
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleSubtreeStream in project freud by LMAX-Exchange.
the class JavaParser method bound.
// $ANTLR start "bound"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:484:1: bound : EXTENDS type ( AND type )* -> ^( EXTENDS_BOUND_LIST[$EXTENDS, \"EXTENDS_BOUND_LIST\"] ( type )+ ) ;
public final JavaParser.bound_return bound() throws RecognitionException {
JavaParser.bound_return retval = new JavaParser.bound_return();
retval.start = input.LT(1);
int bound_StartIndex = input.index();
CommonTree root_0 = null;
Token EXTENDS43 = null;
Token AND45 = null;
JavaParser.type_return type44 = null;
JavaParser.type_return type46 = null;
CommonTree EXTENDS43_tree = null;
CommonTree AND45_tree = null;
RewriteRuleTokenStream stream_AND = new RewriteRuleTokenStream(adaptor, "token AND");
RewriteRuleTokenStream stream_EXTENDS = new RewriteRuleTokenStream(adaptor, "token EXTENDS");
RewriteRuleSubtreeStream stream_type = new RewriteRuleSubtreeStream(adaptor, "rule type");
try {
if (state.backtracking > 0 && alreadyParsedRule(input, 14)) {
return retval;
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:485:5: ( EXTENDS type ( AND type )* -> ^( EXTENDS_BOUND_LIST[$EXTENDS, \"EXTENDS_BOUND_LIST\"] ( type )+ ) )
// /home/langera/dev/freud/trunk/src/grammar/Java.g:485:9: EXTENDS type ( AND type )*
{
EXTENDS43 = (Token) match(input, EXTENDS, FOLLOW_EXTENDS_in_bound5148);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_EXTENDS.add(EXTENDS43);
}
pushFollow(FOLLOW_type_in_bound5150);
type44 = type();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_type.add(type44.getTree());
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:485:22: ( AND type )*
loop14: do {
int alt14 = 2;
int LA14_0 = input.LA(1);
if ((LA14_0 == AND)) {
alt14 = 1;
}
switch(alt14) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:485:23: AND type
{
AND45 = (Token) match(input, AND, FOLLOW_AND_in_bound5153);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_AND.add(AND45);
}
pushFollow(FOLLOW_type_in_bound5155);
type46 = type();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_type.add(type46.getTree());
}
}
break;
default:
break loop14;
}
} while (true);
// wildcard labels:
if (state.backtracking == 0) {
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
root_0 = (CommonTree) adaptor.nil();
// 486:9: -> ^( EXTENDS_BOUND_LIST[$EXTENDS, \"EXTENDS_BOUND_LIST\"] ( type )+ )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:486:13: ^( EXTENDS_BOUND_LIST[$EXTENDS, \"EXTENDS_BOUND_LIST\"] ( type )+ )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(EXTENDS_BOUND_LIST, EXTENDS43, "EXTENDS_BOUND_LIST"), root_1);
if (!(stream_type.hasNext())) {
throw new RewriteEarlyExitException();
}
while (stream_type.hasNext()) {
adaptor.addChild(root_1, stream_type.nextTree());
}
stream_type.reset();
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
}
retval.stop = input.LT(-1);
if (state.backtracking == 0) {
retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
if (state.backtracking > 0) {
memoize(input, 14, bound_StartIndex);
}
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleSubtreeStream in project freud by LMAX-Exchange.
the class CssParser method function.
// $ANTLR start "function"
// /home/langera/dev/freud/src/grammar/Css.g:123:1: function : IDENT '(' ( args )? ')' -> IDENT '(' ( args )* ')' ;
public final CssParser.function_return function() throws RecognitionException {
CssParser.function_return retval = new CssParser.function_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token IDENT69 = null;
Token char_literal70 = null;
Token char_literal72 = null;
CssParser.args_return args71 = null;
CommonTree IDENT69_tree = null;
CommonTree char_literal70_tree = null;
CommonTree char_literal72_tree = null;
RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
RewriteRuleTokenStream stream_62 = new RewriteRuleTokenStream(adaptor, "token 62");
RewriteRuleTokenStream stream_61 = new RewriteRuleTokenStream(adaptor, "token 61");
RewriteRuleSubtreeStream stream_args = new RewriteRuleSubtreeStream(adaptor, "rule args");
try {
// /home/langera/dev/freud/src/grammar/Css.g:124:2: ( IDENT '(' ( args )? ')' -> IDENT '(' ( args )* ')' )
// /home/langera/dev/freud/src/grammar/Css.g:124:4: IDENT '(' ( args )? ')'
{
IDENT69 = (Token) match(input, IDENT, FOLLOW_IDENT_in_function767);
stream_IDENT.add(IDENT69);
char_literal70 = (Token) match(input, 61, FOLLOW_61_in_function769);
stream_61.add(char_literal70);
// /home/langera/dev/freud/src/grammar/Css.g:124:14: ( args )?
int alt26 = 2;
int LA26_0 = input.LA(1);
if ((LA26_0 == IDENT || (LA26_0 >= 36 && LA26_0 <= 37))) {
alt26 = 1;
}
switch(alt26) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:124:14: args
{
pushFollow(FOLLOW_args_in_function771);
args71 = args();
state._fsp--;
stream_args.add(args71.getTree());
}
break;
}
char_literal72 = (Token) match(input, 62, FOLLOW_62_in_function774);
stream_62.add(char_literal72);
// AST REWRITE
// elements: 62, args, 61, IDENT
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
root_0 = (CommonTree) adaptor.nil();
// 124:24: -> IDENT '(' ( args )* ')'
{
adaptor.addChild(root_0, stream_IDENT.nextNode());
adaptor.addChild(root_0, stream_61.nextNode());
// /home/langera/dev/freud/src/grammar/Css.g:124:37: ( args )*
while (stream_args.hasNext()) {
adaptor.addChild(root_0, stream_args.nextTree());
}
stream_args.reset();
adaptor.addChild(root_0, stream_62.nextNode());
}
retval.tree = root_0;
}
retval.stop = input.LT(-1);
retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
}
return retval;
}
Aggregations