-
Notifications
You must be signed in to change notification settings - Fork 82
Description
Hello,
I believe I found a problem with the org.eclipse.imp.pdb.facts.impl classes.
The BottomUpTransformer allows transformations on Rascal values. When no transformations are set to take place (i.e. when the BottomUpTransformer is not extended and the visitor-parameter in its constructor is set to the IdentityVisitor), it should therefore produce the exact same result as was provided in the input. However, using the following syntax definition:
lexical Integer = [0-9] !<< [0-9]+ !>> [0-9];
syntax Exp = "plus" "(" Exp e1 "," Exp e2 ")"
| Integer;
and using the BottomUpTransformer composed with the IdentityVisitor and the concrete expression (Exp)'plus(2, 2)', I get the following result:
appl(prod(sort("Exp"),[lit("plus"),layouts("Whitespace"),lit("("),layouts("Whitespace"),label("e1",sort("Exp")),layouts("Whitespace"),lit(","),layouts("Whitespace"),label("e2",sort("Exp")),layouts("Whitespace"),lit(")")],{}),[[appl(prod(lit("plus"),[\char-class([range(112,112)]),\char-class([range(108,108)]),\char-class([range(117,117)]),\char-class([range(115,115)])],{}),[char(112),char(108),char(117),char(115)]),appl(prod(layouts("Whitespace"),[\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))],{}),[appl(regular(\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))),[])[@loc=|stdin:///|(29,0)]])[@loc=|stdin:///|(29,0)],appl(prod(lit("("),[\char-class([range(40,40)])],{}),[char(40)]),appl(prod(layouts("Whitespace"),[\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))],{}),[appl(regular(\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))),[])[@loc=|stdin:///|(30,0)]])[@loc=|stdin:///|(30,0)],appl(prod(sort("Exp"),[lex("Integer")],{}),[appl(prod(lex("Integer"),[conditional(iter(\char-class([range(48,57)])),{\not-follow(\char-class([range(48,57)])),\not-precede(\char-class([range(48,57)]))})],{}),[appl(regular(iter(\char-class([range(48,57)]))),[char(50)])[@loc=|stdin:///|(30,1)]])[@loc=|stdin:///|(30,1)]])[@loc=|stdin:///|(30,1)],appl(prod(layouts("Whitespace"),[\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))],{}),[appl(regular(\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))),[])[@loc=|stdin:///|(31,0)]])[@loc=|stdin:///|(31,0)],appl(prod(lit(","),[\char-class([range(44,44)])],{}),[char(44)]),appl(prod(layouts("Whitespace"),[\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))],{}),[appl(regular(\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))),[char(32)])[@loc=|stdin:///|(32,1)]])[@loc=|stdin:///|(32,1)],appl(prod(sort("Exp"),[lex("Integer")],{}),[appl(prod(lex("Integer"),[conditional(iter(\char-class([range(48,57)])),{\not-follow(\char-class([range(48,57)])),\not-precede(\char-class([range(48,57)]))})],{}),[appl(regular(iter(\char-class([range(48,57)]))),[char(50)])[@loc=|stdin:///|(33,1)]])[@loc=|stdin:///|(33,1)]])[@loc=|stdin:///|(33,1)],appl(prod(layouts("Whitespace"),[\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))],{}),[appl(regular(\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))),[])[@loc=|stdin:///|(34,0)]])[@loc=|stdin:///|(34,0)],appl(prod(lit(")"),[\char-class([range(41,41)])],{}),[char(41)])]])[@loc=|stdin:///|(25,10)]
Whereas the original value was:
appl(prod(sort("Exp"),[lit("plus"),layouts("Whitespace"),lit("("),layouts("Whitespace"),label("e1",sort("Exp")),layouts("Whitespace"),lit(","),layouts("Whitespace"),label("e2",sort("Exp")),layouts("Whitespace"),lit(")")],{}),[appl(prod(lit("plus"),[\char-class([range(112,112)]),\char-class([range(108,108)]),\char-class([range(117,117)]),\char-class([range(115,115)])],{}),[char(112),char(108),char(117),char(115)]),appl(prod(layouts("Whitespace"),[\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))],{}),[appl(regular(\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))),[])[@loc=|stdin:///|(29,0)]])[@loc=|stdin:///|(29,0)],appl(prod(lit("("),[\char-class([range(40,40)])],{}),[char(40)]),appl(prod(layouts("Whitespace"),[\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))],{}),[appl(regular(\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))),[])[@loc=|stdin:///|(30,0)]])[@loc=|stdin:///|(30,0)],appl(prod(sort("Exp"),[lex("Integer")],{}),[appl(prod(lex("Integer"),[conditional(iter(\char-class([range(48,57)])),{\not-follow(\char-class([range(48,57)])),\not-precede(\char-class([range(48,57)]))})],{}),[appl(regular(iter(\char-class([range(48,57)]))),[char(50)])[@loc=|stdin:///|(30,1)]])[@loc=|stdin:///|(30,1)]])[@loc=|stdin:///|(30,1)],appl(prod(layouts("Whitespace"),[\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))],{}),[appl(regular(\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))),[])[@loc=|stdin:///|(31,0)]])[@loc=|stdin:///|(31,0)],appl(prod(lit(","),[\char-class([range(44,44)])],{}),[char(44)]),appl(prod(layouts("Whitespace"),[\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))],{}),[appl(regular(\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))),[char(32)])[@loc=|stdin:///|(32,1)]])[@loc=|stdin:///|(32,1)],appl(prod(sort("Exp"),[lex("Integer")],{}),[appl(prod(lex("Integer"),[conditional(iter(\char-class([range(48,57)])),{\not-follow(\char-class([range(48,57)])),\not-precede(\char-class([range(48,57)]))})],{}),[appl(regular(iter(\char-class([range(48,57)]))),[char(50)])[@loc=|stdin:///|(33,1)]])[@loc=|stdin:///|(33,1)]])[@loc=|stdin:///|(33,1)],appl(prod(layouts("Whitespace"),[\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))],{}),[appl(regular(\iter-star(\char-class([range(9,10),range(13,13),range(32,32)]))),[])[@loc=|stdin:///|(34,0)]])[@loc=|stdin:///|(34,0)],appl(prod(lit(")"),[\char-class([range(41,41)])],{}),[char(41)])])[@loc=|stdin:///|(25,10)]
Looks quite similar, right? However, the identity transformation's result in Rascal is not printable. After comparing the two results, I found that the transformed result is 2 characters longer, and that the differences start at column 226. Prior to the transformation column 226 starts with:
[appl(prod(lit("plus"),...
While after the transformation column 226 starts with:
[[appl(prod(lit("plus"),...
Is this a bug in one of the org.eclipse.imp.pdb.facts.impl classes, or should I somehow flatten the concrete results after using the get/set-functions?