avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From froehl...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/parser BasicSQLParserTokenManager.java BasicSQLParserConstants.java BasicSQLParser.java
Date Fri, 30 Nov 2001 16:00:15 GMT
froehlich    01/11/30 08:00:15

  Modified:    apps/db/src/java/org/apache/avalon/db/basic/parser
                        BasicSQLParserTokenManager.java
                        BasicSQLParserConstants.java BasicSQLParser.java
  Log:
  SELECT,UPDATE,INSERT,DROP,DELETE and WHERE are parsed now. Halfway done ;)
  
  Revision  Changes    Path
  1.3       +13 -16    jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/parser/BasicSQLParserTokenManager.java
  
  Index: BasicSQLParserTokenManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/parser/BasicSQLParserTokenManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BasicSQLParserTokenManager.java	2001/11/29 20:21:31	1.2
  +++ BasicSQLParserTokenManager.java	2001/11/30 16:00:15	1.3
  @@ -41,11 +41,17 @@
         case 32:
            jjmatchedKind = 1;
            return jjMoveNfa_0(5, 0);
  +      case 40:
  +         jjmatchedKind = 61;
  +         return jjMoveNfa_0(5, 0);
  +      case 41:
  +         jjmatchedKind = 62;
  +         return jjMoveNfa_0(5, 0);
         case 42:
  -         jjmatchedKind = 60;
  +         jjmatchedKind = 63;
            return jjMoveNfa_0(5, 0);
         case 44:
  -         jjmatchedKind = 61;
  +         jjmatchedKind = 60;
            return jjMoveNfa_0(5, 0);
         case 59:
            jjmatchedKind = 59;
  @@ -75,8 +81,6 @@
            return jjMoveStringLiteralDfa1_0(0x4000000000L);
         case 73:
            return jjMoveStringLiteralDfa1_0(0x1080081000L);
  -      case 76:
  -         return jjMoveStringLiteralDfa1_0(0x8000000000000L);
         case 78:
            return jjMoveStringLiteralDfa1_0(0x200000000000L);
         case 79:
  @@ -158,7 +162,7 @@
         case 72:
            return jjMoveStringLiteralDfa2_0(active0, 0x400000000L);
         case 73:
  -         return jjMoveStringLiteralDfa2_0(active0, 0x8040100008300L);
  +         return jjMoveStringLiteralDfa2_0(active0, 0x40100008300L);
         case 76:
            return jjMoveStringLiteralDfa2_0(active0, 0x2000000L);
         case 77:
  @@ -252,8 +256,6 @@
            return jjMoveStringLiteralDfa3_0(active0, 0x500800000L);
         case 71:
            return jjMoveStringLiteralDfa3_0(active0, 0x8000L);
  -      case 75:
  -         return jjMoveStringLiteralDfa3_0(active0, 0x8000000000000L);
         case 76:
            return jjMoveStringLiteralDfa3_0(active0, 0x2000460000L);
         case 77:
  @@ -365,11 +367,6 @@
               jjmatchedKind = 14;
               jjmatchedPos = 3;
            }
  -         else if ((active0 & 0x8000000000000L) != 0L)
  -         {
  -            jjmatchedKind = 51;
  -            jjmatchedPos = 3;
  -         }
            return jjMoveStringLiteralDfa4_0(active0, 0x210024a1100L);
         case 73:
            return jjMoveStringLiteralDfa4_0(active0, 0x400000a000L);
  @@ -1324,16 +1321,16 @@
   "", null, null, null, null, null, null, null, null, null, null, null, null, 
   null, null, null, null, null, null, null, null, null, null, null, null, null, null, 
   null, null, null, null, null, null, null, null, null, null, null, null, null, null, 
  -null, null, null, null, null, "\75", "\76", "\74", "\76\75", "\74\75", null, null, 
  -null, null, null, null, null, null, "\73", "\52", "\54", };
  +null, null, null, null, null, "\75", "\76", "\74", "\76\75", "\74\75", 
  +"\154\151\153\145", null, null, null, null, null, null, null, "\73", "\54", "\50", "\51",
"\52", };
   public static final String[] lexStateNames = {
      "DEFAULT", 
   };
   static final long[] jjtoToken = {
  -   0x3d9fffffffffff81L, 
  +   0xfd9fffffffffff81L, 0x0L, 
   };
   static final long[] jjtoSkip = {
  -   0x7eL, 
  +   0x7eL, 0x0L, 
   };
   static private SimpleCharStream input_stream;
   static private final int[] jjrounds = new int[42];
  
  
  
  1.3       +3 -1      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/parser/BasicSQLParserConstants.java
  
  Index: BasicSQLParserConstants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/parser/BasicSQLParserConstants.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BasicSQLParserConstants.java	2001/11/29 20:21:31	1.2
  +++ BasicSQLParserConstants.java	2001/11/30 16:00:15	1.3
  @@ -122,8 +122,10 @@
       "<EXPONENT>",
       "<STRING_LITERAL>",
       "\";\"",
  -    "\"*\"",
       "\",\"",
  +    "\"(\"",
  +    "\")\"",
  +    "\"*\"",
     };
   
   }
  
  
  
  1.4       +247 -52   jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/parser/BasicSQLParser.java
  
  Index: BasicSQLParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/parser/BasicSQLParser.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BasicSQLParser.java	2001/11/29 20:21:31	1.3
  +++ BasicSQLParser.java	2001/11/30 16:00:15	1.4
  @@ -27,6 +27,8 @@
       protected void getCustomRequestHandlers(AbstractRequestHandler[] handlers) {
       }
   
  +    public BasicSQLParser() { }
  +
       public void initializeAction(Action action) throws ActionException {
           action.setDatabasePersistor(mDatabasePersistor);
           setupLogger(action);
  @@ -47,7 +49,6 @@
    */
     static final public void Test() throws ParseException {
       parseSQLString();
  -    jj_consume_token(59);
     }
   
     static final public String parseSQLString() throws ParseException {
  @@ -59,6 +60,15 @@
       case UPDATE:
         stm = Update();
         break;
  +    case INSERT:
  +      stm = Insert();
  +      break;
  +    case DROP:
  +      stm = Drop();
  +      break;
  +    case DELETE:
  +      stm = Delete();
  +      break;
       default:
         jj_la1[0] = jj_gen;
         jj_consume_token(-1);
  @@ -82,7 +92,6 @@
   
     static final public String Select() throws ParseException {
       String stm;
  -    Token token;
       jj_consume_token(SELECT);
             stm = "SELECT";
       getColumns();
  @@ -102,9 +111,42 @@
   
     static final public String Update() throws ParseException {
        String stm;
  -     Token token;
       jj_consume_token(UPDATE);
             stm = "UPDATE";
  +    getTables();
  +    jj_consume_token(SET);
  +    label_1:
  +    while (true) {
  +      jj_consume_token(IDENTIFIER);
  +      jj_consume_token(EQUAL);
  +      ExprValue();
  +      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +      case 60:
  +        jj_consume_token(60);
  +                  System.out.println(",");
  +        break;
  +      default:
  +        jj_la1[3] = jj_gen;
  +        ;
  +      }
  +      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +      case IDENTIFIER:
  +        ;
  +        break;
  +      default:
  +        jj_la1[4] = jj_gen;
  +        break label_1;
  +      }
  +    }
  +    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +    case WHERE:
  +      Where();
  +      break;
  +    default:
  +      jj_la1[5] = jj_gen;
  +      ;
  +    }
  +      System.out.println("Row(s) updated ;-)");
         {if (true) return stm;}
       throw new Error("Missing return statement in function");
     }
  @@ -113,20 +155,83 @@
       jj_consume_token(0);
     }
   
  -  static final public void Insert() throws ParseException {
  -    jj_consume_token(0);
  +  static final public String Insert() throws ParseException {
  +    String stm;
  +    jj_consume_token(INSERT);
  +    jj_consume_token(INTO);
  +                     stm = "INSERT";
  +    jj_consume_token(IDENTIFIER);
  +    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +    case 61:
  +      label_2:
  +      while (true) {
  +        jj_consume_token(61);
  +        getColumns();
  +        jj_consume_token(62);
  +        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +        case 61:
  +          ;
  +          break;
  +        default:
  +          jj_la1[6] = jj_gen;
  +          break label_2;
  +        }
  +      }
  +      break;
  +    default:
  +      jj_la1[7] = jj_gen;
  +      ;
  +    }
  +    label_3:
  +    while (true) {
  +      jj_consume_token(VALUES);
  +      jj_consume_token(61);
  +      getValues();
  +      jj_consume_token(62);
  +      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +      case VALUES:
  +        ;
  +        break;
  +      default:
  +        jj_la1[8] = jj_gen;
  +        break label_3;
  +      }
  +    }
  +      {if (true) return stm;}
  +    throw new Error("Missing return statement in function");
     }
   
     static final public void Grant() throws ParseException {
       jj_consume_token(0);
     }
   
  -  static final public void Drop() throws ParseException {
  -    jj_consume_token(0);
  +  static final public String Drop() throws ParseException {
  +    String stm;
  +    jj_consume_token(DROP);
  +          stm = "DROP";
  +    jj_consume_token(IDENTIFIER);
  +      System.out.println("Table droped ;-)");
  +      {if (true) return stm;}
  +    throw new Error("Missing return statement in function");
     }
   
  -  static final public void Delete() throws ParseException {
  -    jj_consume_token(0);
  +  static final public String Delete() throws ParseException {
  +    String stm;
  +    jj_consume_token(DELETE);
  +    jj_consume_token(FROM);
  +          stm = "DELETE";
  +    jj_consume_token(IDENTIFIER);
  +    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +    case WHERE:
  +      Where();
  +      break;
  +    default:
  +      jj_la1[9] = jj_gen;
  +      ;
  +    }
  +      System.out.println("Row(s) deleted ;-)");
  +      {if (true) return stm;}
  +    throw new Error("Missing return statement in function");
     }
   
     static final public void Commit() throws ParseException {
  @@ -139,38 +244,38 @@
   
     static final public void Where() throws ParseException {
       jj_consume_token(WHERE);
  -            OrExpr();
  +          OrExpr();
     }
   
     static final public void OrExpr() throws ParseException {
       AndExpr();
  -    label_1:
  +    label_4:
       while (true) {
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
         case OR:
           ;
           break;
         default:
  -        jj_la1[3] = jj_gen;
  -        break label_1;
  +        jj_la1[10] = jj_gen;
  +        break label_4;
         }
         jj_consume_token(OR);
  +             System.out.println("in or");
         AndExpr();
  -          System.out.println("in or");
       }
     }
   
     static final public void AndExpr() throws ParseException {
       NotExpr();
  -    label_2:
  +    label_5:
       while (true) {
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
         case AND:
           ;
           break;
         default:
  -        jj_la1[4] = jj_gen;
  -        break label_2;
  +        jj_la1[11] = jj_gen;
  +        break label_5;
         }
         jj_consume_token(AND);
             System.out.println("in and");
  @@ -185,7 +290,7 @@
                 System.out.println("in not");
         break;
       default:
  -      jj_la1[5] = jj_gen;
  +      jj_la1[12] = jj_gen;
         ;
       }
       CompareExpr();
  @@ -194,67 +299,139 @@
     static final public void CompareExpr() throws ParseException {
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
       case IDENTIFIER:
  +    case INTEGER_LITERAL:
  +    case FLOATING_POINT_LITERAL:
  +    case STRING_LITERAL:
  +      ExprValue();
  +      CompareOps();
  +      ExprValue();
  +      break;
  +    case 61:
  +      Term();
  +      break;
  +    default:
  +      jj_la1[13] = jj_gen;
  +      jj_consume_token(-1);
  +      throw new ParseException();
  +    }
  +  }
  +
  +  static final public void ExprValue() throws ParseException {
  +    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +    case IDENTIFIER:
         jj_consume_token(IDENTIFIER);
  -      jj_consume_token(EQUAL);
  +                   System.out.println("expr is <INDENTIFIER>");
  +      break;
  +    case STRING_LITERAL:
  +      jj_consume_token(STRING_LITERAL);
  +                         System.out.println("expr is <STRING_LITERAL>");
  +      break;
  +    case INTEGER_LITERAL:
  +      jj_consume_token(INTEGER_LITERAL);
  +                          System.out.println("expr is <INTEGER_LITERAL>");
  +      break;
  +    case FLOATING_POINT_LITERAL:
  +      jj_consume_token(FLOATING_POINT_LITERAL);
  +                                 System.out.println("expr is <FLOATING_POINT_LITERAL>");
  +      break;
  +    default:
  +      jj_la1[14] = jj_gen;
  +      jj_consume_token(-1);
  +      throw new ParseException();
  +    }
  +  }
  +
  +  static final public void UpdateValue() throws ParseException {
  +    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +    case STRING_LITERAL:
         jj_consume_token(STRING_LITERAL);
  -                                              System.out.println("EQUAL");
  +                       System.out.println("value is <STRING_LITERAL>");
         break;
  +    case INTEGER_LITERAL:
  +      jj_consume_token(INTEGER_LITERAL);
  +                          System.out.println("value is <INTEGER_LITERAL>");
  +      break;
  +    case FLOATING_POINT_LITERAL:
  +      jj_consume_token(FLOATING_POINT_LITERAL);
  +                                 System.out.println("value expr is <FLOATING_POINT_LITERAL>");
  +      break;
  +    default:
  +      jj_la1[15] = jj_gen;
  +      jj_consume_token(-1);
  +      throw new ParseException();
  +    }
  +  }
  +
  +  static final public void CompareOps() throws ParseException {
  +    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +    case EQUAL:
  +      jj_consume_token(EQUAL);
  +              System.out.println("EQUAL");
  +      break;
       case GREATERTHAN:
         jj_consume_token(GREATERTHAN);
  -                          System.out.println("GREATERTHAN");
  +                       System.out.println("GREATERTHAN");
         break;
       case SMALLERTHAN:
         jj_consume_token(SMALLERTHAN);
  -                          System.out.println("SMALLERTHAN");
  +                       System.out.println("SMALLERTHAN");
         break;
       case GREATERTHANOREQUAL:
         jj_consume_token(GREATERTHANOREQUAL);
  -                                 System.out.println("GREATERTHANOREQUAL");
  +                              System.out.println("GREATERTHANOREQUAL");
         break;
       case SMALLERTHANOREQUAL:
         jj_consume_token(SMALLERTHANOREQUAL);
  -                                 System.out.println("SMALLERTHANOREQUAL");
  +                              System.out.println("SMALLERTHANOREQUAL");
         break;
       case LIKE:
         jj_consume_token(LIKE);
  -                   System.out.println("LIKE");
  +                System.out.println("LIKE");
         break;
       default:
  -      jj_la1[6] = jj_gen;
  +      jj_la1[16] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
       }
     }
   
  +  static final public void Term() throws ParseException {
  +    jj_consume_token(61);
  +             System.out.println("(");
  +    OrExpr();
  +    jj_consume_token(62);
  +             System.out.println(")");
  +  }
  +
     static final public void getColumns() throws ParseException {
       String col;
       Token column;
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  -    case 60:
  -      jj_consume_token(60);
  +    case 63:
  +      jj_consume_token(63);
               System.out.println("all columns");
         break;
       case IDENTIFIER:
         column = jj_consume_token(IDENTIFIER);
                              System.out.println("column=" + column.image);
  -      label_3:
  +      label_6:
         while (true) {
           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  -        case 61:
  +        case 60:
             ;
             break;
           default:
  -          jj_la1[7] = jj_gen;
  -          break label_3;
  +          jj_la1[17] = jj_gen;
  +          break label_6;
           }
  -        jj_consume_token(61);
  +        jj_consume_token(60);
               System.out.println(",");
           column = jj_consume_token(IDENTIFIER);
                                  System.out.println("column=" + column.image);
         }
         break;
       default:
  -      jj_la1[8] = jj_gen;
  +      jj_la1[18] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
       }
  @@ -265,32 +442,50 @@
       Token table;
       table = jj_consume_token(IDENTIFIER);
                             System.out.println("table=" + table.image);
  -    label_4:
  +    label_7:
       while (true) {
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  -      case 61:
  +      case 60:
           ;
           break;
         default:
  -        jj_la1[9] = jj_gen;
  -        break label_4;
  +        jj_la1[19] = jj_gen;
  +        break label_7;
         }
  -      jj_consume_token(61);
  +      jj_consume_token(60);
               System.out.println(",");
         table = jj_consume_token(IDENTIFIER);
                                 System.out.println("table=" + table.image);
       }
     }
   
  +  static final public void getValues() throws ParseException {
  +    UpdateValue();
  +    label_8:
  +    while (true) {
  +      jj_consume_token(60);
  +            System.out.println(",");
  +      UpdateValue();
  +      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +      case 60:
  +        ;
  +        break;
  +      default:
  +        jj_la1[20] = jj_gen;
  +        break label_8;
  +      }
  +    }
  +  }
  +
     static private boolean jj_initialized_once = false;
     static public BasicSQLParserTokenManager token_source;
     static SimpleCharStream jj_input_stream;
     static public Token token, jj_nt;
     static private int jj_ntk;
     static private int jj_gen;
  -  static final private int[] jj_la1 = new int[10];
  -  static final private int[] jj_la1_0 = {0x30000,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};
  -  static final private int[] jj_la1_1 = {0x0,0x8000000,0x4,0x1000,0x800,0x2000,0x1f8000,0x20000000,0x10100000,0x20000000,};
  +  static final private int[] jj_la1 = new int[21];
  +  static final private int[] jj_la1_0 = {0x6b0000,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};
  +  static final private int[] jj_la1_1 = {0x0,0x8000000,0x4,0x10000000,0x100000,0x4,0x20000000,0x20000000,0x20,0x4,0x1000,0x800,0x2000,0x25900000,0x5900000,0x5800000,0xfc000,0x10000000,0x80100000,0x10000000,0x10000000,};
   
     public BasicSQLParser(java.io.InputStream stream) {
       if (jj_initialized_once) {
  @@ -305,7 +500,7 @@
       token = new Token();
       jj_ntk = -1;
       jj_gen = 0;
  -    for (int i = 0; i < 10; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < 21; i++) jj_la1[i] = -1;
     }
   
     static public void ReInit(java.io.InputStream stream) {
  @@ -314,7 +509,7 @@
       token = new Token();
       jj_ntk = -1;
       jj_gen = 0;
  -    for (int i = 0; i < 10; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < 21; i++) jj_la1[i] = -1;
     }
   
     public BasicSQLParser(java.io.Reader stream) {
  @@ -330,7 +525,7 @@
       token = new Token();
       jj_ntk = -1;
       jj_gen = 0;
  -    for (int i = 0; i < 10; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < 21; i++) jj_la1[i] = -1;
     }
   
     static public void ReInit(java.io.Reader stream) {
  @@ -339,7 +534,7 @@
       token = new Token();
       jj_ntk = -1;
       jj_gen = 0;
  -    for (int i = 0; i < 10; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < 21; i++) jj_la1[i] = -1;
     }
   
     public BasicSQLParser(BasicSQLParserTokenManager tm) {
  @@ -354,7 +549,7 @@
       token = new Token();
       jj_ntk = -1;
       jj_gen = 0;
  -    for (int i = 0; i < 10; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < 21; i++) jj_la1[i] = -1;
     }
   
     public void ReInit(BasicSQLParserTokenManager tm) {
  @@ -362,7 +557,7 @@
       token = new Token();
       jj_ntk = -1;
       jj_gen = 0;
  -    for (int i = 0; i < 10; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < 21; i++) jj_la1[i] = -1;
     }
   
     static final private Token jj_consume_token(int kind) throws ParseException {
  @@ -409,15 +604,15 @@
   
     static final public ParseException generateParseException() {
       jj_expentries.removeAllElements();
  -    boolean[] la1tokens = new boolean[62];
  -    for (int i = 0; i < 62; i++) {
  +    boolean[] la1tokens = new boolean[64];
  +    for (int i = 0; i < 64; i++) {
         la1tokens[i] = false;
       }
       if (jj_kind >= 0) {
         la1tokens[jj_kind] = true;
         jj_kind = -1;
       }
  -    for (int i = 0; i < 10; i++) {
  +    for (int i = 0; i < 21; i++) {
         if (jj_la1[i] == jj_gen) {
           for (int j = 0; j < 32; j++) {
             if ((jj_la1_0[i] & (1<<j)) != 0) {
  @@ -429,7 +624,7 @@
           }
         }
       }
  -    for (int i = 0; i < 62; i++) {
  +    for (int i = 0; i < 64; i++) {
         if (la1tokens[i]) {
           jj_expentry = new int[1];
           jj_expentry[0] = i;
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message