inmanta / inmanta-core

Inmanta is an automation and orchestration tool
https://inmanta.com
Apache License 2.0
27 stars 7 forks source link

handling of generic expressions in string formats #4148

Open sanderr opened 2 years ago

sanderr commented 2 years ago

The string format regex in inmanta.parser.plyInmantaParser accepts only variables. As a result {{dct['a']}} does not match. This string formatting is not supported at the moment, but intuitively you would expect this attempt to either work or raise an error. Instead, it is not recognized as an attempted string format and it's just interpreted as the literal string r"{{dct['a']}}". This is undesirable. There are two approaches to resolve this:

Support

Example model

dct = {"a": "World"}
std::print("hello {{dct['a']}}")

prints hello {{dct['a']}}

wouterdb commented 2 years ago

It seems possible to use the parser generator to generate a second parser, with a different entry point, to parse the expression inside the {{ }}