use of org.antlr.runtime.ParserRuleReturnScope in project drools by kiegroup.
the class DSLMapParser method statement.
// $ANTLR start "statement"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:111:1: statement : ( entry | EOL !);
public final DSLMapParser.statement_return statement() throws RecognitionException {
DSLMapParser.statement_return retval = new DSLMapParser.statement_return();
retval.start = input.LT(1);
Object root_0 = null;
Token EOL3 = null;
ParserRuleReturnScope entry2 = null;
Object EOL3_tree = null;
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:112:5: ( entry | EOL !)
int alt2 = 2;
int LA2_0 = input.LA(1);
if ((LA2_0 == LEFT_SQUARE)) {
alt2 = 1;
} else if ((LA2_0 == EOL)) {
alt2 = 2;
} else {
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
NoViableAltException nvae = new NoViableAltException("", 2, 0, input);
throw nvae;
}
switch(alt2) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:112:7: entry
{
root_0 = (Object) adaptor.nil();
pushFollow(FOLLOW_entry_in_statement306);
entry2 = entry();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
adaptor.addChild(root_0, entry2.getTree());
}
break;
case 2:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:113:7: EOL !
{
root_0 = (Object) adaptor.nil();
EOL3 = (Token) match(input, EOL, FOLLOW_EOL_in_statement314);
if (state.failed)
return retval;
}
break;
}
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.ParserRuleReturnScope in project drools by kiegroup.
the class DSLMapParser method key_sentence.
// $ANTLR start "key_sentence"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:154:1: key_sentence : ( variable_definition |cb= key_chunk -> VT_LITERAL[$cb.start, text] );
public final DSLMapParser.key_sentence_return key_sentence() throws RecognitionException {
DSLMapParser.key_sentence_return retval = new DSLMapParser.key_sentence_return();
retval.start = input.LT(1);
Object root_0 = null;
ParserRuleReturnScope cb = null;
ParserRuleReturnScope variable_definition16 = null;
RewriteRuleSubtreeStream stream_key_chunk = new RewriteRuleSubtreeStream(adaptor, "rule key_chunk");
String text = "";
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:158:5: ( variable_definition |cb= key_chunk -> VT_LITERAL[$cb.start, text] )
int alt9 = 2;
int LA9_0 = input.LA(1);
if ((LA9_0 == LEFT_CURLY)) {
alt9 = 1;
} else if ((LA9_0 == COLON || (LA9_0 >= LEFT_SQUARE && LA9_0 <= LITERAL) || LA9_0 == RIGHT_SQUARE)) {
alt9 = 2;
} else {
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
NoViableAltException nvae = new NoViableAltException("", 9, 0, input);
throw nvae;
}
switch(alt9) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:158:7: variable_definition
{
root_0 = (Object) adaptor.nil();
pushFollow(FOLLOW_variable_definition_in_key_sentence608);
variable_definition16 = variable_definition();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
adaptor.addChild(root_0, variable_definition16.getTree());
}
break;
case 2:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:159:7: cb= key_chunk
{
pushFollow(FOLLOW_key_chunk_in_key_sentence618);
cb = key_chunk();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_key_chunk.add(cb.getTree());
if (state.backtracking == 0) {
text = (cb != null ? input.toString(cb.start, cb.stop) : null);
}
// 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();
// 160:5: -> VT_LITERAL[$cb.start, text]
{
adaptor.addChild(root_0, (Object) adaptor.create(VT_LITERAL, (cb != null ? (cb.start) : null), text));
}
retval.tree = root_0;
}
}
break;
}
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.ParserRuleReturnScope in project drools by kiegroup.
the class DSLMapParser method key_chunk.
// $ANTLR start "key_chunk"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:163:1: key_chunk : ( literal )+ ;
public final DSLMapParser.key_chunk_return key_chunk() throws RecognitionException {
DSLMapParser.key_chunk_return retval = new DSLMapParser.key_chunk_return();
retval.start = input.LT(1);
Object root_0 = null;
ParserRuleReturnScope literal17 = null;
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:164:5: ( ( literal )+ )
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:164:7: ( literal )+
{
root_0 = (Object) adaptor.nil();
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:164:7: ( literal )+
int cnt10 = 0;
loop10: while (true) {
int alt10 = 2;
int LA10_0 = input.LA(1);
if ((LA10_0 == COLON || (LA10_0 >= LEFT_SQUARE && LA10_0 <= LITERAL) || LA10_0 == RIGHT_SQUARE)) {
int LA10_2 = input.LA(2);
if ((synpred12_DSLMap())) {
alt10 = 1;
}
}
switch(alt10) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:164:7: literal
{
pushFollow(FOLLOW_literal_in_key_chunk646);
literal17 = literal();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
adaptor.addChild(root_0, literal17.getTree());
}
break;
default:
if (cnt10 >= 1)
break loop10;
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
EarlyExitException eee = new EarlyExitException(10, input);
throw eee;
}
cnt10++;
}
}
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.ParserRuleReturnScope 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.ParserRuleReturnScope in project drools by kiegroup.
the class DSLMapParser method value_chunk.
// $ANTLR start "value_chunk"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:181:1: value_chunk : ( literal | EQUALS | COMMA | DOT )+ ;
public final DSLMapParser.value_chunk_return value_chunk() throws RecognitionException {
DSLMapParser.value_chunk_return retval = new DSLMapParser.value_chunk_return();
retval.start = input.LT(1);
Object root_0 = null;
Token EQUALS21 = null;
Token COMMA22 = null;
Token DOT23 = null;
ParserRuleReturnScope literal20 = null;
Object EQUALS21_tree = null;
Object COMMA22_tree = null;
Object DOT23_tree = null;
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:182:5: ( ( literal | EQUALS | COMMA | DOT )+ )
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:182:7: ( literal | EQUALS | COMMA | DOT )+
{
root_0 = (Object) adaptor.nil();
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:182:7: ( literal | EQUALS | COMMA | DOT )+
int cnt13 = 0;
loop13: while (true) {
int alt13 = 5;
switch(input.LA(1)) {
case COLON:
case LEFT_SQUARE:
case LITERAL:
case RIGHT_SQUARE:
{
int LA13_2 = input.LA(2);
if ((synpred15_DSLMap())) {
alt13 = 1;
}
}
break;
case EQUALS:
{
int LA13_3 = input.LA(2);
if ((synpred16_DSLMap())) {
alt13 = 2;
}
}
break;
case COMMA:
{
int LA13_4 = input.LA(2);
if ((synpred17_DSLMap())) {
alt13 = 3;
}
}
break;
case DOT:
{
int LA13_5 = input.LA(2);
if ((synpred18_DSLMap())) {
alt13 = 4;
}
}
break;
}
switch(alt13) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:182:8: literal
{
pushFollow(FOLLOW_literal_in_value_chunk742);
literal20 = literal();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
adaptor.addChild(root_0, literal20.getTree());
}
break;
case 2:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:182:16: EQUALS
{
EQUALS21 = (Token) match(input, EQUALS, FOLLOW_EQUALS_in_value_chunk744);
if (state.failed)
return retval;
if (state.backtracking == 0) {
EQUALS21_tree = (Object) adaptor.create(EQUALS21);
adaptor.addChild(root_0, EQUALS21_tree);
}
}
break;
case 3:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:182:23: COMMA
{
COMMA22 = (Token) match(input, COMMA, FOLLOW_COMMA_in_value_chunk746);
if (state.failed)
return retval;
if (state.backtracking == 0) {
COMMA22_tree = (Object) adaptor.create(COMMA22);
adaptor.addChild(root_0, COMMA22_tree);
}
}
break;
case 4:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:182:29: DOT
{
DOT23 = (Token) match(input, DOT, FOLLOW_DOT_in_value_chunk748);
if (state.failed)
return retval;
if (state.backtracking == 0) {
DOT23_tree = (Object) adaptor.create(DOT23);
adaptor.addChild(root_0, DOT23_tree);
}
}
break;
default:
if (cnt13 >= 1)
break loop13;
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
EarlyExitException eee = new EarlyExitException(13, input);
throw eee;
}
cnt13++;
}
}
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