]> git.ipfire.org Git - thirdparty/jinja.git/commit
Fix parsing math1 expressions in comparisons
authorKevin Brown <kevin@kevin-brown.com>
Fri, 15 May 2020 23:05:42 +0000 (19:05 -0400)
committerKevin Brown <kevin@kevin-brown.com>
Fri, 15 May 2020 23:05:42 +0000 (19:05 -0400)
commit32a5f9312a28b3e23f32bdac752d0560416f9f07
tree8ec418b13df2d0c63b22ae4523d6fa5fcb48531b
parentb7c80abdace082e7f04cec8720c3e7a2b4fac813
Fix parsing math1 expressions in comparisons

When a math1 expression was used in a comparison before, the right
side would consume the comparison instead of letting it fall back to
the comparison being above it in the AST. This was fixed by restricting
the right side of math1 comparisons to be complex operations only, so
that is any operation that does not involve a comparison, since it's
unlikely that you are looking to do math expressions on the result of
a comparison.

Additionally, this also allows conditional expressions involving basic
operators to consume a complex expression on the left side. Previously
they were restricted to only allowing variables on the left side, so
this allows for more complex comparisons to be made.

Because of the way that conditional expressions with parentheses are
consumed, they have been moved to be the last check within conditional
expressions. This should help to guard against other conditional
expressions which can consume parenthese themselves from being blocked
from parsing because the parentheses have already been consumed.

In order to make things generally easier to understand, the complex
expressions wihch return an actual value (instread of just comparisons)
are now grouped together within the grammar.
grammar.ebnf
src/jinja2/new_parser.py