use of org.antlr.runtime.FailedPredicateException in project xtext-core by eclipse.
the class Lexer method nextToken.
@Override
public Token nextToken() {
while (true) {
this.state.token = null;
this.state.channel = Token.DEFAULT_CHANNEL;
this.state.tokenStartCharIndex = input.index();
this.state.tokenStartCharPositionInLine = input.getCharPositionInLine();
this.state.tokenStartLine = input.getLine();
this.state.text = null;
if (input.LA(1) == CharStream.EOF) {
return Token.EOF_TOKEN;
}
try {
mTokens();
if (this.state.token == null) {
emit();
} else if (this.state.token == Token.SKIP_TOKEN) {
continue;
}
return this.state.token;
} catch (RecognitionException re) {
reportError(re);
if (re instanceof NoViableAltException || re instanceof FailedPredicateException) {
recover(re);
}
// create token that holds mismatched char
Token t = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.HIDDEN_CHANNEL, this.state.tokenStartCharIndex, getCharIndex() - 1);
t.setLine(this.state.tokenStartLine);
t.setCharPositionInLine(this.state.tokenStartCharPositionInLine);
tokenErrorMap.put(t, getErrorMessage(re, this.getTokenNames()));
emit(t);
return this.state.token;
}
}
}
use of org.antlr.runtime.FailedPredicateException 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.FailedPredicateException 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.FailedPredicateException in project drools by kiegroup.
the class DSLMapParser method keyword_key.
// $ANTLR start "keyword_key"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:261:1: keyword_key :{...}?value= LITERAL -> VT_KEYWORD[$value] ;
public final DSLMapParser.keyword_key_return keyword_key() throws RecognitionException {
DSLMapParser.keyword_key_return retval = new DSLMapParser.keyword_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:262:5: ({...}?value= LITERAL -> VT_KEYWORD[$value] )
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:262:7: {...}?value= LITERAL
{
if (!((validateIdentifierKey("keyword")))) {
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
throw new FailedPredicateException(input, "keyword_key", "validateIdentifierKey(\"keyword\")");
}
value = (Token) match(input, LITERAL, FOLLOW_LITERAL_in_keyword_key1663);
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();
// 263:5: -> VT_KEYWORD[$value]
{
adaptor.addChild(root_0, (Object) adaptor.create(VT_KEYWORD, 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.FailedPredicateException in project drools by kiegroup.
the class DSLMapParser method consequence_key.
// $ANTLR start "consequence_key"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:256:1: consequence_key :{...}?value= LITERAL -> VT_CONSEQUENCE[$value] ;
public final DSLMapParser.consequence_key_return consequence_key() throws RecognitionException {
DSLMapParser.consequence_key_return retval = new DSLMapParser.consequence_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:257:5: ({...}?value= LITERAL -> VT_CONSEQUENCE[$value] )
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:257:7: {...}?value= LITERAL
{
if (!((validateIdentifierKey("consequence") || validateIdentifierKey("then")))) {
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
throw new FailedPredicateException(input, "consequence_key", "validateIdentifierKey(\"consequence\")||validateIdentifierKey(\"then\")");
}
value = (Token) match(input, LITERAL, FOLLOW_LITERAL_in_consequence_key1631);
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();
// 258:5: -> VT_CONSEQUENCE[$value]
{
adaptor.addChild(root_0, (Object) adaptor.create(VT_CONSEQUENCE, 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;
}
Aggregations