I am trying to create island grammar using Rascal MPL , but I ran into a problem:
When implementing Island Grammar in SDF, a very common approach is to define "all water production" using the {avoid} attribute. This prevents the parser from using these products, if others are applicable. This allows you to specify default behavior that can be overridden by other manufacturing processes without creating bumps. A very simple example:
context free syntax
Chunk* -> Input
Water -> Chunk
lexical syntax
~[\t\n\ ]+ -> Water {avoid}
I tried to reproduce this behavior using Rascal MPL. My goal is to create an island grammar that collects all conditional preprocessor directives inside a piece of C / C ++ code and skips the rest of the input using Water production.
layout LAYOUT = [\t\n\ ];
lexical WATER = ![\t\n\ ]+;
start syntax Program = Line*;
syntax Line = ConditionalDirective
> WATER;
syntax ConditionalDirective = "#ifdef"
| "#ifndef"
| "#if"
| "#elif";
{avoid}, ConditionalDirective , " > ", . .
#ifdef asd
, , , :

Rascal Documentation, "" - , . , , , SDF .
SDF {avoid} MPL? - , ?