Messages: string interpolation does not show properties properly
Properties in TS error messages do not resolve to their result values.
Error msg:
Multiplicity mismatch: expected Result(10) got OneOrMore in Derivation
Task with result:
task 10 = produce One() -> [One()]
TS code:
Attribute(a, a-ty, Derivation(e, derivationType)) :- where e has multiplicity e-mu and definition of a has multiplicity a-mu and e-mu == a-mu else error $[Multiplicity mismatch: expected [a-mu] got [e-mu] in Derivation] on e
For Type() instead of an NaBL property it works fine.
Submitted by Daco Harkes on 11 March 2014 at 14:54
Issue Log
You need to pretty print messages, use the following code:
pp-message-top = origin-track-forced((id, strip-annos; pp-message)) pp-message = not(is-list); (is-string <+ pp-result <+ pp-java-string <+ (strip-annos; write-to-string)) pp-message = map(pp-message); concat-strings pp-result: result@Result(_) -> msg where if <task-has-failed> result then msg := "fail" else msg := <task-get-results; map(pp-message); separate-by(|" or "); concat-strings> result end
But replace
pp-java-string
with the pretty printer for your language.
Passpp-message-top
to the analysis interfaces:analysis-single-default-interface = analysis-single-default(desugar-top, id, pp-message-top|<language>) analysis-multiple-default-interface = analysis-multiple-default(parse-file <+ !(), desugar-top, id, pp-message-top|<language>, <project-path>)
This should become part of the library at some point.
Thanks, that works indeed. Maybe add this to the library without the pp-java-string.
The properties view and new hover help also use the pretty printer, but only the language pretty printer. The rest of the pretty printing is done inside the library itself. We should probably keep that consistent.
Note that passing the pp doesn’t work at all at the moment, because it only works on complete ASTs, not on subtrees.
prettyprint-Start
only prints the top level Constructor which is Module/4 in my case.
You can use
prettyprint-example
from the SDF3 generated pretty printer. In my case Java has an SDF2 grammar, so I’m using the old pretty printer.Closing this issue, adding another issue to add this code to the library.
Log in to post comments