首先编写.jjt文件SQLParser.jjt:
PARSER_BEGIN(SQLParser)
public class SQLParser{
public static void main(String args[]) {
System.out.println("Reading from standard input...");
SQLParser p = new SQLParser(System.in);
try {
SimpleNode n = p.Start();
n.dump("");
System.out.println("Thank you.");
} catch (Exception e) {
System.out.println("Oops.");
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
PARSER_END(SQLParser)
/*定义词法分析*/
SKIP:{" "}
SKIP:{"\n"|"\r"|"\r\n"}
TOKEN:/*定义关键字*/
{
<CREATE:"create">
| <TABLE:"table">
| <DROP:"drop">
| <SELECT:"select">
| <INSERT:"insert">
| <WHERE:"where">
| <FROM:"from">
| <INTO:"into">
| <DISTINCT:"distinct">
| <LIKE:"like">
| <ORDER:"order">
| <BY:"by">
| <VALUES:"values">
| <AND:"and">
| <IN:"in">
| <INT:"int">
| <CHAR:"char">
| <DATE:"date">
| <DELETE:"delete">
}
TOKEN:/*定义符号*/
{
<UNDERSCORE:"_">
| <COMMA:",">
| <SEMICOLON:";">
| <COLON:":">
| <LEFTPARENTHESES:"(">
| <RIGHTPARENTHESES:")">
| <EQUAL:"=">
| <PLUS:"+">
| <MINUS:"-">
| <TIMES:"*">
| <DIVIDE:"/">
| <LEFTQUOTATION:"\"">
| <LQUOTATION:"'">
}
TOKEN:/* 定义整数 */
{
<INTEGER_LITERAL:["1"-"9"](<DIGIT>)*>
}
TOKEN:/*定义数字*/
{
<#DIGIT:["0"-"9"]>
}
TOKEN:/* 定义标识符 */
{
<IDENTIFIER:<LETTER>
|<LETTER><DIGIT>
| <LETTER>(<LETTER>
| <DIGIT>
| <UNDERSCORE>)*(<LETTER>
| <DIGIT>)+>
| <#LETTER:["a"-"z", "A"-"Z"]>
}
/* 语法解析*/
SimpleNode Start() : {}
{
Expression() ";"
{ return jjtThis; }
}
void Expression() : {}
{
Query()|CreT()|DropT()|DelT()|InsT()
}
void Query():{}
{
SFW()[<ORDER><BY>Attribute()]
}
void SFW():{}
{
<SELECT>[<DISTINCT>]SelList()<FROM>FromList()<WHERE>Condition()
}
void SelList():{}
{
Attribute()[(<COMMA>Attribute())+]
}
void FromList():{}
{
Relation()[(<COMMA>Relation())+]
}
void Condition():{}
{
/*[Condition()<AND>Condition()]|*/
/*[Tuple()<IN>Query()]*/
[Attribute()<EQUAL>Attribute()]
|[Attribute()<LIKE>Pattern()]
|[Attribute()<EQUAL>IDENTIFIER()]
}
void Tuple():{}
{
Attribute()
}
/*-------------------*/
void CreT():{}
{
<CREATE><TABLE>Relation()<LEFTPARENTHESES>ColList()<RIGHTPARENTHESES>
}
void ColList():{}
{
Attribute()Type()[(<COMMA>Attribute()Type())+]
}
void Type():{}
{
<INT>|<DATE>|<CHAR><LEFTPARENTHESES><INTEGER_LITERAL><RIGHTPARENTHESES>
}
/*-------------------*/
void DropT():{}
{
<DROP><TABLE>Relation()
}
void DelT():{}
{
<DELETE>DelList()<FROM>FromList()<WHERE>Condition()
}
void DelList():{}
{
Attribute()[(<COMMA>Attribute())+]
}
/*-------------------*/
void InsT():{}
{
<INSERT><INTO>Relation()<LEFTPARENTHESES>InList()<RIGHTPARENTHESES><VALUES><LEFTPARENTHESES>VList()<RIGHTPARENTHESES>
}
void InList():{}
{
Attribute()[(<COMMA>Attribute())+]
}
void VList():{}
{
<LEFTQUOTATION>IDENTIFIER()<LEFTQUOTATION>[(<COMMA><LEFTQUOTATION>IDENTIFIER()<LEFTQUOTATION>)+]
}
/*-------------------*/
void Attribute():{}
{
IDENTIFIER()
}
void Relation():{}
{
IDENTIFIER()
}
void Pattern():{}
{
<LQUOTATION>IDENTIFIER()<LQUOTATION>
}
/*-------------------*/
void IDENTIFIER():{}
{
<IDENTIFIER>
}
得到SQLParser.jj:
/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. .\SQLParser.jj *//*@egen*/PARSER_BEGIN(SQLParser)public class SQLParser/*@bgen(jjtree)*/implements SQLParserTreeConstants/*@egen*/{/*@bgen(jjtree)*/ protected static JJTSQLParserState jjtree = new JJTSQLParserState();/*@egen*/ public static void main(String args[]) { System.out.println("Reading from standard input..."); SQLParser p = new SQLParser(System.in); try { SimpleNode n = p.Start(); n.dump(""); System.out.println("Thank you."); } catch (Exception e) { System.out.println("Oops."); System.out.println(e.getMessage()); e.printStackTrace(); } }}PARSER_END(SQLParser)/*\u5b9a\u4e49\u8bcd\u6cd5\u5206\u6790*/SKIP:{" "}SKIP:{"\n"|"\r"|"\r\n"}TOKEN:/*\u5b9a\u4e49\u5173\u952e\u5b57*/{ <CREATE:"create"> | <TABLE:"table"> | <DROP:"drop"> | <SELECT:"select"> | <INSERT:"insert"> | <WHERE:"where"> | <FROM:"from"> | <INTO:"into"> | <DISTINCT:"distinct"> | <LIKE:"like"> | <ORDER:"order"> | <BY:"by"> | <VALUES:"values"> | <AND:"and"> | <IN:"in"> | <INT:"int"> | <CHAR:"char"> | <DATE:"date"> | <DELETE:"delete">}TOKEN:/*\u5b9a\u4e49\u7b26\u53f7*/{ <UNDERSCORE:"_"> | <COMMA:","> | <SEMICOLON:";"> | <COLON:":"> | <LEFTPARENTHESES:"("> | <RIGHTPARENTHESES:")"> | <EQUAL:"="> | <PLUS:"+"> | <MINUS:"-"> | <TIMES:"*"> | <DIVIDE:"/"> | <LEFTQUOTATION:"\""> | <LQUOTATION:"'">}TOKEN:/* \u5b9a\u4e49\u6574\u6570 */{ <INTEGER_LITERAL:["1"-"9"](<DIGIT>)*>}TOKEN:/*\u5b9a\u4e49\u6570\u5b57*/{ <#DIGIT:["0"-"9"]>}TOKEN:/* \u5b9a\u4e49\u6807\u8bc6\u7b26 */{ <IDENTIFIER:<LETTER> |<LETTER><DIGIT> | <LETTER>(<LETTER> | <DIGIT> | <UNDERSCORE>)*(<LETTER> | <DIGIT>)+> | <#LETTER:["a"-"z", "A"-"Z"]>}/* \u8bed\u6cd5\u89e3\u6790*/SimpleNode Start() : {/*@bgen(jjtree) Start */ SimpleNode jjtn000 = new SimpleNode(JJTSTART); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) Start */ try {/*@egen*/ Expression() ";"/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; }/*@egen*/ { return jjtn000; }/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } }/*@egen*/}void Expression() : {/*@bgen(jjtree) Expression */ SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) Expression */ try {/*@egen*/ Query()|CreT()|DropT()|DelT()|InsT()/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000; } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } }/*@egen*/}void Query():{/*@bgen(jjtree) Query */ SimpleNode jjtn000 = new SimpleNode(JJTQUERY); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) Query */try {/*@egen*/SFW()[<ORDER><BY>Attribute()]/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}void SFW():{/*@bgen(jjtree) SFW */ SimpleNode jjtn000 = new SimpleNode(JJTSFW); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) SFW */try {/*@egen*/<SELECT>[<DISTINCT>]SelList()<FROM>FromList()<WHERE>Condition()/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}void SelList():{/*@bgen(jjtree) SelList */ SimpleNode jjtn000 = new SimpleNode(JJTSELLIST); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) SelList */try {/*@egen*/Attribute()[(<COMMA>Attribute())+]/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}void FromList():{/*@bgen(jjtree) FromList */ SimpleNode jjtn000 = new SimpleNode(JJTFROMLIST); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) FromList */try {/*@egen*/Relation()[(<COMMA>Relation())+]/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}void Condition():{/*@bgen(jjtree) Condition */ SimpleNode jjtn000 = new SimpleNode(JJTCONDITION); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) Condition */try {/*@egen*//*[Condition()<AND>Condition()]|*//*[Tuple()<IN>Query()]*/[Attribute()<EQUAL>Attribute()]|[Attribute()<LIKE>Pattern()]|[Attribute()<EQUAL>IDENTIFIER()]/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}void Tuple():{/*@bgen(jjtree) Tuple */ SimpleNode jjtn000 = new SimpleNode(JJTTUPLE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) Tuple */try {/*@egen*/Attribute()/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}/*-------------------*/void CreT():{/*@bgen(jjtree) CreT */ SimpleNode jjtn000 = new SimpleNode(JJTCRET); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) CreT */try {/*@egen*/<CREATE><TABLE>Relation()<LEFTPARENTHESES>ColList()<RIGHTPARENTHESES>/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}void ColList():{/*@bgen(jjtree) ColList */ SimpleNode jjtn000 = new SimpleNode(JJTCOLLIST); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) ColList */try {/*@egen*/Attribute()Type()[(<COMMA>Attribute()Type())+]/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}void Type():{/*@bgen(jjtree) Type */ SimpleNode jjtn000 = new SimpleNode(JJTTYPE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) Type */try {/*@egen*/<INT>|<DATE>|<CHAR><LEFTPARENTHESES><INTEGER_LITERAL><RIGHTPARENTHESES>/*@bgen(jjtree)*/} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}/*-------------------*/void DropT():{/*@bgen(jjtree) DropT */ SimpleNode jjtn000 = new SimpleNode(JJTDROPT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) DropT */try {/*@egen*/<DROP><TABLE>Relation()/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}void DelT():{/*@bgen(jjtree) DelT */ SimpleNode jjtn000 = new SimpleNode(JJTDELT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) DelT */try {/*@egen*/<DELETE>DelList()<FROM>FromList()<WHERE>Condition()/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}void DelList():{/*@bgen(jjtree) DelList */ SimpleNode jjtn000 = new SimpleNode(JJTDELLIST); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) DelList */try {/*@egen*/Attribute()[(<COMMA>Attribute())+]/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}/*-------------------*/void InsT():{/*@bgen(jjtree) InsT */ SimpleNode jjtn000 = new SimpleNode(JJTINST); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) InsT */try {/*@egen*/<INSERT><INTO>Relation()<LEFTPARENTHESES>InList()<RIGHTPARENTHESES><VALUES><LEFTPARENTHESES>VList()<RIGHTPARENTHESES>/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}void InList():{/*@bgen(jjtree) InList */ SimpleNode jjtn000 = new SimpleNode(JJTINLIST); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) InList */try {/*@egen*/Attribute()[(<COMMA>Attribute())+]/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}void VList():{/*@bgen(jjtree) VList */ SimpleNode jjtn000 = new SimpleNode(JJTVLIST); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) VList */try {/*@egen*/<LEFTQUOTATION>IDENTIFIER()<LEFTQUOTATION>[(<COMMA><LEFTQUOTATION>IDENTIFIER()<LEFTQUOTATION>)+]/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}/*-------------------*/void Attribute():{/*@bgen(jjtree) Attribute */ SimpleNode jjtn000 = new SimpleNode(JJTATTRIBUTE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) Attribute */try {/*@egen*/IDENTIFIER()/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}void Relation():{/*@bgen(jjtree) Relation */ SimpleNode jjtn000 = new SimpleNode(JJTRELATION); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) Relation */try {/*@egen*/IDENTIFIER()/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}void Pattern():{/*@bgen(jjtree) Pattern */ SimpleNode jjtn000 = new SimpleNode(JJTPATTERN); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) Pattern */try {/*@egen*/<LQUOTATION>IDENTIFIER()<LQUOTATION>/*@bgen(jjtree)*/} catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { throw (RuntimeException)jjte000; } if (jjte000 instanceof ParseException) { throw (ParseException)jjte000; } throw (Error)jjte000;} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}/*-------------------*/void IDENTIFIER():{/*@bgen(jjtree) IDENTIFIER */ SimpleNode jjtn000 = new SimpleNode(JJTIDENTIFIER); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) IDENTIFIER */try {/*@egen*/<IDENTIFIER>/*@bgen(jjtree)*/} finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); }}/*@egen*/}
得到SQLParser.java:
/* Generated By:JJTree&JavaCC: Do not edit this line. SQLParser.java */
public class SQLParser/*@bgen(jjtree)*/implements SQLParserTreeConstants, SQLParserConstants {/*@bgen(jjtree)*/
protected static JJTSQLParserState jjtree = new JJTSQLParserState();public static void main(String args[]) {
System.out.println("Reading from standard input...");
SQLParser p = new SQLParser(System.in);
try {
SimpleNode n = p.Start();
n.dump("");
System.out.println("Thank you.");
} catch (Exception e) {
System.out.println("Oops.");
System.out.println(e.getMessage());
e.printStackTrace();
}
}
/* 语法解析*/
static final public SimpleNode Start() throws ParseException {
/*@bgen(jjtree) Start */
SimpleNode jjtn000 = new SimpleNode(JJTSTART);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
Expression();
jj_consume_token(SEMICOLON);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
{if (true) return jjtn000;}
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
throw new Error("Missing return statement in function");
}
static final public void Expression() throws ParseException {
/*@bgen(jjtree) Expression */
SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SELECT:
Query();
break;
case CREATE:
CreT();
break;
case DROP:
DropT();
break;
case DELETE:
DelT();
break;
case INSERT:
InsT();
break;
default:
jj_la1[0] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static final public void Query() throws ParseException {
/*@bgen(jjtree) Query */
SimpleNode jjtn000 = new SimpleNode(JJTQUERY);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
SFW();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ORDER:
jj_consume_token(ORDER);
jj_consume_token(BY);
Attribute();
break;
default:
jj_la1[1] = jj_gen;
;
}
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static final public void SFW() throws ParseException {
/*@bgen(jjtree) SFW */
SimpleNode jjtn000 = new SimpleNode(JJTSFW);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
jj_consume_token(SELECT);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case DISTINCT:
jj_consume_token(DISTINCT);
break;
default:
jj_la1[2] = jj_gen;
;
}
SelList();
jj_consume_token(FROM);
FromList();
jj_consume_token(WHERE);
Condition();
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static final public void SelList() throws ParseException {
/*@bgen(jjtree) SelList */
SimpleNode jjtn000 = new SimpleNode(JJTSELLIST);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
Attribute();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
label_1:
while (true) {
jj_consume_token(COMMA);
Attribute();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
;
break;
default:
jj_la1[3] = jj_gen;
break label_1;
}
}
break;
default:
jj_la1[4] = jj_gen;
;
}
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static final public void FromList() throws ParseException {
/*@bgen(jjtree) FromList */
SimpleNode jjtn000 = new SimpleNode(JJTFROMLIST);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
Relation();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
label_2:
while (true) {
jj_consume_token(COMMA);
Relation();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
;
break;
default:
jj_la1[5] = jj_gen;
break label_2;
}
}
break;
default:
jj_la1[6] = jj_gen;
;
}
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static final public void Condition() throws ParseException {
/*@bgen(jjtree) Condition */
SimpleNode jjtn000 = new SimpleNode(JJTCONDITION);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case IDENTIFIER:
Attribute();
jj_consume_token(EQUAL);
Attribute();
break;
default:
jj_la1[7] = jj_gen;
;
}
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static final public void Tuple() throws ParseException {
/*@bgen(jjtree) Tuple */
SimpleNode jjtn000 = new SimpleNode(JJTTUPLE);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
Attribute();
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
/*-------------------*/
static final public void CreT() throws ParseException {
/*@bgen(jjtree) CreT */
SimpleNode jjtn000 = new SimpleNode(JJTCRET);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
jj_consume_token(CREATE);
jj_consume_token(TABLE);
Relation();
jj_consume_token(LEFTPARENTHESES);
ColList();
jj_consume_token(RIGHTPARENTHESES);
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static final public void ColList() throws ParseException {
/*@bgen(jjtree) ColList */
SimpleNode jjtn000 = new SimpleNode(JJTCOLLIST);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
Attribute();
Type();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
label_3:
while (true) {
jj_consume_token(COMMA);
Attribute();
Type();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
;
break;
default:
jj_la1[10] = jj_gen;
break label_3;
}
}
break;
default:
jj_la1[11] = jj_gen;
;
}
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static final public void Type() throws ParseException {
/*@bgen(jjtree) Type */
SimpleNode jjtn000 = new SimpleNode(JJTTYPE);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case INT:
jj_consume_token(INT);
break;
case DATE:
jj_consume_token(DATE);
break;
case CHAR:
jj_consume_token(CHAR);
jj_consume_token(LEFTPARENTHESES);
jj_consume_token(INTEGER_LITERAL);
jj_consume_token(RIGHTPARENTHESES);
break;
default:
jj_la1[12] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
/*-------------------*/
static final public void DropT() throws ParseException {
/*@bgen(jjtree) DropT */
SimpleNode jjtn000 = new SimpleNode(JJTDROPT);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
jj_consume_token(DROP);
jj_consume_token(TABLE);
Relation();
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static final public void DelT() throws ParseException {
/*@bgen(jjtree) DelT */
SimpleNode jjtn000 = new SimpleNode(JJTDELT);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
jj_consume_token(DELETE);
DelList();
jj_consume_token(FROM);
FromList();
jj_consume_token(WHERE);
Condition();
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static final public void DelList() throws ParseException {
/*@bgen(jjtree) DelList */
SimpleNode jjtn000 = new SimpleNode(JJTDELLIST);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
Attribute();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
label_4:
while (true) {
jj_consume_token(COMMA);
Attribute();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
;
break;
default:
jj_la1[13] = jj_gen;
break label_4;
}
}
break;
default:
jj_la1[14] = jj_gen;
;
}
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
/*-------------------*/
static final public void InsT() throws ParseException {
/*@bgen(jjtree) InsT */
SimpleNode jjtn000 = new SimpleNode(JJTINST);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
jj_consume_token(INSERT);
jj_consume_token(INTO);
Relation();
jj_consume_token(LEFTPARENTHESES);
InList();
jj_consume_token(RIGHTPARENTHESES);
jj_consume_token(VALUES);
jj_consume_token(LEFTPARENTHESES);
VList();
jj_consume_token(RIGHTPARENTHESES);
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static final public void InList() throws ParseException {
/*@bgen(jjtree) InList */
SimpleNode jjtn000 = new SimpleNode(JJTINLIST);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
Attribute();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
label_5:
while (true) {
jj_consume_token(COMMA);
Attribute();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
;
break;
default:
jj_la1[15] = jj_gen;
break label_5;
}
}
break;
default:
jj_la1[16] = jj_gen;
;
}
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static final public void VList() throws ParseException {
/*@bgen(jjtree) VList */
SimpleNode jjtn000 = new SimpleNode(JJTVLIST);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
jj_consume_token(LEFTQUOTATION);
IDENTIFIER();
jj_consume_token(LEFTQUOTATION);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
label_6:
while (true) {
jj_consume_token(COMMA);
jj_consume_token(LEFTQUOTATION);
IDENTIFIER();
jj_consume_token(LEFTQUOTATION);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case COMMA:
;
break;
default:
jj_la1[17] = jj_gen;
break label_6;
}
}
break;
default:
jj_la1[18] = jj_gen;
;
}
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
/*-------------------*/
static final public void Attribute() throws ParseException {
/*@bgen(jjtree) Attribute */
SimpleNode jjtn000 = new SimpleNode(JJTATTRIBUTE);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
IDENTIFIER();
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static final public void Relation() throws ParseException {
/*@bgen(jjtree) Relation */
SimpleNode jjtn000 = new SimpleNode(JJTRELATION);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
IDENTIFIER();
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static final public void Pattern() throws ParseException {
/*@bgen(jjtree) Pattern */
SimpleNode jjtn000 = new SimpleNode(JJTPATTERN);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
jj_consume_token(LQUOTATION);
IDENTIFIER();
jj_consume_token(LQUOTATION);
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
/*-------------------*/
static final public void IDENTIFIER() throws ParseException {
/*@bgen(jjtree) IDENTIFIER */
SimpleNode jjtn000 = new SimpleNode(JJTIDENTIFIER);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
jj_consume_token(IDENTIFIER);
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
static private boolean jj_initialized_once = false;
static public SQLParserTokenManager 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[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[] {0x8003a0,0x8000,0x2000,0x2000000,0x2000000,0x2000000,0x2000000,0x0,0x0,0x0,0x2000000,0x2000000,0x700000,0x2000000,0x2000000,0x2000000,0x2000000,0x2000000,0x2000000,};
}
private static void jj_la1_1() {
jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};
}
public SQLParser(java.io.InputStream stream) {
this(stream, null);
}
public SQLParser(java.io.InputStream stream, String encoding) {
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;
try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source = new SQLParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 19; i++) jj_la1[i] = -1;
}
static public void ReInit(java.io.InputStream stream) {
ReInit(stream, null);
}
static public void ReInit(java.io.InputStream stream, String encoding) {
try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jjtree.reset();
jj_gen = 0;
for (int i = 0; i < 19; i++) jj_la1[i] = -1;
}
public SQLParser(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 SQLParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 19; 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;
jjtree.reset();
jj_gen = 0;
for (int i = 0; i < 19; i++) jj_la1[i] = -1;
}
public SQLParser(SQLParserTokenManager 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 < 19; i++) jj_la1[i] = -1;
}
public void ReInit(SQLParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jjtree.reset();
jj_gen = 0;
for (int i = 0; i < 19; 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 public ParseException generateParseException() {
jj_expentries.removeAllElements();
boolean[] la1tokens = new boolean[41];
for (int i = 0; i < 41; 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 < 41; 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() {
}
}