Skip to main content



      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 19:52 Go to next message
Eclipse UserFriend
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 04:02 Go to previous messageGo to next message
Eclipse UserFriend
?
Re: Optional ordering with commas where first element can also be optional [message #1841860 is a reply to message #1841848] Tue, 01 June 2021 08:30 Go to previous messageGo to next message
Eclipse UserFriend
i have no idea, maybe you can have the possibility multiplied out.
usually such lists are not hardcoded.
Re: Optional ordering with commas where first element can also be optional [message #1841862 is a reply to message #1841860] Tue, 01 June 2021 08:48 Go to previous message
Eclipse UserFriend
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: Wed Apr 30 17:03:11 EDT 2025

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

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

Back to the top