Compilation fails with errors in pp files on nightly build
I’ve just started using the nightly build (1.2.0.0-s40811).
I’ve created a fresh project for a language called CBS. I’m currently using an SDF2 grammar (
CBS.sdf
). When I try to build the project, I get no warnings, but then this:stratego.jvm.helper: [java] [ Main | error ] *** ("pp-CBS-string",0,0) calls non-existing ("prettyprint-Start",0,0) [java] [] [java] [ Main | error ] Compilation failed (1.88 secs) BUILD FAILED /Volumes/HDD/pdm/Workspaces/Eclipse-4.3.1/CBS-nightly/build.generated.xml:472: The following error occurred while executing this line: /Volumes/HDD/pdm/Workspaces/Eclipse-4.3.1/CBS-nightly/build.generated.xml:531: Java returned: 1
The following files in
trans
have errors:CBS.pp.generated.str Common.pp.generated.str pp.str
It’s
pp.str
that reports the missingprettyprint-Start
.A typical error in
CBS.pp.generated.str
is:strategies prettyprint-KEYWORD = ![S(<is-string>)]
The error marker there says that constructor
S/1
is not declared.None of the files in syntax have any errors. A (currently closed) project with the same
CBS.sdf
builds OK:stratego.jvm.helper: [java] [ Main | info ] Front-end succeeded : [user/system] = [1.60s/0.00s] [java] [ Main | info ] Optimization succeeded -O 2 : [user/system] = [0.13s/0.00s] [java] [ Main | info ] Abstract syntax in '/Volumes/HDD/pdm/Workspaces/Eclipse-4.3.1/CBS/include/cbs.rtree' [java] [ Main | info ] Export of externals succeeded : [user/system] = [0.02s/0.00s] [delete] Deleting: /Volumes/HDD/pdm/Workspaces/Eclipse-4.3.1/CBS/include/cbs.rtree [mkdir] Created dir: /Volumes/HDD/pdm/Workspaces/Eclipse-4.3.1/CBS/bin/trans ...
Let me know if further diagnostics are needed to locate the cause of the issue, and whether it’s easy to fix or work around.
– Peter
Submitted by Peter Mosses on 8 November 2013 at 17:13
Attachments
Issue Log
The new project wizard assumes that you are using SDF3 which generates pretty printer definitions, and have a start symbol called Start. You should be able to fix this by removing the import to pp in your main Stratego file trans/cbs.str.
Thanks for the hints. Unfortunately, removing the pp import in cbs.str gave further errors, so I’ve now converted my SDF2 file to SDF3 (just by removing the exports keyword) and it already had Start as a context-free start symbol.But I still get the same build error…
I now suspect that the issue is the same as reported in #761: generated pretty-printer files contain errors because of missing imports. As I mentioned before, the following files in trans have errors:
CBS.pp.generated.str Common.pp.generated.str pp.str
As suggested there, adding the following lines at the beginning of the two generated files makes the errors in them disappear:
imports include/CBS lib/runtime/tmpl/pp libstratego-gpp
But when I subsequently try to rebuild the project, those added imports of course disappear.
So I’m hoping that when issue #761 has been addressed, this initial problem I’ve run into will disappear.
If it would be easy for me to patch the distribution to insert the generation of the missing imports, I could try that, but I’ve no idea where to look.
Furthermore, I’m puzzled why the build failure doesn’t arise already when one creates a new Spoofax editor project: the
*.pp.generated.str
files in it show errors due to the missing imports, butpp.str
doesn’t indicate any errors, and the build completes OK. (I tried deleting my.cache
, but that didn’t have any noticeable effect.)
You can add these imports to your main Stratego file. The editor will still show errors in the generated files, but the build should succeed.
(Spoofax/IMP 1.2.0.0-s40857)
By “main Stratego file” did you mean
cbs.str
? I tried addinglib/runtime/tmpl/pp
to the listed imports ofcbs.str
(the other two imports were already there) and rebuilding (using the SDF3 grammar) but the build still failed with the same error as before:stratego.jvm.helper: [java] [ Main | error ] *** ("pp-CBS-string",0,0) calls non-existing ("prettyprint-Start",0,0) [java] [] [java] [ Main | error ] Compilation failed (2.22 secs) BUILD FAILED /Volumes/HDD/pdm/Workspaces/Eclipse-4.3.1/CBS-unstable/build.generated.xml:472: The following error occurred while executing this line: /Volumes/HDD/pdm/Workspaces/Eclipse-4.3.1/CBS-unstable/build.generated.xml:531: Java returned: 1
This is in a fresh editor project for CBS. The example editor built OK, and the only files I subsequently changed (apart from those in test) were:
editor/CBS-Colorer.esv syntax/CBS.sdf3 trans/names.nab
Is your start symbol called Start? If it is not, you need to change the call to
prettyprint-Start
in pp.str toprettyprint-<start symbol name>
.
Yes, it is called Start. I’ve now attached the complete grammar.
I see, your grammar is an SDF3 file but it is still written in the SDF2 style, which means no pretty printer rules are generated. If you want to use the generated pretty printer, you need to convert your SDF2 style reductive rules to SDF3 templates. We have a manual on SDF3 here: http://metaborg.org/wiki/sdf/sdf3-intro.
Thanks for the diagnosis! I was aware that the nightly build requires SDF3, but not that it also requires the use of templates, which are explained as merely “an alternative way of defining productions” in the cited manual. I’ll try converting my grammar to use templates.
As a work-around to remove the dependence of the nightly build on the existence of the generated pp rules when building an editor, could I simply add some dummy rules to
syntax/CBS.pp
to define the missingprettyprint-Start
?
It requires templates because the SDF3 language will generate pretty printer rules from templates, not from reductions or productions.
You can remove the import to pp in your main Stratego file (
cbs.str
), and it should compile then. You can indeed also defineprettyprint-Start
, for exampleprettyprint-Start = id
.
Removing the import of
pp
(as suggested above) gave rise to further build errors, e.g.:[java] [ Main | error ] *** ("editor-format",0,0) calls non-existing ("pp-debug",0,0)
So I went back to using the stable Spoofax-1.1 release for a while.
However, I’m now trying again to build Spoofax-1.2 (from the current ‘unstable’ release) and still running into issue #761: generated pretty-printer files contain errors because of missing imports. This time it’s a new project, for Caml Light: I have an SDF2 grammar that builds OK under Spoofax-1.1, and I’ve used the Spoofax SDF editor to convert the context-free productions to SDF3 templates – see the attached
CL.sdf3
andCL-Lexical.sdf3
.My
trans/cl.str
already includes the imports suggested in #761:imports include/CL lib/runtime/tmpl/pp libstratego-gpp
A clean build (using Eclipse 4.3.2) appears to go OK until:
stratego.jvm.helper: [java] [ Main | error ] *** ("prettyprint-CL-global-name",0,0) calls non-existing ("prettyprint-CL-ident",0,0) [java] [] ... [java] [ Main | error ] Compilation failed (2.85 secs) BUILD FAILED
The reported errors all appear to be due to the total absence of imports in
CL.pp.generated.str
andCL-Lexical.pp.generated.str
: when I insert the missing imports manually (and import the latter into the former) all the error flags in the files disappear – but then reappear when I try to build again…My main motivation for trying to use Spoofax-1.2 is the pp generation. Is there any way of persuading the build to insert the missing imports into the generated files? (I’m assuming it isn’t possible to stop it overwriting my edited generated files.)
In addition to converting all context-free productions into templates, you also need to convert lexical productions into a productive form:
lexical syntax CL-ident = CL-lowercase-ident
instead of
lexical syntax CL-lowercase-ident -> CL-ident
Notes:
- this is only required for a lexical production in case its sorts is used in some context-free production. However, you may want to convert all of your lexical productions to keep things consistent.
- you cannot mix productive and reductive forms in a singlelexical syntax
section.Also, I’m not sure if you’re doing this already, but in your
trans/pp.str
you should importCBS.pp.generated
,CL.pp.generated
andCL-Lexical.pp.generated
.
And regarding undefined strategy errors in *.pp.generated files: you can safely ignore those as long as the files that define the strategies are imported intrans/pp.str
ortrans/cl.str
.
Hopefully things will be improved in Spoofax soon though.
Thanks for the hints! After converting
CL-Lexical.sdf3
to productive form, I’ve managed to build my CL editor OK.BTW, I’ve avoided the use of productions with alternatives separated by bars, since they also caused (obscure) errors. It would be helpful if the SDF3 editor could give warnings about things one better avoid in lexical syntax (like it does in context-free syntax). The Introduction to SDF3 states: The symbols in a production can be arbitrarily complex but the implementation may impose some limitations on this. That seems to be an understatement, and former ASF+SDF users may be surprised at the extent of the current limitations, in the absence of explicit warnings.
I’ve replaced the previous attachments with the working versions. Note that I’ve left the disambiguation part of
CL.sdf3
in SDF2 format, as I find the use of production names in priority declarations makes them too difficult to understand.
Log in to post comments