What is the normal approach to perform custom disambiguation in Spoofax, in case that’s needed?
(I don’t really need it at this moment, but if it’s easy, it might come in handy sometime :-))
The ‘natural’ way to me, disambiguating in editor-analyze and returning a disambiguated tree to the Spoofax runtime, does not work (ambiguity markers remain visible). This is what I tried as a quick test:
Submitted by Tobi Vollebregt on 13 January 2011 at 16:24signature constructors amb: List(x) -> x rules editor-analyze: (ast, path, project-path) -> (ast', [], [], []) with editor-init; ast' := <topdown(try(disambiguate)); debug(!"final: ")> ast disambiguate: amb([x | xs]) -> x with debug(!"disambiguating: ")
The easy fix here would be to add a setting to disable the warnings. But then things like the outliner would still work on the ambiguous tree. So there should be some kind of postprocessor that runs just after the parser finishes. If you want to dig into it, https://svn.strategoxt.org/repos/StrategoXT/spoofax-imp/trunk/README offers some advice ;)
Submitted on 13 January 2011 at 19:15 by Lennart Kats
Actually, this is now possible using the
LANGUAGEParseControllerclass, which can be used to override the parser or do pre/post-processing. Maybe also be something to look into for parsing XML? :)(For a pure Stratego approach, open a new issue if needed ;)
Submitted on 22 January 2011 at 16:21 by Lennart Kats
Log in to post comments