You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by fr...@apache.org on 2001/12/03 13:45:56 UTC
cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/parser BasicSQLParserManager.java BasicSQLParserTokenManager.java BasicSQLParserConstants.java
froehlich 01/12/03 04:45:55
Modified: apps/db/src/java/org/apache/avalon/db/basic/parser
BasicSQLParserManager.java
Removed: apps/db/src/java/org/apache/avalon/db/basic/parser
BasicSQLParserTokenManager.java
BasicSQLParserConstants.java
Log:
BasicSQLParser leveled up to BasicSQLParserManager
Revision Changes Path
1.2 +7 -621 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/parser/BasicSQLParserManager.java
Index: BasicSQLParserManager.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/parser/BasicSQLParserManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BasicSQLParserManager.java 2001/12/03 11:18:36 1.1
+++ BasicSQLParserManager.java 2001/12/03 12:45:55 1.2
@@ -1,22 +1,18 @@
-/* Generated By:JavaCC: Do not edit this line. BasicSQLParserManager.java */
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE file.
+ */
package org.apache.avalon.db.basic.parser;
import org.apache.avalon.db.server.sql.AbstractSQLParser;
-import org.apache.avalon.db.server.sql.ParseException;
-import org.apache.avalon.db.server.sql.SimpleCharStream;
-import org.apache.avalon.db.server.sql.Token;
-import org.apache.avalon.db.server.sql.TokenMgrError;
import org.apache.avalon.db.server.AbstractRequestHandler;
-import org.apache.avalon.db.server.stdhandlers.PingHandler;
-import org.apache.avalon.db.server.stdhandlers.CatalogHandler;
-import org.apache.avalon.db.server.stdhandlers.EstablishConnectionHandler;
import org.apache.avalon.db.transport.Request;
-import org.apache.avalon.db.basic.handlers.BasicCloseResultSetHandler;
import org.apache.avalon.db.actions.Action;
import org.apache.avalon.db.actions.ActionException;
-import java.util.ArrayList;
-
/**
* Class BasicSQLParserManager
*
@@ -34,614 +30,4 @@
setupLogger(action);
action.initialize();
}
-
- public static void main(String args[]) {
- BasicSQLParserManager parser = new BasicSQLParserManager(System.in);
- try {
- parser.Test();
- } catch(ParseException pe) {
- pe.printStackTrace();
- }
- }
-
-/**
- * Test Method for command line input
- */
- static final public void Test() throws ParseException {
- parseSQLString();
- }
-
- static final public String parseSQLString() throws ParseException {
- String stm;
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case SELECT:
- stm = Select();
- break;
- 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);
- throw new ParseException();
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case 59:
- jj_consume_token(59);
- break;
- case 0:
- jj_consume_token(0);
- break;
- default:
- jj_la1[1] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- {if (true) return stm;}
- throw new Error("Missing return statement in function");
- }
-
- static final public String Select() throws ParseException {
- String stm;
- jj_consume_token(SELECT);
- stm = "SELECT";
- getColumns();
- jj_consume_token(FROM);
- getTables();
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case WHERE:
- Where();
- break;
- default:
- jj_la1[2] = jj_gen;
- ;
- }
- {if (true) return stm;}
- throw new Error("Missing return statement in function");
- }
-
- static final public String Update() throws ParseException {
- String stm;
- 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");
- }
-
- static final public void Rollback() 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 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 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 {
- jj_consume_token(0);
- }
-
- static final public void Alter() throws ParseException {
- jj_consume_token(0);
- }
-
- static final public void Where() throws ParseException {
- jj_consume_token(WHERE);
- OrExpr();
- }
-
- static final public void OrExpr() throws ParseException {
- AndExpr();
- label_4:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case OR:
- ;
- break;
- default:
- jj_la1[10] = jj_gen;
- break label_4;
- }
- jj_consume_token(OR);
- System.out.println("in or");
- AndExpr();
- }
- }
-
- static final public void AndExpr() throws ParseException {
- NotExpr();
- label_5:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case AND:
- ;
- break;
- default:
- jj_la1[11] = jj_gen;
- break label_5;
- }
- jj_consume_token(AND);
- System.out.println("in and");
- NotExpr();
- }
- }
-
- static final public void NotExpr() throws ParseException {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case NOT:
- jj_consume_token(NOT);
- System.out.println("in not");
- break;
- default:
- jj_la1[12] = jj_gen;
- ;
- }
- CompareExpr();
- }
-
- 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);
- 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("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");
- break;
- case SMALLERTHAN:
- jj_consume_token(SMALLERTHAN);
- System.out.println("SMALLERTHAN");
- break;
- case GREATERTHANOREQUAL:
- jj_consume_token(GREATERTHANOREQUAL);
- System.out.println("GREATERTHANOREQUAL");
- break;
- case SMALLERTHANOREQUAL:
- jj_consume_token(SMALLERTHANOREQUAL);
- System.out.println("SMALLERTHANOREQUAL");
- break;
- case LIKE:
- jj_consume_token(LIKE);
- System.out.println("LIKE");
- break;
- default:
- 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 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_6:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case 60:
- ;
- break;
- default:
- jj_la1[17] = jj_gen;
- break label_6;
- }
- jj_consume_token(60);
- System.out.println(",");
- column = jj_consume_token(IDENTIFIER);
- System.out.println("column=" + column.image);
- }
- break;
- default:
- jj_la1[18] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
-
- static final public void getTables() throws ParseException {
- String tab;
- Token table;
- table = jj_consume_token(IDENTIFIER);
- System.out.println("table=" + table.image);
- label_7:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case 60:
- ;
- break;
- default:
- jj_la1[19] = jj_gen;
- break label_7;
- }
- 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[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 BasicSQLParserManager(java.io.InputStream stream) {
- if (jj_initialized_once) {
- System.out.println("ERROR: Second call to constructor of static parser. You must");
- System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
- System.out.println(" during parser generation.");
- throw new Error();
- }
- jj_initialized_once = true;
- jj_input_stream = new SimpleCharStream(stream, 1, 1);
- token_source = new BasicSQLParserTokenManager(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 21; i++) jj_la1[i] = -1;
- }
-
- static public void ReInit(java.io.InputStream stream) {
- jj_input_stream.ReInit(stream, 1, 1);
- token_source.ReInit(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 21; i++) jj_la1[i] = -1;
- }
-
- public BasicSQLParserManager(java.io.Reader stream) {
- if (jj_initialized_once) {
- System.out.println("ERROR: Second call to constructor of static parser. You must");
- System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
- System.out.println(" during parser generation.");
- throw new Error();
- }
- jj_initialized_once = true;
- jj_input_stream = new SimpleCharStream(stream, 1, 1);
- token_source = new BasicSQLParserTokenManager(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 21; i++) jj_la1[i] = -1;
- }
-
- static public void ReInit(java.io.Reader stream) {
- jj_input_stream.ReInit(stream, 1, 1);
- token_source.ReInit(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 21; i++) jj_la1[i] = -1;
- }
-
- public BasicSQLParserManager(BasicSQLParserTokenManager tm) {
- if (jj_initialized_once) {
- System.out.println("ERROR: Second call to constructor of static parser. You must");
- System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
- System.out.println(" during parser generation.");
- throw new Error();
- }
- jj_initialized_once = true;
- token_source = tm;
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 21; i++) jj_la1[i] = -1;
- }
-
- public void ReInit(BasicSQLParserTokenManager tm) {
- token_source = tm;
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 21; i++) jj_la1[i] = -1;
- }
-
- static final private Token jj_consume_token(int kind) throws ParseException {
- Token oldToken;
- if ((oldToken = token).next != null) token = token.next;
- else token = token.next = token_source.getNextToken();
- jj_ntk = -1;
- if (token.kind == kind) {
- jj_gen++;
- return token;
- }
- token = oldToken;
- jj_kind = kind;
- throw generateParseException();
- }
-
- static final public Token getNextToken() {
- if (token.next != null) token = token.next;
- else token = token.next = token_source.getNextToken();
- jj_ntk = -1;
- jj_gen++;
- return token;
- }
-
- static final public Token getToken(int index) {
- Token t = token;
- for (int i = 0; i < index; i++) {
- if (t.next != null) t = t.next;
- else t = t.next = token_source.getNextToken();
- }
- return t;
- }
-
- static final private int jj_ntk() {
- if ((jj_nt=token.next) == null)
- return (jj_ntk = (token.next=token_source.getNextToken()).kind);
- else
- return (jj_ntk = jj_nt.kind);
- }
-
- static private java.util.Vector jj_expentries = new java.util.Vector();
- static private int[] jj_expentry;
- static private int jj_kind = -1;
-
- static final public ParseException generateParseException() {
- jj_expentries.removeAllElements();
- 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 < 21; i++) {
- if (jj_la1[i] == jj_gen) {
- for (int j = 0; j < 32; j++) {
- if ((jj_la1_0[i] & (1<<j)) != 0) {
- la1tokens[j] = true;
- }
- if ((jj_la1_1[i] & (1<<j)) != 0) {
- la1tokens[32+j] = true;
- }
- }
- }
- }
- for (int i = 0; i < 64; i++) {
- if (la1tokens[i]) {
- jj_expentry = new int[1];
- jj_expentry[0] = i;
- jj_expentries.addElement(jj_expentry);
- }
- }
- int[][] exptokseq = new int[jj_expentries.size()][];
- for (int i = 0; i < jj_expentries.size(); i++) {
- exptokseq[i] = (int[])jj_expentries.elementAt(i);
- }
- return new ParseException(token, exptokseq, tokenImage);
- }
-
- static final public void enable_tracing() {
- }
-
- static final public void disable_tracing() {
- }
-
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>