use of org.antlr.runtime.NoViableAltException in project freud by LMAX-Exchange.
the class CssLexer method mSL_COMMENT.
// $ANTLR end "IDENT"
// $ANTLR start "SL_COMMENT"
public final void mSL_COMMENT() throws RecognitionException {
try {
int _type = SL_COMMENT;
int _channel = DEFAULT_TOKEN_CHANNEL;
// /home/langera/dev/freud/src/grammar/Css.g:135:2: ( '//' (~ ( '\\n' | '\\r' ) )* ( '\\n' | '\\r' ( '\\n' )? ) )
// /home/langera/dev/freud/src/grammar/Css.g:135:4: '//' (~ ( '\\n' | '\\r' ) )* ( '\\n' | '\\r' ( '\\n' )? )
{
match("//");
// /home/langera/dev/freud/src/grammar/Css.g:136:3: (~ ( '\\n' | '\\r' ) )*
loop2: do {
int alt2 = 2;
int LA2_0 = input.LA(1);
if (((LA2_0 >= '\u0000' && LA2_0 <= '\t') || (LA2_0 >= '\u000B' && LA2_0 <= '\f') || (LA2_0 >= '\u000E' && LA2_0 <= '\uFFFF'))) {
alt2 = 1;
}
switch(alt2) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:136:4: ~ ( '\\n' | '\\r' )
{
if ((input.LA(1) >= '\u0000' && input.LA(1) <= '\t') || (input.LA(1) >= '\u000B' && input.LA(1) <= '\f') || (input.LA(1) >= '\u000E' && input.LA(1) <= '\uFFFF')) {
input.consume();
} else {
MismatchedSetException mse = new MismatchedSetException(null, input);
recover(mse);
throw mse;
}
}
break;
default:
break loop2;
}
} while (true);
// /home/langera/dev/freud/src/grammar/Css.g:136:19: ( '\\n' | '\\r' ( '\\n' )? )
int alt4 = 2;
int LA4_0 = input.LA(1);
if ((LA4_0 == '\n')) {
alt4 = 1;
} else if ((LA4_0 == '\r')) {
alt4 = 2;
} else {
NoViableAltException nvae = new NoViableAltException("", 4, 0, input);
throw nvae;
}
switch(alt4) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:136:20: '\\n'
{
match('\n');
}
break;
case 2:
// /home/langera/dev/freud/src/grammar/Css.g:136:25: '\\r' ( '\\n' )?
{
match('\r');
// /home/langera/dev/freud/src/grammar/Css.g:136:29: ( '\\n' )?
int alt3 = 2;
int LA3_0 = input.LA(1);
if ((LA3_0 == '\n')) {
alt3 = 1;
}
switch(alt3) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:136:30: '\\n'
{
match('\n');
}
break;
}
}
break;
}
_channel = HIDDEN;
}
state.type = _type;
state.channel = _channel;
} finally {
}
}
use of org.antlr.runtime.NoViableAltException in project freud by LMAX-Exchange.
the class JavaLexer method mCHARACTER_LITERAL.
// $ANTLR end "FLOAT_TYPE_SUFFIX"
// $ANTLR start "CHARACTER_LITERAL"
public final void mCHARACTER_LITERAL() throws RecognitionException {
try {
int _type = CHARACTER_LITERAL;
int _channel = DEFAULT_TOKEN_CHANNEL;
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1199:5: ( '\\'' ( ESCAPE_SEQUENCE | ~ ( '\\'' | '\\\\' ) ) '\\'' )
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1199:9: '\\'' ( ESCAPE_SEQUENCE | ~ ( '\\'' | '\\\\' ) ) '\\''
{
match('\'');
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1199:14: ( ESCAPE_SEQUENCE | ~ ( '\\'' | '\\\\' ) )
int alt20 = 2;
int LA20_0 = input.LA(1);
if ((LA20_0 == '\\')) {
alt20 = 1;
} else if (((LA20_0 >= '\u0000' && LA20_0 <= '&') || (LA20_0 >= '(' && LA20_0 <= '[') || (LA20_0 >= ']' && LA20_0 <= '\uFFFF'))) {
alt20 = 2;
} else {
NoViableAltException nvae = new NoViableAltException("", 20, 0, input);
throw nvae;
}
switch(alt20) {
case 1:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1199:16: ESCAPE_SEQUENCE
{
mESCAPE_SEQUENCE();
}
break;
case 2:
// /home/langera/dev/freud/trunk/src/grammar/Java.g:1199:34: ~ ( '\\'' | '\\\\' )
{
if ((input.LA(1) >= '\u0000' && input.LA(1) <= '&') || (input.LA(1) >= '(' && input.LA(1) <= '[') || (input.LA(1) >= ']' && input.LA(1) <= '\uFFFF')) {
input.consume();
} else {
MismatchedSetException mse = new MismatchedSetException(null, input);
recover(mse);
throw mse;
}
}
break;
}
match('\'');
}
state.type = _type;
state.channel = _channel;
} finally {
}
}
use of org.antlr.runtime.NoViableAltException in project n4js by eclipse.
the class InternalHighlightingParser method allowASI.
@Override
public boolean allowASI(final RecognitionException re) {
if (re instanceof NoViableAltException) {
final NoViableAltException nvae = (NoViableAltException) re;
if (asiRecoveredEx != null && re.index == asiRecoveredEx.index && nvae.decisionNumber == asiRecoveredEx.decisionNumber) {
return false;
}
asiRecoveredEx = nvae;
}
return true;
}
use of org.antlr.runtime.NoViableAltException 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.NoViableAltException 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;
}
}
}
Aggregations