in src/platform/packages/shared/kbn-monaco/src/languages/painless/antlr/painless_parser.ts [488:778]
public rstatement(): RstatementContext {
let localctx: RstatementContext = new RstatementContext(this, this._ctx, this.state);
this.enterRule(localctx, 8, painless_parser.RULE_rstatement);
let _la: number;
try {
let _alt: number;
this.state = 179;
this._errHandler.sync(this);
switch ( this._interp.adaptivePredict(this._input, 12, this._ctx) ) {
case 1:
localctx = new IfContext(this, localctx);
this.enterOuterAlt(localctx, 1);
{
this.state = 119;
this.match(painless_parser.IF);
this.state = 120;
this.match(painless_parser.LP);
this.state = 121;
this.expression();
this.state = 122;
this.match(painless_parser.RP);
this.state = 123;
this.trailer();
this.state = 127;
this._errHandler.sync(this);
switch ( this._interp.adaptivePredict(this._input, 5, this._ctx) ) {
case 1:
{
this.state = 124;
this.match(painless_parser.ELSE);
this.state = 125;
this.trailer();
}
break;
case 2:
{
this.state = 126;
if (!( this._input.LA(1) != painless_parser.ELSE )) {
throw this.createFailedPredicateException(" this._input.LA(1) != painless_parser.ELSE ");
}
}
break;
}
}
break;
case 2:
localctx = new WhileContext(this, localctx);
this.enterOuterAlt(localctx, 2);
{
this.state = 129;
this.match(painless_parser.WHILE);
this.state = 130;
this.match(painless_parser.LP);
this.state = 131;
this.expression();
this.state = 132;
this.match(painless_parser.RP);
this.state = 135;
this._errHandler.sync(this);
switch (this._input.LA(1)) {
case 3:
case 5:
case 7:
case 9:
case 14:
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
case 26:
case 29:
case 30:
case 34:
case 35:
case 59:
case 60:
case 73:
case 74:
case 75:
case 76:
case 77:
case 78:
case 79:
case 80:
case 81:
case 82:
case 83:
case 84:
{
this.state = 133;
this.trailer();
}
break;
case 13:
{
this.state = 134;
this.empty();
}
break;
default:
throw new NoViableAltException(this);
}
}
break;
case 3:
localctx = new ForContext(this, localctx);
this.enterOuterAlt(localctx, 3);
{
this.state = 137;
this.match(painless_parser.FOR);
this.state = 138;
this.match(painless_parser.LP);
this.state = 140;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (((((_la - 5)) & ~0x1F) === 0 && ((1 << (_la - 5)) & 1661206549) !== 0) || ((((_la - 59)) & ~0x1F) === 0 && ((1 << (_la - 59)) & 67092483) !== 0)) {
{
this.state = 139;
this.initializer();
}
}
this.state = 142;
this.match(painless_parser.SEMICOLON);
this.state = 144;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (((((_la - 5)) & ~0x1F) === 0 && ((1 << (_la - 5)) & 1661206549) !== 0) || ((((_la - 59)) & ~0x1F) === 0 && ((1 << (_la - 59)) & 41926659) !== 0)) {
{
this.state = 143;
this.expression();
}
}
this.state = 146;
this.match(painless_parser.SEMICOLON);
this.state = 148;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (((((_la - 5)) & ~0x1F) === 0 && ((1 << (_la - 5)) & 1661206549) !== 0) || ((((_la - 59)) & ~0x1F) === 0 && ((1 << (_la - 59)) & 41926659) !== 0)) {
{
this.state = 147;
this.afterthought();
}
}
this.state = 150;
this.match(painless_parser.RP);
this.state = 153;
this._errHandler.sync(this);
switch (this._input.LA(1)) {
case 3:
case 5:
case 7:
case 9:
case 14:
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
case 26:
case 29:
case 30:
case 34:
case 35:
case 59:
case 60:
case 73:
case 74:
case 75:
case 76:
case 77:
case 78:
case 79:
case 80:
case 81:
case 82:
case 83:
case 84:
{
this.state = 151;
this.trailer();
}
break;
case 13:
{
this.state = 152;
this.empty();
}
break;
default:
throw new NoViableAltException(this);
}
}
break;
case 4:
localctx = new EachContext(this, localctx);
this.enterOuterAlt(localctx, 4);
{
this.state = 155;
this.match(painless_parser.FOR);
this.state = 156;
this.match(painless_parser.LP);
this.state = 157;
this.decltype();
this.state = 158;
this.match(painless_parser.ID);
this.state = 159;
this.match(painless_parser.COLON);
this.state = 160;
this.expression();
this.state = 161;
this.match(painless_parser.RP);
this.state = 162;
this.trailer();
}
break;
case 5:
localctx = new IneachContext(this, localctx);
this.enterOuterAlt(localctx, 5);
{
this.state = 164;
this.match(painless_parser.FOR);
this.state = 165;
this.match(painless_parser.LP);
this.state = 166;
this.match(painless_parser.ID);
this.state = 167;
this.match(painless_parser.IN);
this.state = 168;
this.expression();
this.state = 169;
this.match(painless_parser.RP);
this.state = 170;
this.trailer();
}
break;
case 6:
localctx = new TryContext(this, localctx);
this.enterOuterAlt(localctx, 6);
{
this.state = 172;
this.match(painless_parser.TRY);
this.state = 173;
this.block();
this.state = 175;
this._errHandler.sync(this);
_alt = 1;
do {
switch (_alt) {
case 1:
{
{
this.state = 174;
this.trap();
}
}
break;
default:
throw new NoViableAltException(this);
}
this.state = 177;
this._errHandler.sync(this);
_alt = this._interp.adaptivePredict(this._input, 11, this._ctx);
} while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER);
}
break;
}
}
catch (re) {
if (re instanceof RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
} else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}