[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.tmf] Re: [XText] serialize parsed tree to String

Hi Michael,

what you are listing below is actually an error message and *not* your serialized model. However, this error message contains fragments of your serialized model.

Are you sure the message resulted from serializing the model from parsing "$varname = 5;"?

The message contains the serialized part of your model:
"] = $current ; $message = "square root found" ; } }"
And this doesn't look to me like it has originated from "$varname = 5;".

regards,
  Moritz

Hi Sebastian,


ok, I've got it running, but not in a way I want.

Parsing and serialization are divided into two classes in my implementation. Thats the reason why XtextResourceSet.getResource() reports: "resource was not registered".


If I merge the methods, I got a different serialization as I hoped for. I put into the parser a line like this:

 $varname = 5;

after parsing and serializing I got something like that:
======
scripts[0] = Assign {
variable = Variable(name='de.btopia.ghandara.charme.impl.VariableNameImpl@55eb1db2 (name: $result)') {
69: "] = $current ; $message = "square root found" ; } }...":
-> Variable_IndexAssignment_1_1: Variable.index is not set.
68: "= $current ; $message = "square root found" ; } } }...":
-> Variable_PropertyAssignment_2_1: Variable.property is not set.
}
value = Expression {
headTerm = IntegerConst(...
====
OK, I found no easy-to-read code snipplet. Sorry. I can give you much more complex examples.


But first, the Injector needs an inject with the registered resources. The use cases (parse and serialize) can be made independent from each other. The parsed model has all information about the original DSL code. There is no need to store resource URIs _OR_ the authority for registration resources is unique in the whole system.

But in my case:
How can I reach my simple DSL code line "$varname = 5;" from serialization?


Ciao, Micha





--- Original-Nachricht ---
Absender: Sebastian Zarnekow
Datum: 11.09.2009 18:17
Hi Michael,

your resource is emtpy and has not been loaded.

Please try something like:

Resource res = resourceSet.getResource(URI.createURI(..existing uri..));
res.save(..);

resourceSet.createResource will create a new resource but won't load it.

res = resourceSet.createResource(..uri..);
res.load(new StringInputStream("valid model"));
res.save(..)

should do the trick as well.

Hope that helps,
Sebastian


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com