Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Check Validity of automatically generated instances
Check Validity of automatically generated instances [message #1852196] Wed, 04 May 2022 14:31 Go to next message
Antoine Gratia is currently offline Antoine GratiaFriend
Messages: 2
Registered: May 2022
Junior Member
Hello,

I am young user of xtext and I have some questions about its usage. I defined a grammar, and I try to generate automatically some instances of the grammar but there are no guaranties about the validity of the instances. The automatic generation is done by changing a few tokens (mutation). I am unsure that these local changes do not break my grammar rules. I am wondering if there is a function that can validate the instance automatically.

I have tried to use the "ParseHelper" class but I cannot use it out of the test project.

Thanks in advance

Antoine
Re: Check Validity of automatically generated instances [message #1852200 is a reply to message #1852196] Wed, 04 May 2022 16:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14349
Registered: July 2009
Senior Member
hi, i cannot follow you. what exactly do you want to validate? syntax? semanctic?
also why cant you use ParseHelper
pase helper just create a resource. you can do the same



Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 04 May 2022 16:38]

Report message to a moderator

Re: Check Validity of automatically generated instances [message #1852201 is a reply to message #1852200] Wed, 04 May 2022 16:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14349
Registered: July 2009
Senior Member
Besides that you can do something like (peudo code)

@Inject
Provider<XtextResourceSet> rsp;

XtextResourceSet rs = rsp.get();
Resource r = rs.createResource(URI.createURI("dummy.mydsl"))
r.load(new StringInputStream("Hello World"), null);


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Check Validity of automatically generated instances [message #1852229 is a reply to message #1852201] Thu, 05 May 2022 13:20 Go to previous messageGo to next message
Antoine Gratia is currently offline Antoine GratiaFriend
Messages: 2
Registered: May 2022
Junior Member
Hello,

Thanks for your answers.

Sorry for not being precise enough. I will reexplain and I attach an image.

I have two scenarios:

First, I have defined a grammar and I can generate automatically instances. I am currently using the factory class created by xtext and modified the body of the methods according to my grammar rules. This can give me N instances from the grammar, but how can I be sure that they are correct w.r.t. the grammar rules? That is the top part of the image.

Second, I select one of the generated instances and I modify it automatically (by changing some of the tokens, i.e., what we call mutation). I want to know whether this new modified instance is valid w.r.t. the grammar. This is the bottom part of the image.

For instance, you can see that the modification inserted "pooling" token after the "conv" one. It is supposedly valid, but I would like to check it with the grammar rules. Is that possible?

I hope it is clearer now.

Thanks.

Antoine

[Updated on: Thu, 05 May 2022 13:20]

Report message to a moderator

Re: Check Validity of automatically generated instances [message #1852242 is a reply to message #1852229] Thu, 05 May 2022 16:46 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14349
Registered: July 2009
Senior Member
this should work with my snippet.

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Xtext 2.27.0.M2 is out
Next Topic:Error: "Message could not be parsed" in Socket Mode
Goto Forum:
  


Current Time: Sun Sep 25 08:39:34 GMT 2022

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

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

Back to the top