in x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/parser/SqlBaseParser.java [5488:5678]
private ValueExpressionContext valueExpression(int _p) throws RecognitionException {
ParserRuleContext _parentctx = _ctx;
int _parentState = getState();
ValueExpressionContext _localctx = new ValueExpressionContext(_ctx, _parentState);
ValueExpressionContext _prevctx = _localctx;
int _startState = 68;
enterRecursionRule(_localctx, 68, RULE_valueExpression, _p);
int _la;
try {
int _alt;
enterOuterAlt(_localctx, 1);
{
setState(632);
_errHandler.sync(this);
switch (_input.LA(1)) {
case T__0:
case ANALYZE:
case ANALYZED:
case CASE:
case CAST:
case CATALOGS:
case COLUMNS:
case CONVERT:
case CURRENT_DATE:
case CURRENT_TIME:
case CURRENT_TIMESTAMP:
case DAY:
case DEBUG:
case EXECUTABLE:
case EXPLAIN:
case EXTRACT:
case FALSE:
case FIRST:
case FORMAT:
case FULL:
case FUNCTIONS:
case GRAPHVIZ:
case HOUR:
case INTERVAL:
case LAST:
case LEFT:
case LIMIT:
case MAPPED:
case MINUTE:
case MONTH:
case NULL:
case OPTIMIZED:
case PARSED:
case PHYSICAL:
case PIVOT:
case PLAN:
case RIGHT:
case RLIKE:
case QUERY:
case SCHEMAS:
case SECOND:
case SHOW:
case SYS:
case TABLES:
case TEXT:
case TRUE:
case TOP:
case TYPE:
case TYPES:
case VERIFY:
case YEAR:
case FUNCTION_ESC:
case DATE_ESC:
case TIME_ESC:
case TIMESTAMP_ESC:
case GUID_ESC:
case ASTERISK:
case PARAM:
case STRING:
case INTEGER_VALUE:
case DECIMAL_VALUE:
case IDENTIFIER:
case DIGIT_IDENTIFIER:
case QUOTED_IDENTIFIER:
case BACKQUOTED_IDENTIFIER: {
_localctx = new ValueExpressionDefaultContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
setState(629);
primaryExpression(0);
}
break;
case PLUS:
case MINUS: {
_localctx = new ArithmeticUnaryContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
setState(630);
((ArithmeticUnaryContext) _localctx).operator = _input.LT(1);
_la = _input.LA(1);
if (!(_la == PLUS || _la == MINUS)) {
((ArithmeticUnaryContext) _localctx).operator = (Token) _errHandler.recoverInline(this);
} else {
if (_input.LA(1) == Token.EOF) matchedEOF = true;
_errHandler.reportMatch(this);
consume();
}
setState(631);
valueExpression(4);
}
break;
default:
throw new NoViableAltException(this);
}
_ctx.stop = _input.LT(-1);
setState(646);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input, 90, _ctx);
while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) {
if (_alt == 1) {
if (_parseListeners != null) triggerExitRuleEvent();
_prevctx = _localctx;
{
setState(644);
_errHandler.sync(this);
switch (getInterpreter().adaptivePredict(_input, 89, _ctx)) {
case 1: {
_localctx = new ArithmeticBinaryContext(new ValueExpressionContext(_parentctx, _parentState));
((ArithmeticBinaryContext) _localctx).left = _prevctx;
pushNewRecursionContext(_localctx, _startState, RULE_valueExpression);
setState(634);
if (!(precpred(_ctx, 3))) throw new FailedPredicateException(this, "precpred(_ctx, 3)");
setState(635);
((ArithmeticBinaryContext) _localctx).operator = _input.LT(1);
_la = _input.LA(1);
if (!(((((_la - 121)) & ~0x3f) == 0 && ((1L << (_la - 121)) & 7L) != 0))) {
((ArithmeticBinaryContext) _localctx).operator = (Token) _errHandler.recoverInline(this);
} else {
if (_input.LA(1) == Token.EOF) matchedEOF = true;
_errHandler.reportMatch(this);
consume();
}
setState(636);
((ArithmeticBinaryContext) _localctx).right = valueExpression(4);
}
break;
case 2: {
_localctx = new ArithmeticBinaryContext(new ValueExpressionContext(_parentctx, _parentState));
((ArithmeticBinaryContext) _localctx).left = _prevctx;
pushNewRecursionContext(_localctx, _startState, RULE_valueExpression);
setState(637);
if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)");
setState(638);
((ArithmeticBinaryContext) _localctx).operator = _input.LT(1);
_la = _input.LA(1);
if (!(_la == PLUS || _la == MINUS)) {
((ArithmeticBinaryContext) _localctx).operator = (Token) _errHandler.recoverInline(this);
} else {
if (_input.LA(1) == Token.EOF) matchedEOF = true;
_errHandler.reportMatch(this);
consume();
}
setState(639);
((ArithmeticBinaryContext) _localctx).right = valueExpression(3);
}
break;
case 3: {
_localctx = new ComparisonContext(new ValueExpressionContext(_parentctx, _parentState));
((ComparisonContext) _localctx).left = _prevctx;
pushNewRecursionContext(_localctx, _startState, RULE_valueExpression);
setState(640);
if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)");
setState(641);
comparisonOperator();
setState(642);
((ComparisonContext) _localctx).right = valueExpression(2);
}
break;
}
}
}
setState(648);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input, 90, _ctx);
}
}
} catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
} finally {
unrollRecursionContexts(_parentctx);
}
return _localctx;
}