Add concat expression support to grammar and parser
This is probably going to be reclassified in the grammar and parser as something different from the conditional expressions once more support for math operators is added in.
This commit is contained in:
parent
983f480532
commit
6c179cf714
@ -222,6 +222,7 @@ conditional_expression
|
||||
| conditional_expression_logical
|
||||
| conditional_expression_comparator
|
||||
| conditional_expression_test
|
||||
| concatenate_expression
|
||||
| variable_identifier
|
||||
;
|
||||
|
||||
@ -275,6 +276,12 @@ variable_tests_logical_operator
|
||||
| "or"
|
||||
;
|
||||
|
||||
concatenate_expression
|
||||
=
|
||||
concatenate+:variable_identifier
|
||||
{ {SP}* "~" {SP}* concatenate+:variable_identifier }+
|
||||
;
|
||||
|
||||
variable_filter
|
||||
=
|
||||
"|" {SP}* @:filter
|
||||
|
||||
@ -280,6 +280,16 @@ def parse_block_with(ast):
|
||||
def parse_comment(ast):
|
||||
return
|
||||
|
||||
def parse_concatenate_expression(ast):
|
||||
vars = [
|
||||
parse_variable(var) for var in ast['concatenate']
|
||||
]
|
||||
|
||||
return nodes.Concat(
|
||||
vars,
|
||||
lineno=lineno_from_parseinfo(ast['parseinfo'])
|
||||
)
|
||||
|
||||
def parse_conditional_expression(ast):
|
||||
if 'variable' in ast:
|
||||
return parse_variable(ast)
|
||||
@ -287,6 +297,9 @@ def parse_conditional_expression(ast):
|
||||
if 'comparator' in ast:
|
||||
return parse_conditional_expression_comparator(ast)
|
||||
|
||||
if 'concatenate' in ast:
|
||||
return parse_concatenate_expression(ast)
|
||||
|
||||
if 'test_expression' in ast:
|
||||
return parse_conditional_expression_if(ast)
|
||||
|
||||
|
||||
@ -65,4 +65,5 @@ across lines #}
|
||||
...
|
||||
</ul>
|
||||
{{ "[{}]".format(page.title) if page.title }}
|
||||
{% extends layout_template if layout_template is defined else 'master.html' %}
|
||||
{% extends layout_template if layout_template is defined else 'master.html' %}
|
||||
{{ "Hello " ~ name ~ "!" }}
|
||||
Loading…
Reference in New Issue
Block a user