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) -> 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: ")

Submitted by Tobi Vollebregt on 13 January 2011 at 16:24

On 13 January 2011 at 19:15 Lennart Kats commented:

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 ;)


On 13 January 2011 at 19:15 Lennart Kats tagged feature

On 13 January 2011 at 19:15 Lennart Kats removed tag feature

On 13 January 2011 at 19:15 Lennart Kats removed tag question

On 13 January 2011 at 19:16 Lennart Kats tagged feature

On 13 January 2011 at 19:16 Lennart Kats tagged parser

On 22 January 2011 at 16:21 Lennart Kats closed this issue.

On 22 January 2011 at 16:21 Lennart Kats commented:

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 ;)


On 22 January 2011 at 16:21 Lennart Kats tagged 0.6.0

On 22 January 2011 at 16:21 Lennart Kats removed tag parser

On 22 January 2011 at 16:22 Lennart Kats tagged parser

On 9 February 2011 at 10:40 Lennart Kats tagged 1.0

On 22 December 2011 at 16:46 Lennart Kats removed tag 0.6.0

On 28 December 2011 at 13:17 Lennart Kats tagged @lennartkats

Log in to post comments