]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Support "in" operator in grammar
authorKevin <kevin@kevin-brown.com>
Tue, 12 May 2020 01:45:43 +0000 (21:45 -0400)
committerKevin <kevin@kevin-brown.com>
Tue, 12 May 2020 01:45:43 +0000 (21:45 -0400)
This changes the previous comparison operations from being marked
as solely comparion expressions and expands them out to be generation
operator expressions. This allows us to easily support the "in"
operator, which in the current Jinja parser is handled exactly the
same as the other operations, but it does require us to special case
the automated conversion of the "not ... in" expression to a "notin"
expression.

grammar.ebnf

index edcb02f6a5c97fc7062aae6d624aec2130ba2836..9a6db39b87e74ea1d8423f387b33a447f428f194 100644 (file)
@@ -220,7 +220,7 @@ conditional_expression
     =\r
     | conditional_expression_if\r
     | conditional_expression_logical\r
-    | conditional_expression_comparator\r
+    | conditional_expression_operator\r
     | conditional_expression_test\r
     | concatenate_expression\r
     | variable_identifier\r
@@ -241,11 +241,19 @@ conditional_expression_logical
     right:conditional_expression\r
     ;\r
 \r
-conditional_expression_comparator\r
+conditional_expression_operator\r
     =\r
-    left:variable_identifier\r
-    {SP}* comparator:variable_tests_comparator {SP}*\r
-    right:variable_identifier\r
+    | (\r
+        "not"\r
+        left:variable_identifier\r
+        {SP}* operator:`"notin"` "in" {SP}*\r
+        right:variable_identifier\r
+    )\r
+    | (\r
+        left:variable_identifier\r
+        {SP}* operator:conditional_expression_operator_operations {SP}*\r
+        right:variable_identifier\r
+    )\r
     ;\r
 \r
 conditional_expression_test\r
@@ -260,7 +268,7 @@ conditional_expression_test
     ]\r
     ;\r
 \r
-variable_tests_comparator\r
+conditional_expression_operator_operations\r
     =\r
     | "=="\r
     | "!="\r
@@ -268,6 +276,7 @@ variable_tests_comparator
     | ">="\r
     | "<"\r
     | "<="\r
+    | ( @:"in" SP )\r
     ;\r
 \r
 variable_tests_logical_operator\r