SDF: pretty-printer is not sound
SDF pretty-printer is not sound, i.e. it is possible to construct a language for which a valid program
p
exists such thatpretty-print(parse(p))
is no longer a valid program.Steps to reproduce:
- build metaborg-sl in Spoofax 2.4.0-SNAPSHOT (currently: 20171026-103626) using the Java parse table generator (
sdf2tabe: java
)- open the following program in
foo.sl
, notice that it parses successfully:function p(a) { (1 < (true / false || m)).x = 1; }
hit Syntax > Format and observe the pretty-printed program:
function p(a) { 1 < true / false || m.x = 1; }
observe the little red box saying “Internal parsing error”.
It looks like the logic that adds parenthesis does not work for this grammar (admittedly; the grammar is kinda weird). I’m not sure if this is intended, so I thought I’d create an issue.
Also, unrelated to the pretty-printer, I’m surprised that the parse fails. Looking at the grammar I can construct a tree that could be the result of the parse, but right now the parse just fails with “Internal parsing error: org.spoofax.jsglr.client.FilterException: Runtime exception when applying filters (recovery failed)”..
Submitted by Martijn on 13 November 2017 at 12:37
Issue Log
Also, unrelated to the pretty-printer, I’m surprised that the parse fails. Looking at the grammar I can construct a tree that could be the result of the parse, but right now the parse just fails with “Internal parsing error: org.spoofax.jsglr.client.FilterException: Runtime exception when applying filters (recovery failed)”.
(I tried editing my original issue and adding above message, but upon saving the edit disappears. Should I create a meta-issue for this?)
Log in to post comments