use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.
the class CssParser method attribRelate.
// $ANTLR start "attribRelate"
// /home/langera/dev/freud/src/grammar/Css.g:97:1: attribRelate : ( '=' -> ATTRIBEQUAL | '~=' -> HASVALUE | '|=' -> BEGINSWITH );
public final CssParser.attribRelate_return attribRelate() throws RecognitionException {
CssParser.attribRelate_return retval = new CssParser.attribRelate_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token char_literal51 = null;
Token string_literal52 = null;
Token string_literal53 = null;
CommonTree char_literal51_tree = null;
CommonTree string_literal52_tree = null;
CommonTree string_literal53_tree = null;
RewriteRuleTokenStream stream_43 = new RewriteRuleTokenStream(adaptor, "token 43");
RewriteRuleTokenStream stream_44 = new RewriteRuleTokenStream(adaptor, "token 44");
RewriteRuleTokenStream stream_42 = new RewriteRuleTokenStream(adaptor, "token 42");
try {
// /home/langera/dev/freud/src/grammar/Css.g:98:2: ( '=' -> ATTRIBEQUAL | '~=' -> HASVALUE | '|=' -> BEGINSWITH )
int alt22 = 3;
switch(input.LA(1)) {
case 42:
{
alt22 = 1;
}
break;
case 43:
{
alt22 = 2;
}
break;
case 44:
{
alt22 = 3;
}
break;
default:
NoViableAltException nvae = new NoViableAltException("", 22, 0, input);
throw nvae;
}
switch(alt22) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:98:4: '='
{
char_literal51 = (Token) match(input, 42, FOLLOW_42_in_attribRelate581);
stream_42.add(char_literal51);
// AST REWRITE
// elements:
// 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();
// 98:9: -> ATTRIBEQUAL
{
adaptor.addChild(root_0, (CommonTree) adaptor.create(ATTRIBEQUAL, "ATTRIBEQUAL"));
}
retval.tree = root_0;
}
break;
case 2:
// /home/langera/dev/freud/src/grammar/Css.g:99:4: '~='
{
string_literal52 = (Token) match(input, 43, FOLLOW_43_in_attribRelate591);
stream_43.add(string_literal52);
// AST REWRITE
// elements:
// 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();
// 99:9: -> HASVALUE
{
adaptor.addChild(root_0, (CommonTree) adaptor.create(HASVALUE, "HASVALUE"));
}
retval.tree = root_0;
}
break;
case 3:
// /home/langera/dev/freud/src/grammar/Css.g:100:4: '|='
{
string_literal53 = (Token) match(input, 44, FOLLOW_44_in_attribRelate600);
stream_44.add(string_literal53);
// AST REWRITE
// elements:
// 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();
// 100:9: -> BEGINSWITH
{
adaptor.addChild(root_0, (CommonTree) adaptor.create(BEGINSWITH, "BEGINSWITH"));
}
retval.tree = root_0;
}
break;
}
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;
}
use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.
the class JavaParser method implementsClause.
// $ANTLR start "implementsClause"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:459:1: implementsClause : IMPLEMENTS typeList -> ^( IMPLEMENTS_CLAUSE[$IMPLEMENTS, \"IMPLEMENTS_CLAUSE\"] typeList ) ;
public final JavaParser.implementsClause_return implementsClause() throws RecognitionException {
JavaParser.implementsClause_return retval = new JavaParser.implementsClause_return();
retval.start = input.LT(1);
int implementsClause_StartIndex = input.index();
CommonTree root_0 = null;
Token IMPLEMENTS31 = null;
JavaParser.typeList_return typeList32 = null;
CommonTree IMPLEMENTS31_tree = null;
RewriteRuleTokenStream stream_IMPLEMENTS = new RewriteRuleTokenStream(adaptor, "token IMPLEMENTS");
RewriteRuleSubtreeStream stream_typeList = new RewriteRuleSubtreeStream(adaptor, "rule typeList");
try {
if (state.backtracking > 0 && alreadyParsedRule(input, 10)) {
return retval;
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:460:5: ( IMPLEMENTS typeList -> ^( IMPLEMENTS_CLAUSE[$IMPLEMENTS, \"IMPLEMENTS_CLAUSE\"] typeList ) )
// /home/langera/dev/freud/trunk/src/grammar/Java.g:460:9: IMPLEMENTS typeList
{
IMPLEMENTS31 = (Token) match(input, IMPLEMENTS, FOLLOW_IMPLEMENTS_in_implementsClause4895);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_IMPLEMENTS.add(IMPLEMENTS31);
}
pushFollow(FOLLOW_typeList_in_implementsClause4897);
typeList32 = typeList();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_typeList.add(typeList32.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();
// 461:9: -> ^( IMPLEMENTS_CLAUSE[$IMPLEMENTS, \"IMPLEMENTS_CLAUSE\"] typeList )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:461:13: ^( IMPLEMENTS_CLAUSE[$IMPLEMENTS, \"IMPLEMENTS_CLAUSE\"] typeList )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(IMPLEMENTS_CLAUSE, IMPLEMENTS31, "IMPLEMENTS_CLAUSE"), root_1);
adaptor.addChild(root_1, stream_typeList.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, 10, implementsClause_StartIndex);
}
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.
the class JavaParser method innerNewExpression.
// $ANTLR start "innerNewExpression"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1141:1: innerNewExpression : NEW ( genericTypeArgumentListSimplified )? IDENT arguments ( classBody )? -> ^( CLASS_CONSTRUCTOR_CALL[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? IDENT arguments ( classBody )? ) ;
public final JavaParser.innerNewExpression_return innerNewExpression() throws RecognitionException {
JavaParser.innerNewExpression_return retval = new JavaParser.innerNewExpression_return();
retval.start = input.LT(1);
int innerNewExpression_StartIndex = input.index();
CommonTree root_0 = null;
Token NEW517 = null;
Token IDENT519 = null;
JavaParser.genericTypeArgumentListSimplified_return genericTypeArgumentListSimplified518 = null;
JavaParser.arguments_return arguments520 = null;
JavaParser.classBody_return classBody521 = null;
CommonTree NEW517_tree = null;
CommonTree IDENT519_tree = null;
RewriteRuleTokenStream stream_NEW = new RewriteRuleTokenStream(adaptor, "token NEW");
RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
RewriteRuleSubtreeStream stream_arguments = new RewriteRuleSubtreeStream(adaptor, "rule arguments");
RewriteRuleSubtreeStream stream_classBody = new RewriteRuleSubtreeStream(adaptor, "rule classBody");
RewriteRuleSubtreeStream stream_genericTypeArgumentListSimplified = new RewriteRuleSubtreeStream(adaptor, "rule genericTypeArgumentListSimplified");
try {
if (state.backtracking > 0 && alreadyParsedRule(input, 108)) {
return retval;
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1142:5: ( NEW ( genericTypeArgumentListSimplified )? IDENT arguments ( classBody )? -> ^( CLASS_CONSTRUCTOR_CALL[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? IDENT arguments ( classBody )? ) )
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1142:9: NEW ( genericTypeArgumentListSimplified )? IDENT arguments ( classBody )?
{
NEW517 = (Token) match(input, NEW, FOLLOW_NEW_in_innerNewExpression14283);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_NEW.add(NEW517);
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1142:13: ( genericTypeArgumentListSimplified )?
int alt149 = 2;
int LA149_0 = input.LA(1);
if ((LA149_0 == LESS_THAN)) {
alt149 = 1;
}
switch(alt149) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: genericTypeArgumentListSimplified
{
pushFollow(FOLLOW_genericTypeArgumentListSimplified_in_innerNewExpression14285);
genericTypeArgumentListSimplified518 = genericTypeArgumentListSimplified();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_genericTypeArgumentListSimplified.add(genericTypeArgumentListSimplified518.getTree());
}
}
break;
}
IDENT519 = (Token) match(input, IDENT, FOLLOW_IDENT_in_innerNewExpression14288);
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_IDENT.add(IDENT519);
}
pushFollow(FOLLOW_arguments_in_innerNewExpression14290);
arguments520 = arguments();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_arguments.add(arguments520.getTree());
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1142:64: ( classBody )?
int alt150 = 2;
int LA150_0 = input.LA(1);
if ((LA150_0 == LCURLY)) {
alt150 = 1;
}
switch(alt150) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: classBody
{
pushFollow(FOLLOW_classBody_in_innerNewExpression14292);
classBody521 = classBody();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_classBody.add(classBody521.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();
// 1143:9: -> ^( CLASS_CONSTRUCTOR_CALL[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? IDENT arguments ( classBody )? )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1143:13: ^( CLASS_CONSTRUCTOR_CALL[$NEW, \"STATIC_ARRAY_CREATOR\"] ( genericTypeArgumentListSimplified )? IDENT arguments ( classBody )? )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(CLASS_CONSTRUCTOR_CALL, NEW517, "STATIC_ARRAY_CREATOR"), root_1);
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1143:68: ( genericTypeArgumentListSimplified )?
if (stream_genericTypeArgumentListSimplified.hasNext()) {
adaptor.addChild(root_1, stream_genericTypeArgumentListSimplified.nextTree());
}
stream_genericTypeArgumentListSimplified.reset();
adaptor.addChild(root_1, stream_IDENT.nextNode());
adaptor.addChild(root_1, stream_arguments.nextTree());
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1143:119: ( 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;
}
}
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, 108, innerNewExpression_StartIndex);
}
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleTokenStream 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.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;
}
Aggregations