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 value_sentence.
// $ANTLR start "value_sentence"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:172:1: value_sentence : ( variable_reference |vc= value_chunk -> VT_LITERAL[$vc.start, text] );
public final DSLMapParser.value_sentence_return value_sentence() throws RecognitionException {
DSLMapParser.value_sentence_return retval = new DSLMapParser.value_sentence_return();
retval.start = input.LT(1);
Object root_0 = null;
ParserRuleReturnScope vc = null;
ParserRuleReturnScope variable_reference19 = null;
RewriteRuleSubtreeStream stream_value_chunk = new RewriteRuleSubtreeStream(adaptor, "rule value_chunk");
String text = "";
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:176:5: ( variable_reference |vc= value_chunk -> VT_LITERAL[$vc.start, text] )
int alt12 = 2;
int LA12_0 = input.LA(1);
if ((LA12_0 == LEFT_CURLY)) {
alt12 = 1;
} else if (((LA12_0 >= COLON && LA12_0 <= DOT) || LA12_0 == EQUALS || (LA12_0 >= LEFT_SQUARE && LA12_0 <= LITERAL) || LA12_0 == RIGHT_SQUARE)) {
alt12 = 2;
} else {
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
NoViableAltException nvae = new NoViableAltException("", 12, 0, input);
throw nvae;
}
switch(alt12) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:176:7: variable_reference
{
root_0 = (Object) adaptor.nil();
pushFollow(FOLLOW_variable_reference_in_value_sentence703);
variable_reference19 = variable_reference();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
adaptor.addChild(root_0, variable_reference19.getTree());
}
break;
case 2:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:177:7: vc= value_chunk
{
pushFollow(FOLLOW_value_chunk_in_value_sentence713);
vc = value_chunk();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_value_chunk.add(vc.getTree());
if (state.backtracking == 0) {
text = (vc != null ? input.toString(vc.start, vc.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();
// 178:5: -> VT_LITERAL[$vc.start, text]
{
adaptor.addChild(root_0, (Object) adaptor.create(VT_LITERAL, (vc != null ? (vc.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 pattern.
// $ANTLR start "pattern"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:219:1: pattern : ( literal | DOT | MISC | LEFT_CURLY literal RIGHT_CURLY | LEFT_SQUARE pattern RIGHT_SQUARE )+ ;
public final DSLMapParser.pattern_return pattern() throws RecognitionException {
DSLMapParser.pattern_return retval = new DSLMapParser.pattern_return();
retval.start = input.LT(1);
Object root_0 = null;
Token DOT28 = null;
Token MISC29 = null;
Token LEFT_CURLY30 = null;
Token RIGHT_CURLY32 = null;
Token LEFT_SQUARE33 = null;
Token RIGHT_SQUARE35 = null;
ParserRuleReturnScope literal27 = null;
ParserRuleReturnScope literal31 = null;
ParserRuleReturnScope pattern34 = null;
Object DOT28_tree = null;
Object MISC29_tree = null;
Object LEFT_CURLY30_tree = null;
Object RIGHT_CURLY32_tree = null;
Object LEFT_SQUARE33_tree = null;
Object RIGHT_SQUARE35_tree = null;
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:220:9: ( ( literal | DOT | MISC | LEFT_CURLY literal RIGHT_CURLY | LEFT_SQUARE pattern RIGHT_SQUARE )+ )
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:220:11: ( literal | DOT | MISC | LEFT_CURLY literal RIGHT_CURLY | LEFT_SQUARE pattern RIGHT_SQUARE )+
{
root_0 = (Object) adaptor.nil();
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:220:11: ( literal | DOT | MISC | LEFT_CURLY literal RIGHT_CURLY | LEFT_SQUARE pattern RIGHT_SQUARE )+
int cnt16 = 0;
loop16: while (true) {
int alt16 = 6;
switch(input.LA(1)) {
case RIGHT_SQUARE:
{
int LA16_2 = input.LA(2);
if ((synpred24_DSLMap())) {
alt16 = 1;
}
}
break;
case LEFT_SQUARE:
{
int LA16_3 = input.LA(2);
if ((synpred24_DSLMap())) {
alt16 = 1;
} else if ((synpred28_DSLMap())) {
alt16 = 5;
}
}
break;
case DOT:
{
alt16 = 2;
}
break;
case MISC:
{
alt16 = 3;
}
break;
case LEFT_CURLY:
{
alt16 = 4;
}
break;
case COLON:
case LITERAL:
{
alt16 = 1;
}
break;
}
switch(alt16) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:220:13: literal
{
pushFollow(FOLLOW_literal_in_pattern1290);
literal27 = literal();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
adaptor.addChild(root_0, literal27.getTree());
}
break;
case 2:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:221:13: DOT
{
DOT28 = (Token) match(input, DOT, FOLLOW_DOT_in_pattern1304);
if (state.failed)
return retval;
if (state.backtracking == 0) {
DOT28_tree = (Object) adaptor.create(DOT28);
adaptor.addChild(root_0, DOT28_tree);
}
}
break;
case 3:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:222:13: MISC
{
MISC29 = (Token) match(input, MISC, FOLLOW_MISC_in_pattern1318);
if (state.failed)
return retval;
if (state.backtracking == 0) {
MISC29_tree = (Object) adaptor.create(MISC29);
adaptor.addChild(root_0, MISC29_tree);
}
}
break;
case 4:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:223:13: LEFT_CURLY literal RIGHT_CURLY
{
LEFT_CURLY30 = (Token) match(input, LEFT_CURLY, FOLLOW_LEFT_CURLY_in_pattern1332);
if (state.failed)
return retval;
if (state.backtracking == 0) {
LEFT_CURLY30_tree = (Object) adaptor.create(LEFT_CURLY30);
adaptor.addChild(root_0, LEFT_CURLY30_tree);
}
pushFollow(FOLLOW_literal_in_pattern1334);
literal31 = literal();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
adaptor.addChild(root_0, literal31.getTree());
RIGHT_CURLY32 = (Token) match(input, RIGHT_CURLY, FOLLOW_RIGHT_CURLY_in_pattern1336);
if (state.failed)
return retval;
if (state.backtracking == 0) {
RIGHT_CURLY32_tree = (Object) adaptor.create(RIGHT_CURLY32);
adaptor.addChild(root_0, RIGHT_CURLY32_tree);
}
}
break;
case 5:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:224:13: LEFT_SQUARE pattern RIGHT_SQUARE
{
LEFT_SQUARE33 = (Token) match(input, LEFT_SQUARE, FOLLOW_LEFT_SQUARE_in_pattern1350);
if (state.failed)
return retval;
if (state.backtracking == 0) {
LEFT_SQUARE33_tree = (Object) adaptor.create(LEFT_SQUARE33);
adaptor.addChild(root_0, LEFT_SQUARE33_tree);
}
pushFollow(FOLLOW_pattern_in_pattern1352);
pattern34 = pattern();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
adaptor.addChild(root_0, pattern34.getTree());
RIGHT_SQUARE35 = (Token) match(input, RIGHT_SQUARE, FOLLOW_RIGHT_SQUARE_in_pattern1354);
if (state.failed)
return retval;
if (state.backtracking == 0) {
RIGHT_SQUARE35_tree = (Object) adaptor.create(RIGHT_SQUARE35);
adaptor.addChild(root_0, RIGHT_SQUARE35_tree);
}
}
break;
default:
if (cnt16 >= 1)
break loop16;
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
EarlyExitException eee = new EarlyExitException(16, input);
throw eee;
}
cnt16++;
}
}
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_section.
// $ANTLR start "value_section"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:167:1: value_section : ( value_sentence )+ -> ^( VT_ENTRY_VAL ( value_sentence )+ ) ;
public final DSLMapParser.value_section_return value_section() throws RecognitionException {
DSLMapParser.value_section_return retval = new DSLMapParser.value_section_return();
retval.start = input.LT(1);
Object root_0 = null;
ParserRuleReturnScope value_sentence18 = null;
RewriteRuleSubtreeStream stream_value_sentence = new RewriteRuleSubtreeStream(adaptor, "rule value_sentence");
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:168:5: ( ( value_sentence )+ -> ^( VT_ENTRY_VAL ( value_sentence )+ ) )
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:168:7: ( value_sentence )+
{
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:168:7: ( value_sentence )+
int cnt11 = 0;
loop11: while (true) {
int alt11 = 2;
int LA11_0 = input.LA(1);
if (((LA11_0 >= COLON && LA11_0 <= DOT) || LA11_0 == EQUALS || (LA11_0 >= LEFT_CURLY && LA11_0 <= LITERAL) || LA11_0 == RIGHT_SQUARE)) {
alt11 = 1;
}
switch(alt11) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:168:7: value_sentence
{
pushFollow(FOLLOW_value_sentence_in_value_section664);
value_sentence18 = value_sentence();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_value_sentence.add(value_sentence18.getTree());
}
break;
default:
if (cnt11 >= 1)
break loop11;
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
EarlyExitException eee = new EarlyExitException(11, input);
throw eee;
}
cnt11++;
}
// 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();
// 169:5: -> ^( VT_ENTRY_VAL ( value_sentence )+ )
{
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:169:8: ^( VT_ENTRY_VAL ( value_sentence )+ )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_ENTRY_VAL, "VT_ENTRY_VAL"), root_1);
if (!(stream_value_sentence.hasNext())) {
throw new RewriteEarlyExitException();
}
while (stream_value_sentence.hasNext()) {
adaptor.addChild(root_1, stream_value_sentence.nextTree());
}
stream_value_sentence.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.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