Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext for generating random dsl code(Generating random sentences(dsl code) corresponding to grammar)
Xtext for generating random dsl code [message #1779819] Sat, 13 January 2018 10:17 Go to next message
Stanislav Gordeev is currently offline Stanislav GordeevFriend
Messages: 2
Registered: January 2018
Junior Member
Hello, everyone, I have idea:
I want to use xtext as generator for random "dsl code" corresponding to xtext grammar.
I have grammar in custom ebnf-like format and I want to translate it to xtext manually, but it is rather complex (grammar for processor arch definition). Before I'll start I want to know is there any possibility to generate "dsl code" using just AST without creating Java code for grammar objects(because it will be very large and complex)?
Or the only possibility to generate such concrete arch definition("dsl code") is writing Java code corresponding to grammar?
If you have better ideas for this problem, I'm very interested.

Idea: this is part of my master's thesis. I want to use it for testing custom parser (written by advisor).
Re: Xtext for generating random dsl code [message #1779913 is a reply to message #1779819] Mon, 15 January 2018 18:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12388
Registered: July 2009
Senior Member
Hi I am not sure if I understand you

If you want to use Xtext to parse file the ast iare the Java objects you don't want to have

An you rephrase your question e.g. with a simple pseudocode and sample of what you want to do


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext for generating random dsl code [message #1780197 is a reply to message #1779913] Thu, 18 January 2018 14:43 Go to previous messageGo to next message
Stanislav Gordeev is currently offline Stanislav GordeevFriend
Messages: 2
Registered: January 2018
Junior Member
Ok, I want to generate dsl code using xtext, so when I call "generate xtext artifacts " xtext creates Java objects of grammar and other stuff.
So, what i want is generate representation of result in Java and result will be serialized --> file.mydsl
and I want to generate huge amount of such files for testing custom parser:

file1.mydsl
file2.mydsl
file3.mydsl
..
etc

I found in separate thread https://www.eclipse.org/forums/index.php/t/1090526/ that it could be done with such code (by you =) :

// pseudo code
URI uri = URI.createURI("platform:/resource/myproject/myfolder/demo.mydsl")
IResourceSetProvider resourceSetProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(uri).get(IResourceSetProvider.class);
ResourceSet resourceSet = resourceSetProvider.get(project);
Resource r = resourceSet.createResource(uri);
//

Now I imagine to write such code:
{
Class c = MyDsl.class;

// here code for generating random "dsl code" by corresponding java objects

// then serialize it to file
URI uri = URI.create("demo.mydsl");
IResourceSetProvider resourceSetProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(uri).get(IResourceSetProvider.class);
ResourceSet resourceSet = resourceSetProvider.get(project);
Resource r = resourceSet.createResource(uri);
}

but eclipse can't find such packages to resolve serializing process, how can I import such packages, where I can find some info about it?

[Updated on: Thu, 18 January 2018 14:51]

Report message to a moderator

Re: Xtext for generating random dsl code [message #1780203 is a reply to message #1780197] Thu, 18 January 2018 15:20 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12388
Registered: July 2009
Senior Member
simpy call resource.save?

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:xText Standalone maven dependencies
Next Topic:Extracts single business aspects into separate grammars
Goto Forum:
  


Current Time: Sat Nov 17 11:14:46 GMT 2018

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

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

Back to the top