Oy. Sqlite users are ... they do some really stupid shit
parent
430f40dc14
commit
4eb5c0a440
|
@ -30,14 +30,13 @@ package net.sf.jsqlparser.expression;
|
|||
public abstract class BinaryExpression implements Expression {
|
||||
private Expression leftExpression;
|
||||
private Expression rightExpression;
|
||||
private boolean not = false;
|
||||
|
||||
public BinaryExpression(Expression leftExpression, Expression rightExpression) {
|
||||
public BinaryExpression(Expression leftExpression, Expression rightExpression) {
|
||||
this.leftExpression = leftExpression;
|
||||
this.rightExpression = rightExpression;
|
||||
this.rightExpression = rightExpression;
|
||||
}
|
||||
public BinaryExpression() {
|
||||
}
|
||||
public BinaryExpression() {
|
||||
}
|
||||
|
||||
|
||||
public Expression getLeftExpression() {
|
||||
|
@ -56,16 +55,8 @@ public abstract class BinaryExpression implements Expression {
|
|||
rightExpression = expression;
|
||||
}
|
||||
|
||||
public void setNot() {
|
||||
not = true;
|
||||
}
|
||||
|
||||
public boolean isNot() {
|
||||
return not;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return (not? "NOT ":"") + getLeftExpression()+" "+getStringExpression()+" "+getRightExpression();
|
||||
return getLeftExpression()+" "+getStringExpression()+" "+getRightExpression();
|
||||
}
|
||||
|
||||
public abstract String getStringExpression();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -156,25 +156,27 @@ public interface CCJSqlParserConstants {
|
|||
/** RegularExpression Id. */
|
||||
int K_INTERSECT = 65;
|
||||
/** RegularExpression Id. */
|
||||
int S_DOUBLE = 66;
|
||||
int K_CAST = 66;
|
||||
/** RegularExpression Id. */
|
||||
int S_INTEGER = 67;
|
||||
int S_DOUBLE = 67;
|
||||
/** RegularExpression Id. */
|
||||
int DIGIT = 68;
|
||||
int S_INTEGER = 68;
|
||||
/** RegularExpression Id. */
|
||||
int LINE_COMMENT = 69;
|
||||
int DIGIT = 69;
|
||||
/** RegularExpression Id. */
|
||||
int MULTI_LINE_COMMENT = 70;
|
||||
int LINE_COMMENT = 70;
|
||||
/** RegularExpression Id. */
|
||||
int S_IDENTIFIER = 71;
|
||||
int MULTI_LINE_COMMENT = 71;
|
||||
/** RegularExpression Id. */
|
||||
int LETTER = 72;
|
||||
int S_IDENTIFIER = 72;
|
||||
/** RegularExpression Id. */
|
||||
int SPECIAL_CHARS = 73;
|
||||
int LETTER = 73;
|
||||
/** RegularExpression Id. */
|
||||
int S_CHAR_LITERAL = 74;
|
||||
int SPECIAL_CHARS = 74;
|
||||
/** RegularExpression Id. */
|
||||
int S_QUOTED_IDENTIFIER = 75;
|
||||
int S_CHAR_LITERAL = 75;
|
||||
/** RegularExpression Id. */
|
||||
int S_QUOTED_IDENTIFIER = 76;
|
||||
|
||||
/** Lexical state. */
|
||||
int DEFAULT = 0;
|
||||
|
@ -247,6 +249,7 @@ public interface CCJSqlParserConstants {
|
|||
"\"TRUNCATE\"",
|
||||
"\"DISTINCT\"",
|
||||
"\"INTERSECT\"",
|
||||
"\"CAST\"",
|
||||
"<S_DOUBLE>",
|
||||
"<S_INTEGER>",
|
||||
"<DIGIT>",
|
||||
|
@ -268,14 +271,14 @@ public interface CCJSqlParserConstants {
|
|||
"\">\"",
|
||||
"\"<\"",
|
||||
"\"==\"",
|
||||
"\">=\"",
|
||||
"\"<=\"",
|
||||
"\">=\"",
|
||||
"\"<>\"",
|
||||
"\"!=\"",
|
||||
"\"@@\"",
|
||||
"\"||\"",
|
||||
"\"|\"",
|
||||
"\"&\"",
|
||||
"\"||\"",
|
||||
"\"+\"",
|
||||
"\"-\"",
|
||||
"\"/\"",
|
||||
|
|
|
@ -37,7 +37,6 @@ import net.sf.jsqlparser.expression.DateValue;
|
|||
import net.sf.jsqlparser.expression.TimeValue;
|
||||
import net.sf.jsqlparser.expression.TimestampValue;
|
||||
import net.sf.jsqlparser.expression.NullValue;
|
||||
import net.sf.jsqlparser.expression.Parenthesis;
|
||||
import net.sf.jsqlparser.expression.StringValue;
|
||||
import net.sf.jsqlparser.expression.BooleanValue;
|
||||
import net.sf.jsqlparser.expression.CaseExpression;
|
||||
|
@ -112,35 +111,35 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
|
|||
switch (pos)
|
||||
{
|
||||
case 0:
|
||||
if ((active0 & 0xffffffffffffffe0L) != 0L || (active1 & 0x3L) != 0L)
|
||||
if ((active0 & 0xffffffffffffffe0L) != 0L || (active1 & 0x7L) != 0L)
|
||||
{
|
||||
jjmatchedKind = 71;
|
||||
jjmatchedKind = 72;
|
||||
return 39;
|
||||
}
|
||||
if ((active1 & 0x200000000L) != 0L)
|
||||
if ((active1 & 0x400000000L) != 0L)
|
||||
return 8;
|
||||
if ((active1 & 0x20000L) != 0L)
|
||||
if ((active1 & 0x40000L) != 0L)
|
||||
return 1;
|
||||
if ((active1 & 0x100000000L) != 0L)
|
||||
if ((active1 & 0x200000000L) != 0L)
|
||||
return 5;
|
||||
return -1;
|
||||
case 1:
|
||||
if ((active0 & 0xff7f67ffffbbf000L) != 0L || (active1 & 0x1L) != 0L)
|
||||
if ((active0 & 0x80980000440fe0L) != 0L || (active1 & 0x2L) != 0L)
|
||||
return 39;
|
||||
if ((active0 & 0xff7f67ffffbbf000L) != 0L || (active1 & 0x5L) != 0L)
|
||||
{
|
||||
if (jjmatchedPos != 1)
|
||||
{
|
||||
jjmatchedKind = 71;
|
||||
jjmatchedKind = 72;
|
||||
jjmatchedPos = 1;
|
||||
}
|
||||
return 39;
|
||||
}
|
||||
if ((active0 & 0x80980000440fe0L) != 0L || (active1 & 0x2L) != 0L)
|
||||
return 39;
|
||||
return -1;
|
||||
case 2:
|
||||
if ((active0 & 0xffffffffffe00000L) != 0L || (active1 & 0x3L) != 0L)
|
||||
if ((active0 & 0xffffffffffe00000L) != 0L || (active1 & 0x7L) != 0L)
|
||||
{
|
||||
jjmatchedKind = 71;
|
||||
jjmatchedKind = 72;
|
||||
jjmatchedPos = 2;
|
||||
return 39;
|
||||
}
|
||||
|
@ -150,27 +149,27 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
|
|||
case 3:
|
||||
if ((active0 & 0xffffffe000000000L) != 0L || (active1 & 0x3L) != 0L)
|
||||
{
|
||||
jjmatchedKind = 71;
|
||||
jjmatchedKind = 72;
|
||||
jjmatchedPos = 3;
|
||||
return 39;
|
||||
}
|
||||
if ((active0 & 0x1fffe00000L) != 0L)
|
||||
if ((active0 & 0x1fffe00000L) != 0L || (active1 & 0x4L) != 0L)
|
||||
return 39;
|
||||
return -1;
|
||||
case 4:
|
||||
if ((active0 & 0x1ffe000000000L) != 0L)
|
||||
return 39;
|
||||
if ((active0 & 0xfffe000000000000L) != 0L || (active1 & 0x3L) != 0L)
|
||||
{
|
||||
jjmatchedKind = 71;
|
||||
jjmatchedKind = 72;
|
||||
jjmatchedPos = 4;
|
||||
return 39;
|
||||
}
|
||||
if ((active0 & 0x1ffe000000000L) != 0L)
|
||||
return 39;
|
||||
return -1;
|
||||
case 5:
|
||||
if ((active0 & 0xf800000000000000L) != 0L || (active1 & 0x3L) != 0L)
|
||||
{
|
||||
jjmatchedKind = 71;
|
||||
jjmatchedKind = 72;
|
||||
jjmatchedPos = 5;
|
||||
return 39;
|
||||
}
|
||||
|
@ -180,7 +179,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
|
|||
case 6:
|
||||
if ((active0 & 0x8000000000000000L) != 0L || (active1 & 0x3L) != 0L)
|
||||
{
|
||||
jjmatchedKind = 71;
|
||||
jjmatchedKind = 72;
|
||||
jjmatchedPos = 6;
|
||||
return 39;
|
||||
}
|
||||
|
@ -188,14 +187,14 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
|
|||
return 39;
|
||||
return -1;
|
||||
case 7:
|
||||
if ((active0 & 0x8000000000000000L) != 0L || (active1 & 0x1L) != 0L)
|
||||
return 39;
|
||||
if ((active1 & 0x2L) != 0L)
|
||||
{
|
||||
jjmatchedKind = 71;
|
||||
jjmatchedKind = 72;
|
||||
jjmatchedPos = 7;
|
||||
return 39;
|
||||
}
|
||||
if ((active0 & 0x8000000000000000L) != 0L || (active1 & 0x1L) != 0L)
|
||||
return 39;
|
||||
return -1;
|
||||
default :
|
||||
return -1;
|
||||
|
@ -216,42 +215,42 @@ private int jjMoveStringLiteralDfa0_0()
|
|||
switch(curChar)
|
||||
{
|
||||
case 33:
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x4000000L);
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x8000000L);
|
||||
case 38:
|
||||
return jjStopAtPos(0, 94);
|
||||
case 40:
|
||||
return jjStopAtPos(0, 79);
|
||||
case 41:
|
||||
return jjStopAtPos(0, 80);
|
||||
case 41:
|
||||
return jjStopAtPos(0, 81);
|
||||
case 42:
|
||||
return jjStopAtPos(0, 82);
|
||||
case 43:
|
||||
return jjStopAtPos(0, 95);
|
||||
case 44:
|
||||
return jjStopAtPos(0, 78);
|
||||
case 45:
|
||||
return jjStartNfaWithStates_0(0, 96, 5);
|
||||
case 46:
|
||||
return jjStartNfaWithStates_0(0, 81, 1);
|
||||
case 47:
|
||||
return jjStartNfaWithStates_0(0, 97, 8);
|
||||
case 59:
|
||||
return jjStopAtPos(0, 76);
|
||||
case 60:
|
||||
jjmatchedKind = 85;
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x3000000L);
|
||||
case 61:
|
||||
jjmatchedKind = 77;
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x400000L);
|
||||
case 62:
|
||||
jjmatchedKind = 84;
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x800000L);
|
||||
case 63:
|
||||
return jjStopAtPos(0, 83);
|
||||
case 43:
|
||||
return jjStopAtPos(0, 96);
|
||||
case 44:
|
||||
return jjStopAtPos(0, 79);
|
||||
case 45:
|
||||
return jjStartNfaWithStates_0(0, 97, 5);
|
||||
case 46:
|
||||
return jjStartNfaWithStates_0(0, 82, 1);
|
||||
case 47:
|
||||
return jjStartNfaWithStates_0(0, 98, 8);
|
||||
case 59:
|
||||
return jjStopAtPos(0, 77);
|
||||
case 60:
|
||||
jjmatchedKind = 86;
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x5000000L);
|
||||
case 61:
|
||||
jjmatchedKind = 78;
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x800000L);
|
||||
case 62:
|
||||
jjmatchedKind = 85;
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x2000000L);
|
||||
case 63:
|
||||
return jjStopAtPos(0, 84);
|
||||
case 64:
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x8000000L);
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x10000000L);
|
||||
case 94:
|
||||
return jjStopAtPos(0, 98);
|
||||
return jjStopAtPos(0, 99);
|
||||
case 65:
|
||||
case 97:
|
||||
return jjMoveStringLiteralDfa1_0(0x47020L, 0x0L);
|
||||
|
@ -260,7 +259,7 @@ private int jjMoveStringLiteralDfa0_0()
|
|||
return jjMoveStringLiteralDfa1_0(0x4000040000000040L, 0x0L);
|
||||
case 67:
|
||||
case 99:
|
||||
return jjMoveStringLiteralDfa1_0(0x4000040000000L, 0x0L);
|
||||
return jjMoveStringLiteralDfa1_0(0x4000040000000L, 0x4L);
|
||||
case 68:
|
||||
case 100:
|
||||
return jjMoveStringLiteralDfa1_0(0x2000002200080L, 0x1L);
|
||||
|
@ -316,12 +315,12 @@ private int jjMoveStringLiteralDfa0_0()
|
|||
case 119:
|
||||
return jjMoveStringLiteralDfa1_0(0x5080000000L, 0x0L);
|
||||
case 123:
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0xe800000000L);
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x1d000000000L);
|
||||
case 124:
|
||||
jjmatchedKind = 93;
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x10000000L);
|
||||
return jjMoveStringLiteralDfa1_0(0x0L, 0x80000000L);
|
||||
case 125:
|
||||
return jjStopAtPos(0, 100);
|
||||
return jjStopAtPos(0, 101);
|
||||
default :
|
||||
return jjMoveNfa_0(7, 0);
|
||||
}
|
||||
|
@ -336,37 +335,37 @@ private int jjMoveStringLiteralDfa1_0(long active0, long active1)
|
|||
switch(curChar)
|
||||
{
|
||||
case 61:
|
||||
if ((active1 & 0x400000L) != 0L)
|
||||
return jjStopAtPos(1, 86);
|
||||
else if ((active1 & 0x800000L) != 0L)
|
||||
if ((active1 & 0x800000L) != 0L)
|
||||
return jjStopAtPos(1, 87);
|
||||
else if ((active1 & 0x1000000L) != 0L)
|
||||
return jjStopAtPos(1, 88);
|
||||
else if ((active1 & 0x4000000L) != 0L)
|
||||
return jjStopAtPos(1, 90);
|
||||
else if ((active1 & 0x2000000L) != 0L)
|
||||
return jjStopAtPos(1, 89);
|
||||
else if ((active1 & 0x8000000L) != 0L)
|
||||
return jjStopAtPos(1, 91);
|
||||
break;
|
||||
case 62:
|
||||
if ((active1 & 0x2000000L) != 0L)
|
||||
return jjStopAtPos(1, 89);
|
||||
if ((active1 & 0x4000000L) != 0L)
|
||||
return jjStopAtPos(1, 90);
|
||||
break;
|
||||
case 64:
|
||||
if ((active1 & 0x8000000L) != 0L)
|
||||
return jjStopAtPos(1, 91);
|
||||
if ((active1 & 0x10000000L) != 0L)
|
||||
return jjStopAtPos(1, 92);
|
||||
break;
|
||||
case 65:
|
||||
case 97:
|
||||
return jjMoveStringLiteralDfa2_0(active0, 0x1240002040000000L, active1, 0L);
|
||||
return jjMoveStringLiteralDfa2_0(active0, 0x1240002040000000L, active1, 0x4L);
|
||||
case 68:
|
||||
case 100:
|
||||
if ((active1 & 0x800000000L) != 0L)
|
||||
return jjStopAtPos(1, 99);
|
||||
if ((active1 & 0x1000000000L) != 0L)
|
||||
return jjStopAtPos(1, 100);
|
||||
break;
|
||||
case 69:
|
||||
case 101:
|
||||
return jjMoveStringLiteralDfa2_0(active0, 0x600a040008228000L, active1, 0L);
|
||||
case 70:
|
||||
case 102:
|
||||
return jjMoveStringLiteralDfa2_0(active0, 0x10000000000000L, active1, 0x8000000000L);
|
||||
return jjMoveStringLiteralDfa2_0(active0, 0x10000000000000L, active1, 0x10000000000L);
|
||||
case 72:
|
||||
case 104:
|
||||
return jjMoveStringLiteralDfa2_0(active0, 0x4180000000L, active1, 0L);
|
||||
|
@ -414,12 +413,12 @@ private int jjMoveStringLiteralDfa1_0(long active0, long active1)
|
|||
return jjMoveStringLiteralDfa2_0(active0, 0x400008000040000L, active1, 0L);
|
||||
case 84:
|
||||
case 116:
|
||||
if ((active1 & 0x2000000000L) != 0L)
|
||||
if ((active1 & 0x4000000000L) != 0L)
|
||||
{
|
||||
jjmatchedKind = 101;
|
||||
jjmatchedKind = 102;
|
||||
jjmatchedPos = 1;
|
||||
}
|
||||
return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x4000000000L);
|
||||
return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x8000000000L);
|
||||
case 85:
|
||||
case 117:
|
||||
return jjMoveStringLiteralDfa2_0(active0, 0x400800800000L, active1, 0L);
|
||||
|
@ -432,8 +431,8 @@ private int jjMoveStringLiteralDfa1_0(long active0, long active1)
|
|||
return jjStartNfaWithStates_0(1, 6, 39);
|
||||
break;
|
||||
case 124:
|
||||
if ((active1 & 0x10000000L) != 0L)
|
||||
return jjStopAtPos(1, 92);
|
||||
if ((active1 & 0x80000000L) != 0L)
|
||||
return jjStopAtPos(1, 95);
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
|
@ -491,8 +490,8 @@ private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long a
|
|||
return jjMoveStringLiteralDfa3_0(active0, 0x200400000000L, active1, 0L);
|
||||
case 78:
|
||||
case 110:
|
||||
if ((active1 & 0x8000000000L) != 0L)
|
||||
return jjStopAtPos(2, 103);
|
||||
if ((active1 & 0x10000000000L) != 0L)
|
||||
return jjStopAtPos(2, 104);
|
||||
return jjMoveStringLiteralDfa3_0(active0, 0x100000000000L, active1, 0L);
|
||||
case 79:
|
||||
case 111:
|
||||
|
@ -504,9 +503,9 @@ private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long a
|
|||
return jjMoveStringLiteralDfa3_0(active0, 0x2000000000000000L, active1, 0L);
|
||||
case 83:
|
||||
case 115:
|
||||
if ((active1 & 0x4000000000L) != 0L)
|
||||
return jjStopAtPos(2, 102);
|
||||
return jjMoveStringLiteralDfa3_0(active0, 0x80000240200000L, active1, 0x1L);
|
||||
if ((active1 & 0x8000000000L) != 0L)
|
||||
return jjStopAtPos(2, 103);
|
||||
return jjMoveStringLiteralDfa3_0(active0, 0x80000240200000L, active1, 0x5L);
|
||||
case 84:
|
||||
case 116:
|
||||
if ((active0 & 0x10000L) != 0L)
|
||||
|
@ -613,6 +612,8 @@ private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long a
|
|||
case 116:
|
||||
if ((active0 & 0x8000000L) != 0L)
|
||||
return jjStartNfaWithStates_0(3, 27, 39);
|
||||
else if ((active1 & 0x4L) != 0L)
|
||||
return jjStartNfaWithStates_0(3, 66, 39);
|
||||
return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x1L);
|
||||
case 85:
|
||||
case 117:
|
||||
|
@ -879,8 +880,8 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
case 7:
|
||||
if ((0x3ff000000000000L & l) != 0L)
|
||||
{
|
||||
if (kind > 67)
|
||||
kind = 67;
|
||||
if (kind > 68)
|
||||
kind = 68;
|
||||
jjCheckNAddStates(0, 5);
|
||||
}
|
||||
else if (curChar == 34)
|
||||
|
@ -898,8 +899,8 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
case 16:
|
||||
if ((0x3ff001000000000L & l) == 0L)
|
||||
break;
|
||||
if (kind > 71)
|
||||
kind = 71;
|
||||
if (kind > 72)
|
||||
kind = 72;
|
||||
jjCheckNAdd(16);
|
||||
break;
|
||||
case 0:
|
||||
|
@ -909,8 +910,8 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
case 1:
|
||||
if ((0x3ff000000000000L & l) == 0L)
|
||||
break;
|
||||
if (kind > 66)
|
||||
kind = 66;
|
||||
if (kind > 67)
|
||||
kind = 67;
|
||||
jjCheckNAddTwoStates(1, 2);
|
||||
break;
|
||||
case 3:
|
||||
|
@ -920,22 +921,22 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
case 4:
|
||||
if ((0x3ff000000000000L & l) == 0L)
|
||||
break;
|
||||
if (kind > 66)
|
||||
kind = 66;
|
||||
if (kind > 67)
|
||||
kind = 67;
|
||||
jjCheckNAdd(4);
|
||||
break;
|
||||
case 5:
|
||||
if (curChar != 45)
|
||||
break;
|
||||
if (kind > 69)
|
||||
kind = 69;
|
||||
if (kind > 70)
|
||||
kind = 70;
|
||||
jjCheckNAdd(6);
|
||||
break;
|
||||
case 6:
|
||||
if ((0xffffffffffffdbffL & l) == 0L)
|
||||
break;
|
||||
if (kind > 69)
|
||||
kind = 69;
|
||||
if (kind > 70)
|
||||
kind = 70;
|
||||
jjCheckNAdd(6);
|
||||
break;
|
||||
case 8:
|
||||
|
@ -959,8 +960,8 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
jjCheckNAddTwoStates(12, 10);
|
||||
break;
|
||||
case 13:
|
||||
if (curChar == 47 && kind > 70)
|
||||
kind = 70;
|
||||
if (curChar == 47 && kind > 71)
|
||||
kind = 71;
|
||||
break;
|
||||
case 14:
|
||||
if (curChar == 47)
|
||||
|
@ -977,8 +978,8 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
case 19:
|
||||
if (curChar != 39)
|
||||
break;
|
||||
if (kind > 74)
|
||||
kind = 74;
|
||||
if (kind > 75)
|
||||
kind = 75;
|
||||
jjstateSet[jjnewStateCnt++] = 20;
|
||||
break;
|
||||
case 20:
|
||||
|
@ -998,8 +999,8 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
jjCheckNAddTwoStates(23, 24);
|
||||
break;
|
||||
case 24:
|
||||
if (curChar == 34 && kind > 75)
|
||||
kind = 75;
|
||||
if (curChar == 34 && kind > 76)
|
||||
kind = 76;
|
||||
break;
|
||||
case 26:
|
||||
if ((0xffffffffffffdbffL & l) != 0L)
|
||||
|
@ -1012,8 +1013,8 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
case 31:
|
||||
if ((0x3ff000000000000L & l) == 0L)
|
||||
break;
|
||||
if (kind > 67)
|
||||
kind = 67;
|
||||
if (kind > 68)
|
||||
kind = 68;
|
||||
jjCheckNAddStates(0, 5);
|
||||
break;
|
||||
case 32:
|
||||
|
@ -1035,15 +1036,15 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
case 37:
|
||||
if ((0x3ff000000000000L & l) == 0L)
|
||||
break;
|
||||
if (kind > 66)
|
||||
kind = 66;
|
||||
if (kind > 67)
|
||||
kind = 67;
|
||||
jjCheckNAdd(37);
|
||||
break;
|
||||
case 38:
|
||||
if ((0x3ff000000000000L & l) == 0L)
|
||||
break;
|
||||
if (kind > 67)
|
||||
kind = 67;
|
||||
if (kind > 68)
|
||||
kind = 68;
|
||||
jjCheckNAdd(38);
|
||||
break;
|
||||
default : break;
|
||||
|
@ -1060,8 +1061,8 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
case 7:
|
||||
if ((0x7fffffe87fffffeL & l) != 0L)
|
||||
{
|
||||
if (kind > 71)
|
||||
kind = 71;
|
||||
if (kind > 72)
|
||||
kind = 72;
|
||||
jjCheckNAddTwoStates(15, 16);
|
||||
}
|
||||
else if (curChar == 91)
|
||||
|
@ -1072,14 +1073,14 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
case 39:
|
||||
if ((0x7fffffe87fffffeL & l) != 0L)
|
||||
{
|
||||
if (kind > 71)
|
||||
kind = 71;
|
||||
if (kind > 72)
|
||||
kind = 72;
|
||||
jjCheckNAdd(16);
|
||||
}
|
||||
if ((0x7fffffe87fffffeL & l) != 0L)
|
||||
{
|
||||
if (kind > 71)
|
||||
kind = 71;
|
||||
if (kind > 72)
|
||||
kind = 72;
|
||||
jjCheckNAddTwoStates(15, 16);
|
||||
}
|
||||
break;
|
||||
|
@ -1088,8 +1089,8 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
jjAddStates(16, 17);
|
||||
break;
|
||||
case 6:
|
||||
if (kind > 69)
|
||||
kind = 69;
|
||||
if (kind > 70)
|
||||
kind = 70;
|
||||
jjstateSet[jjnewStateCnt++] = 6;
|
||||
break;
|
||||
case 9:
|
||||
|
@ -1102,15 +1103,15 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
case 15:
|
||||
if ((0x7fffffe87fffffeL & l) == 0L)
|
||||
break;
|
||||
if (kind > 71)
|
||||
kind = 71;
|
||||
if (kind > 72)
|
||||
kind = 72;
|
||||
jjCheckNAddTwoStates(15, 16);
|
||||
break;
|
||||
case 16:
|
||||
if ((0x7fffffe87fffffeL & l) == 0L)
|
||||
break;
|
||||
if (kind > 71)
|
||||
kind = 71;
|
||||
if (kind > 72)
|
||||
kind = 72;
|
||||
jjCheckNAdd(16);
|
||||
break;
|
||||
case 18:
|
||||
|
@ -1131,8 +1132,8 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
jjCheckNAddTwoStates(26, 27);
|
||||
break;
|
||||
case 27:
|
||||
if (curChar == 96 && kind > 75)
|
||||
kind = 75;
|
||||
if (curChar == 96 && kind > 76)
|
||||
kind = 76;
|
||||
break;
|
||||
case 28:
|
||||
if (curChar == 91)
|
||||
|
@ -1143,8 +1144,8 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
jjCheckNAddTwoStates(29, 30);
|
||||
break;
|
||||
case 30:
|
||||
if (curChar == 93 && kind > 75)
|
||||
kind = 75;
|
||||
if (curChar == 93 && kind > 76)
|
||||
kind = 76;
|
||||
break;
|
||||
case 35:
|
||||
if ((0x2000000020L & l) != 0L)
|
||||
|
@ -1165,8 +1166,8 @@ private int jjMoveNfa_0(int startState, int curPos)
|
|||
case 6:
|
||||
if ((jjbitVec0[i2] & l2) == 0L)
|
||||
break;
|
||||
if (kind > 69)
|
||||
kind = 69;
|
||||
if (kind > 70)
|
||||
kind = 70;
|
||||
jjstateSet[jjnewStateCnt++] = 6;
|
||||
break;
|
||||
case 9:
|
||||
|
@ -1227,9 +1228,9 @@ null, null, null, null, null, null, null, null, null, null, null, null, null, nu
|
|||
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null, null, null, null, "\73", "\75", "\54", "\50", "\51", "\56",
|
||||
"\52", "\77", "\76", "\74", "\75\75", "\76\75", "\74\75", "\74\76", "\41\75",
|
||||
"\100\100", "\174\174", "\174", "\46", "\53", "\55", "\57", "\136", null, "\175", null,
|
||||
null, null, null, null, null, null, null, null, "\73", "\75", "\54", "\50", "\51",
|
||||
"\56", "\52", "\77", "\76", "\74", "\75\75", "\74\75", "\76\75", "\74\76", "\41\75",
|
||||
"\100\100", "\174", "\46", "\174\174", "\53", "\55", "\57", "\136", null, "\175", null,
|
||||
null, null, };
|
||||
|
||||
/** Lexer state names. */
|
||||
|
@ -1237,13 +1238,13 @@ public static final String[] lexStateNames = {
|
|||
"DEFAULT",
|
||||
};
|
||||
static final long[] jjtoToken = {
|
||||
0xffffffffffffffe1L, 0xfffffffc8fL,
|
||||
0xffffffffffffffe1L, 0x1fffffff91fL,
|
||||
};
|
||||
static final long[] jjtoSkip = {
|
||||
0x1eL, 0x60L,
|
||||
0x1eL, 0xc0L,
|
||||
};
|
||||
static final long[] jjtoSpecial = {
|
||||
0x0L, 0x60L,
|
||||
0x0L, 0xc0L,
|
||||
};
|
||||
protected SimpleCharStream input_stream;
|
||||
private final int[] jjrounds = new int[39];
|
||||
|
|
|
@ -69,7 +69,6 @@ import net.sf.jsqlparser.expression.DateValue;
|
|||
import net.sf.jsqlparser.expression.TimeValue;
|
||||
import net.sf.jsqlparser.expression.TimestampValue;
|
||||
import net.sf.jsqlparser.expression.NullValue;
|
||||
import net.sf.jsqlparser.expression.Parenthesis;
|
||||
import net.sf.jsqlparser.expression.StringValue;
|
||||
import net.sf.jsqlparser.expression.BooleanValue;
|
||||
import net.sf.jsqlparser.expression.CaseExpression;
|
||||
|
@ -213,6 +212,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
|
|||
| <K_TRUNCATE:"TRUNCATE">
|
||||
| <K_DISTINCT:"DISTINCT">
|
||||
| <K_INTERSECT:"INTERSECT">
|
||||
| <K_CAST:"CAST">
|
||||
}
|
||||
|
||||
|
||||
|
@ -664,7 +664,7 @@ SelectItem SelectItem():
|
|||
|
|
||||
LOOKAHEAD(AllTableColumns()) selectItem=AllTableColumns()
|
||||
|
|
||||
expression=SimpleExpression() { selectExpressionItem = new SelectExpressionItem(); selectExpressionItem.setExpression(expression); }
|
||||
expression=Expression() { selectExpressionItem = new SelectExpressionItem(); selectExpressionItem.setExpression(expression); }
|
||||
[alias=Alias() { selectExpressionItem.setAlias(alias); }] { selectItem = selectExpressionItem; }
|
||||
)
|
||||
{
|
||||
|
@ -848,7 +848,7 @@ OrderByElement OrderByElement():
|
|||
Expression columnReference = null;
|
||||
}
|
||||
{
|
||||
columnReference = SimpleExpression()
|
||||
columnReference = Expression()
|
||||
[<K_ASC> | (<K_DESC> { orderByElement.setAsc(false); } ) ]
|
||||
{
|
||||
orderByElement.setExpression(columnReference);
|
||||
|
@ -924,15 +924,7 @@ Expression Expression():
|
|||
Expression retval = null;
|
||||
}
|
||||
{
|
||||
(
|
||||
LOOKAHEAD(OrExpression())
|
||||
retval=OrExpression()
|
||||
|
|
||||
"(" retval=Expression() ")" {retval = new Parenthesis(retval); }
|
||||
|
||||
)
|
||||
|
||||
{ return retval; }
|
||||
retval = OrExpression() { return retval; }
|
||||
}
|
||||
|
||||
Expression OrExpression() :
|
||||
|
@ -942,9 +934,7 @@ Expression OrExpression() :
|
|||
{
|
||||
left=AndExpression() { result = left; }
|
||||
(
|
||||
LOOKAHEAD(<K_OR>)
|
||||
<K_OR>
|
||||
right=AndExpression()
|
||||
LOOKAHEAD(<K_OR>) <K_OR> right=AndExpression()
|
||||
{
|
||||
result = new OrExpression(left, right);
|
||||
left = result;
|
||||
|
@ -953,97 +943,76 @@ Expression OrExpression() :
|
|||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Expression AndExpression() :
|
||||
{
|
||||
Expression left, right, result;
|
||||
boolean not = false;
|
||||
}
|
||||
{
|
||||
|
||||
left=Condition() { result = left; }
|
||||
(
|
||||
LOOKAHEAD(Condition())
|
||||
left=Condition()
|
||||
|
|
||||
[ <K_NOT> { not = true; } ]
|
||||
"(" left=OrExpression() ")" {left = new Parenthesis(left); if (not) { ((Parenthesis)left).setNot(); not = false; } }
|
||||
)
|
||||
{ result = left; }
|
||||
|
||||
(
|
||||
LOOKAHEAD(<K_AND>)
|
||||
<K_AND>
|
||||
(
|
||||
LOOKAHEAD(Condition())
|
||||
right=Condition()
|
||||
|
|
||||
[ <K_NOT> { not = true; } ]
|
||||
"(" right=OrExpression() ")" {right = new Parenthesis(right); if (not) { ((Parenthesis)right).setNot(); not = false; } }
|
||||
)
|
||||
{
|
||||
result = new AndExpression(left, right);
|
||||
left = result;
|
||||
}
|
||||
)*
|
||||
{
|
||||
return result;
|
||||
}
|
||||
LOOKAHEAD(<K_AND>) <K_AND> right=Condition()
|
||||
{
|
||||
result = new AndExpression(left, right);
|
||||
left = result;
|
||||
}
|
||||
)*
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Expression Condition():
|
||||
{
|
||||
Expression result;
|
||||
Token tok;
|
||||
}
|
||||
{
|
||||
(LOOKAHEAD(SQLCondition()) result=SQLCondition()
|
||||
| result=RegularCondition())
|
||||
( LOOKAHEAD(<K_NOT>) (<K_NOT> result = Condition()
|
||||
{ result = new InverseExpression(result); })
|
||||
| LOOKAHEAD(SQLCondition()) result=SQLCondition()
|
||||
| LOOKAHEAD(RegularCondition()) result=RegularCondition()
|
||||
)
|
||||
|
||||
{ return result; }
|
||||
}
|
||||
|
||||
Expression RegularCondition():
|
||||
{
|
||||
Expression result = null;
|
||||
BinaryExpression result;
|
||||
Expression leftExpression;
|
||||
Expression rightExpression;
|
||||
boolean not = false;
|
||||
}
|
||||
{
|
||||
|
||||
[ <K_NOT> { not = true; } ]
|
||||
leftExpression=ComparisonItem() { result = leftExpression; }
|
||||
|
||||
(
|
||||
">" { result = new GreaterThan(); }
|
||||
leftExpression=SimpleExpression()
|
||||
[ LOOKAHEAD(">" | "<" | "==" | "=" | "<=" | ">=" | "<>" | "!=" | "@@" | <K_IS> | <K_LIKE> | <K_NOT> <K_LIKE> ) (
|
||||
">" { result = new GreaterThan(); }
|
||||
| "<" { result = new MinorThan(); }
|
||||
| "==" { result = new EqualsTo(); }
|
||||
| "=" { result = new EqualsTo(); }
|
||||
| ("==" | "=" | <K_IS> ) { result = new EqualsTo(); }
|
||||
| ">=" { result = new GreaterThanEquals(); }
|
||||
| "<=" { result = new MinorThanEquals(); }
|
||||
| ("<>" | "!=") { result = new NotEqualsTo(); }
|
||||
| "@@" { result = new Matches(); }
|
||||
| <K_LIKE> { result = new LikeExpression(); }
|
||||
| <K_NOT> <K_LIKE> { result = new LikeExpression(); ((LikeExpression)result).setNot(true); }
|
||||
)
|
||||
rightExpression=ComparisonItem()
|
||||
rightExpression=ComparisonItem()
|
||||
{
|
||||
result.setLeftExpression(leftExpression);
|
||||
result.setRightExpression(rightExpression);
|
||||
leftExpression = result;
|
||||
}
|
||||
]
|
||||
{
|
||||
BinaryExpression regCond = (BinaryExpression) result;
|
||||
regCond.setLeftExpression(leftExpression);
|
||||
regCond.setRightExpression(rightExpression);
|
||||
if (not)
|
||||
regCond.setNot();
|
||||
return leftExpression;
|
||||
}
|
||||
|
||||
{ return result; }
|
||||
}
|
||||
|
||||
|
||||
Expression SQLCondition():
|
||||
{
|
||||
Expression result;
|
||||
Token tok;
|
||||
}
|
||||
{
|
||||
(
|
||||
|
@ -1051,30 +1020,19 @@ Expression SQLCondition():
|
|||
| LOOKAHEAD(Between()) result=Between()
|
||||
| LOOKAHEAD(IsNullExpression()) result=IsNullExpression()
|
||||
| LOOKAHEAD(ExistsExpression()) result=ExistsExpression()
|
||||
| LOOKAHEAD(LikeExpression()) result=LikeExpression()
|
||||
| LOOKAHEAD(1) tok = <S_INTEGER> {
|
||||
if(Long.parseLong(tok.image) != 0){
|
||||
result = BooleanValue.TRUE;
|
||||
} else {
|
||||
result = BooleanValue.FALSE;
|
||||
}
|
||||
}
|
||||
)
|
||||
{ return result; }
|
||||
}
|
||||
|
||||
Expression InExpression() :
|
||||
ItemsList ItemList() :
|
||||
{
|
||||
InExpression result = new InExpression();
|
||||
ItemsList itemsList = null;
|
||||
Expression leftExpression = null;
|
||||
Table table = null;
|
||||
}
|
||||
{
|
||||
leftExpression=SimpleExpression()
|
||||
[<K_NOT> { result.setNot(true); } ] <K_IN> ( ("("
|
||||
(("("
|
||||
[ ( LOOKAHEAD(SubSelect()) itemsList=SubSelect()
|
||||
| LOOKAHEAD(SimpleExpressionList()) itemsList=SimpleExpressionList()
|
||||
| LOOKAHEAD(ExpressionList()) itemsList=ExpressionList()
|
||||
)] ")")
|
||||
| LOOKAHEAD(Table()) table = Table() {
|
||||
// Encode `x IN tableName` as `x in (SELECT * FROM tableName)`
|
||||
|
@ -1087,8 +1045,19 @@ Expression InExpression() :
|
|||
new AllColumns()
|
||||
));
|
||||
itemsList = subSel;
|
||||
})
|
||||
}
|
||||
) { return itemsList; }
|
||||
}
|
||||
|
||||
Expression InExpression() :
|
||||
{
|
||||
InExpression result = new InExpression();
|
||||
ItemsList itemsList = null;
|
||||
Expression leftExpression = null;
|
||||
}
|
||||
{
|
||||
leftExpression=SimpleExpression()
|
||||
[<K_NOT> { result.setNot(true); } ] <K_IN> itemsList = ItemList()
|
||||
{
|
||||
result.setLeftExpression(leftExpression);
|
||||
result.setItemsList(itemsList);
|
||||
|
@ -1116,23 +1085,6 @@ Expression Between() :
|
|||
}
|
||||
}
|
||||
|
||||
Expression LikeExpression() :
|
||||
{
|
||||
LikeExpression result = new LikeExpression();
|
||||
Expression leftExpression = null;
|
||||
Expression rightExpression = null;
|
||||
}
|
||||
{
|
||||
leftExpression=SimpleExpression()
|
||||
[<K_NOT> { result.setNot(true); } ] <K_LIKE> rightExpression=SimpleExpression()
|
||||
[<K_ESCAPE> token=<S_CHAR_LITERAL> { result.setEscape((new StringValue(token.image)).getValue()); }]
|
||||
{
|
||||
result.setLeftExpression(leftExpression);
|
||||
result.setRightExpression(rightExpression);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Expression IsNullExpression():
|
||||
{
|
||||
IsNullExpression result = new IsNullExpression();
|
||||
|
@ -1155,7 +1107,7 @@ Expression ExistsExpression():
|
|||
Expression rightExpression = null;
|
||||
}
|
||||
{
|
||||
[<K_NOT> { result.setNot(true); } ] <K_EXISTS> rightExpression=SimpleExpression()
|
||||
<K_EXISTS> rightExpression=SimpleExpression()
|
||||
{
|
||||
result.setRightExpression(rightExpression);
|
||||
return result;
|
||||
|
@ -1163,28 +1115,15 @@ Expression ExistsExpression():
|
|||
}
|
||||
|
||||
|
||||
ExpressionList SQLExpressionList():
|
||||
ExpressionList ExpressionList():
|
||||
{
|
||||
ExpressionList retval = new ExpressionList();
|
||||
List expressions = new ArrayList();
|
||||
Expression expr = null;
|
||||
}
|
||||
{
|
||||
expr=Expression() { expressions.add(expr); } ("," expr=Expression() { expressions.add(expr); })*
|
||||
{
|
||||
retval.setExpressions(expressions);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
ExpressionList SimpleExpressionList():
|
||||
{
|
||||
ExpressionList retval = new ExpressionList();
|
||||
List expressions = new ArrayList();
|
||||
Expression expr = null;
|
||||
}
|
||||
{
|
||||
expr=SimpleExpression() { expressions.add(expr); } ("," expr=SimpleExpression() { expressions.add(expr); })*
|
||||
expr=Expression() { expressions.add(expr); }
|
||||
( LOOKAHEAD(",") "," expr=Expression() { expressions.add(expr); })*
|
||||
{
|
||||
retval.setExpressions(expressions);
|
||||
return retval;
|
||||
|
@ -1197,8 +1136,8 @@ Expression ComparisonItem() :
|
|||
}
|
||||
{
|
||||
(
|
||||
retval=AllComparisonExpression()
|
||||
| retval=AnyComparisonExpression()
|
||||
LOOKAHEAD(2) retval=AllComparisonExpression()
|
||||
| LOOKAHEAD(2) retval=AnyComparisonExpression()
|
||||
| retval=SimpleExpression()
|
||||
)
|
||||
|
||||
|
@ -1236,89 +1175,74 @@ Expression SimpleExpression():
|
|||
Expression retval = null;
|
||||
}
|
||||
{
|
||||
(
|
||||
LOOKAHEAD(BitwiseAndOr())
|
||||
retval=BitwiseAndOr()
|
||||
|
|
||||
"(" retval=BitwiseAndOr() ")" {retval = new Parenthesis(retval); }
|
||||
|
||||
)
|
||||
|
||||
{
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
Expression ConcatExpression():
|
||||
{
|
||||
Expression result = null;
|
||||
Expression leftExpression = null;
|
||||
Expression rightExpression = null;
|
||||
}
|
||||
{
|
||||
leftExpression=AdditiveExpression() { result = leftExpression; }
|
||||
(
|
||||
"||"
|
||||
rightExpression=AdditiveExpression()
|
||||
{
|
||||
Concat binExp = new Concat();
|
||||
binExp.setLeftExpression(leftExpression);
|
||||
binExp.setRightExpression(rightExpression);
|
||||
result = binExp;
|
||||
leftExpression = result;
|
||||
}
|
||||
)*
|
||||
|
||||
{ return result; }
|
||||
retval=BitwiseAndOr() { return retval; }
|
||||
}
|
||||
|
||||
Expression BitwiseAndOr():
|
||||
{
|
||||
BinaryExpression binExp;
|
||||
Expression result = null;
|
||||
Expression leftExpression = null;
|
||||
Expression rightExpression = null;
|
||||
}
|
||||
{
|
||||
leftExpression=ConcatExpression() { result = leftExpression; }
|
||||
result=ConcatExpression()
|
||||
(
|
||||
LOOKAHEAD(2) (
|
||||
"|" { result = new BitwiseOr(); }
|
||||
"|" { binExp = new BitwiseOr(); }
|
||||
|
|
||||
"&" { result = new BitwiseAnd(); }
|
||||
"&" { binExp = new BitwiseAnd(); }
|
||||
)
|
||||
|
||||
rightExpression=ConcatExpression()
|
||||
|
||||
{
|
||||
BinaryExpression binExp = (BinaryExpression) result;
|
||||
binExp.setLeftExpression(leftExpression);
|
||||
binExp.setLeftExpression(result);
|
||||
binExp.setRightExpression(rightExpression);
|
||||
leftExpression = result;
|
||||
result = binExp;
|
||||
}
|
||||
)*
|
||||
|
||||
{ return result; }
|
||||
}
|
||||
|
||||
Expression AdditiveExpression():
|
||||
Expression ConcatExpression():
|
||||
{
|
||||
Expression result = null;
|
||||
Expression leftExpression = null;
|
||||
Expression rightExpression = null;
|
||||
}
|
||||
{
|
||||
leftExpression=MultiplicativeExpression() { result = leftExpression; }
|
||||
result=AdditiveExpression()
|
||||
(
|
||||
LOOKAHEAD(2) ("+" { result = new Addition(); }
|
||||
| "-" { result = new Subtraction(); } )
|
||||
"||"
|
||||
rightExpression=AdditiveExpression()
|
||||
{
|
||||
Concat binExp = new Concat();
|
||||
binExp.setLeftExpression(result);
|
||||
binExp.setRightExpression(rightExpression);
|
||||
result = binExp;
|
||||
}
|
||||
)*
|
||||
{ return result; }
|
||||
}
|
||||
|
||||
Expression AdditiveExpression():
|
||||
{
|
||||
BinaryExpression binExp = null;
|
||||
Expression result = null;
|
||||
Expression rightExpression = null;
|
||||
}
|
||||
{
|
||||
result=MultiplicativeExpression()
|
||||
(
|
||||
LOOKAHEAD(2) ("+" { binExp = new Addition(); }
|
||||
| "-" { binExp = new Subtraction(); } )
|
||||
|
||||
rightExpression=MultiplicativeExpression()
|
||||
|
||||
{
|
||||
BinaryExpression binExp = (BinaryExpression) result;
|
||||
binExp.setLeftExpression(leftExpression);
|
||||
binExp.setLeftExpression(result);
|
||||
binExp.setRightExpression(rightExpression);
|
||||
leftExpression = result;
|
||||
result = binExp;
|
||||
}
|
||||
)*
|
||||
|
||||
|
@ -1328,34 +1252,20 @@ Expression AdditiveExpression():
|
|||
|
||||
Expression MultiplicativeExpression():
|
||||
{
|
||||
BinaryExpression binExp = null;
|
||||
Expression result = null;
|
||||
Expression leftExpression = null;
|
||||
Expression rightExpression = null;
|
||||
}
|
||||
{
|
||||
(
|
||||
LOOKAHEAD(BitwiseXor())
|
||||
leftExpression=BitwiseXor()
|
||||
|
|
||||
"(" leftExpression=AdditiveExpression() ")" {leftExpression = new Parenthesis(leftExpression); }
|
||||
)
|
||||
{ result = leftExpression; }
|
||||
result=BitwiseXor()
|
||||
(
|
||||
LOOKAHEAD(2) ("*" { result = new Multiplication(); }
|
||||
| "/" { result = new Division(); } )
|
||||
|
||||
(
|
||||
LOOKAHEAD(BitwiseXor())
|
||||
rightExpression=BitwiseXor()
|
||||
|
|
||||
"(" rightExpression=AdditiveExpression() ")" {rightExpression = new Parenthesis(rightExpression); }
|
||||
)
|
||||
|
||||
LOOKAHEAD(2) ("*" { binExp = new Multiplication(); }
|
||||
| "/" { binExp = new Division(); } )
|
||||
rightExpression=BitwiseXor()
|
||||
{
|
||||
BinaryExpression binExp = (BinaryExpression) result;
|
||||
binExp.setLeftExpression(leftExpression);
|
||||
binExp.setLeftExpression(result);
|
||||
binExp.setRightExpression(rightExpression);
|
||||
leftExpression = result;
|
||||
result = binExp;
|
||||
}
|
||||
)*
|
||||
{ return result; }
|
||||
|
@ -1364,32 +1274,43 @@ Expression MultiplicativeExpression():
|
|||
Expression BitwiseXor():
|
||||
{
|
||||
Expression result = null;
|
||||
Expression leftExpression = null;
|
||||
Expression rightExpression = null;
|
||||
}
|
||||
{
|
||||
leftExpression=PrimaryExpression() { result = leftExpression; }
|
||||
result=PMExpression()
|
||||
(
|
||||
"^"
|
||||
rightExpression=PrimaryExpression()
|
||||
rightExpression=PMExpression()
|
||||
{
|
||||
BitwiseXor binExp = new BitwiseXor();
|
||||
binExp.setLeftExpression(leftExpression);
|
||||
binExp.setLeftExpression(result);
|
||||
binExp.setRightExpression(rightExpression);
|
||||
result = binExp;
|
||||
leftExpression = result;
|
||||
}
|
||||
)*
|
||||
|
||||
{ return result; }
|
||||
}
|
||||
|
||||
Expression PMExpression():
|
||||
{
|
||||
Expression retval = null;
|
||||
boolean isInverse = false;
|
||||
}
|
||||
{
|
||||
[ "+" |
|
||||
("-" { isInverse = false; })
|
||||
] retval = PrimaryExpression()
|
||||
{
|
||||
if(isInverse) { retval = new InverseExpression(retval); }
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
Expression PrimaryExpression():
|
||||
{
|
||||
Expression retval = null;
|
||||
Token token = null;
|
||||
boolean isInverse = false;
|
||||
String tmp = "";
|
||||
}
|
||||
{
|
||||
|
@ -1398,37 +1319,33 @@ Expression PrimaryExpression():
|
|||
|
||||
<K_NULL> { retval = new NullValue(); }
|
||||
|
||||
| retval=CaseWhenExpression()
|
||||
| LOOKAHEAD(CaseWhenExpression()) retval=CaseWhenExpression()
|
||||
|
||||
| "?" { retval = new JdbcParameter(); }
|
||||
|
||||
| LOOKAHEAD([ "+" | "-"] Function()) [ "+" | "-" { isInverse = true; }] retval=Function()
|
||||
| LOOKAHEAD(Function()) retval=Function()
|
||||
|
||||
| LOOKAHEAD([ "+" | "-"] <S_DOUBLE>) [ "+" | "-" { tmp = "-"; }] token=<S_DOUBLE> { retval = new DoubleValue(tmp+token.image); }
|
||||
| token=<S_DOUBLE> { retval = new DoubleValue(token.image); }
|
||||
|
||||
| LOOKAHEAD([ "+" | "-"] <S_INTEGER>) [ "+" | "-" { tmp = "-"; }] token=<S_INTEGER> { retval = new LongValue(tmp+token.image); }
|
||||
| token=<S_INTEGER> { retval = new LongValue(token.image); }
|
||||
|
||||
| LOOKAHEAD(2) [ "+" | "-" { isInverse = true; }] retval=Column()
|
||||
| LOOKAHEAD(Column()) retval=Column()
|
||||
|
||||
| LOOKAHEAD(2) [ "+" | "-" { isInverse = true; }] "(" retval=PrimaryExpression() ")" {retval = new Parenthesis(retval); }
|
||||
| ( "(" (
|
||||
LOOKAHEAD(SubSelect()) retval=SubSelect()
|
||||
| LOOKAHEAD(Expression()) retval=Expression()
|
||||
) ")" )
|
||||
|
||||
| token=<S_CHAR_LITERAL> { retval = new StringValue(token.image); }
|
||||
|
||||
| [ "+" | "-" { isInverse = true; }] "(" retval=SubSelect() ")"
|
||||
|
||||
| "{d" token=<S_CHAR_LITERAL> "}" { retval = new DateValue(token.image); }
|
||||
|
||||
| "{t" token=<S_CHAR_LITERAL> "}" { retval = new TimeValue(token.image); }
|
||||
|
||||
| "{ts" token=<S_CHAR_LITERAL> "}" { retval = new TimestampValue(token.image); }
|
||||
|
||||
|
||||
)
|
||||
|
||||
{
|
||||
if (isInverse) {
|
||||
retval = new InverseExpression(retval);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
@ -1446,11 +1363,11 @@ Expression CaseWhenExpression():
|
|||
<K_CASE>
|
||||
(
|
||||
( clause=WhenThenSearchCondition() { whenClauses.add(clause); } )+
|
||||
[<K_ELSE> elseExp=PrimaryExpression()]
|
||||
[<K_ELSE> elseExp=Expression()]
|
||||
|
|
||||
switchExp=PrimaryExpression()
|
||||
switchExp=Expression()
|
||||
( clause=WhenThenValue() { whenClauses.add(clause); } )*
|
||||
[<K_ELSE> elseExp=PrimaryExpression()]
|
||||
[<K_ELSE> elseExp=Expression()]
|
||||
)
|
||||
<K_END>
|
||||
{
|
||||
|
@ -1468,7 +1385,7 @@ WhenClause WhenThenSearchCondition():
|
|||
Expression thenExp = null;
|
||||
}
|
||||
{
|
||||
<K_WHEN> whenExp=Expression() <K_THEN> thenExp=SimpleExpression()
|
||||
<K_WHEN> whenExp=Expression() <K_THEN> thenExp=Expression()
|
||||
{
|
||||
whenThen.setWhenExpression(whenExp);
|
||||
whenThen.setThenExpression(thenExp);
|
||||
|
@ -1483,7 +1400,7 @@ WhenClause WhenThenValue():
|
|||
Expression thenExp = null;
|
||||
}
|
||||
{
|
||||
<K_WHEN> whenExp=PrimaryExpression() <K_THEN> thenExp=SimpleExpression()
|
||||
<K_WHEN> whenExp=Expression() <K_THEN> thenExp=Expression()
|
||||
{
|
||||
whenThen.setWhenExpression(whenExp);
|
||||
whenThen.setThenExpression(thenExp);
|
||||
|
@ -1497,19 +1414,36 @@ Function Function():
|
|||
Function retval = new Function();
|
||||
String funcName = null;
|
||||
String tmp = null;
|
||||
ExpressionList expressionList = null;
|
||||
ExpressionList expressionList = null;
|
||||
Expression expression = null;
|
||||
}
|
||||
{
|
||||
["{fn" { retval.setEscaped(true); } ]
|
||||
// workaround for "CAST" function with non-standard syntax
|
||||
(( <K_CAST> "(" expression = SimpleExpression() <K_AS> tmp = RelObjectName() ")" {
|
||||
funcName = "CAST";
|
||||
expressionList = new ExpressionList();
|
||||
List expressions = new ArrayList();
|
||||
expressions.add(expression);
|
||||
expressions.add(new StringValue("'"+tmp+"'"));
|
||||
})
|
||||
| ["{fn" { retval.setEscaped(true); } ]
|
||||
(
|
||||
funcName=RelObjectName()
|
||||
|
|
||||
// workaround for replace(string) function (name clash with mysql REPLACE expression)
|
||||
<K_REPLACE> { funcName = "REPLACE"; }
|
||||
) [ "." tmp=RelObjectName() { funcName+= "." + tmp; } ["." tmp=RelObjectName() { funcName+= "." + tmp; }]]
|
||||
"(" [ [<K_DISTINCT> { retval.setDistinct(true); } | <K_ALL> { retval.setAllColumns(true); }] (expressionList=SimpleExpressionList() | "*" { retval.setAllColumns(true); }) ] ")"
|
||||
"(" [
|
||||
[ <K_DISTINCT> { retval.setDistinct(true); }
|
||||
| <K_ALL> { retval.setAllColumns(true); }
|
||||
]
|
||||
( expressionList=ExpressionList()
|
||||
| "*" { retval.setAllColumns(true); }
|
||||
)
|
||||
] ")"
|
||||
|
||||
["}"]
|
||||
)
|
||||
{
|
||||
retval.setParameters(expressionList);
|
||||
retval.setName(funcName);
|
||||
|
|
|
@ -231,8 +231,6 @@ public class ExpressionDeParser implements ExpressionVisitor, ItemsListVisitor {
|
|||
}
|
||||
|
||||
private void visitBinaryExpression(BinaryExpression binaryExpression, String operator) {
|
||||
if (binaryExpression.isNot())
|
||||
buffer.append(" NOT ");
|
||||
binaryExpression.getLeftExpression().accept(this);
|
||||
buffer.append(operator);
|
||||
binaryExpression.getRightExpression().accept(this);
|
||||
|
|
Loading…
Reference in New Issue