SLING-7700 - [HTL] Implement operator precedence for binary operations
diff --git a/src/main/antlr4/org/apache/sling/scripting/sightly/impl/parser/expr/generated/SightlyLexer.g4 b/src/main/antlr4/org/apache/sling/scripting/sightly/impl/parser/expr/generated/SightlyLexer.g4
index de8c1fc..255fb2a 100644
--- a/src/main/antlr4/org/apache/sling/scripting/sightly/impl/parser/expr/generated/SightlyLexer.g4
+++ b/src/main/antlr4/org/apache/sling/scripting/sightly/impl/parser/expr/generated/SightlyLexer.g4
@@ -115,7 +115,7 @@
fragment
ESC_SEQ
- : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
+ : '\\' ('b'|'t'|'n'|'f'|'r'|'"'|'\''|'\\')
| UNICODE_ESC
;
diff --git a/src/main/antlr4/org/apache/sling/scripting/sightly/impl/parser/expr/generated/SightlyParser.g4 b/src/main/antlr4/org/apache/sling/scripting/sightly/impl/parser/expr/generated/SightlyParser.g4
index 2470086..e605fca 100644
--- a/src/main/antlr4/org/apache/sling/scripting/sightly/impl/parser/expr/generated/SightlyParser.g4
+++ b/src/main/antlr4/org/apache/sling/scripting/sightly/impl/parser/expr/generated/SightlyParser.g4
@@ -72,18 +72,21 @@
exprNode returns [ExpressionNode node]
- : condition=binaryOp TERNARY_Q_OP thenBranch=binaryOp TERNARY_BRANCHES_OP elseBranch=binaryOp
+ : condition=orBinaryOp TERNARY_Q_OP thenBranch=orBinaryOp TERNARY_BRANCHES_OP elseBranch=orBinaryOp
{$node = new TernaryOperator($condition.node, $thenBranch.node, $elseBranch.node);}
- | binaryOp {$node = $binaryOp.node;}
+ | orBinaryOp {$node = $orBinaryOp.node;}
;
-binaryOp returns [ExpressionNode node] //is there any priority precedence between AND & OR ?
- : left=comparisonTerm { $node = $left.node; }
- (operator right=comparisonTerm { $node = new BinaryOperation($operator.op, $node, $right.node); })*
+orBinaryOp returns [ExpressionNode node]
+ : left=andBinaryOp { $node = $left.node; } (OR_OP right=andBinaryOp { $node = new BinaryOperation(BinaryOperator.OR, $node, $right.node);})*
;
-
-operator returns [BinaryOperator op]
- : AND_OP { $op = BinaryOperator.AND; } | OR_OP { $op = BinaryOperator.OR; } | IN_OP { $op = BinaryOperator.IN; }
+
+andBinaryOp returns [ExpressionNode node]
+ : left=inBinaryOp { $node = $left.node; } (AND_OP right=inBinaryOp{ $node = new BinaryOperation(BinaryOperator.AND, $node, $right.node);})*
+ ;
+
+inBinaryOp returns [ExpressionNode node]
+ : left=comparisonTerm { $node = $left.node; } (IN_OP right=comparisonTerm { $node = new BinaryOperation(BinaryOperator.IN, $node, $right.node); })*
;
comparisonTerm returns [ExpressionNode node]