Xtext double hash comment [message #1744240] |
Fri, 23 September 2016 14:45 |
Sachin Samaram Messages: 271 Registered: April 2016 |
Senior Member |
|
|
Hi,
I have concatenation operator '##' and also # comment which can just starts with double hash '##'.
For that I have written grammar,
Model:
greetings+=(Statements)*;
Statements : Greeting|HASH_COMMENT;
Greeting:
'Hello' exp=Expression '!';
Expression:
Concatenation
;
Concatenation returns Expression:
Primary ({Concatenation.left=current} '##' right=Primary)*
;
Primary returns Expression: {Expression}
name=STRING | name=ID
;
terminal HASH_COMMENT : ('#'('\r'? '\n')?) | ('#' !('#'|'\n'|'\r')+ ('\r'? '\n')?) | (('#''#''#') !('\n'|'\r')* ('\r'? '\n')?);
But I am getting this error if I use '##',

How to solve this? Always Concatenation gets consumed but I want to consume terminal rule if the '##' comes starting or end of a line not middle of any string or ID or etc..
[Updated on: Fri, 23 September 2016 14:48] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01529 seconds