Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Optional ordering with commas where first element can also be optional
Optional ordering with commas where first element can also be optional [message #1841807] Sun, 30 May 2021 23:52 Go to next message
M D is currently offline M DFriend
Messages: 33
Registered: January 2021
Member
I'm developing a JSON like DSL. Objects appear in the same order, but I want them to be optionals. I can see a solution if the first object is not optional, as the commas would just belong to the next object, but what if the first object as well can be optional?

I've tried setting the commas to being optional, but this does not work when the object in between is also optional - I believe because the written comma can be either of the optional commas then.

Example:
   '{'
      '"One"' ':' '{'
         one = JsonValue
      '}' ','
      '"Two"' ':' '{'
         two = JsonValue
      '}' ','
      '"Three"' ':' '{'
         three = JsonValue 
      '}'
   '}'
;


JsonValue: 
	'"value"' ':' value = INT
;
Re: Optional ordering with commas where first element can also be optional [message #1841848 is a reply to message #1841807] Tue, 01 June 2021 08:02 Go to previous messageGo to next message
M D is currently offline M DFriend
Messages: 33
Registered: January 2021
Member
?
Re: Optional ordering with commas where first element can also be optional [message #1841860 is a reply to message #1841848] Tue, 01 June 2021 12:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i have no idea, maybe you can have the possibility multiplied out.
usually such lists are not hardcoded.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Optional ordering with commas where first element can also be optional [message #1841862 is a reply to message #1841860] Tue, 01 June 2021 12:48 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The idiom is

(First (',' Next)*)?

First and Next are not optional unless commas can be scattered gratuitously. You need to factor your terms so that First and Next contribute precisely one term of progress.

Regards

Ed Willink
Previous Topic:Lexer mixes some inputs even though it is set to non-greedy?
Next Topic:Making editor regions read-only
Goto Forum:
  


Current Time: Fri Apr 26 14:22:05 GMT 2024

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

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

Back to the top