Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Empty line separated language elements
Empty line separated language elements [message #1814691] Mon, 16 September 2019 09:23 Go to next message
Eclipse UserFriend
Hello everyone,

I wish to create my own language with Xtext and I wish to make it separated by empty lines.

Please see my example
Name Groupname
Globalsettings ValidSetting

Task ImportantTask1
Options SimpleOption
Deadline Yesterday

Task ImportantTask2
Options OtherOption
Deadline Tomorrow


Is it possible to create a langauge rule set like this?
I have so far defined the new line terminal:
terminal NEWLINE: '\r'? '\n'


Whenever I try to collect more than one NEWLINE my language fails due to ambiguity.

I appreciate any helps.
Thank you in forward!
Re: Empty line separated language elements [message #1814701 is a reply to message #1814691] Mon, 16 September 2019 16:24 Go to previous messageGo to next message
Eclipse UserFriend
IMHO you should not restrict this in the grammar. Better use a combination of formatting, validation & quickfix. In a validation rule you could check by visiting the node model that certain elements are preceeded by new lines, with quick fix and formatting you could fix that.
Re: Empty line separated language elements [message #1814726 is a reply to message #1814701] Tue, 17 September 2019 03:34 Go to previous messageGo to next message
Eclipse UserFriend
Thank you for the feedback.

So you are saying that instead of separating by new line, I should check for empty lines e.g. after Deadline language elements.

Correct me please if I am wrong.
Re: Empty line separated language elements [message #1814735 is a reply to message #1814726] Tue, 17 September 2019 05:05 Go to previous messageGo to next message
Eclipse UserFriend
Yes, check for newline or EOF after a Deadline element. The parser should be fine without newlines, but your semantic constraint for Deadline is that it has to be followed by NL/EOF. Implement a formatter that would insert these newlines on formatting the document to fix the situations.
The grammar itself should not be so restrictive, and esp. be very limited with terminal rules.
Re: Empty line separated language elements [message #1814736 is a reply to message #1814735] Tue, 17 September 2019 05:07 Go to previous message
Eclipse UserFriend
Thank you again, I will give it a try.
Previous Topic:Exporting DSL as Xtext feature has cross reference problems
Next Topic:Use *completely external* EMF model?
Goto Forum:
  


Current Time: Sun Apr 27 04:14:12 EDT 2025

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

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

Back to the top