Using WS as delimiter in part of grammar [message #1794563] |
Mon, 03 September 2018 02:49  |
Eclipse User |
|
|
|
We have an expression like grammar, simplified as following:
MainRule:
'{' 'MAIN'? main=Pattern '}' ';'?
;
Pattern :
Concat
;
Concat returns Pattern :
Union ({Concat.left=current} right=Union)*
;
Union returns Pattern:
And ({Union.left=current} '|' right=And)*
;
And returns Pattern:
Primary ({And.left=current} '&' right=Primary)*
;
Primary returns Pattern
: {Optional} '(' pattern=Concat ')'
| {Multi} '{' pattern=Concat '}'
| {Not} '!' pattern=Primary
| {Atomic} pattern=Atomic
;
Atomic returns Pattern
: {Word} value=STRING
| {Feature} value=ID
;
as you can see we use WS as delimiter in rule Concat.
Our language users report that they often miss type "&" or "|" between words and/or features, but xtext wont report any error.
FeatureA"someword" // what they typed and no error
FeatureA&"someword" // what they should type
FeatureA "someword" // xtext parsed as Concat
I've tried to override the global hidden() on Concat rule(hidden(ML_COMMENT, SL_COMMENT)), make WS not hidden, but it seems all following rules are WS sensitive, thats not what i want.
Is there a way to make only Concat rule WS sensitive?
Or any other way to solve this problem?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03873 seconds