Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How could empty elements be allowed in a whitespace-aware DSL in xtext?(How could empty elements be allowed in a whitespace-aware DSL in xtext?)
How could empty elements be allowed in a whitespace-aware DSL in xtext? [message #1847443] Wed, 27 October 2021 08:39 Go to next message
Weixing Zhang is currently offline Weixing ZhangFriend
Messages: 19
Registered: April 2021
Junior Member
Hey,

I have modified the domainmodel example into a whitespace DSL, see as follows:
datatype String
 
entity Blog
    title: String
    many posts: Post
 
entity HasAuthor
    author: String
 
entity Post extends HasAuthor
    title: String
    content: String
    many comments: Comment
 
entity Comment extends HasAuthor
    content: String

it's quite nice, but the problem now is that I have to type in an element underneath an entity, even though I have make the expression "(features+=Feature)*" optional. See as follows:
datatype String
 
entity Blog
    title: String
    many posts: Post
 
entity HasAuthor
 
entity Post extends HasAuthor
    title: String
    content: String
    many comments: Comment
 
entity Comment extends HasAuthor
    content: String

Then I would receive error message at line "entity Post...", that:
mismatched input 'entity' expecting RULE_BEGIN.

So how could I make it allow empty element exist?

[Updated on: Wed, 27 October 2021 08:40]

Report message to a moderator

Re: How could empty elements be allowed in a whitespace-aware DSL in xtext? [message #1847446 is a reply to message #1847443] Wed, 27 October 2021 09:43 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14699
Registered: July 2009
Senior Member
the naive variant does not work?

Model:
	entities+=Entity*;

Entity: "entity" name=ID
(BEGIN
	f+=Field*
END)?;	

Field:
	name=ID
;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Disable new resource creation for every character entry
Next Topic:How to add Template Proposal in Xtext as LSP for VSCODE
Goto Forum:
  


Current Time: Sat Jul 27 10:13:53 GMT 2024

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

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

Back to the top