Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Multiline Comment processing
Multiline Comment processing [message #997833] Tue, 08 January 2013 15:54 Go to next message
Eclipse UserFriend
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] Tue, 08 January 2013 21:17 Go to previous messageGo to next message
Eclipse UserFriend
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 09:37 Go to previous messageGo to next message
Eclipse UserFriend
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 09:50 Go to previous message
Eclipse UserFriend
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: Tue Jul 08 15:38:23 EDT 2025

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

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

Back to the top