protected SQLExpr parseInterval() { accept(Token.INTERVAL); if (lexer.token() == Token.LPAREN) { lexer.nextToken(); SQLMethodInvokeExpr methodInvokeExpr = new SQLMethodInvokeExpr("INTERVAL"); if (lexer.token() != Token.RPAREN) { exprList(methodInvokeExpr.getParameters(), methodInvokeExpr); } accept(Token.RPAREN); return primaryRest(methodInvokeExpr); } else { SQLExpr value = expr(); if (lexer.token() != Token.IDENTIFIER) { throw new ParserException("Syntax error"); } String unit = lexer.stringVal(); lexer.nextToken(); MySqlIntervalExpr intervalExpr = new MySqlIntervalExpr(); intervalExpr.setValue(value); intervalExpr.setUnit(MySqlIntervalUnit.valueOf(unit.toUpperCase())); return intervalExpr; } }
@Override public boolean visit(MySqlIntervalExpr x) { print("INTERVAL "); x.getValue().accept(this); print(' '); print(x.getUnit().name()); return false; }