Need simple parser and text generator (based on EMF) - Xtext? [message #1069652] |
Tue, 16 July 2013 10:03 |
Kirsten M. Z. Messages: 132 Registered: July 2010 |
Senior Member |
|
|
Hi @all,
I don't know yet, if Xtext is really what I need. I worked with some examples and browsed generated code, but I doubt that the complexity and output of Xtext is what I need. So please let me ask, if I can/should use Xtext or another tool within the eclipse world.
In several projects I have the following problem:
I have data based on EMF objects. Lists of such objects must be converted to (complex) strings. And, the strings must be converted back again. So basically I need some kind of string serialization/deserialization. However, the strings are tied to specified formats (far away from XML).
For example:
class EMF_class
{
a: String;
b: String;
c: String;
}
I have a list of three such objects (1,2,3), so the string should look like:
1.a[1.b] = "1.c", 2.a[2.b] = "2.c", 3.a[3.b] = "3.c"
However, this is just an example. Some rules of our string specifications are really complex. In past, I worked with JavaCC for specifying a parser. However, integrating with EMF and serialization is always additional work (overhead). Therefore, I thought working with "modern" tools like Xtext would be meaningful. However, I am not happy with the (default) output of Xtext. I expected to get a (simple) "parse" Method which generates my EMF ojects and another method vice versa. In addition, I don't want to get any further dependencies (Xtext libraries, Xtend, UI generation etc). Just simple methods like parser generators generated in the past decades.
Is this possible with Xtext? Can you recommend another way?
Thanks in advance!
[Updated on: Tue, 16 July 2013 10:03] Report message to a moderator
|
|
|
|
Re: Need simple parser and text generator (based on EMF) - Xtext? [message #1070174 is a reply to message #1070132] |
Wed, 17 July 2013 11:44 |
Kirsten M. Z. Messages: 132 Registered: July 2010 |
Senior Member |
|
|
Thanks for sharing your experience.
No, it is not the complexity of the language. I think Xtext is designed very carefully and has a great syntax. I am thinking about the overhead when using Xtext: library dependencies, creation of additional projects, MWE, bunch of generated/non generated files etc.
In my world it should be as simple as this:
specification file ---- generate ----> one or multiple Java files
Inside the generated file(s) there should be two public methods:
- From EMF objects to language string
- From language string to EMF objects
BTW: By using JJTree (JavaCC) you can generate an AST easily. But this is not EMF, JJTree is even harder to learn (compared to modern stuff like Xtext) and still the other way around must be coded by hand.
I'm wondering if there is no project which makes such tasks feasible.
[Updated on: Wed, 17 July 2013 11:46] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02967 seconds