You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/05/09 22:18:03 UTC
svn commit: r169351 [7/12] - in /incubator/beehive/trunk/system-controls: ./
ant/ external/ external/commons/ external/ejb/ external/jms/ src/ src/ejb/
src/ejb/org/ src/ejb/org/apache/ src/ejb/org/apache/beehive/
src/ejb/org/apache/beehive/controls/
src/ejb/org/apache/beehive/controls/system/
src/ejb/org/apache/beehive/controls/system/ejb/ src/ejb/schema/ src/jdbc/
src/jdbc/org/ src/jdbc/org/apache/ src/jdbc/org/apache/beehive/
src/jdbc/org/apache/beehive/controls/
src/jdbc/org/apache/beehive/controls/system/
src/jdbc/org/apache/beehive/controls/system/jdbc/
src/jdbc/org/apache/beehive/controls/system/jdbc/parser/ src/jms/
src/jms/org/ src/jms/org/apache/ src/jms/org/apache/beehive/
src/jms/org/apache/beehive/controls/
src/jms/org/apache/beehive/controls/system/
src/jms/org/apache/beehive/controls/system/jms/
src/jms/org/apache/beehive/controls/system/jms/impl/
src/jms/org/apache/beehive/controls/system/jndi/
src/jms/org/apache/beehive/controls/system/jndi/impl/ src/webservice/
src/webservice/org/ src/webservice/org/apache/
src/webservice/org/apache/beehive/
src/webservice/org/apache/beehive/controls/
src/webservice/org/apache/beehive/controls/system/
src/webservice/org/apache/beehive/controls/system/webservice/
src/webservice/org/apache/beehive/controls/system/webservice/generator/
src/webservice/org/apache/beehive/controls/system/webservice/jaxrpc/
src/webservice/org/apache/beehive/controls/system/webservice/utils/ test/
test/ant/ test/conf/ test/src/ test/src/jdbc/ test/src/jdbc/controls/
test/src/jdbc/controls/org/ test/src/jdbc/controls/org/apache/
test/src/jdbc/controls/org/apache/beehive/
test/src/jdbc/controls/org/apache/beehive/controls/
test/src/jdbc/controls/org/apache/beehive/controls/system/
test/src/jdbc/controls/org/apache/beehive/controls/system/jdbc/
test/src/jdbc/controls/org/apache/beehive/controls/system/jdbc/test/
test/src/jdbc/controls/org/apache/beehive/controls/system/jdbc/test/dbconnection/
test/src/jdbc/controls/org/apache/beehive/controls/system/jdbc/test/errors/
test/src/jdbc/controls/org/apache/beehive/controls/system/jdbc/test/results/
test/src/jdbc/controls/schemas/ test/src/jdbc/controls/schemas/badusers/
test/src/jdbc/controls/schemas/users/ test/src/jdbc/jdbc-container/
test/src/jdbc/jdbc-container/application/ test/src/jdbc/jdbc-container/src/
test/src/jdbc/jdbc-container/src/org/
test/src/jdbc/jdbc-container/src/org/apache/
test/src/jdbc/jdbc-container/src/org/apache/beehive/
test/src/jdbc/jdbc-container/src/org/apache/beehive/controls/
test/src/jdbc/jdbc-container/src/org/apache/beehive/controls/system/
test/src/jdbc/jdbc-container/src/org/apache/beehive/controls/system/jdbc/
test/src/jdbc/jdbc-container/src/org/apache/beehive/controls/system/jdbc/containertest/
test/src/jdbc/jdbc-container/webapp/
test/src/jdbc/jdbc-container/webapp/WEB-INF/
test/src/jdbc/jdbc-container/webapp/conf/
test/src/jdbc/jdbc-container/webapp/conf/Catalina/
test/src/jdbc/jdbc-container/webapp/conf/Catalina/localhost/
test/src/jdbc/junitTests/ test/src/jdbc/junitTests/org/
test/src/jdbc/junitTests/org/apache/
test/src/jdbc/junitTests/org/apache/beehive/
test/src/jdbc/junitTests/org/apache/beehive/controls/
test/src/jdbc/junitTests/org/apache/beehive/controls/system/
test/src/jdbc/junitTests/org/apache/beehive/controls/system/jdbc/
test/src/jdbc/junitTests/org/apache/beehive/controls/system/jdbc/units/
test/src/jdbc/junitTests/org/apache/beehive/controls/system/jdbc/units/dbconnection/
test/src/jdbc/junitTests/org/apache/beehive/controls/system/jdbc/units/errors/
test/src/jdbc/junitTests/org/apache/beehive/controls/system/jdbc/units/results/
test/src/jdbc/junitTests/org/apache/beehive/controls/system/jdbc/units/sqlparser/
test/src/jdbc/junitTests/org/apache/beehive/controls/system/jdbc/units/utils/
Added: incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammar.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammar.java?rev=169351&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammar.java (added)
+++ incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammar.java Mon May 9 13:17:58 2005
@@ -0,0 +1,514 @@
+/* Generated By:JavaCC: Do not edit this line. SqlGrammar.java */
+package org.apache.beehive.controls.system.jdbc.parser;
+import java.io.StringReader;
+
+public class SqlGrammar implements SqlGrammarConstants {
+ private StringBuilder buffer = new StringBuilder();
+ public static void main(String[] args) throws Exception
+ {
+ SqlGrammar parser = new SqlGrammar(new StringReader(args[0]));
+ SqlStatement statement = parser.parse();
+ System.out.println(statement.toString());
+ }
+
+//
+// Parse methods
+//
+
+
+//
+// Main parse method
+//
+ final public SqlStatement parse() throws ParseException {
+ SqlStatement statement = new SqlStatement();
+ SqlFragment frag;
+ Token t, sq;
+ label_1:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case NON_EXPRESSION_TEXT:
+ case START_EXPRESSION:
+ case SQUOTE:
+ ;
+ break;
+ default:
+ jj_la1[0] = jj_gen;
+ break label_1;
+ }
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case NON_EXPRESSION_TEXT:
+ t = jj_consume_token(NON_EXPRESSION_TEXT);
+ statement.addChild(new LiteralFragment(t.image));
+ break;
+ case SQUOTE:
+ sq = jj_consume_token(SQUOTE);
+ t = jj_consume_token(STRING_LITERAL);
+ statement.addChild(new LiteralFragment(sq.image + t.image));
+ break;
+ case START_EXPRESSION:
+ frag = parseExpression();
+ statement.addChild(frag);
+ break;
+ default:
+ jj_la1[1] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ jj_consume_token(0);
+ {if (true) return statement;}
+ throw new Error("Missing return statement in function");
+ }
+
+//
+// Parse an expression delimited by '{}'
+//
+ final public SqlFragment parseExpression() throws ParseException {
+ Token t, tt = null;
+ SqlFragment frag = null;
+ jj_consume_token(START_EXPRESSION);
+ label_2:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case WHITESPACE:
+ ;
+ break;
+ default:
+ jj_la1[2] = jj_gen;
+ break label_2;
+ }
+ jj_consume_token(WHITESPACE);
+ }
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case SQL_ESCAPE:
+ case SQL_SUBST:
+ case SQL_FN:
+ frag = parseSqlEscape();
+ break;
+ case JDBC_CALL:
+ case JDBC_RET:
+ case JDBC_DATE:
+ case JDBC_TIME:
+ case JDBC_TIMESTAMP:
+ case JDBC_FUNCTION:
+ case JDBC_ESCAPE:
+ case JDBC_OUTERJOIN:
+ frag = parseJdbcEscape();
+ break;
+ case IDENTIFIER:
+ t = jj_consume_token(IDENTIFIER);
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case REFLECT_SEP:
+ jj_consume_token(REFLECT_SEP);
+ tt = jj_consume_token(IDENTIFIER);
+ break;
+ default:
+ jj_la1[3] = jj_gen;
+ ;
+ }
+ jj_consume_token(END_EXPRESSION);
+ frag = new ReflectionFragment(t.image,(tt == null) ? null : tt.image);
+ break;
+ default:
+ jj_la1[4] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ label_3:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case WHITESPACE:
+ ;
+ break;
+ default:
+ jj_la1[5] = jj_gen;
+ break label_3;
+ }
+ jj_consume_token(WHITESPACE);
+ }
+ {if (true) return frag;}
+ throw new Error("Missing return statement in function");
+ }
+
+//
+// parse an sql: escape sequence
+//
+ final public SqlSubstitutionFragment parseSqlEscape() throws ParseException {
+ Token id1, id2;
+ Token t = null;
+ SqlSubstitutionFragment frag;
+ String func = null;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case SQL_ESCAPE:
+ case SQL_SUBST:
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case SQL_ESCAPE:
+ jj_consume_token(SQL_ESCAPE);
+ break;
+ case SQL_SUBST:
+ jj_consume_token(SQL_SUBST);
+ break;
+ default:
+ jj_la1[6] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ t = jj_consume_token(IDENTIFIER);
+ if (t != null) {
+ frag = new SqlSubstitutionFragment(new ReflectionFragment(t.image));
+ } else {
+ frag = new SqlSubstitutionFragment(new LiteralFragment(func));
+ }
+ break;
+ case SQL_FN:
+ jj_consume_token(SQL_FN);
+ jj_consume_token(SQL_FN_NM);
+ jj_consume_token(SQL_FN_PAREN);
+ label_4:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case SQL_FN_WHITESPACE:
+ ;
+ break;
+ default:
+ jj_la1[7] = jj_gen;
+ break label_4;
+ }
+ jj_consume_token(SQL_FN_WHITESPACE);
+ }
+ id1 = jj_consume_token(SQL_FN_IDENTIFIER);
+ label_5:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case SQL_FN_WHITESPACE:
+ ;
+ break;
+ default:
+ jj_la1[8] = jj_gen;
+ break label_5;
+ }
+ jj_consume_token(SQL_FN_WHITESPACE);
+ }
+ jj_consume_token(SQL_FN_COMMA);
+ label_6:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case SQL_FN_WHITESPACE:
+ ;
+ break;
+ default:
+ jj_la1[9] = jj_gen;
+ break label_6;
+ }
+ jj_consume_token(SQL_FN_WHITESPACE);
+ }
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case SQL_FN_PSTART:
+ t = jj_consume_token(SQL_FN_PSTART);
+ break;
+ default:
+ jj_la1[10] = jj_gen;
+ ;
+ }
+ id2 = jj_consume_token(SQL_FN_IDENTIFIER);
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case SQL_FN_PEND:
+ jj_consume_token(SQL_FN_PEND);
+ break;
+ default:
+ jj_la1[11] = jj_gen;
+ ;
+ }
+ label_7:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case SQL_FN_WHITESPACE:
+ ;
+ break;
+ default:
+ jj_la1[12] = jj_gen;
+ break label_7;
+ }
+ jj_consume_token(SQL_FN_WHITESPACE);
+ }
+ jj_consume_token(SQL_FN_END);
+ if (t == null) {
+ frag = new SqlSubstitutionFragment(new LiteralFragment("(" + id1.image + " IN (" + id2.image + ")"));
+ } else {
+ frag = new SqlSubstitutionFragment(new LiteralFragment("(" + id1.image + " IN ("),
+ new ReflectionFragment(id2.image),
+ new LiteralFragment("))"));
+ }
+ break;
+ default:
+ jj_la1[13] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ jj_consume_token(END_EXPRESSION);
+ {if (true) return frag;}
+ throw new Error("Missing return statement in function");
+ }
+
+//
+// parse a param sub inside of a jdbc escape
+//
+ final public SqlFragment parseReflect() throws ParseException {
+ Token t, tt = null;
+ SqlFragment frag;
+ jj_consume_token(JDBC_PARAM);
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case PARAM_IDENTIFIER:
+ t = jj_consume_token(PARAM_IDENTIFIER);
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case PARAM_REFLECT_SEP:
+ jj_consume_token(PARAM_REFLECT_SEP);
+ tt = jj_consume_token(IDENTIFIER);
+ break;
+ default:
+ jj_la1[14] = jj_gen;
+ ;
+ }
+ frag = new ReflectionFragment(t.image, (tt == null) ? null : tt.image);
+ break;
+ case PARAM_LITERAL:
+ t = jj_consume_token(PARAM_LITERAL);
+ frag = new LiteralFragment(t.image);
+ break;
+ default:
+ jj_la1[15] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ jj_consume_token(PARAM_END);
+ {if (true) return frag;}
+ throw new Error("Missing return statement in function");
+ }
+
+//
+// parse a jdbc escape sequence
+//
+ final public JdbcFragment parseJdbcEscape() throws ParseException {
+ Token lit, c;
+ JdbcFragment jfrag = new JdbcFragment();
+ jfrag.addChild(new LiteralFragment("{"));
+ SqlFragment frag = null;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case JDBC_CALL:
+ c = jj_consume_token(JDBC_CALL);
+ break;
+ case JDBC_RET:
+ c = jj_consume_token(JDBC_RET);
+ break;
+ case JDBC_DATE:
+ c = jj_consume_token(JDBC_DATE);
+ break;
+ case JDBC_ESCAPE:
+ c = jj_consume_token(JDBC_ESCAPE);
+ break;
+ case JDBC_FUNCTION:
+ c = jj_consume_token(JDBC_FUNCTION);
+ break;
+ case JDBC_TIME:
+ c = jj_consume_token(JDBC_TIME);
+ break;
+ case JDBC_TIMESTAMP:
+ c = jj_consume_token(JDBC_TIMESTAMP);
+ break;
+ case JDBC_OUTERJOIN:
+ c = jj_consume_token(JDBC_OUTERJOIN);
+ break;
+ default:
+ jj_la1[16] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ jfrag.addChild(new LiteralFragment(c.image));
+ label_8:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case JDBC_LIT:
+ lit = jj_consume_token(JDBC_LIT);
+ jfrag.addChild(new LiteralFragment(lit.image));
+ break;
+ case JDBC_PARAM:
+ frag = parseReflect();
+ jfrag.addChild(frag);
+ break;
+ default:
+ jj_la1[17] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case JDBC_LIT:
+ case JDBC_PARAM:
+ ;
+ break;
+ default:
+ jj_la1[18] = jj_gen;
+ break label_8;
+ }
+ }
+ jj_consume_token(JDBC_END);
+ jfrag.addChild(new LiteralFragment("}"));
+ {if (true) return jfrag;}
+ throw new Error("Missing return statement in function");
+ }
+
+ public SqlGrammarTokenManager token_source;
+ SimpleCharStream jj_input_stream;
+ public Token token, jj_nt;
+ private int jj_ntk;
+ private int jj_gen;
+ final private int[] jj_la1 = new int[19];
+ static private int[] jj_la1_0;
+ static private int[] jj_la1_1;
+ static {
+ jj_la1_0();
+ jj_la1_1();
+ }
+ private static void jj_la1_0() {
+ jj_la1_0 = new int[] {0xe,0xe,0x100000,0x100,0x2ffe00,0x100000,0x600,0x40000000,0x40000000,0x40000000,0x10000000,0x20000000,0x40000000,0xe00,0x0,0x0,0xff000,0x0,0x0,};
+ }
+ private static void jj_la1_1() {
+ jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x28,0x0,0x6,0x6,};
+ }
+
+ public SqlGrammar(java.io.InputStream stream) {
+ jj_input_stream = new SimpleCharStream(stream, 1, 1);
+ token_source = new SqlGrammarTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 19; i++) jj_la1[i] = -1;
+ }
+
+ 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 < 19; i++) jj_la1[i] = -1;
+ }
+
+ public SqlGrammar(java.io.Reader stream) {
+ jj_input_stream = new SimpleCharStream(stream, 1, 1);
+ token_source = new SqlGrammarTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 19; i++) jj_la1[i] = -1;
+ }
+
+ 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 < 19; i++) jj_la1[i] = -1;
+ }
+
+ public SqlGrammar(SqlGrammarTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 19; i++) jj_la1[i] = -1;
+ }
+
+ public void ReInit(SqlGrammarTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 19; i++) jj_la1[i] = -1;
+ }
+
+ 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();
+ }
+
+ 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;
+ }
+
+ 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;
+ }
+
+ 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);
+ }
+
+ private java.util.Vector jj_expentries = new java.util.Vector();
+ private int[] jj_expentry;
+ private int jj_kind = -1;
+
+ public ParseException generateParseException() {
+ jj_expentries.removeAllElements();
+ boolean[] la1tokens = new boolean[39];
+ for (int i = 0; i < 39; i++) {
+ la1tokens[i] = false;
+ }
+ if (jj_kind >= 0) {
+ la1tokens[jj_kind] = true;
+ jj_kind = -1;
+ }
+ for (int i = 0; i < 19; 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 < 39; 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);
+ }
+
+ final public void enable_tracing() {
+ }
+
+ final public void disable_tracing() {
+ }
+
+}
Added: incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammar.jj
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammar.jj?rev=169351&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammar.jj (added)
+++ incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammar.jj Mon May 9 13:17:58 2005
@@ -0,0 +1,314 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+
+options {
+ STATIC = false;
+ UNICODE_INPUT = true;
+ DEBUG_TOKEN_MANAGER = false;
+ DEBUG_PARSER = false;
+}
+
+//
+// parser declarations
+//
+PARSER_BEGIN(SqlGrammar)
+
+package org.apache.beehive.controls.system.jdbc.parser;
+import java.io.StringReader;
+
+public class SqlGrammar
+{
+ private StringBuilder buffer = new StringBuilder();
+ public static void main(String[] args) throws Exception
+ {
+ SqlGrammar parser = new SqlGrammar(new StringReader(args[0]));
+ SqlStatement statement = parser.parse();
+ System.out.println(statement.toString());
+ }
+}
+
+PARSER_END(SqlGrammar)
+
+//
+// token mgr decls
+//
+TOKEN_MGR_DECLS : { }
+
+//
+// default token mgr state -- just collect anything until a { or ' is read
+//
+<DEFAULT> TOKEN:
+{
+ < NON_EXPRESSION_TEXT : (~["{","}","'"])+ >
+ | < START_EXPRESSION : "{"> : IN_EXPRESSION
+ | < SQUOTE : "'"> : IN_LITERAL
+}
+
+//
+// this token mgr state is used to skip over literal values which occur in non_expression_text,
+// they need to be skipped in this state since they may contain a '{}' which needs to be ignored.
+//
+<IN_LITERAL> TOKEN:
+{
+ <STRING_LITERAL : (((~["'", "\\", "\n", "\r"])|<ECMA_ESCAPE_SEQUENCE>)* "'") > : DEFAULT
+ | <#ECMA_ESCAPE_SEQUENCE: "\\" |
+ (
+ ["n", "t", "b", "r", "f", "\\", "\""] |
+ ["0"-"7"] (["0"-"7"])? |
+ ["0"-"3"] ["0"-"7"] ["0"-"7"] |
+ ["x","X"] <HIT> <HIT> |
+ ["u","U"] <HIT> <HIT> <HIT> <HIT>
+ )
+ >
+ | <#HIT: ["0"-"9","a"-"f","A"-"F"] >
+}
+
+//
+// state for parse db control sql expressions, delimited by {}
+//
+<IN_EXPRESSION> TOKEN:
+{
+ <END_EXPRESSION : "}" > { SwitchTo(DEFAULT); }
+ | <REFLECT_SEP : "|">
+ | <SQL_ESCAPE : "sql: ">
+ | <SQL_SUBST : "sql:subst ">
+ | <SQL_FN : "sql:fn "> : IN_SQLFN
+ | <JDBC_CALL : "call "> : IN_JDBC
+ | <JDBC_RET : "?= "|"?="|"? ="> : IN_JDBC
+ | <JDBC_DATE : "d "> : IN_JDBC
+ | <JDBC_TIME : "t "> : IN_JDBC
+ | <JDBC_TIMESTAMP : "ts "> : IN_JDBC
+ | <JDBC_FUNCTION : "fn "> : IN_JDBC
+ | <JDBC_ESCAPE : "escape "> : IN_JDBC
+ | <JDBC_OUTERJOIN : "oj "> : IN_JDBC
+ | <WHITESPACE : " " | "\t" | "\r" | "\n">
+ | <IDENTIFIER : (<LETTER>) (<LETTER>|<DIGIT>|".")* >
+ | < #LETTER :
+ [
+ "\u0024",
+ "\u0041"-"\u005a",
+ "\u005f",
+ "\u0061"-"\u007a",
+ "\u00c0"-"\u00d6",
+ "\u00d8"-"\u00f6",
+ "\u00f8"-"\u00ff",
+ "\u0100"-"\u1fff",
+ "\u3040"-"\u318f",
+ "\u3300"-"\u337f",
+ "\u3400"-"\u3d2d",
+ "\u4e00"-"\u9fff",
+ "\uf900"-"\ufaff"
+ ]
+ >
+ | < #DIGIT :
+ [
+ "\u0030"-"\u0039",
+ "\u0660"-"\u0669",
+ "\u06f0"-"\u06f9",
+ "\u0966"-"\u096f",
+ "\u09e6"-"\u09ef",
+ "\u0a66"-"\u0a6f",
+ "\u0ae6"-"\u0aef",
+ "\u0b66"-"\u0b6f",
+ "\u0be7"-"\u0bef",
+ "\u0c66"-"\u0c6f",
+ "\u0ce6"-"\u0cef",
+ "\u0d66"-"\u0d6f",
+ "\u0e50"-"\u0e59",
+ "\u0ed0"-"\u0ed9",
+ "\u1040"-"\u1049"
+ ]
+ >
+}
+
+//
+// special state for the sql:fn constuct
+//
+<IN_SQLFN> TOKEN:
+{
+ <SQL_FN_END : ")" > : IN_EXPRESSION
+ | <SQL_FN_NM : "in">
+ | <SQL_FN_PAREN : "(">
+ | <SQL_FN_COMMA : ",">
+ | <SQL_FN_PSTART : <START_EXPRESSION>>
+ | <SQL_FN_PEND : <END_EXPRESSION>>
+ | <SQL_FN_WHITESPACE : <WHITESPACE>>
+ | <SQL_FN_IDENTIFIER : <IDENTIFIER> >
+}
+
+<IN_JDBC> TOKEN:
+{
+ <JDBC_END : <END_EXPRESSION> > { SwitchTo(DEFAULT); }
+ | <JDBC_LIT : (~["{","}"])+ >
+ | <JDBC_PARAM : <START_EXPRESSION> > : IN_PARAM
+}
+
+<IN_PARAM> TOKEN:
+{
+ <PARAM_IDENTIFIER : <IDENTIFIER> >
+ | <PARAM_REFLECT_SEP : <REFLECT_SEP> >
+ | <PARAM_LITERAL : ("'" ((~["'", "\\", "\n", "\r"])|<ECMA_ESCAPE_SEQUENCE>)* "'") >
+ | <PARAM_END : <END_EXPRESSION> > { SwitchTo(IN_JDBC); }
+}
+
+
+//
+// Parse methods
+//
+
+
+//
+// Main parse method
+//
+SqlStatement parse() :
+{
+ SqlStatement statement = new SqlStatement();
+ SqlFragment frag;
+ Token t, sq;
+}
+{
+ (
+ (
+ (t=<NON_EXPRESSION_TEXT> {statement.addChild(new LiteralFragment(t.image));})
+ |
+ (sq=<SQUOTE>t=<STRING_LITERAL> {statement.addChild(new LiteralFragment(sq.image + t.image));})
+ |
+ (frag=parseExpression() {statement.addChild(frag);})
+ )
+ )* <EOF>
+
+ {
+ return statement;
+ }
+}
+
+//
+// Parse an expression delimited by '{}'
+//
+SqlFragment parseExpression() :
+{
+ Token t, tt = null;
+ SqlFragment frag = null;
+}
+{
+ <START_EXPRESSION>(<WHITESPACE>)*
+ (
+ frag = parseSqlEscape()
+ | frag = parseJdbcEscape()
+ | (t=<IDENTIFIER> (<REFLECT_SEP>tt=<IDENTIFIER>)? <END_EXPRESSION> {frag = new ReflectionFragment(t.image,(tt == null) ? null : tt.image);})
+ )
+ (<WHITESPACE>)*
+ //<END_EXPRESSION>
+
+ {
+ return frag;
+ }
+}
+
+//
+// parse an sql: escape sequence
+//
+SqlSubstitutionFragment parseSqlEscape() :
+{
+ Token id1, id2;
+ Token t = null;
+ SqlSubstitutionFragment frag;
+ String func = null;
+}
+{
+(
+ (
+ (
+ (<SQL_ESCAPE> | <SQL_SUBST>) t=<IDENTIFIER>)
+ {
+ if (t != null) {
+ frag = new SqlSubstitutionFragment(new ReflectionFragment(t.image));
+ } else {
+ frag = new SqlSubstitutionFragment(new LiteralFragment(func));
+ }
+ }
+ )
+ |
+ (
+ (
+ <SQL_FN> <SQL_FN_NM> <SQL_FN_PAREN> (<SQL_FN_WHITESPACE>)* id1=<SQL_FN_IDENTIFIER> (<SQL_FN_WHITESPACE>)*
+ <SQL_FN_COMMA> (<SQL_FN_WHITESPACE>)* (t=<SQL_FN_PSTART>)? id2=<SQL_FN_IDENTIFIER> (<SQL_FN_PEND>)?
+ (<SQL_FN_WHITESPACE>)* <SQL_FN_END>
+ )
+ {
+ if (t == null) {
+ frag = new SqlSubstitutionFragment(new LiteralFragment("(" + id1.image + " IN (" + id2.image + ")"));
+ } else {
+ frag = new SqlSubstitutionFragment(new LiteralFragment("(" + id1.image + " IN ("),
+ new ReflectionFragment(id2.image),
+ new LiteralFragment("))"));
+ }
+ }
+ )
+) <END_EXPRESSION>
+
+ { return frag; }
+}
+
+//
+// parse a param sub inside of a jdbc escape
+//
+SqlFragment parseReflect() :
+{
+ Token t, tt = null;
+ SqlFragment frag;
+}
+{
+ <JDBC_PARAM>
+ (((t=<PARAM_IDENTIFIER>)(<PARAM_REFLECT_SEP>tt=<IDENTIFIER>)?
+ { frag = new ReflectionFragment(t.image, (tt == null) ? null : tt.image); })
+
+ |
+ ((t=<PARAM_LITERAL>)
+ { frag = new LiteralFragment(t.image); }))
+ <PARAM_END>
+
+ {return frag;}
+}
+
+//
+// parse a jdbc escape sequence
+//
+JdbcFragment parseJdbcEscape() :
+{
+ Token lit, c;
+ JdbcFragment jfrag = new JdbcFragment();
+ jfrag.addChild(new LiteralFragment("{"));
+ SqlFragment frag = null;
+}
+
+{
+ (c=<JDBC_CALL>|c=<JDBC_RET>|c=<JDBC_DATE>|c=<JDBC_ESCAPE>|c=<JDBC_FUNCTION>|c=<JDBC_TIME>|c=<JDBC_TIMESTAMP>|c=<JDBC_OUTERJOIN>)
+ {jfrag.addChild(new LiteralFragment(c.image));}
+ (
+ (lit=<JDBC_LIT> {jfrag.addChild(new LiteralFragment(lit.image));}
+ | (frag=parseReflect()) { jfrag.addChild(frag);})
+ )+
+ <JDBC_END>
+
+ {
+ jfrag.addChild(new LiteralFragment("}"));
+ return jfrag;
+ }
+}
+
Added: incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammarConstants.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammarConstants.java?rev=169351&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammarConstants.java (added)
+++ incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammarConstants.java Mon May 9 13:17:58 2005
@@ -0,0 +1,95 @@
+/* Generated By:JavaCC: Do not edit this line. SqlGrammarConstants.java */
+package org.apache.beehive.controls.system.jdbc.parser;
+
+public interface SqlGrammarConstants {
+
+ int EOF = 0;
+ int NON_EXPRESSION_TEXT = 1;
+ int START_EXPRESSION = 2;
+ int SQUOTE = 3;
+ int STRING_LITERAL = 4;
+ int ECMA_ESCAPE_SEQUENCE = 5;
+ int HIT = 6;
+ int END_EXPRESSION = 7;
+ int REFLECT_SEP = 8;
+ int SQL_ESCAPE = 9;
+ int SQL_SUBST = 10;
+ int SQL_FN = 11;
+ int JDBC_CALL = 12;
+ int JDBC_RET = 13;
+ int JDBC_DATE = 14;
+ int JDBC_TIME = 15;
+ int JDBC_TIMESTAMP = 16;
+ int JDBC_FUNCTION = 17;
+ int JDBC_ESCAPE = 18;
+ int JDBC_OUTERJOIN = 19;
+ int WHITESPACE = 20;
+ int IDENTIFIER = 21;
+ int LETTER = 22;
+ int DIGIT = 23;
+ int SQL_FN_END = 24;
+ int SQL_FN_NM = 25;
+ int SQL_FN_PAREN = 26;
+ int SQL_FN_COMMA = 27;
+ int SQL_FN_PSTART = 28;
+ int SQL_FN_PEND = 29;
+ int SQL_FN_WHITESPACE = 30;
+ int SQL_FN_IDENTIFIER = 31;
+ int JDBC_END = 32;
+ int JDBC_LIT = 33;
+ int JDBC_PARAM = 34;
+ int PARAM_IDENTIFIER = 35;
+ int PARAM_REFLECT_SEP = 36;
+ int PARAM_LITERAL = 37;
+ int PARAM_END = 38;
+
+ int DEFAULT = 0;
+ int IN_LITERAL = 1;
+ int IN_EXPRESSION = 2;
+ int IN_SQLFN = 3;
+ int IN_JDBC = 4;
+ int IN_PARAM = 5;
+
+ String[] tokenImage = {
+ "<EOF>",
+ "<NON_EXPRESSION_TEXT>",
+ "\"{\"",
+ "\"\\\'\"",
+ "<STRING_LITERAL>",
+ "<ECMA_ESCAPE_SEQUENCE>",
+ "<HIT>",
+ "\"}\"",
+ "\"|\"",
+ "\"sql: \"",
+ "\"sql:subst \"",
+ "\"sql:fn \"",
+ "\"call \"",
+ "<JDBC_RET>",
+ "\"d \"",
+ "\"t \"",
+ "\"ts \"",
+ "\"fn \"",
+ "\"escape \"",
+ "\"oj \"",
+ "<WHITESPACE>",
+ "<IDENTIFIER>",
+ "<LETTER>",
+ "<DIGIT>",
+ "\")\"",
+ "\"in\"",
+ "\"(\"",
+ "\",\"",
+ "<SQL_FN_PSTART>",
+ "<SQL_FN_PEND>",
+ "<SQL_FN_WHITESPACE>",
+ "<SQL_FN_IDENTIFIER>",
+ "<JDBC_END>",
+ "<JDBC_LIT>",
+ "<JDBC_PARAM>",
+ "<PARAM_IDENTIFIER>",
+ "<PARAM_REFLECT_SEP>",
+ "<PARAM_LITERAL>",
+ "<PARAM_END>",
+ };
+
+}
Added: incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammarTokenManager.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammarTokenManager.java?rev=169351&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammarTokenManager.java (added)
+++ incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlGrammarTokenManager.java Mon May 9 13:17:58 2005
@@ -0,0 +1,1578 @@
+/* Generated By:JavaCC: Do not edit this line. SqlGrammarTokenManager.java */
+package org.apache.beehive.controls.system.jdbc.parser;
+import java.io.StringReader;
+
+public class SqlGrammarTokenManager implements SqlGrammarConstants
+{
+ public java.io.PrintStream debugStream = System.out;
+ public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
+private final int jjStopStringLiteralDfa_0(int pos, long active0)
+{
+ switch (pos)
+ {
+ default :
+ return -1;
+ }
+}
+private final int jjStartNfa_0(int pos, long active0)
+{
+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
+}
+private final int jjStopAtPos(int pos, int kind)
+{
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ return pos + 1;
+}
+private final int jjStartNfaWithStates_0(int pos, int kind, int state)
+{
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return pos + 1; }
+ return jjMoveNfa_0(state, pos + 1);
+}
+private final int jjMoveStringLiteralDfa0_0()
+{
+ switch(curChar)
+ {
+ case 39:
+ return jjStopAtPos(0, 3);
+ case 123:
+ return jjStopAtPos(0, 2);
+ default :
+ return jjMoveNfa_0(0, 0);
+ }
+}
+private final void jjCheckNAdd(int state)
+{
+ if (jjrounds[state] != jjround)
+ {
+ jjstateSet[jjnewStateCnt++] = state;
+ jjrounds[state] = jjround;
+ }
+}
+private final void jjAddStates(int start, int end)
+{
+ do {
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];
+ } while (start++ != end);
+}
+private final void jjCheckNAddTwoStates(int state1, int state2)
+{
+ jjCheckNAdd(state1);
+ jjCheckNAdd(state2);
+}
+private final void jjCheckNAddStates(int start, int end)
+{
+ do {
+ jjCheckNAdd(jjnextStates[start]);
+ } while (start++ != end);
+}
+private final void jjCheckNAddStates(int start)
+{
+ jjCheckNAdd(jjnextStates[start]);
+ jjCheckNAdd(jjnextStates[start + 1]);
+}
+static final long[] jjbitVec0 = {
+ 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static final long[] jjbitVec2 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+private final int jjMoveNfa_0(int startState, int curPos)
+{
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 1;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (;;)
+ {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64)
+ {
+ long l = 1L << curChar;
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if ((0xffffff7fffffffffL & l) == 0L)
+ break;
+ kind = 1;
+ jjstateSet[jjnewStateCnt++] = 0;
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else if (curChar < 128)
+ {
+ long l = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if ((0xd7ffffffffffffffL & l) == 0L)
+ break;
+ kind = 1;
+ jjstateSet[jjnewStateCnt++] = 0;
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else
+ {
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 1)
+ kind = 1;
+ jjstateSet[jjnewStateCnt++] = 0;
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ if (kind != 0x7fffffff)
+ {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 1 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return curPos; }
+ }
+}
+private final int jjStopStringLiteralDfa_3(int pos, long active0)
+{
+ switch (pos)
+ {
+ case 0:
+ if ((active0 & 0x2000000L) != 0L)
+ {
+ jjmatchedKind = 31;
+ return 4;
+ }
+ return -1;
+ default :
+ return -1;
+ }
+}
+private final int jjStartNfa_3(int pos, long active0)
+{
+ return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0), pos + 1);
+}
+private final int jjStartNfaWithStates_3(int pos, int kind, int state)
+{
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return pos + 1; }
+ return jjMoveNfa_3(state, pos + 1);
+}
+private final int jjMoveStringLiteralDfa0_3()
+{
+ switch(curChar)
+ {
+ case 40:
+ return jjStopAtPos(0, 26);
+ case 41:
+ return jjStopAtPos(0, 24);
+ case 44:
+ return jjStopAtPos(0, 27);
+ case 105:
+ return jjMoveStringLiteralDfa1_3(0x2000000L);
+ default :
+ return jjMoveNfa_3(0, 0);
+ }
+}
+private final int jjMoveStringLiteralDfa1_3(long active0)
+{
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_3(0, active0);
+ return 1;
+ }
+ switch(curChar)
+ {
+ case 110:
+ if ((active0 & 0x2000000L) != 0L)
+ return jjStartNfaWithStates_3(1, 25, 4);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_3(0, active0);
+}
+static final long[] jjbitVec3 = {
+ 0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L
+};
+static final long[] jjbitVec4 = {
+ 0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL
+};
+static final long[] jjbitVec5 = {
+ 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
+};
+static final long[] jjbitVec6 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L
+};
+static final long[] jjbitVec7 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0x0L, 0x0L
+};
+static final long[] jjbitVec8 = {
+ 0x3fffffffffffL, 0x0L, 0x0L, 0x0L
+};
+private final int jjMoveNfa_3(int startState, int curPos)
+{
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 5;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (;;)
+ {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64)
+ {
+ long l = 1L << curChar;
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if ((0x100002600L & l) != 0L)
+ {
+ if (kind > 30)
+ kind = 30;
+ }
+ else if (curChar == 36)
+ {
+ if (kind > 31)
+ kind = 31;
+ jjCheckNAdd(4);
+ }
+ break;
+ case 2:
+ if ((0x100002600L & l) != 0L)
+ kind = 30;
+ break;
+ case 3:
+ if (curChar != 36)
+ break;
+ if (kind > 31)
+ kind = 31;
+ jjCheckNAdd(4);
+ break;
+ case 4:
+ if ((0x3ff401000000000L & l) == 0L)
+ break;
+ if (kind > 31)
+ kind = 31;
+ jjCheckNAdd(4);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else if (curChar < 128)
+ {
+ long l = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if ((0x7fffffe87fffffeL & l) != 0L)
+ {
+ if (kind > 31)
+ kind = 31;
+ jjCheckNAdd(4);
+ }
+ else if (curChar == 125)
+ {
+ if (kind > 29)
+ kind = 29;
+ }
+ else if (curChar == 123)
+ {
+ if (kind > 28)
+ kind = 28;
+ }
+ break;
+ case 1:
+ if (curChar == 125)
+ kind = 29;
+ break;
+ case 3:
+ case 4:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 31)
+ kind = 31;
+ jjCheckNAdd(4);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else
+ {
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ case 4:
+ if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 31)
+ kind = 31;
+ jjCheckNAdd(4);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ if (kind != 0x7fffffff)
+ {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 5 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return curPos; }
+ }
+}
+private final int jjMoveStringLiteralDfa0_1()
+{
+ return jjMoveNfa_1(14, 0);
+}
+private final int jjMoveNfa_1(int startState, int curPos)
+{
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 14;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (;;)
+ {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64)
+ {
+ long l = 1L << curChar;
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 14:
+ if ((0xffffff7fffffdbffL & l) != 0L)
+ jjCheckNAddStates(0, 5);
+ else if (curChar == 39)
+ {
+ if (kind > 4)
+ kind = 4;
+ }
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAddStates(6, 11);
+ if ((0xf000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 9;
+ break;
+ case 0:
+ if ((0xffffff7fffffdbffL & l) != 0L)
+ jjCheckNAddStates(0, 5);
+ break;
+ case 2:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 3;
+ break;
+ case 3:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 4;
+ break;
+ case 4:
+ case 7:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAdd(5);
+ break;
+ case 5:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(0, 5);
+ break;
+ case 8:
+ if ((0xf000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 9;
+ break;
+ case 9:
+ if ((0xff000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 10;
+ break;
+ case 10:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAddStates(0, 5);
+ break;
+ case 11:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAddStates(6, 11);
+ break;
+ case 12:
+ if (curChar == 39)
+ kind = 4;
+ break;
+ case 13:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAddStates(12, 18);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else if (curChar < 128)
+ {
+ long l = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 14:
+ jjCheckNAddStates(0, 5);
+ if ((0x100000001000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 7;
+ else if ((0x20000000200000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 2;
+ break;
+ case 0:
+ jjCheckNAddStates(0, 5);
+ break;
+ case 1:
+ if ((0x20000000200000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 2;
+ break;
+ case 2:
+ if ((0x7e0000007eL & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 3;
+ break;
+ case 3:
+ if ((0x7e0000007eL & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 4;
+ break;
+ case 4:
+ case 7:
+ if ((0x7e0000007eL & l) != 0L)
+ jjCheckNAdd(5);
+ break;
+ case 5:
+ if ((0x7e0000007eL & l) != 0L)
+ jjCheckNAddStates(0, 5);
+ break;
+ case 6:
+ if ((0x100000001000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 7;
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else
+ {
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 14:
+ case 0:
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2))
+ jjCheckNAddStates(0, 5);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ if (kind != 0x7fffffff)
+ {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 14 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return curPos; }
+ }
+}
+private final int jjMoveStringLiteralDfa0_4()
+{
+ return jjMoveNfa_4(0, 0);
+}
+private final int jjMoveNfa_4(int startState, int curPos)
+{
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 3;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (;;)
+ {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64)
+ {
+ long l = 1L << curChar;
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ case 1:
+ kind = 33;
+ jjCheckNAdd(1);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else if (curChar < 128)
+ {
+ long l = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if ((0xd7ffffffffffffffL & l) != 0L)
+ {
+ if (kind > 33)
+ kind = 33;
+ jjCheckNAdd(1);
+ }
+ else if (curChar == 123)
+ {
+ if (kind > 34)
+ kind = 34;
+ }
+ else if (curChar == 125)
+ {
+ if (kind > 32)
+ kind = 32;
+ }
+ break;
+ case 1:
+ if ((0xd7ffffffffffffffL & l) == 0L)
+ break;
+ kind = 33;
+ jjCheckNAdd(1);
+ break;
+ case 2:
+ if (curChar == 123)
+ kind = 34;
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else
+ {
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ case 1:
+ if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 33)
+ kind = 33;
+ jjCheckNAdd(1);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ if (kind != 0x7fffffff)
+ {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return curPos; }
+ }
+}
+private final int jjStopStringLiteralDfa_2(int pos, long active0)
+{
+ switch (pos)
+ {
+ case 0:
+ if ((active0 & 0xfde00L) != 0L)
+ {
+ jjmatchedKind = 21;
+ return 2;
+ }
+ return -1;
+ case 1:
+ if ((active0 & 0xf1e00L) != 0L)
+ {
+ jjmatchedKind = 21;
+ jjmatchedPos = 1;
+ return 2;
+ }
+ return -1;
+ case 2:
+ if ((active0 & 0x41e00L) != 0L)
+ {
+ jjmatchedKind = 21;
+ jjmatchedPos = 2;
+ return 2;
+ }
+ return -1;
+ case 3:
+ if ((active0 & 0x41000L) != 0L)
+ {
+ jjmatchedKind = 21;
+ jjmatchedPos = 3;
+ return 2;
+ }
+ if ((active0 & 0xe00L) != 0L)
+ {
+ if (jjmatchedPos < 2)
+ {
+ jjmatchedKind = 21;
+ jjmatchedPos = 2;
+ }
+ return -1;
+ }
+ return -1;
+ case 4:
+ if ((active0 & 0x40000L) != 0L)
+ {
+ jjmatchedKind = 21;
+ jjmatchedPos = 4;
+ return 2;
+ }
+ if ((active0 & 0xe00L) != 0L)
+ {
+ if (jjmatchedPos < 2)
+ {
+ jjmatchedKind = 21;
+ jjmatchedPos = 2;
+ }
+ return -1;
+ }
+ return -1;
+ case 5:
+ if ((active0 & 0xc00L) != 0L)
+ {
+ if (jjmatchedPos < 2)
+ {
+ jjmatchedKind = 21;
+ jjmatchedPos = 2;
+ }
+ return -1;
+ }
+ if ((active0 & 0x40000L) != 0L)
+ {
+ jjmatchedKind = 21;
+ jjmatchedPos = 5;
+ return 2;
+ }
+ return -1;
+ case 6:
+ if ((active0 & 0xc00L) != 0L)
+ {
+ if (jjmatchedPos < 2)
+ {
+ jjmatchedKind = 21;
+ jjmatchedPos = 2;
+ }
+ return -1;
+ }
+ return -1;
+ case 7:
+ if ((active0 & 0x400L) != 0L)
+ {
+ if (jjmatchedPos < 2)
+ {
+ jjmatchedKind = 21;
+ jjmatchedPos = 2;
+ }
+ return -1;
+ }
+ return -1;
+ case 8:
+ if ((active0 & 0x400L) != 0L)
+ {
+ if (jjmatchedPos < 2)
+ {
+ jjmatchedKind = 21;
+ jjmatchedPos = 2;
+ }
+ return -1;
+ }
+ return -1;
+ default :
+ return -1;
+ }
+}
+private final int jjStartNfa_2(int pos, long active0)
+{
+ return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1);
+}
+private final int jjStartNfaWithStates_2(int pos, int kind, int state)
+{
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return pos + 1; }
+ return jjMoveNfa_2(state, pos + 1);
+}
+private final int jjMoveStringLiteralDfa0_2()
+{
+ switch(curChar)
+ {
+ case 99:
+ return jjMoveStringLiteralDfa1_2(0x1000L);
+ case 100:
+ return jjMoveStringLiteralDfa1_2(0x4000L);
+ case 101:
+ return jjMoveStringLiteralDfa1_2(0x40000L);
+ case 102:
+ return jjMoveStringLiteralDfa1_2(0x20000L);
+ case 111:
+ return jjMoveStringLiteralDfa1_2(0x80000L);
+ case 115:
+ return jjMoveStringLiteralDfa1_2(0xe00L);
+ case 116:
+ return jjMoveStringLiteralDfa1_2(0x18000L);
+ case 124:
+ return jjStopAtPos(0, 8);
+ case 125:
+ return jjStopAtPos(0, 7);
+ default :
+ return jjMoveNfa_2(0, 0);
+ }
+}
+private final int jjMoveStringLiteralDfa1_2(long active0)
+{
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_2(0, active0);
+ return 1;
+ }
+ switch(curChar)
+ {
+ case 32:
+ if ((active0 & 0x4000L) != 0L)
+ return jjStopAtPos(1, 14);
+ else if ((active0 & 0x8000L) != 0L)
+ return jjStopAtPos(1, 15);
+ break;
+ case 97:
+ return jjMoveStringLiteralDfa2_2(active0, 0x1000L);
+ case 106:
+ return jjMoveStringLiteralDfa2_2(active0, 0x80000L);
+ case 110:
+ return jjMoveStringLiteralDfa2_2(active0, 0x20000L);
+ case 113:
+ return jjMoveStringLiteralDfa2_2(active0, 0xe00L);
+ case 115:
+ return jjMoveStringLiteralDfa2_2(active0, 0x50000L);
+ default :
+ break;
+ }
+ return jjStartNfa_2(0, active0);
+}
+private final int jjMoveStringLiteralDfa2_2(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_2(0, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_2(1, active0);
+ return 2;
+ }
+ switch(curChar)
+ {
+ case 32:
+ if ((active0 & 0x10000L) != 0L)
+ return jjStopAtPos(2, 16);
+ else if ((active0 & 0x20000L) != 0L)
+ return jjStopAtPos(2, 17);
+ else if ((active0 & 0x80000L) != 0L)
+ return jjStopAtPos(2, 19);
+ break;
+ case 99:
+ return jjMoveStringLiteralDfa3_2(active0, 0x40000L);
+ case 108:
+ return jjMoveStringLiteralDfa3_2(active0, 0x1e00L);
+ default :
+ break;
+ }
+ return jjStartNfa_2(1, active0);
+}
+private final int jjMoveStringLiteralDfa3_2(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_2(1, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_2(2, active0);
+ return 3;
+ }
+ switch(curChar)
+ {
+ case 58:
+ return jjMoveStringLiteralDfa4_2(active0, 0xe00L);
+ case 97:
+ return jjMoveStringLiteralDfa4_2(active0, 0x40000L);
+ case 108:
+ return jjMoveStringLiteralDfa4_2(active0, 0x1000L);
+ default :
+ break;
+ }
+ return jjStartNfa_2(2, active0);
+}
+private final int jjMoveStringLiteralDfa4_2(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_2(2, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_2(3, active0);
+ return 4;
+ }
+ switch(curChar)
+ {
+ case 32:
+ if ((active0 & 0x200L) != 0L)
+ return jjStopAtPos(4, 9);
+ else if ((active0 & 0x1000L) != 0L)
+ return jjStopAtPos(4, 12);
+ break;
+ case 102:
+ return jjMoveStringLiteralDfa5_2(active0, 0x800L);
+ case 112:
+ return jjMoveStringLiteralDfa5_2(active0, 0x40000L);
+ case 115:
+ return jjMoveStringLiteralDfa5_2(active0, 0x400L);
+ default :
+ break;
+ }
+ return jjStartNfa_2(3, active0);
+}
+private final int jjMoveStringLiteralDfa5_2(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_2(3, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_2(4, active0);
+ return 5;
+ }
+ switch(curChar)
+ {
+ case 101:
+ return jjMoveStringLiteralDfa6_2(active0, 0x40000L);
+ case 110:
+ return jjMoveStringLiteralDfa6_2(active0, 0x800L);
+ case 117:
+ return jjMoveStringLiteralDfa6_2(active0, 0x400L);
+ default :
+ break;
+ }
+ return jjStartNfa_2(4, active0);
+}
+private final int jjMoveStringLiteralDfa6_2(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_2(4, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_2(5, active0);
+ return 6;
+ }
+ switch(curChar)
+ {
+ case 32:
+ if ((active0 & 0x800L) != 0L)
+ return jjStopAtPos(6, 11);
+ else if ((active0 & 0x40000L) != 0L)
+ return jjStopAtPos(6, 18);
+ break;
+ case 98:
+ return jjMoveStringLiteralDfa7_2(active0, 0x400L);
+ default :
+ break;
+ }
+ return jjStartNfa_2(5, active0);
+}
+private final int jjMoveStringLiteralDfa7_2(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_2(5, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_2(6, active0);
+ return 7;
+ }
+ switch(curChar)
+ {
+ case 115:
+ return jjMoveStringLiteralDfa8_2(active0, 0x400L);
+ default :
+ break;
+ }
+ return jjStartNfa_2(6, active0);
+}
+private final int jjMoveStringLiteralDfa8_2(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_2(6, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_2(7, active0);
+ return 8;
+ }
+ switch(curChar)
+ {
+ case 116:
+ return jjMoveStringLiteralDfa9_2(active0, 0x400L);
+ default :
+ break;
+ }
+ return jjStartNfa_2(7, active0);
+}
+private final int jjMoveStringLiteralDfa9_2(long old0, long active0)
+{
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_2(7, old0);
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) {
+ jjStopStringLiteralDfa_2(8, active0);
+ return 9;
+ }
+ switch(curChar)
+ {
+ case 32:
+ if ((active0 & 0x400L) != 0L)
+ return jjStopAtPos(9, 10);
+ break;
+ default :
+ break;
+ }
+ return jjStartNfa_2(8, active0);
+}
+private final int jjMoveNfa_2(int startState, int curPos)
+{
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 8;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (;;)
+ {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64)
+ {
+ long l = 1L << curChar;
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if ((0x100002600L & l) != 0L)
+ {
+ if (kind > 20)
+ kind = 20;
+ }
+ else if (curChar == 36)
+ {
+ if (kind > 21)
+ kind = 21;
+ jjCheckNAdd(2);
+ }
+ else if (curChar == 63)
+ jjCheckNAddStates(19, 21);
+ break;
+ case 1:
+ if (curChar != 36)
+ break;
+ if (kind > 21)
+ kind = 21;
+ jjCheckNAdd(2);
+ break;
+ case 2:
+ if ((0x3ff401000000000L & l) == 0L)
+ break;
+ if (kind > 21)
+ kind = 21;
+ jjCheckNAdd(2);
+ break;
+ case 3:
+ if (curChar == 63)
+ jjCheckNAddStates(19, 21);
+ break;
+ case 4:
+ if (curChar == 32 && kind > 13)
+ kind = 13;
+ break;
+ case 5:
+ if (curChar == 61)
+ jjstateSet[jjnewStateCnt++] = 4;
+ break;
+ case 6:
+ if (curChar == 61 && kind > 13)
+ kind = 13;
+ break;
+ case 7:
+ if (curChar == 32)
+ jjCheckNAdd(6);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else if (curChar < 128)
+ {
+ long l = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ case 2:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 21)
+ kind = 21;
+ jjCheckNAdd(2);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else
+ {
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ case 2:
+ if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 21)
+ kind = 21;
+ jjCheckNAdd(2);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ if (kind != 0x7fffffff)
+ {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 8 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return curPos; }
+ }
+}
+private final int jjMoveStringLiteralDfa0_5()
+{
+ return jjMoveNfa_5(0, 0);
+}
+private final int jjMoveNfa_5(int startState, int curPos)
+{
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 19;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (;;)
+ {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64)
+ {
+ long l = 1L << curChar;
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if (curChar == 39)
+ jjCheckNAddStates(22, 27);
+ else if (curChar == 36)
+ {
+ if (kind > 35)
+ kind = 35;
+ jjCheckNAdd(1);
+ }
+ break;
+ case 1:
+ if ((0x3ff401000000000L & l) == 0L)
+ break;
+ if (kind > 35)
+ kind = 35;
+ jjCheckNAdd(1);
+ break;
+ case 3:
+ if (curChar == 39)
+ jjCheckNAddStates(22, 27);
+ break;
+ case 4:
+ if ((0xffffff7fffffdbffL & l) != 0L)
+ jjCheckNAddStates(22, 27);
+ break;
+ case 6:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 7;
+ break;
+ case 7:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 8;
+ break;
+ case 8:
+ case 11:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAdd(9);
+ break;
+ case 9:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(22, 27);
+ break;
+ case 12:
+ if ((0xf000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 13;
+ break;
+ case 13:
+ if ((0xff000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 14;
+ break;
+ case 14:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAddStates(22, 27);
+ break;
+ case 15:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAddStates(28, 33);
+ break;
+ case 16:
+ if (curChar == 39 && kind > 37)
+ kind = 37;
+ break;
+ case 17:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAddStates(34, 40);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else if (curChar < 128)
+ {
+ long l = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ if ((0x7fffffe87fffffeL & l) != 0L)
+ {
+ if (kind > 35)
+ kind = 35;
+ jjCheckNAdd(1);
+ }
+ else if (curChar == 125)
+ {
+ if (kind > 38)
+ kind = 38;
+ }
+ else if (curChar == 124)
+ {
+ if (kind > 36)
+ kind = 36;
+ }
+ break;
+ case 1:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 35)
+ kind = 35;
+ jjCheckNAdd(1);
+ break;
+ case 2:
+ if (curChar == 124 && kind > 36)
+ kind = 36;
+ break;
+ case 4:
+ jjCheckNAddStates(22, 27);
+ break;
+ case 5:
+ if ((0x20000000200000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 6;
+ break;
+ case 6:
+ if ((0x7e0000007eL & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 7;
+ break;
+ case 7:
+ if ((0x7e0000007eL & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 8;
+ break;
+ case 8:
+ case 11:
+ if ((0x7e0000007eL & l) != 0L)
+ jjCheckNAdd(9);
+ break;
+ case 9:
+ if ((0x7e0000007eL & l) != 0L)
+ jjCheckNAddStates(22, 27);
+ break;
+ case 10:
+ if ((0x100000001000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 11;
+ break;
+ case 18:
+ if (curChar == 125 && kind > 38)
+ kind = 38;
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ else
+ {
+ int hiByte = (int)(curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop: do
+ {
+ switch(jjstateSet[--i])
+ {
+ case 0:
+ case 1:
+ if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 35)
+ kind = 35;
+ jjCheckNAdd(1);
+ break;
+ case 4:
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2))
+ jjAddStates(22, 27);
+ break;
+ default : break;
+ }
+ } while(i != startsAt);
+ }
+ if (kind != 0x7fffffff)
+ {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 19 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try { curChar = input_stream.readChar(); }
+ catch(java.io.IOException e) { return curPos; }
+ }
+}
+static final int[] jjnextStates = {
+ 0, 1, 6, 8, 11, 12, 0, 1, 6, 8, 12, 13, 0, 1, 6, 8,
+ 11, 12, 13, 5, 6, 7, 4, 5, 10, 12, 15, 16, 4, 5, 10, 12,
+ 16, 17, 4, 5, 10, 12, 15, 16, 17,
+};
+private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
+{
+ switch(hiByte)
+ {
+ case 0:
+ return ((jjbitVec2[i2] & l2) != 0L);
+ default :
+ if ((jjbitVec0[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+}
+private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2)
+{
+ switch(hiByte)
+ {
+ case 0:
+ return ((jjbitVec4[i2] & l2) != 0L);
+ case 48:
+ return ((jjbitVec5[i2] & l2) != 0L);
+ case 49:
+ return ((jjbitVec6[i2] & l2) != 0L);
+ case 51:
+ return ((jjbitVec7[i2] & l2) != 0L);
+ case 61:
+ return ((jjbitVec8[i2] & l2) != 0L);
+ default :
+ if ((jjbitVec3[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+}
+public static final String[] jjstrLiteralImages = {
+"", null, "\173", "\47", null, null, null, "\175", "\174",
+"\163\161\154\72\40", "\163\161\154\72\163\165\142\163\164\40", "\163\161\154\72\146\156\40",
+"\143\141\154\154\40", null, "\144\40", "\164\40", "\164\163\40", "\146\156\40",
+"\145\163\143\141\160\145\40", "\157\152\40", null, null, null, null, "\51", "\151\156", "\50", "\54", null,
+null, null, null, null, null, null, null, null, null, null, };
+public static final String[] lexStateNames = {
+ "DEFAULT",
+ "IN_LITERAL",
+ "IN_EXPRESSION",
+ "IN_SQLFN",
+ "IN_JDBC",
+ "IN_PARAM",
+};
+public static final int[] jjnewLexState = {
+ -1, -1, 2, 1, 0, -1, -1, -1, -1, -1, -1, 3, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1, -1, -1, 2,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, -1, -1, -1, -1,
+};
+protected SimpleCharStream input_stream;
+private final int[] jjrounds = new int[19];
+private final int[] jjstateSet = new int[38];
+StringBuffer image;
+int jjimageLen;
+int lengthOfMatch;
+protected char curChar;
+public SqlGrammarTokenManager(SimpleCharStream stream)
+{
+ if (SimpleCharStream.staticFlag)
+ throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
+ input_stream = stream;
+}
+public SqlGrammarTokenManager(SimpleCharStream stream, int lexState)
+{
+ this(stream);
+ SwitchTo(lexState);
+}
+public void ReInit(SimpleCharStream stream)
+{
+ jjmatchedPos = jjnewStateCnt = 0;
+ curLexState = defaultLexState;
+ input_stream = stream;
+ ReInitRounds();
+}
+private final void ReInitRounds()
+{
+ int i;
+ jjround = 0x80000001;
+ for (i = 19; i-- > 0;)
+ jjrounds[i] = 0x80000000;
+}
+public void ReInit(SimpleCharStream stream, int lexState)
+{
+ ReInit(stream);
+ SwitchTo(lexState);
+}
+public void SwitchTo(int lexState)
+{
+ if (lexState >= 6 || lexState < 0)
+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
+ else
+ curLexState = lexState;
+}
+
+protected Token jjFillToken()
+{
+ Token t = Token.newToken(jjmatchedKind);
+ t.kind = jjmatchedKind;
+ String im = jjstrLiteralImages[jjmatchedKind];
+ t.image = (im == null) ? input_stream.GetImage() : im;
+ t.beginLine = input_stream.getBeginLine();
+ t.beginColumn = input_stream.getBeginColumn();
+ t.endLine = input_stream.getEndLine();
+ t.endColumn = input_stream.getEndColumn();
+ return t;
+}
+
+int curLexState = 0;
+int defaultLexState = 0;
+int jjnewStateCnt;
+int jjround;
+int jjmatchedPos;
+int jjmatchedKind;
+
+public Token getNextToken()
+{
+ int kind;
+ Token specialToken = null;
+ Token matchedToken;
+ int curPos = 0;
+
+ EOFLoop :
+ for (;;)
+ {
+ try
+ {
+ curChar = input_stream.BeginToken();
+ }
+ catch(java.io.IOException e)
+ {
+ jjmatchedKind = 0;
+ matchedToken = jjFillToken();
+ return matchedToken;
+ }
+ image = null;
+ jjimageLen = 0;
+
+ switch(curLexState)
+ {
+ case 0:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_0();
+ break;
+ case 1:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_1();
+ break;
+ case 2:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_2();
+ break;
+ case 3:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_3();
+ break;
+ case 4:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_4();
+ break;
+ case 5:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_5();
+ break;
+ }
+ if (jjmatchedKind != 0x7fffffff)
+ {
+ if (jjmatchedPos + 1 < curPos)
+ input_stream.backup(curPos - jjmatchedPos - 1);
+ matchedToken = jjFillToken();
+ TokenLexicalActions(matchedToken);
+ if (jjnewLexState[jjmatchedKind] != -1)
+ curLexState = jjnewLexState[jjmatchedKind];
+ return matchedToken;
+ }
+ int error_line = input_stream.getEndLine();
+ int error_column = input_stream.getEndColumn();
+ String error_after = null;
+ boolean EOFSeen = false;
+ try { input_stream.readChar(); input_stream.backup(1); }
+ catch (java.io.IOException e1) {
+ EOFSeen = true;
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ if (curChar == '\n' || curChar == '\r') {
+ error_line++;
+ error_column = 0;
+ }
+ else
+ error_column++;
+ }
+ if (!EOFSeen) {
+ input_stream.backup(1);
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ }
+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
+ }
+}
+
+void TokenLexicalActions(Token matchedToken)
+{
+ switch(jjmatchedKind)
+ {
+ case 7 :
+ if (image == null)
+ image = new StringBuffer(jjstrLiteralImages[7]);
+ else
+ image.append(jjstrLiteralImages[7]);
+ SwitchTo(DEFAULT);
+ break;
+ case 32 :
+ if (image == null)
+ image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
+ else
+ image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
+ SwitchTo(DEFAULT);
+ break;
+ case 38 :
+ if (image == null)
+ image = new StringBuffer(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
+ else
+ image.append(new String(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))));
+ SwitchTo(IN_JDBC);
+ break;
+ default :
+ break;
+ }
+}
+}
Added: incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlParser.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlParser.java?rev=169351&view=auto
==============================================================================
--- incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlParser.java (added)
+++ incubator/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/parser/SqlParser.java Mon May 9 13:17:58 2005
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+
+package org.apache.beehive.controls.system.jdbc.parser;
+
+import org.apache.beehive.controls.api.ControlException;
+
+import java.util.HashMap;
+import java.io.StringReader;
+
+/**
+ * The SqlParser class is a thread-safe class which parses a string containing a SQL statement
+ * with JdbcControl substitituion delimiters. It is important to note that the SQL is not parsed/validated - only
+ * the sections within the SQL string which are delimited by '{' and '}' are parsed.
+ * <p/>
+ * Parsing is accomplished using the JavaCC grammar file <tt>SqlGrammer.jj</tt>. As the string is parsed it is broken
+ * into fragments by the parser. Any portion of the string which is not between '{' and '}' delimiters becomes a
+ * <tt>LiteralFragment</tt>. The portions of the SQL string which fall between the start and end delimiters are categorized as
+ * either <tt>JdbcFragment</tt>, <tt>ReflectionFragment</tt>, or <tt>SqlSubstitutionFragment</tt>.
+ * <p/>
+ * Fragments which subclass <tt>SqlFragmentContainer</tt> may contain other fragments as children. Fragements subclassed
+ * from <tt>SqlFragment</tt> my not contain child fragments. Upon completion of parsing a <tt>SqlStatement</tt> is
+ * returned to the caller. The <tt>SqlStatement</tt> contains the heirarchary of fragments which have been derived
+ * from the orignal SQL string.
+ * <p/>
+ * The parser will also cache all <tt>SqlStatements</tt> which contain non-volitale SQL. Only <tt>SqlEscapeFragments</tt>
+ * contain volitile SQL at this point.
+ */
+public final class SqlParser {
+
+ // maintain a cache of SQLStatements which have already been parsed
+ private HashMap<String, SqlStatement> _cachedSqlStatements;
+
+ /**
+ * Create a new instance of the SqlParser.
+ */
+ public SqlParser() {
+ _cachedSqlStatements = new HashMap<String, SqlStatement>();
+ }
+
+ /**
+ * Parse the sql and return an SqlStatement.
+ *
+ * @param sql A String contianing the sql to parse.
+ * @return A SqlStatement instance.
+ */
+ public SqlStatement parse(String sql) {
+
+ // does a cached parse result exist for this statement?
+ if (_cachedSqlStatements.containsKey(sql)) {
+ return _cachedSqlStatements.get(sql);
+ }
+
+ SqlGrammar _parser = new SqlGrammar(new StringReader(sql));
+ SqlStatement parsed = null;
+ try {
+ parsed = _parser.parse();
+ } catch (ParseException e) {
+ throw new ControlException("Error parsing SQL statment." + e.getMessage(), e);
+ } catch (TokenMgrError tme) {
+ throw new ControlException("Error parsing SQL statment. " + tme.getMessage(), tme);
+ }
+
+ if (parsed.isCacheable()) {
+ _cachedSqlStatements.put(sql, parsed);
+ }
+ return parsed;
+ }
+}