parser.jj
来自「mysql集群」· JJ 代码 · 共 1,575 行 · 第 1/3 页
JJ
1,575 行
}
/*@egen*/
{
jjtn001.setFunction(tokenImage[MUL], new Multiply());
}
)/*@bgen(jjtree)*/
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
throw (RuntimeException)jjte001;
}
if (jjte001 instanceof ParseException) {
throw (ParseException)jjte001;
}
throw (Error)jjte001;
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, 2);
}
}
/*@egen*/
|/*@bgen(jjtree) #FunNode( 2) */
{
ASTFunNode jjtn002 = new ASTFunNode(JJTFUNNODE);
boolean jjtc002 = true;
jjtree.openNodeScope(jjtn002);
}
try {
/*@egen*/
( <DIV> UnaryExpression()/*@bgen(jjtree)*/
{
jjtree.closeNodeScope(jjtn002, 2);
jjtc002 = false;
}
/*@egen*/
{
jjtn002.setFunction(tokenImage[DIV], new Divide());
}
)/*@bgen(jjtree)*/
} catch (Throwable jjte002) {
if (jjtc002) {
jjtree.clearNodeScope(jjtn002);
jjtc002 = false;
} else {
jjtree.popNode();
}
if (jjte002 instanceof RuntimeException) {
throw (RuntimeException)jjte002;
}
if (jjte002 instanceof ParseException) {
throw (ParseException)jjte002;
}
throw (Error)jjte002;
} finally {
if (jjtc002) {
jjtree.closeNodeScope(jjtn002, 2);
}
}
/*@egen*/
|/*@bgen(jjtree) #FunNode( 2) */
{
ASTFunNode jjtn003 = new ASTFunNode(JJTFUNNODE);
boolean jjtc003 = true;
jjtree.openNodeScope(jjtn003);
}
try {
/*@egen*/
( <DIV2> UnaryExpression()/*@bgen(jjtree)*/
{
jjtree.closeNodeScope(jjtn003, 2);
jjtc003 = false;
}
/*@egen*/
{
jjtn003.setFunction(tokenImage[DIV2], new Divide());
}
)/*@bgen(jjtree)*/
} catch (Throwable jjte003) {
if (jjtc003) {
jjtree.clearNodeScope(jjtn003);
jjtc003 = false;
} else {
jjtree.popNode();
}
if (jjte003 instanceof RuntimeException) {
throw (RuntimeException)jjte003;
}
if (jjte003 instanceof ParseException) {
throw (ParseException)jjte003;
}
throw (Error)jjte003;
} finally {
if (jjtc003) {
jjtree.closeNodeScope(jjtn003, 2);
}
}
/*@egen*/
|/*@bgen(jjtree) #FunNode( 2) */
{
ASTFunNode jjtn004 = new ASTFunNode(JJTFUNNODE);
boolean jjtc004 = true;
jjtree.openNodeScope(jjtn004);
}
try {
/*@egen*/
( <MOD> UnaryExpression()/*@bgen(jjtree)*/
{
jjtree.closeNodeScope(jjtn004, 2);
jjtc004 = false;
}
/*@egen*/
{
jjtn004.setFunction(tokenImage[MOD], new Modulus());
}
)/*@bgen(jjtree)*/
} catch (Throwable jjte004) {
if (jjtc004) {
jjtree.clearNodeScope(jjtn004);
jjtc004 = false;
} else {
jjtree.popNode();
}
if (jjte004 instanceof RuntimeException) {
throw (RuntimeException)jjte004;
}
if (jjte004 instanceof ParseException) {
throw (ParseException)jjte004;
}
throw (Error)jjte004;
} finally {
if (jjtc004) {
jjtree.closeNodeScope(jjtn004, 2);
}
}
/*@egen*/
)*
}
void UnaryExpression() :
{
}
{
( <PLUS> UnaryExpression())
|/*@bgen(jjtree) #FunNode( 1) */
{
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
}
try {
/*@egen*/
( <MINUS> UnaryExpression()/*@bgen(jjtree)*/
{
jjtree.closeNodeScope(jjtn001, 1);
jjtc001 = false;
}
/*@egen*/
{
jjtn001.setFunction(tokenImage[MINUS], new UMinus());
}
)/*@bgen(jjtree)*/
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
throw (RuntimeException)jjte001;
}
if (jjte001 instanceof ParseException) {
throw (ParseException)jjte001;
}
throw (Error)jjte001;
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, 1);
}
}
/*@egen*/
|/*@bgen(jjtree) #FunNode( 1) */
{
ASTFunNode jjtn002 = new ASTFunNode(JJTFUNNODE);
boolean jjtc002 = true;
jjtree.openNodeScope(jjtn002);
}
try {
/*@egen*/
( <NOT> UnaryExpression()/*@bgen(jjtree)*/
{
jjtree.closeNodeScope(jjtn002, 1);
jjtc002 = false;
}
/*@egen*/
{
jjtn002.setFunction(tokenImage[NOT], new LogicalNOT());
}
)/*@bgen(jjtree)*/
} catch (Throwable jjte002) {
if (jjtc002) {
jjtree.clearNodeScope(jjtn002);
jjtc002 = false;
} else {
jjtree.popNode();
}
if (jjte002 instanceof RuntimeException) {
throw (RuntimeException)jjte002;
}
if (jjte002 instanceof ParseException) {
throw (ParseException)jjte002;
}
throw (Error)jjte002;
} finally {
if (jjtc002) {
jjtree.closeNodeScope(jjtn002, 1);
}
}
/*@egen*/
|
UnaryExpressionNotPlusMinus()
}
void UnaryExpressionNotPlusMinus() :
{
String identString = "";
int type;
}
{
AnyConstant()
|
( LOOKAHEAD({ getToken(1).kind == IDENTIFIER &&
containsKey(getToken(1).image) })
Function()
|
Variable()
)
|
"(" Expression() ")"
}
void Variable() :
{
String identString = "";
}
{/*@bgen(jjtree) VarNode */
{
ASTVarNode jjtn001 = new ASTVarNode(JJTVARNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
}
try {
/*@egen*/
(identString = Identifier()/*@bgen(jjtree)*/
{
jjtree.closeNodeScope(jjtn001, true);
jjtc001 = false;
}
/*@egen*/
{
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 +"\"");
}
}
}
)/*@bgen(jjtree)*/
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
throw (RuntimeException)jjte001;
}
if (jjte001 instanceof ParseException) {
throw (ParseException)jjte001;
}
throw (Error)jjte001;
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, true);
}
}
/*@egen*/
}
void Function() :
{
int reqArguments = 0;
String identString = "";
}
{/*@bgen(jjtree) FunNode */
{
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
}
try {
/*@egen*/
( 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 +"\"");
}
}
"("ArgumentList(reqArguments, identString)")"
)/*@bgen(jjtree)*/
} catch (Throwable jjte001) {
if (jjtc001) {
jjtree.clearNodeScope(jjtn001);
jjtc001 = false;
} else {
jjtree.popNode();
}
if (jjte001 instanceof RuntimeException) {
throw (RuntimeException)jjte001;
}
if (jjte001 instanceof ParseException) {
throw (ParseException)jjte001;
}
throw (Error)jjte001;
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, true);
}
}
/*@egen*/
}
void ArgumentList(int reqArguments, String functionName) :
{
int count = 0;
String errorStr = "";
}
{
[
Expression() { count++; }
(
","
Expression() { count++; }
)*
]
{
if (reqArguments != count && reqArguments != -1) {
errorStr = "Function \"" + functionName +"\" requires "
+ reqArguments + " parameter";
if (reqArguments!=1) errorStr += "s";
addToErrorList(errorStr);
}
}
}
String Identifier() :
{
Token t;
}
{
t=<IDENTIFIER>
{
if(t.image.startsWith("`")){
return t.image.substring(1,t.image.length()-1);
}else
{
return t.image;
}
}
}
void Array() :
{/*@bgen(jjtree) Array */
ASTArray jjtn000 = new ASTArray(JJTARRAY);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
/*@egen*/
}
{/*@bgen(jjtree) Array */
try {
/*@egen*/
"("
AdditiveExpression()
(
","
AdditiveExpression()
)*
")"/*@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 AnyConstant() :
{/*@bgen(jjtree) Constant */
ASTConstant jjtn000 = new ASTConstant(JJTCONSTANT);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
/*@egen*/
Token t;
}
{/*@bgen(jjtree) Constant */
try {
/*@egen*/
t=<NULL_LITERAL>/*@bgen(jjtree)*/
{
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
}
/*@egen*/ {
jjtn000.value = null;
}
|
t=<TRUE_LITERAL>/*@bgen(jjtree)*/
{
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
}
/*@egen*/ {
jjtn000.value = Boolean.TRUE;
}
|
t=<FALSE_LITERAL>/*@bgen(jjtree)*/
{
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
}
/*@egen*/ {
jjtn000.value = Boolean.FALSE;
}
|
t=<STRING_LITERAL>/*@bgen(jjtree)*/
{
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
}
/*@egen*/ {
// 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;
}
|
t=<INTEGER_LITERAL>/*@bgen(jjtree)*/
{
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
}
/*@egen*/ {
try {
jjtn000.value = Long.valueOf(t.image);
}
catch (Exception e) {
jjtn000.value = null;
addToErrorList("Can't parse \"" + t.image + "\"");
}
}
|
t=<FLOATING_POINT_LITERAL>/*@bgen(jjtree)*/
{
jjtree.closeNodeScope(jjtn000, true);
jjtc000 = false;
}
/*@egen*/ {
try {
jjtn000.value = new BigDecimal(t.image);
}
catch (Exception e) {
jjtn000.value = null;
addToErrorList("Can't parse \"" + t.image + "\"");
}
}/*@bgen(jjtree)*/
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
/*@egen*/
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?