in modules/lang-painless/src/main/java/org/elasticsearch/painless/antlr/PainlessParser.java [941:1213]
public final RstatementContext rstatement() throws RecognitionException {
RstatementContext _localctx = new RstatementContext(_ctx, getState());
enterRule(_localctx, 8, RULE_rstatement);
int _la;
try {
int _alt;
setState(179);
_errHandler.sync(this);
switch (getInterpreter().adaptivePredict(_input, 12, _ctx)) {
case 1:
_localctx = new IfContext(_localctx);
enterOuterAlt(_localctx, 1); {
setState(119);
match(IF);
setState(120);
match(LP);
setState(121);
expression();
setState(122);
match(RP);
setState(123);
trailer();
setState(127);
_errHandler.sync(this);
switch (getInterpreter().adaptivePredict(_input, 5, _ctx)) {
case 1: {
setState(124);
match(ELSE);
setState(125);
trailer();
}
break;
case 2: {
setState(126);
if (!(_input.LA(1) != ELSE)) throw new FailedPredicateException(this, " _input.LA(1) != ELSE ");
}
break;
}
}
break;
case 2:
_localctx = new WhileContext(_localctx);
enterOuterAlt(_localctx, 2); {
setState(129);
match(WHILE);
setState(130);
match(LP);
setState(131);
expression();
setState(132);
match(RP);
setState(135);
_errHandler.sync(this);
switch (_input.LA(1)) {
case LBRACK:
case LBRACE:
case LP:
case DOLLAR:
case IF:
case WHILE:
case DO:
case FOR:
case CONTINUE:
case BREAK:
case RETURN:
case NEW:
case TRY:
case THROW:
case BOOLNOT:
case BWNOT:
case ADD:
case SUB:
case INCR:
case DECR:
case OCTAL:
case HEX:
case INTEGER:
case DECIMAL:
case STRING:
case REGEX:
case TRUE:
case FALSE:
case NULL:
case PRIMITIVE:
case DEF:
case ID: {
setState(133);
trailer();
}
break;
case SEMICOLON: {
setState(134);
empty();
}
break;
default:
throw new NoViableAltException(this);
}
}
break;
case 3:
_localctx = new ForContext(_localctx);
enterOuterAlt(_localctx, 3); {
setState(137);
match(FOR);
setState(138);
match(LP);
setState(140);
_errHandler.sync(this);
_la = _input.LA(1);
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 1729382310068880032L) != 0)
|| ((((_la - 73)) & ~0x3f) == 0 && ((1L << (_la - 73)) & 4095L) != 0)) {
{
setState(139);
initializer();
}
}
setState(142);
match(SEMICOLON);
setState(144);
_errHandler.sync(this);
_la = _input.LA(1);
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 1729382310068880032L) != 0)
|| ((((_la - 73)) & ~0x3f) == 0 && ((1L << (_la - 73)) & 2559L) != 0)) {
{
setState(143);
expression();
}
}
setState(146);
match(SEMICOLON);
setState(148);
_errHandler.sync(this);
_la = _input.LA(1);
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 1729382310068880032L) != 0)
|| ((((_la - 73)) & ~0x3f) == 0 && ((1L << (_la - 73)) & 2559L) != 0)) {
{
setState(147);
afterthought();
}
}
setState(150);
match(RP);
setState(153);
_errHandler.sync(this);
switch (_input.LA(1)) {
case LBRACK:
case LBRACE:
case LP:
case DOLLAR:
case IF:
case WHILE:
case DO:
case FOR:
case CONTINUE:
case BREAK:
case RETURN:
case NEW:
case TRY:
case THROW:
case BOOLNOT:
case BWNOT:
case ADD:
case SUB:
case INCR:
case DECR:
case OCTAL:
case HEX:
case INTEGER:
case DECIMAL:
case STRING:
case REGEX:
case TRUE:
case FALSE:
case NULL:
case PRIMITIVE:
case DEF:
case ID: {
setState(151);
trailer();
}
break;
case SEMICOLON: {
setState(152);
empty();
}
break;
default:
throw new NoViableAltException(this);
}
}
break;
case 4:
_localctx = new EachContext(_localctx);
enterOuterAlt(_localctx, 4); {
setState(155);
match(FOR);
setState(156);
match(LP);
setState(157);
decltype();
setState(158);
match(ID);
setState(159);
match(COLON);
setState(160);
expression();
setState(161);
match(RP);
setState(162);
trailer();
}
break;
case 5:
_localctx = new IneachContext(_localctx);
enterOuterAlt(_localctx, 5); {
setState(164);
match(FOR);
setState(165);
match(LP);
setState(166);
match(ID);
setState(167);
match(IN);
setState(168);
expression();
setState(169);
match(RP);
setState(170);
trailer();
}
break;
case 6:
_localctx = new TryContext(_localctx);
enterOuterAlt(_localctx, 6); {
setState(172);
match(TRY);
setState(173);
block();
setState(175);
_errHandler.sync(this);
_alt = 1;
do {
switch (_alt) {
case 1: {
{
setState(174);
trap();
}
}
break;
default:
throw new NoViableAltException(this);
}
setState(177);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input, 11, _ctx);
} while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER);
}
break;
}
} catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
} finally {
exitRule();
}
return _localctx;
}