Single Lined Comments With Ending Characters - Grammar Question [message #1805086] |
Fri, 05 April 2019 09:40  |
Eclipse User |
|
|
|
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!
|
|
|
|
Powered by
FUDForum. Page generated in 0.04654 seconds