Closed PierreR closed 7 years ago
This is a large feature, and I will certainly not have time to implement it in the foreseeable future ...
This is tricky because there are two use cases:
${foo}
, where it should be interpreted as variable $foo
${foo[$bar]}
, where it should be interpreted as $foo[$bar]
${foo($bar)}
, where it should be interpreted as foo($bar)
Perhaps the simplest solution would be to add the full expression parser after try simpleIndexing
and try rvariable
on lines 204-207 of the parser.
This is really horrible:
"${::interfaces.split(',')[3]}"
This does't handle the case where you do arbitrary stuff to a variable, but should parse most expressions. To be toroughly tested!
The commit broke this kind of code:
class test {
exec {
"test":
command => "test",
onlyif => "grep '^${sanitised_title}$'",
}
}
puppetresources --parse test.pp
puppetresources: parse error:ParseError {errorPos = SourcePos {sourceName = "test.pp", sourceLine = Pos 5, sourceColumn = Pos 49} :| [], errorUnexpected = fromList [Tokens ('\'' :| "")], errorExpected = fromList [Tokens (':' :| ":"),Tokens ('{' :| "")], errorCustom = fromList []}
CallStack (from HasCallStack):
error, called at progs/PuppetResources.hs:374:24 in main:Main
Just pushed a change that should fix that.
Doesn't break anymore in any obvious way. Thanks.