fix: precedence of unary operators and expressions
Signed-off-by: Michael Hoffmann <mhoffm@posteo.de>
This commit is contained in:
43
test/corpus/expresssion.txt
Normal file
43
test/corpus/expresssion.txt
Normal file
@@ -0,0 +1,43 @@
|
||||
======
|
||||
Unary operation on variable with splat expression
|
||||
=====
|
||||
|
||||
foo = !var.bar
|
||||
|
||||
------
|
||||
|
||||
(config_file
|
||||
(body
|
||||
(attribute
|
||||
(identifier)
|
||||
(expression
|
||||
(operation
|
||||
(unary_operation
|
||||
(variable_expr
|
||||
(identifier))
|
||||
(get_attr
|
||||
(identifier))))))))
|
||||
|
||||
=====
|
||||
Attribute as conditional expression
|
||||
=====
|
||||
|
||||
foo = local.bar == local.baz
|
||||
|
||||
-----
|
||||
|
||||
(config_file
|
||||
(body
|
||||
(attribute
|
||||
(identifier)
|
||||
(expression
|
||||
(operation
|
||||
(binary_operation
|
||||
(variable_expr
|
||||
(identifier))
|
||||
(get_attr
|
||||
(identifier))
|
||||
(variable_expr
|
||||
(identifier))
|
||||
(get_attr
|
||||
(identifier))))))))
|
||||
@@ -81,3 +81,48 @@ foo = a != b && c == d
|
||||
(identifier))
|
||||
(variable_expr
|
||||
(identifier))))))))))
|
||||
|
||||
================================================================================
|
||||
precedence in binary operators 2
|
||||
================================================================================
|
||||
|
||||
foo = a.foo != "" && b.foo == "" ? 1 : 0
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(config_file
|
||||
(body
|
||||
(attribute
|
||||
(identifier)
|
||||
(expression
|
||||
(conditional
|
||||
(expression
|
||||
(operation
|
||||
(binary_operation
|
||||
(operation
|
||||
(binary_operation
|
||||
(variable_expr
|
||||
(identifier))
|
||||
(get_attr
|
||||
(identifier))
|
||||
(literal_value
|
||||
(string_lit
|
||||
(quoted_template_start)
|
||||
(quoted_template_end)))))
|
||||
(operation
|
||||
(binary_operation
|
||||
(variable_expr
|
||||
(identifier))
|
||||
(get_attr
|
||||
(identifier))
|
||||
(literal_value
|
||||
(string_lit
|
||||
(quoted_template_start)
|
||||
(quoted_template_end))))))))
|
||||
(expression
|
||||
(literal_value
|
||||
(numeric_lit)))
|
||||
(expression
|
||||
(literal_value
|
||||
(numeric_lit))))))))
|
||||
|
||||
@@ -390,24 +390,24 @@ resource "azurerm_storage_blob" "proxy_cert" {
|
||||
(binary_operation
|
||||
(operation
|
||||
(binary_operation
|
||||
(operation
|
||||
(binary_operation
|
||||
(variable_expr
|
||||
(identifier))
|
||||
(get_attr
|
||||
(identifier))
|
||||
(literal_value
|
||||
(string_lit
|
||||
(quoted_template_start)
|
||||
(quoted_template_end)))))
|
||||
(variable_expr
|
||||
(identifier))))
|
||||
(get_attr
|
||||
(identifier))
|
||||
(literal_value
|
||||
(string_lit
|
||||
(quoted_template_start)
|
||||
(quoted_template_end))))))
|
||||
(identifier))
|
||||
(get_attr
|
||||
(identifier))
|
||||
(literal_value
|
||||
(string_lit
|
||||
(quoted_template_start)
|
||||
(quoted_template_end)))))
|
||||
(operation
|
||||
(binary_operation
|
||||
(variable_expr
|
||||
(identifier))
|
||||
(get_attr
|
||||
(identifier))
|
||||
(literal_value
|
||||
(string_lit
|
||||
(quoted_template_start)
|
||||
(quoted_template_end))))))))
|
||||
(expression
|
||||
(literal_value
|
||||
(numeric_lit)))
|
||||
|
||||
Reference in New Issue
Block a user