parser.java
来自「mysql集群」· Java 代码 · 共 1,787 行 · 第 1/4 页
JAVA
1,787 行
if (jjte004 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte004;}
}
if (jjte004 instanceof ParseException) {
{if (true) throw (ParseException)jjte004;}
}
{if (true) throw (Error)jjte004;}
} finally {
if (jjtc004) {
jjtree.closeNodeScope(jjtn004, 2);
}
}
break;
default:
jj_la1[12] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
}
final public void UnaryExpression() throws ParseException {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case PLUS:
jj_consume_token(PLUS);
UnaryExpression();
break;
case MINUS:
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
try {
jj_consume_token(MINUS);
UnaryExpression();
jjtree.closeNodeScope(jjtn001, 1);
jjtc001 = false;
jjtn001.setFunction(tokenImage[MINUS], new UMinus());
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte001;}
}
if (jjte001 instanceof ParseException) {
{if (true) throw (ParseException)jjte001;}
}
{if (true) throw (Error)jjte001;}
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, 1);
}
}
break;
case NOT:
ASTFunNode jjtn002 = new ASTFunNode(JJTFUNNODE);
boolean jjtc002 = true;
jjtree.openNodeScope(jjtn002);
try {
jj_consume_token(NOT);
UnaryExpression();
jjtree.closeNodeScope(jjtn002, 1);
jjtc002 = false;
jjtn002.setFunction(tokenImage[NOT], new LogicalNOT());
} catch (Throwable jjte002) {
if (jjtc002) {
jjtree.clearNodeScope(jjtn002);
jjtc002 = false;
} else {
jjtree.popNode();
}
if (jjte002 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte002;}
}
if (jjte002 instanceof ParseException) {
{if (true) throw (ParseException)jjte002;}
}
{if (true) throw (Error)jjte002;}
} finally {
if (jjtc002) {
jjtree.closeNodeScope(jjtn002, 1);
}
}
break;
default:
jj_la1[13] = jj_gen;
if (jj_2_2(1)) {
UnaryExpressionNotPlusMinus();
} else {
jj_consume_token(-1);
throw new ParseException();
}
}
}
final public void UnaryExpressionNotPlusMinus() throws ParseException {
String identString = "";
int type;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NULL_LITERAL:
case TRUE_LITERAL:
case FALSE_LITERAL:
case INTEGER_LITERAL:
case FLOATING_POINT_LITERAL:
case STRING_LITERAL:
AnyConstant();
break;
default:
jj_la1[15] = jj_gen;
if (jj_2_3(1)) {
if (getToken(1).kind == IDENTIFIER &&
containsKey(getToken(1).image)) {
Function();
} else {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case IDENTIFIER:
Variable();
break;
default:
jj_la1[14] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
} else {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 40:
jj_consume_token(40);
Expression();
jj_consume_token(41);
break;
default:
jj_la1[16] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
}
}
final public void Variable() throws ParseException {
String identString = "";
ASTVarNode jjtn001 = new ASTVarNode(JJTVARNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
try {
identString = Identifier();
jjtree.closeNodeScope(jjtn001, true);
jjtc001 = false;
Variable c = getVariable(identString);
if (c != null) {
jjtn001.index = -1;
jjtn001.variable = c;
}
else {
int i = findColumn(identString);
if (i >= 0) {
jjtn001.index = i;
jjtn001.variable = null;
}
else {
addToErrorList("Unrecognized symbol \"" + identString +"\"");
}
}
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte001;}
}
if (jjte001 instanceof ParseException) {
{if (true) throw (ParseException)jjte001;}
}
{if (true) throw (Error)jjte001;}
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, true);
}
}
}
final public void Function() throws ParseException {
int reqArguments = 0;
String identString = "";
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
try {
identString = Identifier();
PostfixCommandI func = getFunction(identString);
if (func != null) {
//Set number of required arguments
reqArguments = func.getNumberOfParameters();
jjtn001.setFunction(identString, func);
} else {
addToErrorList("!!! Unrecognized function \"" + identString +"\"");
}
jj_consume_token(40);
ArgumentList(reqArguments, identString);
jj_consume_token(41);
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte001;}
}
if (jjte001 instanceof ParseException) {
{if (true) throw (ParseException)jjte001;}
}
{if (true) throw (Error)jjte001;}
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, true);
}
}
}
final public void ArgumentList(int reqArguments, String functionName) throws ParseException {
int count = 0;
String errorStr = "";
if (jj_2_4(1)) {
Expression();
count++;
label_7:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 42:
;
break;
default:
jj_la1[17] = jj_gen;
break label_7;
}
jj_consume_token(42);
Expression();
count++;
}
} else {
;
}
if (reqArguments != count && reqArguments != -1) {
errorStr = "Function \"" + functionName +"\" requires "
+ reqArguments + " parameter";
if (reqArguments!=1) errorStr += "s";
addToErrorList(errorStr);
}
}
final public String Identifier() throws ParseException {
Token t;
t = jj_consume_token(IDENTIFIER);
if(t.image.startsWith("`")){
{if (true) return t.image.substring(1,t.image.length()-1);}
}else
{
{if (true) return t.image;}
}
throw new Error("Missing return statement in function");
}
final public void Array() throws ParseException {
/*@bgen(jjtree) Array */
ASTArray jjtn000 = new ASTArray(JJTARRAY);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
jj_consume_token(40);
AdditiveExpression();
label_8:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 42:
;
break;
default:
jj_la1[18] = jj_gen;
break label_8;
}
jj_consume_token(42);
AdditiveExpression();
}
jj_consume_token(41);
} 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);
}
}
}
final public void AnyConstant() throws ParseException {
/*@bgen(jjtree) Constant */
ASTConstant jjtn000 = new ASTConstant(JJTCONSTANT);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);Token t;
try {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NULL_LITERAL:
t = jj_consume_token(NULL_LITERAL);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
jjtn000.value = null;
break;
case TRUE_LITERAL:
t = jj_consume_token(TRUE_LITERAL);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
jjtn000.value = Boolean.TRUE;
break;
case FALSE_LITERAL:
t = jj_consume_token(FALSE_LITERAL);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
jjtn000.value = Boolean.FALSE;
break;
case STRING_LITERAL:
t = jj_consume_token(STRING_LITERAL);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
// strip away double quotes at end of string
String temp = (t.image).substring(1,t.image.length()-1);
// replace escape characters
temp = replaceEscape(temp);
jjtn000.value = temp;
break;
case INTEGER_LITERAL:
t = jj_consume_token(INTEGER_LITERAL);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
try {
jjtn000.value = Long.valueOf(t.image);
}
catch (Exception e) {
jjtn000.value = null;
addToErrorList("Can't parse \"" + t.image + "\"");
}
break;
case FLOATING_POINT_LITERAL:
t = jj_consume_token(FLOATING_POINT_LITERAL);
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
try {
jjtn000.value = new BigDecimal(t.image);
}
catch (Exception e) {
jjtn000.value = null;
addToErrorList("Can't parse \"" + t.image + "\"");
}
break;
default:
jj_la1[19] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
}
final private boolean jj_2_1(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_1(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(0, xla); }
}
final private boolean jj_2_2(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_2(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(1, xla); }
}
final private boolean jj_2_3(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_3(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(2, xla); }
}
final private boolean jj_2_4(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_4(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(3, xla); }
}
final private boolean jj_3R_12() {
if (jj_3R_17()) return true;
return false;
}
final private boolean jj_3R_29() {
if (jj_3R_30()) return true;
return false;
}
final private boolean jj_3R_27() {
if (jj_scan_token(FLOATING_POINT_LITERAL)) return true;
return false;
}
final private boolean jj_3R_9() {
if (jj_3R_13()) return true;
return false;
}
final private boolean jj_3R_15() {
if (jj_scan_token(40)) return true;
return false;
}
final private boolean jj_3R_30() {
if (jj_3R_31()) return true;
return false;
}
final private boolean jj_3R_21() {
if (jj_3R_28()) return true;
return false;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?