⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mysqlparser.java

📁 mysql集群
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        jj_consume_token(IDENTIFIER);
        break;
      case S_COMMA_IDENTIFIER:
        jj_consume_token(S_COMMA_IDENTIFIER);
        break;
      default:
        jj_la1[86] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      break;
    default:
      jj_la1[87] = jj_gen;
      ;
    }
    label_16:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case 128:
        ;
        break;
      default:
        jj_la1[88] = jj_gen;
        break label_16;
      }
      jj_consume_token(128);
      OrderByColumn();
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case IDENTIFIER:
      case S_COMMA_IDENTIFIER:
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case IDENTIFIER:
          jj_consume_token(IDENTIFIER);
          break;
        case S_COMMA_IDENTIFIER:
          jj_consume_token(S_COMMA_IDENTIFIER);
          break;
        default:
          jj_la1[89] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
        break;
      default:
        jj_la1[90] = jj_gen;
        ;
      }
    }
  }

  final public void OrderByColumn() throws ParseException {
    SQLSimpleExpression();
  }

  final public Expression SQLExpression() throws ParseException {
        OrExpression orExpression = null;
        AndExpression andExpression = null;
        Expression expression = null;
        Token token;
        int count = 0;
    expression = SQLAndExpression();
        orExpression = new OrExpression(expression);
    label_17:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case K_OR:
        ;
        break;
      default:
        jj_la1[91] = jj_gen;
        break label_17;
      }
      jj_consume_token(K_OR);
      expression = SQLAndExpression();
                        count++;
                        orExpression.addExpression(expression);
    }
        if(count >0){
                {if (true) return orExpression;}
        }else{
                {if (true) return expression;}
        }
    throw new Error("Missing return statement in function");
  }

  final public Expression SQLAndExpression() throws ParseException {
        AndExpression andExpression = null;;
        Expression expression;
        Expression currentExpression;
    expression = SQLUnaryLogicalExpression();
    label_18:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case K_AND:
        ;
        break;
      default:
        jj_la1[92] = jj_gen;
        break label_18;
      }
      jj_consume_token(K_AND);
      currentExpression = SQLUnaryLogicalExpression();
        if(andExpression == null && currentExpression != null){
                andExpression = new AndExpression(expression);
        }
        if(currentExpression != null){
                andExpression.addExpression(currentExpression);
        }
    }
        if(andExpression != null){
                {if (true) return andExpression;}
        }else{
                {if (true) return expression;}
        }
    throw new Error("Missing return statement in function");
  }

  final public Expression SQLUnaryLogicalExpression() throws ParseException {
        Expression expression = null;
        boolean not = false;
    if (jj_2_13(2)) {
      ExistsClause();
    } else if (jj_2_14(1)) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case K_NOT:
        jj_consume_token(K_NOT);
            not = true;
        break;
      default:
        jj_la1[93] = jj_gen;
        ;
      }
      expression = SQLRelationalExpression();
                {if (true) return reverseExpression(not,expression);}
    } else {
      jj_consume_token(-1);
      throw new ParseException();
    }
    throw new Error("Missing return statement in function");
  }

  final public Expression ExistsClause() throws ParseException {
        Expression expression = null;
        boolean not = false;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case K_NOT:
      jj_consume_token(K_NOT);
           not = true;
      break;
    default:
      jj_la1[94] = jj_gen;
      ;
    }
    jj_consume_token(K_EXISTS);
    jj_consume_token(129);
    expression = FullSelectStatement();
    jj_consume_token(130);
        {if (true) return reverseExpression(not,expression);}
    throw new Error("Missing return statement in function");
  }

  final public Expression SQLRelationalExpression() throws ParseException {
        Expression expression = null;
        Expression otherExpression = null;
        String functionName = null;
        int function = 0;
    if (jj_2_15(2147483647)) {
      jj_consume_token(129);
      SQLExpressionList();
      jj_consume_token(130);
    } else if (jj_2_16(1)) {
      expression = SQLSimpleExpression();
    } else {
      jj_consume_token(-1);
      throw new ParseException();
    }
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case K_BETWEEN:
    case K_IN:
    case K_IS:
    case K_LIKE:
    case K_NOT:
    case 127:
    case 131:
    case 132:
    case 133:
    case 134:
    case 135:
    case 136:
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case 127:
      case 131:
      case 132:
      case 133:
      case 134:
      case 135:
      case 136:
        functionName = Relop();
                function =      Comparative.getComparisonByIdent(functionName);
        otherExpression = SQLRelationalOperatorExpression();
                                if(expression == null ||  otherExpression == null){
                                        {if (true) return null;}
                                }

                                if(expression instanceof ColumnExpression && !(otherExpression instanceof ColumnExpression)){
                                        ColumnExpression colExp = (ColumnExpression)expression;
                                        ComparisonExpression comparativeExpression = new ComparisonExpression();
                                        comparativeExpression.setComparison(function);
                                        comparativeExpression.setExpression(otherExpression);
                                        colExp.setExpression(comparativeExpression);
                                        {if (true) return colExp;}
                                }else if(!(expression instanceof ColumnExpression) && (otherExpression instanceof ColumnExpression)){
                                        ColumnExpression colExp = (ColumnExpression)otherExpression;
                                        ComparisonExpression comparativeExpression = new ComparisonExpression();
                                        comparativeExpression.setComparison(Comparative.exchangeComparison(function));
                                        comparativeExpression.setExpression(expression);
                                        colExp.setExpression(comparativeExpression);
                                        {if (true) return colExp;}
                                }else{
                                        {if (true) return null;}
                                }
        break;
      default:
        jj_la1[95] = jj_gen;
        if (jj_2_17(2)) {
          otherExpression = SQLInClause(expression);
                        {if (true) return otherExpression;}
        } else if (jj_2_18(2)) {
          otherExpression = SQLBetweenClause(expression);
                {if (true) return otherExpression;}
        } else if (jj_2_19(2)) {
          otherExpression = SQLLikeClause();
                if(expression instanceof ColumnExpression){
                        ColumnExpression colExp = (ColumnExpression)expression;
                        colExp.setExpression((ComparisonExpression)otherExpression);
                        {if (true) return colExp;}
                }else{
                        {if (true) return null;}
                }
        } else if (jj_2_20(2)) {
          otherExpression = IsNullClause();
                if(expression instanceof ColumnExpression){
                        ColumnExpression colExp = (ColumnExpression)expression;
                        colExp.setExpression((ComparisonExpression)otherExpression);
                        {if (true) return colExp;}
                }else{
                        {if (true) return null;}
                }
        } else {
          jj_consume_token(-1);
          throw new ParseException();
        }
      }
      break;
    default:
      jj_la1[96] = jj_gen;
      ;
    }
                {if (true) return expression;}
    throw new Error("Missing return statement in function");
  }

  final public List<Expression> SQLExpressionList() throws ParseException {
        List<Expression> list = new ArrayList<Expression>();
        Expression expression;
    expression = SQLSimpleExpression();
        list.add(expression);
    label_19:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case 128:
        ;
        break;
      default:
        jj_la1[97] = jj_gen;
        break label_19;
      }
      jj_consume_token(128);
      expression = SQLSimpleExpression();
                list.add(expression);
    }
        {if (true) return list;}
    throw new Error("Missing return statement in function");
  }

  final public Expression SQLRelationalOperatorExpression() throws ParseException {
        Expression expression = null;
        String functionName;
        int function;
    if (jj_2_21(2147483647)) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case K_ALL:
      case K_ANY:
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case K_ALL:
          jj_consume_token(K_ALL);
          break;
        case K_ANY:
          jj_consume_token(K_ANY);
          break;
        default:
          jj_la1[98] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
        break;
      default:
        jj_la1[99] = jj_gen;
        ;
      }
      jj_consume_token(129);
      FullSelectStatement();
      jj_consume_token(130);
    } else if (jj_2_22(1)) {
      expression = SQLSimpleExpression();
    } else {
      jj_consume_token(-1);
      throw new ParseException();
    }
        {if (true) return expression;}
    throw new Error("Missing return statement in function");
  }

  final public Expression SQLInClause(Expression inputExpression) throws ParseException {
        boolean not = false;
        Expression expression = null;
        List<Expression> list = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case K_NOT:
      jj_consume_token(K_NOT);
           not = true;
      break;
    default:
      jj_la1[100] = jj_gen;
      ;
    }
    jj_consume_token(K_IN);
    jj_consume_token(129);
    if (jj_2_23(2)) {
      list = SQLExpressionList();
    } else {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case K_SELECT:
      case 129:
        expression = FullSelectStatement();
        break;
      default:
        jj_la1[101] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    }
    jj_consume_token(130);
        if(list == null){
                {if (true) return expression;}
        }
        if(list.size()==1){

                Expression item = list.get(0);
                ComparisonExpression comparativeExpression = new ComparisonExpression();
                comparativeExpression.setExpression(item);
                comparativeExpression.setComparison(not?Comparative.NotEquivalent:Comparative.Equivalent);

                if(inputExpression instanceof ColumnExpression){
                                ((ColumnExpression)inputExpression).setExpression(comparativeExpression);
                                {if (true) return  inputExpression;}
                }else{
                        {if (true) return comparativeExpression;}
                }

        }else{
                BaseExpressionList baseList = null;
                if(not){
                        baseList = new AndExpression(null);
                }else{
                        baseList = new OrExpression(null);
                }

                for(Expression item:list){

                        ComparisonExpression comparativeExpression = new ComparisonExpression();
                        comparativeExpression.setExpression(item);
                        comparativeExpression.setComparison(not?Comparative.NotEquivalent:Comparative.Equivalent);
                        if(inputExpression instanceof ColumnExpression){
                                ColumnExpression columnExpression = new ColumnExpression();
                                columnExpression.setExpression(comparativeExpression);
                                columnExpression.setColumn(((ColumnExpression)inputExpression).getColumn());
                                baseList.addExpression(columnExpression);
                        }else{
                                baseList.addExpression(comparativeExpression);
                        }
                }
                {if (true) return baseList;}
        }
    throw new Error("Missing return statement in function");
  }

  final public Expression SQLBetweenClause(Expression inputExpression) throws ParseException {
        boolean not = false;
        Expression minExpression = null;
        Expression maxExpression = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case K_NOT:
      jj_consume_token(K_NOT);
           not = true;
      break;
    default:
      jj_la1[102] = jj_gen;
      ;
    }
    jj_consume_token(K_BETWEEN);
    minExpression = SQLSimpleExpression();
    jj_consume_token(K_AND);
    maxExpression = SQLSimpleExpression();
        ComparisonExpression comparativeMinExpression = new ComparisonExpression();
        comparativeMinExpression.setExpression(minExpression);
        comparativeMinExpression.setComparison(Comparative.GreaterThanOrEqual);

        ComparisonExpression comparativeMaxExpression = new ComparisonExpression();
        comparativeMaxExpression.setExpression(maxExpression);
        comparativeMaxExpression.setComparison(Comparative.LessThanOrEqual);
        AndExpression andExpression = new AndExpression();
        if(inputExpression instanceof ColumnExpression){
                ColumnExpression columnMinExpression = new ColumnExpression();
                        columnMinExpression.setExpression(comparativeMinExpression);
                        columnMinExpression.setColumn(

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -