During code generation it might become necessary to create '[' and ']' and characters in the output file. Unfortunately those characters are part of the the Stratego grammar.

Asked by Sven Stork on 15 January 2013 at 23:02

To generate those characters inside a formatted string (i.e., $[...]) you first have to enclose them in double quotes and the enclose them in '[' and ']' to escape into the variable area. (e.g., Subscript(e, index) -> $[ ([e']) ["["] [index'] ["]"] ])

Answered by Sven Stork on 15 January 2013 at 23:04

You can also use the ${...} or $<...> string formatters if you want to easily use [ and ].

Answered by Gabriƫl Konat on 16 January 2013 at 12:19

Yet another way is to use escaping like this: $[ ...... $]$ ...... ]

Answered by Lennart Kats on 16 January 2013 at 17:18