diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-09-28 16:19:30 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-09-28 16:19:30 +0200 |
commit | 3d49f155fccfa4fc08882b01e7a6e3a982c55212 (patch) | |
tree | 865d6e301e5fcd3fba248807ff980bcc7e18d41f /searchlib/src/main/javacc | |
parent | 7cfc4fa47828261ee1f839a27a437d8bc49eb26f (diff) |
Fold comparisons into the other operators
Diffstat (limited to 'searchlib/src/main/javacc')
-rwxr-xr-x | searchlib/src/main/javacc/RankingExpressionParser.jj | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/searchlib/src/main/javacc/RankingExpressionParser.jj b/searchlib/src/main/javacc/RankingExpressionParser.jj index ebe1e048247..2261d39829c 100755 --- a/searchlib/src/main/javacc/RankingExpressionParser.jj +++ b/searchlib/src/main/javacc/RankingExpressionParser.jj @@ -72,13 +72,13 @@ TOKEN : <COMMA: ","> | <COLON: ":"> | - <LE: "<="> | - <LT: "<"> | - <EQ: "=="> | - <NQ: "!="> | - <AQ: "~="> | - <GE: ">="> | - <GT: ">"> | + <GREATEREQUAL: ">="> | + <GREATER: ">"> | + <LESSEQUAL: "<="> | + <LESS: "<"> | + <APPROX: "~="> | + <NOTEQUAL: "!="> | + <EQUAL: "=="> | <STRING: ("\"" (~["\""] | "\\\"")* "\"") | ("'" (~["'"] | "\\'")* "'")> | @@ -188,14 +188,12 @@ ExpressionNode expression() : { ExpressionNode left, right; List<ExpressionNode> rightList; - TruthOperator comparatorOp; } { ( left = arithmeticExpression() ( - ( comparatorOp = comparator() right = arithmeticExpression() { left = new ComparisonNode(left, comparatorOp, right); } ) | ( <IN> rightList = expressionList() { left = new SetMembershipNode(left, rightList); } ) - ) * + ) ? ) { return left; } } @@ -214,29 +212,26 @@ ExpressionNode arithmeticExpression() : ArithmeticOperator arithmetic() : { } { - ( <ADD> { return ArithmeticOperator.PLUS; } | - <SUB> { return ArithmeticOperator.MINUS; } | - <DIV> { return ArithmeticOperator.DIVIDE; } | - <MUL> { return ArithmeticOperator.MULTIPLY; } | - <MOD> { return ArithmeticOperator.MODULO; } | - <AND> { return ArithmeticOperator.AND; } | - <OR> { return ArithmeticOperator.OR; } | - <POWOP> { return ArithmeticOperator.POWER; } ) + ( + <OR> { return ArithmeticOperator.OR; } | + <AND> { return ArithmeticOperator.AND; } | + <GREATEREQUAL> { return ArithmeticOperator.GREATEREQUAL; } | + <GREATER> { return ArithmeticOperator.GREATER; } | + <LESSEQUAL> { return ArithmeticOperator.LESSEQUAL; } | + <LESS> { return ArithmeticOperator.LESS; } | + <APPROX> { return ArithmeticOperator.APPROX; } | + <NOTEQUAL> { return ArithmeticOperator.NOTEQUAL; } | + <EQUAL> { return ArithmeticOperator.EQUAL; } | + <ADD> { return ArithmeticOperator.PLUS; } | + <SUB> { return ArithmeticOperator.MINUS; } | + <DIV> { return ArithmeticOperator.DIVIDE; } | + <MUL> { return ArithmeticOperator.MULTIPLY; } | + <MOD> { return ArithmeticOperator.MODULO; } | + <POWOP> { return ArithmeticOperator.POWER; } + ) { return null; } } -TruthOperator comparator() : { } -{ - ( <LE> { return TruthOperator.SMALLEREQUAL; } | - <LT> { return TruthOperator.SMALLER; } | - <EQ> { return TruthOperator.EQUAL; } | - <NQ> { return TruthOperator.NOTEQUAL; } | - <AQ> { return TruthOperator.APPROX_EQUAL; } | - <GE> { return TruthOperator.LARGEREQUAL; } | - <GT> { return TruthOperator.LARGER; } ) - { return null; } -} - ExpressionNode value() : { ExpressionNode value; @@ -665,7 +660,7 @@ TensorType.Value optionalTensorValueTypeParameter() : String valueType = "double"; } { - ( <LT> valueType = identifier() <GT> )? + ( <LESS> valueType = identifier() <GREATER> )? { return TensorType.Value.fromId(valueType); } } |