Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Multiline Comment processing
Multiline Comment processing [message #997833] Tue, 08 January 2013 20:54 Go to next message
Nathan M is currently offline Nathan M
Messages: 5
Registered: January 2013
Junior Member
I'm new to xtext, and I'm trying to figure out how to get my DSL going. my DSL essentially lives inside comment blocks, e.g., /** ... */

The comment blocks that begin with two asterisks are the ones that are processed, while the ones with just a single opening asterisk are treated like normal comments.

It took me awhile but I figured out that to process the inside of the comment blocks I need to unhide the ML_COMMENT terminal.

What I want to know how is how to remove the default processing going on where when you hit enter it automatically adds a "*" at the beginning of the next line when inside of a comment. My comment blocks don't have asterisks at the beginning of each line, only at the start and end of the block. I can't figure out where this is being done though and how to stop it.
Re: Multiline Comment processing [message #997929 is a reply to message #997833] Wed, 09 January 2013 02:17 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik Lindberg
Messages: 2500
Registered: July 2009
Senior Member
On 2013-08-01 22:11, Nathan M wrote:
> I'm new to xtext, and I'm trying to figure out how to get my DSL going.
> my DSL essentially lives inside comment blocks, e.g., /** ... */
>
> The comment blocks that begin with two asterisks are the ones that are
> processed, while the ones with just a single opening asterisk are
> treated like normal comments.
> It took me awhile but I figured out that to process the inside of the
> comment blocks I need to unhide the ML_COMMENT terminal.
> What I want to know how is how to remove the default processing going on
> where when you hit enter it automatically adds a "*" at the beginning of
> the next line when inside of a comment. My comment blocks don't have
> asterisks at the beginning of each line, only at the start and end of
> the block. I can't figure out where this is being done though and how to
> stop it.

Checkout the class DefaultAutoEditStrategyProvider which sets this up
for the default terminals. You can override this, and bind your own
derived configuration in the UI module of your DSL.

If you have both /* */ comments and /** */ comments you probably want to
add a terminal with higher priority for the /** */ comment, and call it
something like DOC_COMMENT. That would also skip the auto edits which
works on ML_COMMENT by default (IIRC).

Hope that helps.
Regards
- henrik
Re: Multiline Comment processing [message #998193 is a reply to message #997929] Wed, 09 January 2013 14:37 Go to previous messageGo to next message
Nathan M is currently offline Nathan M
Messages: 5
Registered: January 2013
Junior Member
Thanks!!!!

Overriding the method worked.

Quote:

If you have both /* */ comments and /** */ comments you probably want to
add a terminal with higher priority for the /** */ comment, and call it
something like DOC_COMMENT. That would also skip the auto edits which
works on ML_COMMENT by default (IIRC).


I had tried doing that, but with the presence of either a ML_COMMENT or DOC_COMMENT terminal, nothing is parsable. For example, with something like


AnnotationBlock:
     start=BlockStart
     (annotations += Annotatation)*
     end=BlockEnd
;

BlockStart: '/**' ;
BlockEnd: '*/' ;

...

terminal DOC_COMMENT: '/**' -> '*/';
terminal ML_COMMENT: '/*' -> '*/';


and source

/**
 @annotation test
*/


It just complains about the whole thing saying extraneous input at EOF.

So i just removed DOC_COMMENT and changed ML_COMMENT to
terminal ML_COMMENT: '/*'(!'*') -> '*/';
Re: Multiline Comment processing [message #998200 is a reply to message #998193] Wed, 09 January 2013 14:50 Go to previous message
Henrik Lindberg is currently offline Henrik Lindberg
Messages: 2500
Registered: July 2009
Senior Member
Ah,
Then your DOC comments are actually parsed. That works.
Sorry about the confusion.

Regards
- henrik

On 2013-09-01 15:37, Nathan M wrote:
> Thanks!!!!
>
> Overriding the method worked.
>
> Quote:
>> If you have both /* */ comments and /** */ comments you probably want
>> to add a terminal with higher priority for the /** */ comment, and
>> call it something like DOC_COMMENT. That would also skip the auto
>> edits which works on ML_COMMENT by default (IIRC).
>
>
> I had tried doing that, but with the presence of either a ML_COMMENT or
> DOC_COMMENT terminal, nothing is parsable. For example, with something like
>
> AnnotationBlock:
> start=BlockStart
> (annotations += Annotatation)*
> end=BlockEnd
> ;
>
> BlockStart: '/**' ;
> BlockEnd: '*/' ;
>
> ...
>
> terminal DOC_COMMENT: '/**' -> '*/';
> terminal ML_COMMENT: '/*' -> '*/';
>
> and source
>
> /**
> @annotation test
> */
>
> It just complains about the whole thing saying extraneous input at EOF.
>
> So i just removed DOC_COMMENT and changed ML_COMMENT to
> terminal ML_COMMENT: '/*'(!'*') -> '*/';
Previous Topic: Using Xtext code in an Eclipse Plugin
Next Topic:plugin source
Goto Forum:
  


Current Time: Sat Oct 25 10:29:32 GMT 2014

Powered by FUDForum. Page generated in 0.01625 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software