Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Strict grammar vs Relax grammar
Strict grammar vs Relax grammar [message #1697656] Fri, 05 June 2015 18:31 Go to next message
Luis De Bello is currently offline Luis De BelloFriend
Messages: 95
Registered: January 2015
Member
Hi guys,

I am trying to improve the autocomplete for my grammar but I would like to check if this is the best approach.

Original Grammar:
MultipleKeyValuePairObj:
{MultipleKeyValuePairObj} "{" (elements+=ObjectElement ("," elements+=ObjectElement)*)? "}";

Case 1: This is valid
{
"data": {
"child": 1234
}
}

Case 2: In this case the autocompletion provides me with the model for the container object instead with the current key value pair, because the , --> is provoking that my grammar is invalid
{
"data": {
"child": 1234,
@CursorHere@
}
}

I solve the case 2 changing my grammar to put "ObjectElement" with "?" cardinality
MultipleKeyValuePairObj:
{MultipleKeyValuePairObj} "{" (elements+=ObjectElement ("," elements+=ObjectElement?)*)? "}";

Now I need to add some validation to check if my grammar is fine.

From what I read it seems ok but I would like to get your comments/opinion

Regards,
Luis
Re: Strict grammar vs Relax grammar [message #1697748 is a reply to message #1697656] Mon, 08 June 2015 07:13 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Luis,

yes it's considered good practice to have a grammar which doesn't impose
too tight constraints and validate the model explicitly to provider
better user feedback et al.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Re: Strict grammar vs Relax grammar [message #1698083 is a reply to message #1697748] Wed, 10 June 2015 22:57 Go to previous message
Luis De Bello is currently offline Luis De BelloFriend
Messages: 95
Registered: January 2015
Member
Sebastian,

Thanks for your answer.

Regards,
Luis
Previous Topic:buckminster junit launch -- headless
Next Topic:Generate non text files
Goto Forum:
  


Current Time: Tue Mar 19 06:08:21 GMT 2024

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

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

Back to the top