use of org.antlr.runtime.tree.RewriteRuleTokenStream 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.RewriteRuleTokenStream in project freud by LMAX-Exchange.
the class JavaParser method newExpression.
// $ANTLR start "newExpression"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1128:1: newExpression : NEW ( primitiveType newArrayConstruction -> ^( STATIC_ARRAY_CREATOR[$NEW, \"STATIC_ARRAY_CREATOR\"] primitiveType newArrayConstruction ) | ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified ( newArrayConstruction -> ^( STATIC_ARRAY_CREATOR[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified newArrayConstruction ) | arguments ( classBody )? -> ^( CLASS_CONSTRUCTOR_CALL[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified arguments ( classBody )? ) ) ) ;
public final JavaParser.newExpression_return newExpression() throws RecognitionException {
JavaParser.newExpression_return retval = new JavaParser.newExpression_return();
retval.start = input.LT(1);
int newExpression_StartIndex = input.index();
CommonTree root_0 = null;
Token NEW509 = null;
JavaParser.primitiveType_return primitiveType510 = null;
JavaParser.newArrayConstruction_return newArrayConstruction511 = null;
JavaParser.genericTypeArgumentListSimplified_return genericTypeArgumentListSimplified512 = null;
JavaParser.qualifiedTypeIdentSimplified_return qualifiedTypeIdentSimplified513 = null;
JavaParser.newArrayConstruction_return newArrayConstruction514 = null;
JavaParser.arguments_return arguments515 = null;
JavaParser.classBody_return classBody516 = null;
CommonTree NEW509_tree = null;
RewriteRuleTokenStream stream_NEW = new RewriteRuleTokenStream(adaptor, "token NEW");
RewriteRuleSubtreeStream stream_newArrayConstruction = new RewriteRuleSubtreeStream(adaptor, "rule newArrayConstruction");
RewriteRuleSubtreeStream stream_arguments = new RewriteRuleSubtreeStream(adaptor, "rule arguments");
RewriteRuleSubtreeStream stream_qualifiedTypeIdentSimplified = new RewriteRuleSubtreeStream(adaptor, "rule qualifiedTypeIdentSimplified");
RewriteRuleSubtreeStream stream_primitiveType = new RewriteRuleSubtreeStream(adaptor, "rule primitiveType");
RewriteRuleSubtreeStream stream_classBody = new RewriteRuleSubtreeStream(adaptor, "rule classBody");
RewriteRuleSubtreeStream stream_genericTypeArgumentListSimplified = new RewriteRuleSubtreeStream(adaptor, "rule genericTypeArgumentListSimplified");
try {
if (state.backtracking > 0 && alreadyParsedRule(input, 107)) {
return retval;
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1129:5: ( NEW ( primitiveType newArrayConstruction -> ^( STATIC_ARRAY_CREATOR[$NEW, \"STATIC_ARRAY_CREATOR\"] primitiveType newArrayConstruction ) | ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified ( newArrayConstruction -> ^( STATIC_ARRAY_CREATOR[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified newArrayConstruction ) | arguments ( classBody )? -> ^( CLASS_CONSTRUCTOR_CALL[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified arguments ( classBody )? ) ) ) )
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1129:9: NEW ( primitiveType newArrayConstruction -> ^( STATIC_ARRAY_CREATOR[$NEW, \"STATIC_ARRAY_CREATOR\"] primitiveType newArrayConstruction ) | ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified ( newArrayConstruction -> ^( STATIC_ARRAY_CREATOR[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified newArrayConstruction ) | arguments ( classBody )? -> ^( CLASS_CONSTRUCTOR_CALL[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified arguments ( classBody )? ) ) )
{
NEW509 = (Token) match(input, NEW, FOLLOW_NEW_in_newExpression14040);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_NEW.add(NEW509);
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1130:9: ( primitiveType newArrayConstruction -> ^( STATIC_ARRAY_CREATOR[$NEW, \"STATIC_ARRAY_CREATOR\"] primitiveType newArrayConstruction ) | ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified ( newArrayConstruction -> ^( STATIC_ARRAY_CREATOR[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified newArrayConstruction ) | arguments ( classBody )? -> ^( CLASS_CONSTRUCTOR_CALL[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified arguments ( classBody )? ) ) )
int alt148 = 2;
int LA148_0 = input.LA(1);
if ((LA148_0 == BOOLEAN || LA148_0 == BYTE || LA148_0 == CHAR || LA148_0 == DOUBLE || LA148_0 == FLOAT || (LA148_0 >= INT && LA148_0 <= LONG) || LA148_0 == SHORT)) {
alt148 = 1;
} else if ((LA148_0 == LESS_THAN || LA148_0 == IDENT)) {
alt148 = 2;
} else {
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
NoViableAltException nvae = new NoViableAltException("", 148, 0, input);
throw nvae;
}
switch(alt148) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1130:13: primitiveType newArrayConstruction
{
pushFollow(FOLLOW_primitiveType_in_newExpression14054);
primitiveType510 = primitiveType();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_primitiveType.add(primitiveType510.getTree());
}
pushFollow(FOLLOW_newArrayConstruction_in_newExpression14056);
newArrayConstruction511 = newArrayConstruction();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_newArrayConstruction.add(newArrayConstruction511.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();
// 1131:13: -> ^( STATIC_ARRAY_CREATOR[$NEW, \"STATIC_ARRAY_CREATOR\"] primitiveType newArrayConstruction )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1131:17: ^( STATIC_ARRAY_CREATOR[$NEW, \"STATIC_ARRAY_CREATOR\"] primitiveType newArrayConstruction )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(STATIC_ARRAY_CREATOR, NEW509, "STATIC_ARRAY_CREATOR"), root_1);
adaptor.addChild(root_1, stream_primitiveType.nextTree());
adaptor.addChild(root_1, stream_newArrayConstruction.nextTree());
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
}
break;
case 2:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1132:13: ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified ( newArrayConstruction -> ^( STATIC_ARRAY_CREATOR[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified newArrayConstruction ) | arguments ( classBody )? -> ^( CLASS_CONSTRUCTOR_CALL[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified arguments ( classBody )? ) )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1132:13: ( genericTypeArgumentListSimplified )?
int alt145 = 2;
int LA145_0 = input.LA(1);
if ((LA145_0 == LESS_THAN)) {
alt145 = 1;
}
switch(alt145) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: genericTypeArgumentListSimplified
{
pushFollow(FOLLOW_genericTypeArgumentListSimplified_in_newExpression14100);
genericTypeArgumentListSimplified512 = genericTypeArgumentListSimplified();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_genericTypeArgumentListSimplified.add(genericTypeArgumentListSimplified512.getTree());
}
}
break;
}
pushFollow(FOLLOW_qualifiedTypeIdentSimplified_in_newExpression14103);
qualifiedTypeIdentSimplified513 = qualifiedTypeIdentSimplified();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_qualifiedTypeIdentSimplified.add(qualifiedTypeIdentSimplified513.getTree());
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1133:13: ( newArrayConstruction -> ^( STATIC_ARRAY_CREATOR[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified newArrayConstruction ) | arguments ( classBody )? -> ^( CLASS_CONSTRUCTOR_CALL[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified arguments ( classBody )? ) )
int alt147 = 2;
int LA147_0 = input.LA(1);
if ((LA147_0 == LBRACK)) {
alt147 = 1;
} else if ((LA147_0 == LPAREN)) {
alt147 = 2;
} else {
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
NoViableAltException nvae = new NoViableAltException("", 147, 0, input);
throw nvae;
}
switch(alt147) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1133:17: newArrayConstruction
{
pushFollow(FOLLOW_newArrayConstruction_in_newExpression14121);
newArrayConstruction514 = newArrayConstruction();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_newArrayConstruction.add(newArrayConstruction514.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();
// 1134:17: -> ^( STATIC_ARRAY_CREATOR[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified newArrayConstruction )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1134:21: ^( STATIC_ARRAY_CREATOR[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified newArrayConstruction )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(STATIC_ARRAY_CREATOR, NEW509, "STATIC_ARRAY_CREATOR"), root_1);
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1134:74: ( genericTypeArgumentListSimplified )?
if (stream_genericTypeArgumentListSimplified.hasNext()) {
adaptor.addChild(root_1, stream_genericTypeArgumentListSimplified.nextTree());
}
stream_genericTypeArgumentListSimplified.reset();
adaptor.addChild(root_1, stream_qualifiedTypeIdentSimplified.nextTree());
adaptor.addChild(root_1, stream_newArrayConstruction.nextTree());
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
}
break;
case 2:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1135:17: arguments ( classBody )?
{
pushFollow(FOLLOW_arguments_in_newExpression14186);
arguments515 = arguments();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_arguments.add(arguments515.getTree());
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1135:27: ( classBody )?
int alt146 = 2;
int LA146_0 = input.LA(1);
if ((LA146_0 == LCURLY)) {
alt146 = 1;
}
switch(alt146) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: classBody
{
pushFollow(FOLLOW_classBody_in_newExpression14188);
classBody516 = classBody();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_classBody.add(classBody516.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();
// 1136:17: -> ^( CLASS_CONSTRUCTOR_CALL[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified arguments ( classBody )? )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1136:21: ^( CLASS_CONSTRUCTOR_CALL[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? qualifiedTypeIdentSimplified arguments ( classBody )? )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(CLASS_CONSTRUCTOR_CALL, NEW509, "STATIC_ARRAY_CREATOR"), root_1);
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1136:76: ( genericTypeArgumentListSimplified )?
if (stream_genericTypeArgumentListSimplified.hasNext()) {
adaptor.addChild(root_1, stream_genericTypeArgumentListSimplified.nextTree());
}
stream_genericTypeArgumentListSimplified.reset();
adaptor.addChild(root_1, stream_qualifiedTypeIdentSimplified.nextTree());
adaptor.addChild(root_1, stream_arguments.nextTree());
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1136:150: ( classBody )?
if (stream_classBody.hasNext()) {
adaptor.addChild(root_1, stream_classBody.nextTree());
}
stream_classBody.reset();
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
}
break;
}
}
break;
}
}
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, 107, newExpression_StartIndex);
}
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.
the class JavaParser method parenthesizedExpression.
// $ANTLR start "parenthesizedExpression"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:920:1: parenthesizedExpression : LPAREN expression RPAREN -> ^( PARENTESIZED_EXPR[$LPAREN, \"PARENTESIZED_EXPR\"] expression ) ;
public final JavaParser.parenthesizedExpression_return parenthesizedExpression() throws RecognitionException {
JavaParser.parenthesizedExpression_return retval = new JavaParser.parenthesizedExpression_return();
retval.start = input.LT(1);
int parenthesizedExpression_StartIndex = input.index();
CommonTree root_0 = null;
Token LPAREN359 = null;
Token RPAREN361 = null;
JavaParser.expression_return expression360 = null;
CommonTree LPAREN359_tree = null;
CommonTree RPAREN361_tree = null;
RewriteRuleTokenStream stream_RPAREN = new RewriteRuleTokenStream(adaptor, "token RPAREN");
RewriteRuleTokenStream stream_LPAREN = new RewriteRuleTokenStream(adaptor, "token LPAREN");
RewriteRuleSubtreeStream stream_expression = new RewriteRuleSubtreeStream(adaptor, "rule expression");
try {
if (state.backtracking > 0 && alreadyParsedRule(input, 86)) {
return retval;
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:921:5: ( LPAREN expression RPAREN -> ^( PARENTESIZED_EXPR[$LPAREN, \"PARENTESIZED_EXPR\"] expression ) )
// /home/langera/dev/freud/trunk/src/grammar/Java.g:921:9: LPAREN expression RPAREN
{
LPAREN359 = (Token) match(input, LPAREN, FOLLOW_LPAREN_in_parenthesizedExpression10148);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_LPAREN.add(LPAREN359);
}
pushFollow(FOLLOW_expression_in_parenthesizedExpression10150);
expression360 = expression();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_expression.add(expression360.getTree());
}
RPAREN361 = (Token) match(input, RPAREN, FOLLOW_RPAREN_in_parenthesizedExpression10152);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_RPAREN.add(RPAREN361);
}
// 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();
// 922:9: -> ^( PARENTESIZED_EXPR[$LPAREN, \"PARENTESIZED_EXPR\"] expression )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:922:13: ^( PARENTESIZED_EXPR[$LPAREN, \"PARENTESIZED_EXPR\"] expression )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(PARENTESIZED_EXPR, LPAREN359, "PARENTESIZED_EXPR"), root_1);
adaptor.addChild(root_1, stream_expression.nextTree());
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, 86, parenthesizedExpression_StartIndex);
}
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.
the class JavaParser method unaryExpressionRest.
// $ANTLR start "unaryExpressionRest"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1037:1: unaryExpressionRest : ( NOT unaryExpressionAll -> ^( NOT unaryExpressionAll ) | LOGICAL_NOT unaryExpressionAll -> ^( LOGICAL_NOT unaryExpressionAll ) | LPAREN simpleType RPAREN unaryExpressionAll -> ^( CAST_EXPR[$LPAREN, \"CAST_EXPR\"] simpleType unaryExpressionAll ) | LPAREN objectType RPAREN unaryExpressionRest -> ^( CAST_EXPR[$LPAREN, \"CAST_EXPR\"] objectType unaryExpressionRest ) | postfixedExpression );
public final JavaParser.unaryExpressionRest_return unaryExpressionRest() throws RecognitionException {
JavaParser.unaryExpressionRest_return retval = new JavaParser.unaryExpressionRest_return();
retval.start = input.LT(1);
int unaryExpressionRest_StartIndex = input.index();
CommonTree root_0 = null;
Token NOT436 = null;
Token LOGICAL_NOT438 = null;
Token LPAREN440 = null;
Token RPAREN442 = null;
Token LPAREN444 = null;
Token RPAREN446 = null;
JavaParser.unaryExpressionAll_return unaryExpressionAll437 = null;
JavaParser.unaryExpressionAll_return unaryExpressionAll439 = null;
JavaParser.simpleType_return simpleType441 = null;
JavaParser.unaryExpressionAll_return unaryExpressionAll443 = null;
JavaParser.objectType_return objectType445 = null;
JavaParser.unaryExpressionRest_return unaryExpressionRest447 = null;
JavaParser.postfixedExpression_return postfixedExpression448 = null;
CommonTree NOT436_tree = null;
CommonTree LOGICAL_NOT438_tree = null;
CommonTree LPAREN440_tree = null;
CommonTree RPAREN442_tree = null;
CommonTree LPAREN444_tree = null;
CommonTree RPAREN446_tree = null;
RewriteRuleTokenStream stream_RPAREN = new RewriteRuleTokenStream(adaptor, "token RPAREN");
RewriteRuleTokenStream stream_LOGICAL_NOT = new RewriteRuleTokenStream(adaptor, "token LOGICAL_NOT");
RewriteRuleTokenStream stream_NOT = new RewriteRuleTokenStream(adaptor, "token NOT");
RewriteRuleTokenStream stream_LPAREN = new RewriteRuleTokenStream(adaptor, "token LPAREN");
RewriteRuleSubtreeStream stream_simpleType = new RewriteRuleSubtreeStream(adaptor, "rule simpleType");
RewriteRuleSubtreeStream stream_unaryExpressionRest = new RewriteRuleSubtreeStream(adaptor, "rule unaryExpressionRest");
RewriteRuleSubtreeStream stream_objectType = new RewriteRuleSubtreeStream(adaptor, "rule objectType");
RewriteRuleSubtreeStream stream_unaryExpressionAll = new RewriteRuleSubtreeStream(adaptor, "rule unaryExpressionAll");
try {
if (state.backtracking > 0 && alreadyParsedRule(input, 103)) {
return retval;
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1038:5: ( NOT unaryExpressionAll -> ^( NOT unaryExpressionAll ) | LOGICAL_NOT unaryExpressionAll -> ^( LOGICAL_NOT unaryExpressionAll ) | LPAREN simpleType RPAREN unaryExpressionAll -> ^( CAST_EXPR[$LPAREN, \"CAST_EXPR\"] simpleType unaryExpressionAll ) | LPAREN objectType RPAREN unaryExpressionRest -> ^( CAST_EXPR[$LPAREN, \"CAST_EXPR\"] objectType unaryExpressionRest ) | postfixedExpression )
int alt128 = 5;
alt128 = dfa128.predict(input);
switch(alt128) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1038:9: NOT unaryExpressionAll
{
NOT436 = (Token) match(input, NOT, FOLLOW_NOT_in_unaryExpressionRest11393);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_NOT.add(NOT436);
}
pushFollow(FOLLOW_unaryExpressionAll_in_unaryExpressionRest11395);
unaryExpressionAll437 = unaryExpressionAll();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_unaryExpressionAll.add(unaryExpressionAll437.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();
// 1038:57: -> ^( NOT unaryExpressionAll )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1038:61: ^( NOT unaryExpressionAll )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot(stream_NOT.nextNode(), root_1);
adaptor.addChild(root_1, stream_unaryExpressionAll.nextTree());
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
}
break;
case 2:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1039:9: LOGICAL_NOT unaryExpressionAll
{
LOGICAL_NOT438 = (Token) match(input, LOGICAL_NOT, FOLLOW_LOGICAL_NOT_in_unaryExpressionRest11439);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_LOGICAL_NOT.add(LOGICAL_NOT438);
}
pushFollow(FOLLOW_unaryExpressionAll_in_unaryExpressionRest11441);
unaryExpressionAll439 = unaryExpressionAll();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_unaryExpressionAll.add(unaryExpressionAll439.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();
// 1039:57: -> ^( LOGICAL_NOT unaryExpressionAll )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1039:61: ^( LOGICAL_NOT unaryExpressionAll )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot(stream_LOGICAL_NOT.nextNode(), root_1);
adaptor.addChild(root_1, stream_unaryExpressionAll.nextTree());
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
}
break;
case 3:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1040:9: LPAREN simpleType RPAREN unaryExpressionAll
{
LPAREN440 = (Token) match(input, LPAREN, FOLLOW_LPAREN_in_unaryExpressionRest11477);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_LPAREN.add(LPAREN440);
}
pushFollow(FOLLOW_simpleType_in_unaryExpressionRest11479);
simpleType441 = simpleType();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_simpleType.add(simpleType441.getTree());
}
RPAREN442 = (Token) match(input, RPAREN, FOLLOW_RPAREN_in_unaryExpressionRest11481);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_RPAREN.add(RPAREN442);
}
pushFollow(FOLLOW_unaryExpressionAll_in_unaryExpressionRest11483);
unaryExpressionAll443 = unaryExpressionAll();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_unaryExpressionAll.add(unaryExpressionAll443.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();
// 1040:57: -> ^( CAST_EXPR[$LPAREN, \"CAST_EXPR\"] simpleType unaryExpressionAll )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1040:61: ^( CAST_EXPR[$LPAREN, \"CAST_EXPR\"] simpleType unaryExpressionAll )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(CAST_EXPR, LPAREN440, "CAST_EXPR"), root_1);
adaptor.addChild(root_1, stream_simpleType.nextTree());
adaptor.addChild(root_1, stream_unaryExpressionAll.nextTree());
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
}
break;
case 4:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1041:9: LPAREN objectType RPAREN unaryExpressionRest
{
LPAREN444 = (Token) match(input, LPAREN, FOLLOW_LPAREN_in_unaryExpressionRest11509);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_LPAREN.add(LPAREN444);
}
pushFollow(FOLLOW_objectType_in_unaryExpressionRest11511);
objectType445 = objectType();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_objectType.add(objectType445.getTree());
}
RPAREN446 = (Token) match(input, RPAREN, FOLLOW_RPAREN_in_unaryExpressionRest11513);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_RPAREN.add(RPAREN446);
}
pushFollow(FOLLOW_unaryExpressionRest_in_unaryExpressionRest11515);
unaryExpressionRest447 = unaryExpressionRest();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_unaryExpressionRest.add(unaryExpressionRest447.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();
// 1041:57: -> ^( CAST_EXPR[$LPAREN, \"CAST_EXPR\"] objectType unaryExpressionRest )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1041:61: ^( CAST_EXPR[$LPAREN, \"CAST_EXPR\"] objectType unaryExpressionRest )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(CAST_EXPR, LPAREN444, "CAST_EXPR"), root_1);
adaptor.addChild(root_1, stream_objectType.nextTree());
adaptor.addChild(root_1, stream_unaryExpressionRest.nextTree());
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
}
break;
case 5:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1042:9: postfixedExpression
{
root_0 = (CommonTree) adaptor.nil();
pushFollow(FOLLOW_postfixedExpression_in_unaryExpressionRest11540);
postfixedExpression448 = postfixedExpression();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
adaptor.addChild(root_0, postfixedExpression448.getTree());
}
}
break;
}
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, 103, unaryExpressionRest_StartIndex);
}
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.
the class JavaParser method enumTypeDeclaration.
// $ANTLR start "enumTypeDeclaration"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:489:1: enumTypeDeclaration[CommonTree modifiers] : ENUM IDENT ( implementsClause )? enumBody -> ^( ENUM IDENT ( implementsClause )? enumBody ) ;
public final JavaParser.enumTypeDeclaration_return enumTypeDeclaration(CommonTree modifiers) throws RecognitionException {
JavaParser.enumTypeDeclaration_return retval = new JavaParser.enumTypeDeclaration_return();
retval.start = input.LT(1);
int enumTypeDeclaration_StartIndex = input.index();
CommonTree root_0 = null;
Token ENUM47 = null;
Token IDENT48 = null;
JavaParser.implementsClause_return implementsClause49 = null;
JavaParser.enumBody_return enumBody50 = null;
CommonTree ENUM47_tree = null;
CommonTree IDENT48_tree = null;
RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
RewriteRuleTokenStream stream_ENUM = new RewriteRuleTokenStream(adaptor, "token ENUM");
RewriteRuleSubtreeStream stream_implementsClause = new RewriteRuleSubtreeStream(adaptor, "rule implementsClause");
RewriteRuleSubtreeStream stream_enumBody = new RewriteRuleSubtreeStream(adaptor, "rule enumBody");
try {
if (state.backtracking > 0 && alreadyParsedRule(input, 15)) {
return retval;
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:490:5: ( ENUM IDENT ( implementsClause )? enumBody -> ^( ENUM IDENT ( implementsClause )? enumBody ) )
// /home/langera/dev/freud/trunk/src/grammar/Java.g:490:9: ENUM IDENT ( implementsClause )? enumBody
{
ENUM47 = (Token) match(input, ENUM, FOLLOW_ENUM_in_enumTypeDeclaration5196);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_ENUM.add(ENUM47);
}
IDENT48 = (Token) match(input, IDENT, FOLLOW_IDENT_in_enumTypeDeclaration5198);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_IDENT.add(IDENT48);
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:490:20: ( implementsClause )?
int alt15 = 2;
int LA15_0 = input.LA(1);
if ((LA15_0 == IMPLEMENTS)) {
alt15 = 1;
}
switch(alt15) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: implementsClause
{
pushFollow(FOLLOW_implementsClause_in_enumTypeDeclaration5200);
implementsClause49 = implementsClause();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_implementsClause.add(implementsClause49.getTree());
}
}
break;
}
pushFollow(FOLLOW_enumBody_in_enumTypeDeclaration5203);
enumBody50 = enumBody();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_enumBody.add(enumBody50.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();
// 491:9: -> ^( ENUM IDENT ( implementsClause )? enumBody )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:491:13: ^( ENUM IDENT ( implementsClause )? enumBody )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot(stream_ENUM.nextNode(), root_1);
adaptor.addChild(root_1, modifiers);
adaptor.addChild(root_1, stream_IDENT.nextNode());
// /home/langera/dev/freud/trunk/src/grammar/Java.g:491:39: ( implementsClause )?
if (stream_implementsClause.hasNext()) {
adaptor.addChild(root_1, stream_implementsClause.nextTree());
}
stream_implementsClause.reset();
adaptor.addChild(root_1, stream_enumBody.nextTree());
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, 15, enumTypeDeclaration_StartIndex);
}
}
return retval;
}
Aggregations