Package com.alibaba.druid.sql.parser

Examples of com.alibaba.druid.sql.parser.Lexer


  }

  @Test
  public void testLexer() {
    String sql = "SELECT * FROM T WHERE F1 = ? ORDER BY F2";
    Lexer lexer = new Lexer(sql);
    System.out.println("--------------------------------------------");
    for (;;) {
      lexer.nextToken();
      Token tok = lexer.token();

      if (tok == Token.IDENTIFIER) {
        System.out.println(tok.name() + "\t\t" + lexer.stringVal());
      } else {
        System.out.println(tok.name() + "\t\t\t" + tok.name);
      }

      if (tok == Token.EOF) {
View Full Code Here


        return out.toString();
    }
   
    public static SQLExpr toSQLExpr(String sql) {
        Lexer lexer = new Lexer(sql);
        lexer.nextToken();

        SQLExprParser parser = new SQLExprParser(lexer);
        SQLExpr expr = parser.expr();

        if (lexer.token() != Token.EOF) {
            throw new ParserException("illegal sql expr : " + sql);
        }

        return expr;
    }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.sql.parser.Lexer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.