private ExprKraken parseCmpExpr ( ) { // Expr left = parseConcatExpr(); ExprKraken left = parseAddExpr ( ) ; Token token = scanToken ( ) ; boolean isNot = false ; /* if (token == NOT) { isNot = true; token = scanToken(); if (token != BETWEEN && token != LIKE && token != IN) { _token = token; return left; } } */ switch ( token ) { case EQ : return new BinaryExpr ( BinaryOp . EQ , left , parseAddExpr ( ) ) ; case NE : return new BinaryExpr ( BinaryOp . NE , left , parseAddExpr ( ) ) ; case LT : return new BinaryExpr ( BinaryOp . LT , left , parseAddExpr ( ) ) ; case LE : return new BinaryExpr ( BinaryOp . LE , left , parseAddExpr ( ) ) ; case GT : return new BinaryExpr ( BinaryOp . GT , left , parseAddExpr ( ) ) ; case GE : return new BinaryExpr ( BinaryOp . GE , left , parseAddExpr ( ) ) ; case BETWEEN : { ExprKraken min = parseAddExpr ( ) ; token = scanToken ( ) ; if ( token != Token . AND ) throw error ( L . l ( "expected AND at '{0}'" , token ) ) ; ExprKraken max = parseAddExpr ( ) ; return new BetweenExpr ( left , min , max , isNot ) ; } /* case LT: case LE: case GT: case GE: case NE: return new CmpExpr(left, parseConcatExpr(), token); case BETWEEN: { Expr min = parseConcatExpr(); token = scanToken(); if (token != AND) throw error(L.l("expected AND at '{0}'", tokenName(token))); Expr max = parseConcatExpr(); return new BetweenExpr(left, min, max, isNot); } case IS: { token = scanToken(); isNot = false; if (token == NOT) { token = scanToken(); isNot = true; } if (token == NULL) return new IsNullExpr(left, isNot); else throw error(L.l("expected NULL at '{0}'", tokenName(token))); } case LIKE: { token = scanToken(); if (token == STRING) return new LikeExpr(left, _lexeme, isNot); else throw error(L.l("expected string at '{0}'", tokenName(token))); } case IN: { HashSet<String> values = parseInValues(); return new InExpr(left, values, isNot); } */ default : _token = token ; return left ; } }
Parses a CMP expression .