Add support for tests

Right now these are very basic and don't appear to form the correct
parse tree for logical comparisons which use tests as well. But it
parses at lease somewaht correctly, so there is something to work
with here.
This commit is contained in:
Kevin Brown 2020-05-08 13:51:14 -04:00 committed by Kevin
parent e7ff13e6e1
commit 7ac9e2d978
2 changed files with 39 additions and 2 deletions

View File

@ -125,7 +125,33 @@ variable_accessor_call_parameter_value_only
variable_accessor_call_parameter_value
=
{SP}* @:variable_identifier {SP}*
{SP}* @:( variable_tests | variable_identifier ) {SP}*
;
variable_tests
=
left:variable_identifier {SP}*
(
| ( "is" {SP}* test_function:variable_accessor_call_parameter_value )
| ( comparator:variable_tests_comparator right: variable_accessor_call_parameter_value )
| ( logical_operator:variable_tests_logical_operator right: variable_accessor_call_parameter_value )
)
;
variable_tests_comparator
=
| "=="
| "!="
| ">"
| ">="
| "<"
| "<="
;
variable_tests_logical_operator
=
| "and"
| "or"
;
variable_accessor_dot

View File

@ -18,4 +18,15 @@ across lines #}
('downloads.html', 'Downloads')] %}
<li><a href="{{ href }}">{{ caption }}</a></li>
{% endfor %}
{% trans user=user.username %}Hello, {{ user }}!{% endtrans %}
{% trans user=user.username %}Hello, {{ user }}!{% endtrans %}
{% set navigation = [('index.html', 'Index'), ('about.html', 'About')] %}
{% set key, value = call_something() %}
{% for value in values %}
{% if loop.previtem is defined and value > loop.previtem %}
The value just increased!
{% endif %}
{{ value }}
{% if loop.nextitem is defined and loop.nextitem > value %}
The value will increase even more!
{% endif %}
{% endfor %}