Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Single Lined Comments With Ending Characters - Grammar Question(XText Grammar Question)
Single Lined Comments With Ending Characters - Grammar Question [message #1805086] Fri, 05 April 2019 13:40 Go to next message
Ja Mcco is currently offline Ja MccoFriend
Messages: 1
Registered: April 2019
Junior Member
Hello All!

I am looking to do something like this:

// Commented text **
// Commented text -
// Commented text +

I am running into an issue with having ending characters with single line comments.

The valid ending characters are **, -, + I'm just looking to classify comments in a specific way.

There will be in a terminal fragment for the ending would look like:

terminal fragment ENDING:
('+' | '-' | '**' );


The following is the closest I can get to what I am looking for. I have tried a lot of alternatives that follow this logic.

terminal COMMENT:
	
	 ('//'  !('\n'|'\r')*  ENDING ('r'? '\n' )?;

Everything works until you add a space or tab after the comment. I don't want to include this in the terminal rule because I will have unnecessary white space on the end of the comment. I don't want to have to trim the string every time.

I essentially want to capture the comments as everything from '//' to an ENDING and not allow new lines. Also anything beyond the ENDING should not be stored so I can avoid trimming every time.

// Commented text +


I hope I explained the question well enough, thanks to anyone who helps out!
Re: Single Lined Comments With Ending Characters - Grammar Question [message #1805370 is a reply to message #1805086] Fri, 12 April 2019 16:53 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
hi,

Also anything beyond the ENDING should not be stored so I can avoid trimming every time.

did you have a look at the concept of valueconverters


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Problem on launching Eclipse 2019.03 with Xtext and xcore
Next Topic:Xtext Web: 'The parameter \'serviceType\' is required.'
Goto Forum:
  


Current Time: Thu Sep 19 18:21:43 GMT 2024

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

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

Back to the top