use of org.antlr.runtime.tree.RewriteRuleTokenStream in project drools by kiegroup.
the class DSLMapParser method any_key.
// $ANTLR start "any_key"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:266:1: any_key :{...}?value= LITERAL -> VT_ANY[$value] ;
public final DSLMapParser.any_key_return any_key() throws RecognitionException {
DSLMapParser.any_key_return retval = new DSLMapParser.any_key_return();
retval.start = input.LT(1);
Object root_0 = null;
Token value = null;
Object value_tree = null;
RewriteRuleTokenStream stream_LITERAL = new RewriteRuleTokenStream(adaptor, "token LITERAL");
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:267:5: ({...}?value= LITERAL -> VT_ANY[$value] )
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:267:7: {...}?value= LITERAL
{
if (!((validateIdentifierKey("*")))) {
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
throw new FailedPredicateException(input, "any_key", "validateIdentifierKey(\"*\")");
}
value = (Token) match(input, LITERAL, FOLLOW_LITERAL_in_any_key1695);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_LITERAL.add(value);
// wildcard labels:
if (state.backtracking == 0) {
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
root_0 = (Object) adaptor.nil();
// 268:5: -> VT_ANY[$value]
{
adaptor.addChild(root_0, (Object) adaptor.create(VT_ANY, value));
}
retval.tree = root_0;
}
}
retval.stop = input.LT(-1);
if (state.backtracking == 0) {
retval.tree = (Object) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
// do for sure before leaving
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleTokenStream in project drools by kiegroup.
the class DSLMapParser method variable_reference.
// $ANTLR start "variable_reference"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:228:1: variable_reference : lc= LEFT_CURLY name= variable_reference_expr rc= RIGHT_CURLY -> { hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) VT_SPACE -> { hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) VT_SPACE -> ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) ;
public final DSLMapParser.variable_reference_return variable_reference() throws RecognitionException {
DSLMapParser.variable_reference_return retval = new DSLMapParser.variable_reference_return();
retval.start = input.LT(1);
Object root_0 = null;
Token lc = null;
Token rc = null;
ParserRuleReturnScope name = null;
Object lc_tree = null;
Object rc_tree = null;
RewriteRuleTokenStream stream_RIGHT_CURLY = new RewriteRuleTokenStream(adaptor, "token RIGHT_CURLY");
RewriteRuleTokenStream stream_LEFT_CURLY = new RewriteRuleTokenStream(adaptor, "token LEFT_CURLY");
RewriteRuleSubtreeStream stream_variable_reference_expr = new RewriteRuleSubtreeStream(adaptor, "rule variable_reference_expr");
boolean hasSpaceBefore = false;
boolean hasSpaceAfter = false;
String text = "";
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:234:5: (lc= LEFT_CURLY name= variable_reference_expr rc= RIGHT_CURLY -> { hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) VT_SPACE -> { hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) VT_SPACE -> ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) )
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:234:7: lc= LEFT_CURLY name= variable_reference_expr rc= RIGHT_CURLY
{
lc = (Token) match(input, LEFT_CURLY, FOLLOW_LEFT_CURLY_in_variable_reference1389);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_LEFT_CURLY.add(lc);
if (state.backtracking == 0) {
CommonToken back2 = (CommonToken) input.LT(-2);
if (back2 != null && back2.getStopIndex() < ((CommonToken) lc).getStartIndex() - 1)
hasSpaceBefore = true;
}
pushFollow(FOLLOW_variable_reference_expr_in_variable_reference1409);
name = variable_reference_expr();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_variable_reference_expr.add(name.getTree());
rc = (Token) match(input, RIGHT_CURLY, FOLLOW_RIGHT_CURLY_in_variable_reference1413);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_RIGHT_CURLY.add(rc);
if (state.backtracking == 0) {
if (((CommonToken) rc).getStopIndex() < ((CommonToken) input.LT(1)).getStartIndex() - 1)
hasSpaceAfter = true;
}
// wildcard labels:
if (state.backtracking == 0) {
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
root_0 = (Object) adaptor.nil();
// 241:5: -> { hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) VT_SPACE
if (hasSpaceBefore && hasSpaceAfter) {
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:241:54: ^( VT_VAR_REF LITERAL[$name.start,$name.text] )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_REF, "VT_VAR_REF"), root_1);
adaptor.addChild(root_1, (Object) adaptor.create(LITERAL, (name != null ? (name.start) : null), (name != null ? input.toString(name.start, name.stop) : null)));
adaptor.addChild(root_0, root_1);
}
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
} else // 242:5: -> { hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF LITERAL[$name.start,$name.text] )
if (hasSpaceBefore && !hasSpaceAfter) {
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:242:54: ^( VT_VAR_REF LITERAL[$name.start,$name.text] )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_REF, "VT_VAR_REF"), root_1);
adaptor.addChild(root_1, (Object) adaptor.create(LITERAL, (name != null ? (name.start) : null), (name != null ? input.toString(name.start, name.stop) : null)));
adaptor.addChild(root_0, root_1);
}
} else // 243:5: -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) VT_SPACE
if (!hasSpaceBefore && hasSpaceAfter) {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:243:54: ^( VT_VAR_REF LITERAL[$name.start,$name.text] )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_REF, "VT_VAR_REF"), root_1);
adaptor.addChild(root_1, (Object) adaptor.create(LITERAL, (name != null ? (name.start) : null), (name != null ? input.toString(name.start, name.stop) : null)));
adaptor.addChild(root_0, root_1);
}
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
} else // 244:5: -> ^( VT_VAR_REF LITERAL[$name.start,$name.text] )
{
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:244:54: ^( VT_VAR_REF LITERAL[$name.start,$name.text] )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_REF, "VT_VAR_REF"), root_1);
adaptor.addChild(root_1, (Object) adaptor.create(LITERAL, (name != null ? (name.start) : null), (name != null ? input.toString(name.start, name.stop) : null)));
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
}
retval.stop = input.LT(-1);
if (state.backtracking == 0) {
retval.tree = (Object) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
// do for sure before leaving
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleTokenStream in project drools by kiegroup.
the class DSLMapParser method condition_key.
// $ANTLR start "condition_key"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:251:1: condition_key :{...}?value= LITERAL -> VT_CONDITION[$value] ;
public final DSLMapParser.condition_key_return condition_key() throws RecognitionException {
DSLMapParser.condition_key_return retval = new DSLMapParser.condition_key_return();
retval.start = input.LT(1);
Object root_0 = null;
Token value = null;
Object value_tree = null;
RewriteRuleTokenStream stream_LITERAL = new RewriteRuleTokenStream(adaptor, "token LITERAL");
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:252:5: ({...}?value= LITERAL -> VT_CONDITION[$value] )
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:252:7: {...}?value= LITERAL
{
if (!((validateIdentifierKey("condition") || validateIdentifierKey("when")))) {
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
throw new FailedPredicateException(input, "condition_key", "validateIdentifierKey(\"condition\")||validateIdentifierKey(\"when\")");
}
value = (Token) match(input, LITERAL, FOLLOW_LITERAL_in_condition_key1599);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_LITERAL.add(value);
// wildcard labels:
if (state.backtracking == 0) {
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
root_0 = (Object) adaptor.nil();
// 253:5: -> VT_CONDITION[$value]
{
adaptor.addChild(root_0, (Object) adaptor.create(VT_CONDITION, value));
}
retval.tree = root_0;
}
}
retval.stop = input.LT(-1);
if (state.backtracking == 0) {
retval.tree = (Object) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
// do for sure before leaving
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleTokenStream in project cuba by cuba-platform.
the class JPA2Parser method orderby_clause.
// $ANTLR start "orderby_clause"
// JPA2.g:208:1: orderby_clause : 'ORDER' 'BY' orderby_item ( ',' orderby_item )* -> ^( T_ORDER_BY[] 'ORDER' 'BY' ( orderby_item )* ) ;
public final JPA2Parser.orderby_clause_return orderby_clause() throws RecognitionException {
JPA2Parser.orderby_clause_return retval = new JPA2Parser.orderby_clause_return();
retval.start = input.LT(1);
Object root_0 = null;
Token string_literal145 = null;
Token string_literal146 = null;
Token char_literal148 = null;
ParserRuleReturnScope orderby_item147 = null;
ParserRuleReturnScope orderby_item149 = null;
Object string_literal145_tree = null;
Object string_literal146_tree = null;
Object char_literal148_tree = null;
RewriteRuleTokenStream stream_66 = new RewriteRuleTokenStream(adaptor, "token 66");
RewriteRuleTokenStream stream_ORDER = new RewriteRuleTokenStream(adaptor, "token ORDER");
RewriteRuleTokenStream stream_BY = new RewriteRuleTokenStream(adaptor, "token BY");
RewriteRuleSubtreeStream stream_orderby_item = new RewriteRuleSubtreeStream(adaptor, "rule orderby_item");
try {
// JPA2.g:209:5: ( 'ORDER' 'BY' orderby_item ( ',' orderby_item )* -> ^( T_ORDER_BY[] 'ORDER' 'BY' ( orderby_item )* ) )
// JPA2.g:209:7: 'ORDER' 'BY' orderby_item ( ',' orderby_item )*
{
string_literal145 = (Token) match(input, ORDER, FOLLOW_ORDER_in_orderby_clause1809);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_ORDER.add(string_literal145);
string_literal146 = (Token) match(input, BY, FOLLOW_BY_in_orderby_clause1811);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_BY.add(string_literal146);
pushFollow(FOLLOW_orderby_item_in_orderby_clause1813);
orderby_item147 = orderby_item();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_orderby_item.add(orderby_item147.getTree());
// JPA2.g:209:33: ( ',' orderby_item )*
loop45: while (true) {
int alt45 = 2;
int LA45_0 = input.LA(1);
if ((LA45_0 == 66)) {
alt45 = 1;
}
switch(alt45) {
case 1:
// JPA2.g:209:34: ',' orderby_item
{
char_literal148 = (Token) match(input, 66, FOLLOW_66_in_orderby_clause1816);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_66.add(char_literal148);
pushFollow(FOLLOW_orderby_item_in_orderby_clause1818);
orderby_item149 = orderby_item();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_orderby_item.add(orderby_item149.getTree());
}
break;
default:
break loop45;
}
}
// wildcard labels:
if (state.backtracking == 0) {
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
root_0 = (Object) adaptor.nil();
// 210:5: -> ^( T_ORDER_BY[] 'ORDER' 'BY' ( orderby_item )* )
{
// JPA2.g:210:8: ^( T_ORDER_BY[] 'ORDER' 'BY' ( orderby_item )* )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot(new OrderByNode(T_ORDER_BY), root_1);
adaptor.addChild(root_1, stream_ORDER.nextNode());
adaptor.addChild(root_1, stream_BY.nextNode());
// JPA2.g:210:49: ( orderby_item )*
while (stream_orderby_item.hasNext()) {
adaptor.addChild(root_1, stream_orderby_item.nextTree());
}
stream_orderby_item.reset();
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
}
retval.stop = input.LT(-1);
if (state.backtracking == 0) {
retval.tree = (Object) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
// do for sure before leaving
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleTokenStream in project cuba by cuba-platform.
the class JPA2Parser method enum_function.
// $ANTLR start "enum_function"
// JPA2.g:482:1: enum_function : '@ENUM' '(' enum_value_literal ')' -> ^( T_ENUM_MACROS[$enum_value_literal.text] ) ;
public final JPA2Parser.enum_function_return enum_function() throws RecognitionException {
JPA2Parser.enum_function_return retval = new JPA2Parser.enum_function_return();
retval.start = input.LT(1);
Object root_0 = null;
Token string_literal571 = null;
Token char_literal572 = null;
Token char_literal574 = null;
ParserRuleReturnScope enum_value_literal573 = null;
Object string_literal571_tree = null;
Object char_literal572_tree = null;
Object char_literal574_tree = null;
RewriteRuleTokenStream stream_LPAREN = new RewriteRuleTokenStream(adaptor, "token LPAREN");
RewriteRuleTokenStream stream_82 = new RewriteRuleTokenStream(adaptor, "token 82");
RewriteRuleTokenStream stream_RPAREN = new RewriteRuleTokenStream(adaptor, "token RPAREN");
RewriteRuleSubtreeStream stream_enum_value_literal = new RewriteRuleSubtreeStream(adaptor, "rule enum_value_literal");
try {
// JPA2.g:483:5: ( '@ENUM' '(' enum_value_literal ')' -> ^( T_ENUM_MACROS[$enum_value_literal.text] ) )
// JPA2.g:483:7: '@ENUM' '(' enum_value_literal ')'
{
string_literal571 = (Token) match(input, 82, FOLLOW_82_in_enum_function4474);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_82.add(string_literal571);
char_literal572 = (Token) match(input, LPAREN, FOLLOW_LPAREN_in_enum_function4476);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_LPAREN.add(char_literal572);
pushFollow(FOLLOW_enum_value_literal_in_enum_function4478);
enum_value_literal573 = enum_value_literal();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_enum_value_literal.add(enum_value_literal573.getTree());
char_literal574 = (Token) match(input, RPAREN, FOLLOW_RPAREN_in_enum_function4480);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_RPAREN.add(char_literal574);
// wildcard labels:
if (state.backtracking == 0) {
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
root_0 = (Object) adaptor.nil();
// 483:42: -> ^( T_ENUM_MACROS[$enum_value_literal.text] )
{
// JPA2.g:483:45: ^( T_ENUM_MACROS[$enum_value_literal.text] )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot(new EnumConditionNode(T_ENUM_MACROS, (enum_value_literal573 != null ? input.toString(enum_value_literal573.start, enum_value_literal573.stop) : null)), root_1);
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
}
retval.stop = input.LT(-1);
if (state.backtracking == 0) {
retval.tree = (Object) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
// do for sure before leaving
}
return retval;
}
Aggregations