How to resolve terminal conflict [message #1806143] |
Fri, 03 May 2019 10:39  |
Eclipse User |
|
|
|
My DSL extends from Xbase, which uses the '|' token for named lambda parameters.
In my DSL, I want to parse input such as
|foo| |123|anything could be here~
that is, table columns with more-or-less-arbitrary content, separated by bars '|' and terminated by a tilde '~'.
The terminal rule for this input currently looks like this:
terminal LINE:
'|' !('|' | '~') (!'~')* '~';
This shadows the '|' terminal used in the aforementioned Xbase definition, which means that lambda parameters renaming doesn't work anymore.
Since such input doesn't appear in the same context as lambdas, I considered rewriting the terminal rule as a data type rule. Something like
Line:
'|' LINE_CONTENT '~';
terminal LINE_CONTENT:
!('|' | '~') (!'~')*;
The problem here of course is, that now LINE_CONTENT shadows basically everything! No good at all.
Is there a way to write my grammar so it parses both these inputs as well as the Xbase lambdas?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02566 seconds