Custom disambiguation filter
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:
signature
constructors
amb: List(x) -> xrules
editor-analyze:
(ast, path, project-path) -> (ast’, [], [], [])
with
editor-init;
ast’ := <topdown(try(disambiguate)); debug(!"final: ")> astdisambiguate:
Submitted by Tobi Vollebregt on 13 January 2011 at 16:24
amb([x | xs]) -> x
with
debug(!"disambiguating: ")
Issue Log
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 ;)
Actually, this is now possible using the
LANGUAGEParseController
class, 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 ;)
Log in to post comments