use of antlr.NoViableAltException in project cxf by apache.
the class IDLParser method case_stmt.
public final void case_stmt() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
AST case_stmt_AST = null;
try {
// for error handling
{
int _cnt160 = 0;
_loop160: do {
switch(LA(1)) {
case LITERAL_case:
{
AST tmp154_AST = null;
tmp154_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp154_AST);
match(LITERAL_case);
const_exp();
astFactory.addASTChild(currentAST, returnAST);
match(COLON);
break;
}
case LITERAL_default:
{
AST tmp156_AST = null;
tmp156_AST = astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp156_AST);
match(LITERAL_default);
match(COLON);
break;
}
default:
{
if (_cnt160 >= 1) {
break _loop160;
} else {
throw new NoViableAltException(LT(1), getFilename());
}
}
}
_cnt160++;
} while (true);
}
element_spec();
astFactory.addASTChild(currentAST, returnAST);
match(SEMI);
case_stmt_AST = (AST) currentAST.root;
} catch (RecognitionException ex) {
if (inputState.guessing == 0) {
reportError(ex);
consume();
consumeUntil(_tokenSet_52);
} else {
throw ex;
}
}
returnAST = case_stmt_AST;
}
use of antlr.NoViableAltException in project cxf by apache.
the class IDLParser method simple_type_spec.
public final void simple_type_spec() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
AST simple_type_spec_AST = null;
try {
// for error handling
switch(LA(1)) {
case LITERAL_float:
case LITERAL_double:
case LITERAL_long:
case LITERAL_short:
case LITERAL_unsigned:
case LITERAL_char:
case LITERAL_wchar:
case LITERAL_boolean:
case LITERAL_octet:
case LITERAL_any:
case LITERAL_Object:
case LITERAL_ValueBase:
{
base_type_spec();
astFactory.addASTChild(currentAST, returnAST);
simple_type_spec_AST = (AST) currentAST.root;
break;
}
case LITERAL_sequence:
case LITERAL_string:
case LITERAL_wstring:
case LITERAL_fixed:
{
template_type_spec();
astFactory.addASTChild(currentAST, returnAST);
simple_type_spec_AST = (AST) currentAST.root;
break;
}
case SCOPEOP:
case IDENT:
{
scoped_name();
astFactory.addASTChild(currentAST, returnAST);
simple_type_spec_AST = (AST) currentAST.root;
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
} catch (RecognitionException ex) {
if (inputState.guessing == 0) {
reportError(ex);
consume();
consumeUntil(_tokenSet_36);
} else {
throw ex;
}
}
returnAST = simple_type_spec_AST;
}
use of antlr.NoViableAltException in project sonarqube by SonarSource.
the class ValidWhenParser method integer.
public final void integer() throws RecognitionException, TokenStreamException {
Token d = null;
Token h = null;
Token o = null;
switch(LA(1)) {
case DECIMAL_LITERAL:
{
d = LT(1);
match(DECIMAL_LITERAL);
argStack.push(Integer.decode(d.getText()));
break;
}
case HEX_LITERAL:
{
h = LT(1);
match(HEX_LITERAL);
argStack.push(Integer.decode(h.getText()));
break;
}
case OCTAL_LITERAL:
{
o = LT(1);
match(OCTAL_LITERAL);
argStack.push(Integer.decode(o.getText()));
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
use of antlr.NoViableAltException in project sonarqube by SonarSource.
the class ValidWhenParser method expr.
public final void expr() throws RecognitionException, TokenStreamException {
if ((LA(1) == LPAREN) && (_tokenSet_1.member(LA(2)))) {
match(LPAREN);
comparisonExpression();
match(RPAREN);
} else if ((LA(1) == LPAREN) && (LA(2) == LPAREN)) {
match(LPAREN);
joinedExpression();
match(RPAREN);
} else {
throw new NoViableAltException(LT(1), getFilename());
}
}
use of antlr.NoViableAltException in project groovy by apache.
the class SourceUnit method failedWithUnexpectedEOF.
/**
* Convenience routine, primarily for use by the InteractiveShell,
* that returns true if parse() failed with an unexpected EOF.
*/
public boolean failedWithUnexpectedEOF() {
// If you find another way, please add it.
if (getErrorCollector().hasErrors()) {
Message last = (Message) getErrorCollector().getLastError();
Throwable cause = null;
if (last instanceof SyntaxErrorMessage) {
cause = ((SyntaxErrorMessage) last).getCause().getCause();
}
if (cause != null) {
if (cause instanceof NoViableAltException) {
return isEofToken(((NoViableAltException) cause).token);
} else if (cause instanceof NoViableAltForCharException) {
char badChar = ((NoViableAltForCharException) cause).foundChar;
return badChar == CharScanner.EOF_CHAR;
} else if (cause instanceof MismatchedCharException) {
char badChar = (char) ((MismatchedCharException) cause).foundChar;
return badChar == CharScanner.EOF_CHAR;
} else if (cause instanceof MismatchedTokenException) {
return isEofToken(((MismatchedTokenException) cause).token);
}
}
}
return false;
}
Aggregations