Currently I'm implementing a DSL with Oslo, but I've got some trouble with making the MGrammar.
In my language I've defined some keywords, which I've marked as an "final token" and with the appropiate highlight tag before the token. This works correctly. But nowI want to create a token whereI can use the keyword in a different context. To make the example more concreteI will show some example of my language:
module home
site
site/index.html : home()
end
def home()
....
end
Site is a keyword, but not when used inside a path, then it's correct in that context. I can imagine more examples in my language which would give this type of problems. So my question is how I can arrange my grammar to solve this problem, because now it raises an error? Currently the site token looks like this:
@{Classification["Keyword"]} final token SiteKeyword = "site";
and my path grammar looks like this:
// ~[\ \t\n\r\.\/\\]+
token PathElement = ^(
'\u0020' | // Space Character
'\u0009' | // Horizontal tab
'\u000A' | // New Line
'\u000D' | // Carriage Return
'\u002E' | // Point
'\u005C' | // Backslash
'\u002F')+ // Slash
;
//{PathElement "/"}+ -> Directory
syntax Directory
= item:PathElement
=> item
| list: PathElement "/" item:PathElement
=> [valuesof(list), item];
syntax Filename = p:PathElement "." f:FileExt
=> Filename[p,f];
syntax Path = Directory "/" Filename | Filename;