Open soasme opened 3 years ago
In case it helps somebody, I fixed this issue by adding the parenthesis to the transformer, whenever an expression is found:
from hcl2.parser import hcl2 as parser
from hcl2.transformer import DictTransformer
class DictTransformerMod(DictTransformer):
def expr_term(self, args: list) -> object:
term = super().expr_term(args)
if isinstance(term, str) and " " in term:
return f"({term})"
return term
transformer = DictTransformerMod()
tree = parser.parse('a=1*(2+3)')
transformer.transform(tree)
, which returns the expected:
{'a': '${1 * (2 + 3)}'}
I won't do a PR because I know too little about how this package is used to understand possible side effects
Issue
Expect