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 variable_definition.
// $ANTLR start "variable_definition"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:190:1: variable_definition : lc= LEFT_CURLY name= LITERAL ( ( COLON q= LITERAL )? COLON pat= pattern )? rc= RIGHT_CURLY -> { hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) -> {!hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) -> { hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) -> {!hasSpaceBefore && !hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) -> { hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) VT_SPACE -> {!hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) VT_SPACE -> { hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) VT_SPACE -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) VT_SPACE -> ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) ;
public final DSLMapParser.variable_definition_return variable_definition() throws RecognitionException {
DSLMapParser.variable_definition_return retval = new DSLMapParser.variable_definition_return();
retval.start = input.LT(1);
Object root_0 = null;
Token lc = null;
Token name = null;
Token q = null;
Token rc = null;
Token COLON25 = null;
Token COLON26 = null;
ParserRuleReturnScope pat = null;
Object lc_tree = null;
Object name_tree = null;
Object q_tree = null;
Object rc_tree = null;
Object COLON25_tree = null;
Object COLON26_tree = null;
RewriteRuleTokenStream stream_COLON = new RewriteRuleTokenStream(adaptor, "token COLON");
RewriteRuleTokenStream stream_LITERAL = new RewriteRuleTokenStream(adaptor, "token LITERAL");
RewriteRuleTokenStream stream_RIGHT_CURLY = new RewriteRuleTokenStream(adaptor, "token RIGHT_CURLY");
RewriteRuleTokenStream stream_LEFT_CURLY = new RewriteRuleTokenStream(adaptor, "token LEFT_CURLY");
RewriteRuleSubtreeStream stream_pattern = new RewriteRuleSubtreeStream(adaptor, "rule pattern");
String text = "";
boolean hasSpaceBefore = false;
boolean hasSpaceAfter = false;
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:196:5: (lc= LEFT_CURLY name= LITERAL ( ( COLON q= LITERAL )? COLON pat= pattern )? rc= RIGHT_CURLY -> { hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) -> {!hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) -> { hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) -> {!hasSpaceBefore && !hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) -> { hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) VT_SPACE -> {!hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) VT_SPACE -> { hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) VT_SPACE -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) VT_SPACE -> ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) )
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:196:7: lc= LEFT_CURLY name= LITERAL ( ( COLON q= LITERAL )? COLON pat= pattern )? rc= RIGHT_CURLY
{
lc = (Token) match(input, LEFT_CURLY, FOLLOW_LEFT_CURLY_in_variable_definition809);
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;
}
name = (Token) match(input, LITERAL, FOLLOW_LITERAL_in_variable_definition827);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_LITERAL.add(name);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:201:18: ( ( COLON q= LITERAL )? COLON pat= pattern )?
int alt15 = 2;
int LA15_0 = input.LA(1);
if ((LA15_0 == COLON)) {
alt15 = 1;
}
switch(alt15) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:201:20: ( COLON q= LITERAL )? COLON pat= pattern
{
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:201:20: ( COLON q= LITERAL )?
int alt14 = 2;
int LA14_0 = input.LA(1);
if ((LA14_0 == COLON)) {
int LA14_1 = input.LA(2);
if ((LA14_1 == LITERAL)) {
int LA14_2 = input.LA(3);
if ((LA14_2 == COLON)) {
int LA14_4 = input.LA(4);
if ((synpred22_DSLMap())) {
alt14 = 1;
}
}
}
}
switch(alt14) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:201:21: COLON q= LITERAL
{
COLON25 = (Token) match(input, COLON, FOLLOW_COLON_in_variable_definition832);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_COLON.add(COLON25);
q = (Token) match(input, LITERAL, FOLLOW_LITERAL_in_variable_definition836);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_LITERAL.add(q);
}
break;
}
COLON26 = (Token) match(input, COLON, FOLLOW_COLON_in_variable_definition840);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_COLON.add(COLON26);
pushFollow(FOLLOW_pattern_in_variable_definition844);
pat = pattern();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_pattern.add(pat.getTree());
if (state.backtracking == 0) {
text = (pat != null ? input.toString(pat.start, pat.stop) : null);
}
}
break;
}
rc = (Token) match(input, RIGHT_CURLY, FOLLOW_RIGHT_CURLY_in_variable_definition853);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_RIGHT_CURLY.add(rc);
if (state.backtracking == 0) {
CommonToken rc1 = (CommonToken) input.LT(1);
if (!"=".equals(rc1.getText()) && ((CommonToken) rc).getStopIndex() < rc1.getStartIndex() - 1)
hasSpaceAfter = true;
isIdentifier(name);
}
// wildcard labels:
if (state.backtracking == 0) {
retval.tree = root_0;
RewriteRuleTokenStream stream_q = new RewriteRuleTokenStream(adaptor, "token q", q);
RewriteRuleTokenStream stream_name = new RewriteRuleTokenStream(adaptor, "token name", name);
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
root_0 = (Object) adaptor.nil();
// 208:5: -> { hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] )
if (hasSpaceBefore && !"".equals(text) && !hasSpaceAfter) {
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:208:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:208:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:208:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_1, (Object) adaptor.create(VT_PATTERN, (pat != null ? (pat.start) : null), text));
adaptor.addChild(root_0, root_1);
}
} else // 209:5: -> {!hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] )
if (!hasSpaceBefore && !"".equals(text) && !hasSpaceAfter) {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:209:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:209:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:209:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_1, (Object) adaptor.create(VT_PATTERN, (pat != null ? (pat.start) : null), text));
adaptor.addChild(root_0, root_1);
}
} else // 210:5: -> { hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
if (hasSpaceBefore && !hasSpaceAfter) {
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:210:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:210:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:210:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_0, root_1);
}
} else // 211:5: -> {!hasSpaceBefore && !hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
if (!hasSpaceBefore && !hasSpaceAfter) {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:211:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:211:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:211:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_0, root_1);
}
} else // 212:5: -> { hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) VT_SPACE
if (hasSpaceBefore && !"".equals(text) && hasSpaceAfter) {
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:212:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:212:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:212:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_1, (Object) adaptor.create(VT_PATTERN, (pat != null ? (pat.start) : null), text));
adaptor.addChild(root_0, root_1);
}
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
} else // 213:5: -> {!hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) VT_SPACE
if (!hasSpaceBefore && !"".equals(text) && hasSpaceAfter) {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:213:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:213:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:213:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_1, (Object) adaptor.create(VT_PATTERN, (pat != null ? (pat.start) : null), text));
adaptor.addChild(root_0, root_1);
}
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
} else // 214:5: -> { hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) 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:214:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:214:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:214:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_0, root_1);
}
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
} else // 215:5: -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) VT_SPACE
if (!hasSpaceBefore && hasSpaceAfter) {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:215:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:215:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:215:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_0, root_1);
}
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
} else // 216:5: -> ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
{
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:216:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:216:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:216:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
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 variable_definition.
// $ANTLR start "variable_definition"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:190:1: variable_definition : lc= LEFT_CURLY name= LITERAL ( ( COLON q= LITERAL )? COLON pat= pattern )? rc= RIGHT_CURLY -> { hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) -> {!hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) -> { hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) -> {!hasSpaceBefore && !hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) -> { hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) VT_SPACE -> {!hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) VT_SPACE -> { hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) VT_SPACE -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) VT_SPACE -> ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) ;
public final DSLMapParser.variable_definition_return variable_definition() throws RecognitionException {
DSLMapParser.variable_definition_return retval = new DSLMapParser.variable_definition_return();
retval.start = input.LT(1);
Object root_0 = null;
Token lc = null;
Token name = null;
Token q = null;
Token rc = null;
Token COLON25 = null;
Token COLON26 = null;
ParserRuleReturnScope pat = null;
Object lc_tree = null;
Object name_tree = null;
Object q_tree = null;
Object rc_tree = null;
Object COLON25_tree = null;
Object COLON26_tree = null;
RewriteRuleTokenStream stream_COLON = new RewriteRuleTokenStream(adaptor, "token COLON");
RewriteRuleTokenStream stream_LITERAL = new RewriteRuleTokenStream(adaptor, "token LITERAL");
RewriteRuleTokenStream stream_RIGHT_CURLY = new RewriteRuleTokenStream(adaptor, "token RIGHT_CURLY");
RewriteRuleTokenStream stream_LEFT_CURLY = new RewriteRuleTokenStream(adaptor, "token LEFT_CURLY");
RewriteRuleSubtreeStream stream_pattern = new RewriteRuleSubtreeStream(adaptor, "rule pattern");
String text = "";
boolean hasSpaceBefore = false;
boolean hasSpaceAfter = false;
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:196:5: (lc= LEFT_CURLY name= LITERAL ( ( COLON q= LITERAL )? COLON pat= pattern )? rc= RIGHT_CURLY -> { hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) -> {!hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) -> { hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) -> {!hasSpaceBefore && !hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) -> { hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) VT_SPACE -> {!hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) VT_SPACE -> { hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) VT_SPACE -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) VT_SPACE -> ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) )
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:196:7: lc= LEFT_CURLY name= LITERAL ( ( COLON q= LITERAL )? COLON pat= pattern )? rc= RIGHT_CURLY
{
lc = (Token) match(input, LEFT_CURLY, FOLLOW_LEFT_CURLY_in_variable_definition809);
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;
}
name = (Token) match(input, LITERAL, FOLLOW_LITERAL_in_variable_definition827);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_LITERAL.add(name);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:201:18: ( ( COLON q= LITERAL )? COLON pat= pattern )?
int alt15 = 2;
int LA15_0 = input.LA(1);
if ((LA15_0 == COLON)) {
alt15 = 1;
}
switch(alt15) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:201:20: ( COLON q= LITERAL )? COLON pat= pattern
{
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:201:20: ( COLON q= LITERAL )?
int alt14 = 2;
int LA14_0 = input.LA(1);
if ((LA14_0 == COLON)) {
int LA14_1 = input.LA(2);
if ((LA14_1 == LITERAL)) {
int LA14_2 = input.LA(3);
if ((LA14_2 == COLON)) {
int LA14_4 = input.LA(4);
if ((synpred22_DSLMap())) {
alt14 = 1;
}
}
}
}
switch(alt14) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:201:21: COLON q= LITERAL
{
COLON25 = (Token) match(input, COLON, FOLLOW_COLON_in_variable_definition832);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_COLON.add(COLON25);
q = (Token) match(input, LITERAL, FOLLOW_LITERAL_in_variable_definition836);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_LITERAL.add(q);
}
break;
}
COLON26 = (Token) match(input, COLON, FOLLOW_COLON_in_variable_definition840);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_COLON.add(COLON26);
pushFollow(FOLLOW_pattern_in_variable_definition844);
pat = pattern();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_pattern.add(pat.getTree());
if (state.backtracking == 0) {
text = (pat != null ? input.toString(pat.start, pat.stop) : null);
}
}
break;
}
rc = (Token) match(input, RIGHT_CURLY, FOLLOW_RIGHT_CURLY_in_variable_definition853);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_RIGHT_CURLY.add(rc);
if (state.backtracking == 0) {
CommonToken rc1 = (CommonToken) input.LT(1);
if (!"=".equals(rc1.getText()) && ((CommonToken) rc).getStopIndex() < rc1.getStartIndex() - 1)
hasSpaceAfter = true;
isIdentifier(name);
}
// wildcard labels:
if (state.backtracking == 0) {
retval.tree = root_0;
RewriteRuleTokenStream stream_q = new RewriteRuleTokenStream(adaptor, "token q", q);
RewriteRuleTokenStream stream_name = new RewriteRuleTokenStream(adaptor, "token name", name);
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
root_0 = (Object) adaptor.nil();
// 208:5: -> { hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] )
if (hasSpaceBefore && !"".equals(text) && !hasSpaceAfter) {
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:208:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:208:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:208:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_1, (Object) adaptor.create(VT_PATTERN, (pat != null ? (pat.start) : null), text));
adaptor.addChild(root_0, root_1);
}
} else // 209:5: -> {!hasSpaceBefore && !\"\".equals(text) && !hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] )
if (!hasSpaceBefore && !"".equals(text) && !hasSpaceAfter) {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:209:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:209:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:209:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_1, (Object) adaptor.create(VT_PATTERN, (pat != null ? (pat.start) : null), text));
adaptor.addChild(root_0, root_1);
}
} else // 210:5: -> { hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
if (hasSpaceBefore && !hasSpaceAfter) {
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:210:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:210:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:210:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_0, root_1);
}
} else // 211:5: -> {!hasSpaceBefore && !hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
if (!hasSpaceBefore && !hasSpaceAfter) {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:211:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:211:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:211:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_0, root_1);
}
} else // 212:5: -> { hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) VT_SPACE
if (hasSpaceBefore && !"".equals(text) && hasSpaceAfter) {
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:212:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:212:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:212:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_1, (Object) adaptor.create(VT_PATTERN, (pat != null ? (pat.start) : null), text));
adaptor.addChild(root_0, root_1);
}
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
} else // 213:5: -> {!hasSpaceBefore && !\"\".equals(text) && hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] ) VT_SPACE
if (!hasSpaceBefore && !"".equals(text) && hasSpaceAfter) {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:213:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) VT_PATTERN[$pat.start, text] )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:213:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:213:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_1, (Object) adaptor.create(VT_PATTERN, (pat != null ? (pat.start) : null), text));
adaptor.addChild(root_0, root_1);
}
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
} else // 214:5: -> { hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) 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:214:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:214:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:214:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_0, root_1);
}
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
} else // 215:5: -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) ) VT_SPACE
if (!hasSpaceBefore && hasSpaceAfter) {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:215:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:215:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:215:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
adaptor.addChild(root_0, root_1);
}
adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
} else // 216:5: -> ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
{
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:216:74: ^( VT_VAR_DEF $name ^( VT_QUAL ( $q)? ) )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_DEF, "VT_VAR_DEF"), root_1);
adaptor.addChild(root_1, stream_name.nextNode());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:216:93: ^( VT_QUAL ( $q)? )
{
Object root_2 = (Object) adaptor.nil();
root_2 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_QUAL, "VT_QUAL"), root_2);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:216:104: ( $q)?
if (stream_q.hasNext()) {
adaptor.addChild(root_2, stream_q.nextNode());
}
stream_q.reset();
adaptor.addChild(root_1, root_2);
}
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 scope_section.
// $ANTLR start "scope_section"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:130:1: scope_section : LEFT_SQUARE (value1= condition_key |value2= consequence_key |value3= keyword_key |value4= any_key ) RIGHT_SQUARE -> ^( VT_SCOPE[$LEFT_SQUARE, \"SCOPE SECTION\"] ( $value1)? ( $value2)? ( $value3)? ( $value4)? ) ;
public final DSLMapParser.scope_section_return scope_section() throws RecognitionException {
DSLMapParser.scope_section_return retval = new DSLMapParser.scope_section_return();
retval.start = input.LT(1);
Object root_0 = null;
Token LEFT_SQUARE11 = null;
Token RIGHT_SQUARE12 = null;
ParserRuleReturnScope value1 = null;
ParserRuleReturnScope value2 = null;
ParserRuleReturnScope value3 = null;
ParserRuleReturnScope value4 = null;
Object LEFT_SQUARE11_tree = null;
Object RIGHT_SQUARE12_tree = null;
RewriteRuleTokenStream stream_RIGHT_SQUARE = new RewriteRuleTokenStream(adaptor, "token RIGHT_SQUARE");
RewriteRuleTokenStream stream_LEFT_SQUARE = new RewriteRuleTokenStream(adaptor, "token LEFT_SQUARE");
RewriteRuleSubtreeStream stream_any_key = new RewriteRuleSubtreeStream(adaptor, "rule any_key");
RewriteRuleSubtreeStream stream_condition_key = new RewriteRuleSubtreeStream(adaptor, "rule condition_key");
RewriteRuleSubtreeStream stream_keyword_key = new RewriteRuleSubtreeStream(adaptor, "rule keyword_key");
RewriteRuleSubtreeStream stream_consequence_key = new RewriteRuleSubtreeStream(adaptor, "rule consequence_key");
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:131:5: ( LEFT_SQUARE (value1= condition_key |value2= consequence_key |value3= keyword_key |value4= any_key ) RIGHT_SQUARE -> ^( VT_SCOPE[$LEFT_SQUARE, \"SCOPE SECTION\"] ( $value1)? ( $value2)? ( $value3)? ( $value4)? ) )
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:131:7: LEFT_SQUARE (value1= condition_key |value2= consequence_key |value3= keyword_key |value4= any_key ) RIGHT_SQUARE
{
LEFT_SQUARE11 = (Token) match(input, LEFT_SQUARE, FOLLOW_LEFT_SQUARE_in_scope_section412);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_LEFT_SQUARE.add(LEFT_SQUARE11);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:132:9: (value1= condition_key |value2= consequence_key |value3= keyword_key |value4= any_key )
int alt6 = 4;
int LA6_0 = input.LA(1);
if ((LA6_0 == LITERAL)) {
int LA6_1 = input.LA(2);
if ((((validateIdentifierKey("condition") || validateIdentifierKey("when")) && synpred6_DSLMap()))) {
alt6 = 1;
} else if (((synpred7_DSLMap() && (validateIdentifierKey("consequence") || validateIdentifierKey("then"))))) {
alt6 = 2;
} else if (((synpred8_DSLMap() && (validateIdentifierKey("keyword"))))) {
alt6 = 3;
} else if (((validateIdentifierKey("*")))) {
alt6 = 4;
} else {
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
int nvaeMark = input.mark();
try {
input.consume();
NoViableAltException nvae = new NoViableAltException("", 6, 1, input);
throw nvae;
} finally {
input.rewind(nvaeMark);
}
}
} else {
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
NoViableAltException nvae = new NoViableAltException("", 6, 0, input);
throw nvae;
}
switch(alt6) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:132:10: value1= condition_key
{
pushFollow(FOLLOW_condition_key_in_scope_section425);
value1 = condition_key();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_condition_key.add(value1.getTree());
}
break;
case 2:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:133:11: value2= consequence_key
{
pushFollow(FOLLOW_consequence_key_in_scope_section439);
value2 = consequence_key();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_consequence_key.add(value2.getTree());
}
break;
case 3:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:134:11: value3= keyword_key
{
pushFollow(FOLLOW_keyword_key_in_scope_section453);
value3 = keyword_key();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_keyword_key.add(value3.getTree());
}
break;
case 4:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:135:11: value4= any_key
{
pushFollow(FOLLOW_any_key_in_scope_section467);
value4 = any_key();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_any_key.add(value4.getTree());
}
break;
}
RIGHT_SQUARE12 = (Token) match(input, RIGHT_SQUARE, FOLLOW_RIGHT_SQUARE_in_scope_section483);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_RIGHT_SQUARE.add(RIGHT_SQUARE12);
// wildcard labels:
if (state.backtracking == 0) {
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
RewriteRuleSubtreeStream stream_value3 = new RewriteRuleSubtreeStream(adaptor, "rule value3", value3 != null ? value3.getTree() : null);
RewriteRuleSubtreeStream stream_value4 = new RewriteRuleSubtreeStream(adaptor, "rule value4", value4 != null ? value4.getTree() : null);
RewriteRuleSubtreeStream stream_value1 = new RewriteRuleSubtreeStream(adaptor, "rule value1", value1 != null ? value1.getTree() : null);
RewriteRuleSubtreeStream stream_value2 = new RewriteRuleSubtreeStream(adaptor, "rule value2", value2 != null ? value2.getTree() : null);
root_0 = (Object) adaptor.nil();
// 138:5: -> ^( VT_SCOPE[$LEFT_SQUARE, \"SCOPE SECTION\"] ( $value1)? ( $value2)? ( $value3)? ( $value4)? )
{
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:138:8: ^( VT_SCOPE[$LEFT_SQUARE, \"SCOPE SECTION\"] ( $value1)? ( $value2)? ( $value3)? ( $value4)? )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_SCOPE, LEFT_SQUARE11, "SCOPE SECTION"), root_1);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:138:51: ( $value1)?
if (stream_value1.hasNext()) {
adaptor.addChild(root_1, stream_value1.nextTree());
}
stream_value1.reset();
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:138:60: ( $value2)?
if (stream_value2.hasNext()) {
adaptor.addChild(root_1, stream_value2.nextTree());
}
stream_value2.reset();
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:138:69: ( $value3)?
if (stream_value3.hasNext()) {
adaptor.addChild(root_1, stream_value3.nextTree());
}
stream_value3.reset();
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:138:78: ( $value4)?
if (stream_value4.hasNext()) {
adaptor.addChild(root_1, stream_value4.nextTree());
}
stream_value4.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 entry.
// $ANTLR start "entry"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:119:1: entry : scope_section ( meta_section )? key_section EQUALS ( value_section )? ( EOL | EOF ) -> ^( VT_ENTRY scope_section ( meta_section )? key_section ( value_section )? ) ;
public final DSLMapParser.entry_return entry() throws RecognitionException {
DSLMapParser.entry_return retval = new DSLMapParser.entry_return();
retval.start = input.LT(1);
Object root_0 = null;
Token EQUALS7 = null;
Token EOL9 = null;
Token EOF10 = null;
ParserRuleReturnScope scope_section4 = null;
ParserRuleReturnScope meta_section5 = null;
ParserRuleReturnScope key_section6 = null;
ParserRuleReturnScope value_section8 = null;
Object EQUALS7_tree = null;
Object EOL9_tree = null;
Object EOF10_tree = null;
RewriteRuleTokenStream stream_EQUALS = new RewriteRuleTokenStream(adaptor, "token EQUALS");
RewriteRuleTokenStream stream_EOL = new RewriteRuleTokenStream(adaptor, "token EOL");
RewriteRuleTokenStream stream_EOF = new RewriteRuleTokenStream(adaptor, "token EOF");
RewriteRuleSubtreeStream stream_meta_section = new RewriteRuleSubtreeStream(adaptor, "rule meta_section");
RewriteRuleSubtreeStream stream_key_section = new RewriteRuleSubtreeStream(adaptor, "rule key_section");
RewriteRuleSubtreeStream stream_scope_section = new RewriteRuleSubtreeStream(adaptor, "rule scope_section");
RewriteRuleSubtreeStream stream_value_section = new RewriteRuleSubtreeStream(adaptor, "rule value_section");
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:119:8: ( scope_section ( meta_section )? key_section EQUALS ( value_section )? ( EOL | EOF ) -> ^( VT_ENTRY scope_section ( meta_section )? key_section ( value_section )? ) )
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:119:10: scope_section ( meta_section )? key_section EQUALS ( value_section )? ( EOL | EOF )
{
pushFollow(FOLLOW_scope_section_in_entry336);
scope_section4 = scope_section();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_scope_section.add(scope_section4.getTree());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:119:24: ( meta_section )?
int alt3 = 2;
int LA3_0 = input.LA(1);
if ((LA3_0 == LEFT_SQUARE)) {
int LA3_1 = input.LA(2);
if ((LA3_1 == LITERAL)) {
int LA3_3 = input.LA(3);
if ((LA3_3 == RIGHT_SQUARE)) {
int LA3_5 = input.LA(4);
if ((synpred3_DSLMap())) {
alt3 = 1;
}
}
} else if ((LA3_1 == RIGHT_SQUARE)) {
int LA3_4 = input.LA(3);
if ((synpred3_DSLMap())) {
alt3 = 1;
}
}
}
switch(alt3) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:119:24: meta_section
{
pushFollow(FOLLOW_meta_section_in_entry338);
meta_section5 = meta_section();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_meta_section.add(meta_section5.getTree());
}
break;
}
pushFollow(FOLLOW_key_section_in_entry341);
key_section6 = key_section();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_key_section.add(key_section6.getTree());
EQUALS7 = (Token) match(input, EQUALS, FOLLOW_EQUALS_in_entry343);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_EQUALS.add(EQUALS7);
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:119:57: ( value_section )?
int alt4 = 2;
int LA4_0 = input.LA(1);
if (((LA4_0 >= COLON && LA4_0 <= DOT) || LA4_0 == EQUALS || (LA4_0 >= LEFT_CURLY && LA4_0 <= LITERAL) || LA4_0 == RIGHT_SQUARE)) {
alt4 = 1;
}
switch(alt4) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:119:57: value_section
{
pushFollow(FOLLOW_value_section_in_entry345);
value_section8 = value_section();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_value_section.add(value_section8.getTree());
}
break;
}
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:119:72: ( EOL | EOF )
int alt5 = 2;
int LA5_0 = input.LA(1);
if ((LA5_0 == EOL)) {
alt5 = 1;
} else if ((LA5_0 == EOF)) {
alt5 = 2;
} else {
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
NoViableAltException nvae = new NoViableAltException("", 5, 0, input);
throw nvae;
}
switch(alt5) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:119:73: EOL
{
EOL9 = (Token) match(input, EOL, FOLLOW_EOL_in_entry349);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_EOL.add(EOL9);
}
break;
case 2:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:119:77: EOF
{
EOF10 = (Token) match(input, EOF, FOLLOW_EOF_in_entry351);
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_EOF.add(EOF10);
}
break;
}
// 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();
// 120:5: -> ^( VT_ENTRY scope_section ( meta_section )? key_section ( value_section )? )
{
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:120:8: ^( VT_ENTRY scope_section ( meta_section )? key_section ( value_section )? )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_ENTRY, "VT_ENTRY"), root_1);
adaptor.addChild(root_1, stream_scope_section.nextTree());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:120:33: ( meta_section )?
if (stream_meta_section.hasNext()) {
adaptor.addChild(root_1, stream_meta_section.nextTree());
}
stream_meta_section.reset();
adaptor.addChild(root_1, stream_key_section.nextTree());
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:120:59: ( value_section )?
if (stream_value_section.hasNext()) {
adaptor.addChild(root_1, stream_value_section.nextTree());
}
stream_value_section.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 e) {
reportError(e);
} catch (RewriteEmptyStreamException e) {
} finally {
// do for sure before leaving
}
return retval;
}
Aggregations