Weird behaviour with multiple multi line comments [message #645382] |
Thu, 16 December 2010 22:03 |
No real name Messages: 25 Registered: April 2010 |
Junior Member |
|
|
Hi,
I am trying to implement something similar to java doc in xtext (because the language supports it). Currently I have multiple problems with Xtext.
1) There seems to be a weird bug. Consider the following example grammar:
grammar org.xtext.example.mydsl.MyDsl hidden(WS, DOC_COMMENT, ML_COMMENT, SL_COMMENT)
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
Model:
a='a';
terminal DOC_COMMENT: '/**' -> '*/';
terminal ML_COMMENT : '/*' -> '*/';
terminal SL_COMMENT : '//' !('\n'|'\r')* ('\r'? '\n')?;
terminal WS : (' '|'\t'|'\r'|'\n')+;
terminal ANY_OTHER: .;
This seems to show a very weird behaviour when using the compiled Editor. The following code:
works as expected. It seems to show weird behaviour when the end of File is on the next line or after a space, where the /** */ doesnt get lexed properly. If I remove one of the multiline comments (e.g. If I only have DOC_COMMENT and not ML_COMMENT) everything works as expected. If I change the characters for DOC_COMMENT everything works fine. Is this a bug or am i doing something horribly wrong? If this is the wrong approach, how would I go about doing this correctly?
I would love the DOC_COMMENT to be a production rule, but then I cannot color the whole text, and have other problems (e.g. cannot make the rule hidden)
Finally, I would also like to be able to nest a DOC_COMMENT inside a ML_COMMENT, is that possible at all?
|
|
|
|
|
|
|
Re: Weird behaviour with multiple multi line comments [message #645724 is a reply to message #645382] |
Mon, 20 December 2010 09:03 |
Jan Koehnlein Messages: 760 Registered: July 2009 Location: Hamburg |
Senior Member |
|
|
We have a similar documentation feature in the context of hovers in
Xtext 2.0.
You could have a look at the source code for inspiration, especially
/org.eclipse.xtext/src/org/eclipse/xtext/documentation/impl/ MultiLineCommentDocumentationProvider.java
Am 16.12.10 23:03, schrieb Wattos@gmail.com:
> Hi,
>
> I am trying to implement something similar to java doc in xtext (because
> the language supports it). Currently I have multiple problems with Xtext.
>
> 1) There seems to be a weird bug. Consider the following example grammar:
>
>
> grammar org.xtext.example.mydsl.MyDsl hidden(WS, DOC_COMMENT,
> ML_COMMENT, SL_COMMENT)
>
> generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
>
> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>
> Model:
> a='a';
> terminal DOC_COMMENT: '/**' -> '*/';
> terminal ML_COMMENT : '/*' -> '*/';
> terminal SL_COMMENT : '//' !('\n'|'\r')* ('\r'? '\n')?;
>
> terminal WS : (' '|'\t'|'\r'|'\n')+;
>
> terminal ANY_OTHER: .;
>
>
> This seems to show a very weird behaviour when using the compiled
> Editor. The following code:
>
>
> a
> /**
> *
> */<EOF>
>
>
> works as expected. It seems to show weird behaviour when the end of File
> is on the next line or after a space, where the /** */ doesnt get lexed
> properly. If I remove one of the multiline comments (e.g. If I only have
> DOC_COMMENT and not ML_COMMENT) everything works as expected. If I
> change the characters for DOC_COMMENT everything works fine. Is this a
> bug or am i doing something horribly wrong? If this is the wrong
> approach, how would I go about doing this correctly?
>
> I would love the DOC_COMMENT to be a production rule, but then I cannot
> color the whole text, and have other problems (e.g. cannot make the rule
> hidden)
> Finally, I would also like to be able to nest a DOC_COMMENT inside a
> ML_COMMENT, is that possible at all?
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
---
Get professional support from the Xtext committers at www.typefox.io
|
|
|
Powered by
FUDForum. Page generated in 0.04796 seconds