How can I find the cause for a failing pretty-printing strategy?
I try to translate a DSL to another language. Parsing the source file into ATerm is okay, but rewriting fails and I try to find out where the error is. Rule
genPcdis defined. And to my knowledge,
on may be related to tools such as
abox2text. So how can I locate errors ?
PS: The transformation is developed with
libaspectj-front. To be specific, the DSL
extends Java and is transformed to AspectJ with the help of Spoofax.
Console output:Asked by Guido Wachsmuth on 31 July 2013 at 05:40
EventCJ: rewriting failed, trace: generate_java_0_0 to_java_0_0 map_1_0 map_1_0 genPcd_0_3 pp_java_string_0_0 pp_java5_to_string_0_0 box2text_string_0_1 abox2text_0_1 abox2text_1_2 abox2text_list_1_2
The trace tells us that pretty-printing fails. Typically, this is caused by an erroneous AST, which contains terms which cannot be handled by the pretty-printer. To find such terms, you can use the following code:
output := <the-pp-strategy> input <+ <bottomup(try(not(is-string) ; not(is-list) ; not(the-pp-strategy) ; debug(!"cannot pp "))); fail> input
Make sure to replaceAnswered by Guido Wachsmuth on 31 July 2013 at 05:47
the-pp-strategywith your actual pretty-printing strategy. The second line performs a bottomup traversal and tries to find terms which cannot be pretty-printed and reports those terms to the console (