|Custom terminal rule for /**-style documentation [message #878889]
||Wed, 30 May 2012 06:19
| Ralph Mayr
Registered: August 2011
I'm trying to implement a grammar with a special terminal rule for documentation, which should be highlighted in a different color than normal comments, but otherwise behave analogously. (Basically like in Java where JavaDoc-Comments starting with /** are highlighted differently to ordinary comments starting with /* ).
My first attempt was to create an additional terminal rule, and add it to the "hidden" rules of my grammar:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals hidden(WS, ML_DOCUMENTATION, ML_COMMENT, SL_COMMENT)
'Hello' name=ID '!';
terminal ML_DOCUMENTATION : '/**' -> '*/';
Unfortunately, this leads to unexpected parsing errors at runtime. E.g. in the following test:
I get a parser error in the very first line (- no viable alternative at character '<EOF>', - missing EOF at '*'), as soon as I enter the code in the fourth line. Without the code in the fourth line, the comment parses fine.
I also tried a few different versions (copying all terminals defined in org.eclipse.xtext.common.Terminals to my grammar, changing the order of the terminals in the grammar, ...) but could not find a valid solution.
I would be grateful for any hints!
Powered by FUDForum
. Page generated in 0.01906 seconds