@Override public BigInteger visitNumericLiteral(NumericLiteralContext ctx) { return new BigInteger(ctx.INTEGER_VALUE().getText()); }
@JsonProperty("reason") @Override public String toString() { return "Undeclared variable " + ctx.Identifier().getText() + positionString(); }
/** {@inheritDoc} */ @Override public Set<String> visitXgTree(XGBoostModelParser.XgTreeContext ctx) { Set<String> featureNames = new HashSet<>(); for (XGBoostModelParser.XgNodeContext nodeCtx : ctx.xgNode()) { String featureName = nodeCtx.STRING().getText(); featureNames.add(featureName); } return featureNames; } }
private String parseIdentifier(InfluxLineProtocolParser.IdentifierContext ctx) { if (ctx.BOOLEAN() != null || ctx.NUMBER() != null) { return ctx.getText(); } return IDENTIFIER_PATTERN.matcher(ctx.IDENTIFIER_STRING().getText()).replaceAll("$1"); }
@Override public Node visitBinaryLiteral(SqlBaseParser.BinaryLiteralContext context) { String raw = context.BINARY_LITERAL().getText(); return new BinaryLiteral(getLocation(context), unquote(raw.substring(1))); }
/** * WHERE clause */ public Integer where(HplsqlParser.Where_clauseContext ctx) { boolean oldBuildSql = exec.buildSql; exec.buildSql = true; StringBuilder sql = new StringBuilder(); sql.append(ctx.T_WHERE().getText()); sql.append(" " + evalPop(ctx.bool_expr())); exec.stackPush(sql); exec.buildSql = oldBuildSql; return 0; }
/** * Parses value (int of double). * * @param valCtx Value context. * @return Value. */ private double parseXgValue(XGBoostModelParser.XgValueContext valCtx) { TerminalNode terminalNode = valCtx.INT() != null ? valCtx.INT() : valCtx.DOUBLE(); return Double.valueOf(terminalNode.getText()); } }
@Override public Node visitSetProperty(final SqlBaseParser.SetPropertyContext context) { final String propertyName = unquote(context.STRING(0).getText(), "'"); final String propertyValue = unquote(context.STRING(1).getText(), "'"); return new SetProperty(Optional.ofNullable(getLocation(context)), propertyName, propertyValue); }
private void parseField(InfluxLineProtocolParser.Field_pairContext field, Map<String, Object> out) { String key = parseIdentifier(field.identifier()); InfluxLineProtocolParser.Field_valueContext valueContext = field.field_value(); Object value; if (valueContext.NUMBER() != null) { value = parseNumber(valueContext.NUMBER().getText()); } else if (valueContext.BOOLEAN() != null) { value = parseBool(valueContext.BOOLEAN().getText()); } else { value = parseQuotedString(valueContext.QUOTED_STRING().getText()); } out.put(key, value); }
@Override public Node visitBasicStringLiteral(SqlBaseParser.BasicStringLiteralContext context) { return new StringLiteral(getLocation(context), unquote(context.STRING().getText())); }
@Override public void exitNamedArgs(RuleLangParser.NamedArgsContext ctx) { final Map<String, Expression> argMap = Maps.newHashMap(); for (RuleLangParser.PropAssignmentContext propAssignmentContext : ctx.propAssignment()) { final String argName = unquote(propAssignmentContext.Identifier().getText(), '`'); final Expression argValue = exprs.get(propAssignmentContext.expression()); argMap.put(argName, argValue); } args.put(ctx, argMap); }
private void setProperty(final SqlBaseParser.SingleStatementContext statementContext) { final SqlBaseParser.SetPropertyContext setPropertyContext = (SqlBaseParser.SetPropertyContext) statementContext.statement(); final String property = AstBuilder.unquote(setPropertyContext.STRING(0).getText(), "'"); final String value = AstBuilder.unquote(setPropertyContext.STRING(1).getText(), "'"); setProperty(property, value); }
@Override public Node visitUnsetProperty(final SqlBaseParser.UnsetPropertyContext context) { final String propertyName = unquote(context.STRING().getText(), "'"); return new UnsetProperty(Optional.ofNullable(getLocation(context)), propertyName); }
@Override public Node visitBinaryLiteral(final SqlBaseParser.BinaryLiteralContext context) { final String raw = context.BINARY_LITERAL().getText(); return new BinaryLiteral(getLocation(context), unquote(raw.substring(1), "'")); }
@Override public void exitMapLiteralExpr(RuleLangParser.MapLiteralExprContext ctx) { final HashMap<String, Expression> map = Maps.newHashMap(); for (RuleLangParser.PropAssignmentContext propAssignmentContext : ctx.propAssignment()) { final String key = unquote(propAssignmentContext.Identifier().getText(), '`'); final Expression value = exprs.get(propAssignmentContext.expression()); map.put(key, value); } exprs.put(ctx, new MapLiteralExpression(ctx.getStart(), map)); }
@Override public Node visitTimeZoneString(final SqlBaseParser.TimeZoneStringContext context) { return new StringLiteral(getLocation(context), unquote(context.STRING().getText(), "'")); }
@Override public void exitUnquotedIdentifier(SqlBaseParser.UnquotedIdentifierContext context) { String identifier = context.IDENTIFIER().getText(); for (IdentifierSymbol identifierSymbol : EnumSet.complementOf(allowedIdentifierSymbols)) { char symbol = identifierSymbol.getSymbol(); if (identifier.indexOf(symbol) >= 0) { throw new ParsingException("identifiers must not contain '" + identifierSymbol.getSymbol() + "'", null, context.IDENTIFIER().getSymbol().getLine(), context.IDENTIFIER().getSymbol().getCharPositionInLine()); } } }
/** * CREATE TABLE options for MySQL */ public Integer createTableMysqlOptions(HplsqlParser.Create_table_options_mysql_itemContext ctx) { if (ctx.T_COMMENT() != null) { evalString(ctx.T_COMMENT().getText() + " " + evalPop(ctx.expr()).toSqlString()); } return 0; }