use of org.antlr.runtime.EarlyExitException in project freud by LMAX-Exchange.
the class JavaLexer method mHEX_LITERAL.
// $ANTLR end "WHILE"
// $ANTLR start "HEX_LITERAL"
public final void mHEX_LITERAL() throws RecognitionException {
try {
int _type = HEX_LITERAL;
int _channel = DEFAULT_TOKEN_CHANNEL;
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1170:13: ( '0' ( 'x' | 'X' ) ( HEX_DIGIT )+ ( INTEGER_TYPE_SUFFIX )? )
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1170:15: '0' ( 'x' | 'X' ) ( HEX_DIGIT )+ ( INTEGER_TYPE_SUFFIX )?
{
match('0');
if (input.LA(1) == 'X' || input.LA(1) == 'x') {
input.consume();
} else {
MismatchedSetException mse = new MismatchedSetException(null, input);
recover(mse);
throw mse;
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1170:29: ( HEX_DIGIT )+
int cnt1 = 0;
loop1: do {
int alt1 = 2;
int LA1_0 = input.LA(1);
if (((LA1_0 >= '0' && LA1_0 <= '9') || (LA1_0 >= 'A' && LA1_0 <= 'F') || (LA1_0 >= 'a' && LA1_0 <= 'f'))) {
alt1 = 1;
}
switch(alt1) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1170:29: HEX_DIGIT
{
mHEX_DIGIT();
}
break;
default:
if (cnt1 >= 1) {
break loop1;
}
EarlyExitException eee = new EarlyExitException(1, input);
throw eee;
}
cnt1++;
} while (true);
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1170:40: ( INTEGER_TYPE_SUFFIX )?
int alt2 = 2;
int LA2_0 = input.LA(1);
if ((LA2_0 == 'L' || LA2_0 == 'l')) {
alt2 = 1;
}
switch(alt2) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1170:40: INTEGER_TYPE_SUFFIX
{
mINTEGER_TYPE_SUFFIX();
}
break;
}
}
state.type = _type;
state.channel = _channel;
} finally {
}
}
use of org.antlr.runtime.EarlyExitException in project freud by LMAX-Exchange.
the class JavaParser method arrayDeclaratorList.
// $ANTLR start "arrayDeclaratorList"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:603:1: arrayDeclaratorList : ( arrayDeclarator )+ -> ^( ARRAY_DECLARATOR_LIST ( arrayDeclarator )+ ) ;
public final JavaParser.arrayDeclaratorList_return arrayDeclaratorList() throws RecognitionException {
JavaParser.arrayDeclaratorList_return retval = new JavaParser.arrayDeclaratorList_return();
retval.start = input.LT(1);
int arrayDeclaratorList_StartIndex = input.index();
CommonTree root_0 = null;
JavaParser.arrayDeclarator_return arrayDeclarator142 = null;
RewriteRuleSubtreeStream stream_arrayDeclarator = new RewriteRuleSubtreeStream(adaptor, "rule arrayDeclarator");
try {
if (state.backtracking > 0 && alreadyParsedRule(input, 34)) {
return retval;
}
// /home/langera/dev/freud/trunk/src/grammar/Java.g:604:5: ( ( arrayDeclarator )+ -> ^( ARRAY_DECLARATOR_LIST ( arrayDeclarator )+ ) )
// /home/langera/dev/freud/trunk/src/grammar/Java.g:604:9: ( arrayDeclarator )+
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:604:9: ( arrayDeclarator )+
int cnt50 = 0;
loop50: do {
int alt50 = 2;
int LA50_0 = input.LA(1);
if ((LA50_0 == LBRACK)) {
int LA50_2 = input.LA(2);
if ((synpred59_Java())) {
alt50 = 1;
}
}
switch(alt50) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: arrayDeclarator
{
pushFollow(FOLLOW_arrayDeclarator_in_arrayDeclaratorList6489);
arrayDeclarator142 = arrayDeclarator();
state._fsp--;
if (state.failed) {
return retval;
}
if (state.backtracking == 0) {
stream_arrayDeclarator.add(arrayDeclarator142.getTree());
}
}
break;
default:
if (cnt50 >= 1) {
break loop50;
}
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
EarlyExitException eee = new EarlyExitException(50, input);
throw eee;
}
cnt50++;
} while (true);
// wildcard labels:
if (state.backtracking == 0) {
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
root_0 = (CommonTree) adaptor.nil();
// 605:9: -> ^( ARRAY_DECLARATOR_LIST ( arrayDeclarator )+ )
{
// /home/langera/dev/freud/trunk/src/grammar/Java.g:605:13: ^( ARRAY_DECLARATOR_LIST ( arrayDeclarator )+ )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(ARRAY_DECLARATOR_LIST, "ARRAY_DECLARATOR_LIST"), root_1);
if (!(stream_arrayDeclarator.hasNext())) {
throw new RewriteEarlyExitException();
}
while (stream_arrayDeclarator.hasNext()) {
adaptor.addChild(root_1, stream_arrayDeclarator.nextTree());
}
stream_arrayDeclarator.reset();
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
}
retval.stop = input.LT(-1);
if (state.backtracking == 0) {
retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
if (state.backtracking > 0) {
memoize(input, 34, arrayDeclaratorList_StartIndex);
}
}
return retval;
}
use of org.antlr.runtime.EarlyExitException in project drools by kiegroup.
the class DSLMapParser method key_section.
// $ANTLR start "key_section"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:149:1: key_section : (ks= key_sentence )+ -> ^( VT_ENTRY_KEY ( key_sentence )+ ) ;
public final DSLMapParser.key_section_return key_section() throws RecognitionException {
DSLMapParser.key_section_return retval = new DSLMapParser.key_section_return();
retval.start = input.LT(1);
Object root_0 = null;
ParserRuleReturnScope ks = null;
RewriteRuleSubtreeStream stream_key_sentence = new RewriteRuleSubtreeStream(adaptor, "rule key_sentence");
try {
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:150:5: ( (ks= key_sentence )+ -> ^( VT_ENTRY_KEY ( key_sentence )+ ) )
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:150:7: (ks= key_sentence )+
{
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:150:9: (ks= key_sentence )+
int cnt8 = 0;
loop8: while (true) {
int alt8 = 2;
int LA8_0 = input.LA(1);
if ((LA8_0 == COLON || (LA8_0 >= LEFT_CURLY && LA8_0 <= LITERAL) || LA8_0 == RIGHT_SQUARE)) {
alt8 = 1;
}
switch(alt8) {
case 1:
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:150:9: ks= key_sentence
{
pushFollow(FOLLOW_key_sentence_in_key_section568);
ks = key_sentence();
state._fsp--;
if (state.failed)
return retval;
if (state.backtracking == 0)
stream_key_sentence.add(ks.getTree());
}
break;
default:
if (cnt8 >= 1)
break loop8;
if (state.backtracking > 0) {
state.failed = true;
return retval;
}
EarlyExitException eee = new EarlyExitException(8, input);
throw eee;
}
cnt8++;
}
// 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();
// 151:5: -> ^( VT_ENTRY_KEY ( key_sentence )+ )
{
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:151:8: ^( VT_ENTRY_KEY ( key_sentence )+ )
{
Object root_1 = (Object) adaptor.nil();
root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_ENTRY_KEY, "VT_ENTRY_KEY"), root_1);
if (!(stream_key_sentence.hasNext())) {
throw new RewriteEarlyExitException();
}
while (stream_key_sentence.hasNext()) {
adaptor.addChild(root_1, stream_key_sentence.nextTree());
}
stream_key_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.EarlyExitException 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.EarlyExitException in project drools by kiegroup.
the class DroolsParserExceptionFactory method createErrorMessage.
/**
* This will take a RecognitionException, and create a sensible error
* message out of it
*/
private List<String> createErrorMessage(RecognitionException e) {
List<String> codeAndMessage = new ArrayList<String>(2);
String message;
if (e instanceof MismatchedTokenException) {
MismatchedTokenException mte = (MismatchedTokenException) e;
String expecting = mte instanceof DroolsMismatchedTokenException ? ((DroolsMismatchedTokenException) mte).getTokenText() : getBetterToken(mte.expecting);
if (tokenNames != null && mte.expecting >= 0 && mte.expecting < tokenNames.length) {
message = String.format(MISMATCHED_TOKEN_MESSAGE_COMPLETE, e.line, e.charPositionInLine, getBetterToken(e.token), expecting, formatParserLocation());
codeAndMessage.add(message);
codeAndMessage.add("ERR 102");
} else {
message = String.format(MISMATCHED_TOKEN_MESSAGE_PART, e.line, e.charPositionInLine, getBetterToken(e.token), formatParserLocation());
codeAndMessage.add(message);
codeAndMessage.add("ERR 102");
}
} else if (e instanceof MismatchedTreeNodeException) {
MismatchedTreeNodeException mtne = (MismatchedTreeNodeException) e;
if (mtne.expecting >= 0 && mtne.expecting < tokenNames.length) {
message = String.format(MISMATCHED_TREE_NODE_MESSAGE_COMPLETE, e.line, e.charPositionInLine, getBetterToken(e.token), getBetterToken(mtne.expecting), formatParserLocation());
codeAndMessage.add(message);
codeAndMessage.add("ERR 106");
} else {
message = String.format(MISMATCHED_TREE_NODE_MESSAGE_PART, e.line, e.charPositionInLine, getBetterToken(e.token), formatParserLocation());
codeAndMessage.add(message);
codeAndMessage.add("ERR 106");
}
} else if (e instanceof NoViableAltException) {
// NoViableAltException nvae = (NoViableAltException) e;
message = String.format(NO_VIABLE_ALT_MESSAGE, e.line, e.charPositionInLine, getBetterToken(e.token), formatParserLocation());
codeAndMessage.add(message);
codeAndMessage.add("ERR 101");
} else if (e instanceof EarlyExitException) {
// EarlyExitException eee = (EarlyExitException) e;
message = String.format(EARLY_EXIT_MESSAGE, e.line, e.charPositionInLine, getBetterToken(e.token), formatParserLocation());
codeAndMessage.add(message);
codeAndMessage.add("ERR 105");
} else if (e instanceof MismatchedSetException) {
MismatchedSetException mse = (MismatchedSetException) e;
String expected = expectedTokensAsString(mse.expecting);
message = String.format(MISMATCHED_SET_MESSAGE, e.line, e.charPositionInLine, getBetterToken(e.token), expected, formatParserLocation());
codeAndMessage.add(message);
codeAndMessage.add("ERR 107");
} else if (e instanceof DroolsMismatchedSetException) {
DroolsMismatchedSetException mse = (DroolsMismatchedSetException) e;
String expected = Arrays.asList(mse.getTokenText()).toString();
message = String.format(MISMATCHED_SET_MESSAGE, e.line, e.charPositionInLine, getBetterToken(e.token), expected, formatParserLocation());
codeAndMessage.add(message);
codeAndMessage.add("ERR 107");
} else if (e instanceof MismatchedNotSetException) {
MismatchedNotSetException mse = (MismatchedNotSetException) e;
String expected = expectedTokensAsString(mse.expecting);
message = String.format(MISMATCHED_NOT_SET_MESSAGE, e.line, e.charPositionInLine, getBetterToken(e.token), expected, formatParserLocation());
codeAndMessage.add(message);
codeAndMessage.add("ERR 108");
} else if (e instanceof FailedPredicateException) {
FailedPredicateException fpe = (FailedPredicateException) e;
message = String.format(FAILED_PREDICATE_MESSAGE, e.line, e.charPositionInLine, fpe.ruleName, fpe.predicateText, formatParserLocation());
codeAndMessage.add(message);
codeAndMessage.add("ERR 103");
}
if (codeAndMessage.get(0).length() == 0) {
codeAndMessage.add("?????");
}
return codeAndMessage;
}
Aggregations