Semicolon optional at end of line [message #1806908] |
Fri, 17 May 2019 08:20  |
Eclipse User |
|
|
|
I would like to define a language that uses semicolons to separate statements form each other. However, I want semicolons optional at the end of a line only. If two statements (or more) are on the same line the semicolon should be required between statement 1 and 2, but not after statement 2. (Line breaks should still be allowed everywhere where whitespace is allowed.)
For example, with the trivial greeting language:
Valid:
Hello X!;
Hello Y!
Hello Z!
Hello A!; Hello B!; Hello C!
Hello K
!; Hello L!
Hello M!; Hello
N!
Invalid:
Hello X! Hello Y!
Hello A! Hello B!;
How do I do this in Xtext? It seems like I need to treat '\n' as non whitespace, but then I'd have to insert explicit '\n' everywhere in the grammar. Is there an easier way to do this?
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05873 seconds