Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Keyword serialization order
Keyword serialization order [message #810637] Thu, 01 March 2012 11:07
Bryce Brinkley is currently offline Bryce BrinkleyFriend
Messages: 8
Registered: October 2011
Junior Member
We are using Xtext to define the syntax of a complex parameter file.
To give users the most freedom, at some places parameters/keywords can be specified in arbitrary order. The keywords are also optional.

A small example for "Options":
See railway diagram: img16.imageshack.us/img16/6340/optionsy.png

The corresponding grammar rule looks like this:
Options:
	options='Options' ((report?='Report' reportType=('Postscript' | 'Contour')?) | noEcho?='NoEcho' |
	listMaterialParams?='ListMaterialParams' | listDriftDiffusionParams?='ListDriftDiffusionParams' |
	InterpolationSearch?='InterpolationSearch' | singleDipole?='SingleDipole' | dense?='Dense')*;


Parsing works fine, but when the data structure is serialized, the order of the keywords is totally random. This makes it very difficult to read parts where whole blocks are ordered randomly at each save operation.

The file is serialized using this code:
public static String serializePar(Model model) {
      Injector in = new ParLegacyStandaloneSetup().createInjectorAndDoEMFRegistration();
      Serializer serializer = in.getInstance(Serializer.class);
      return serializer.serialize(model, SaveOptions.newBuilder().format().getOptions());
   }


Now I would like to ask, if there is a formatter option to specify a keyword priority for a case mentioned above. Or is there a better way to define it in the grammar?

Thanks in advance.

B
  • Attachment: Options.png
    (Size: 6.81KB, Downloaded 150 times)

[Updated on: Thu, 01 March 2012 11:08]

Report message to a moderator

Previous Topic:Validation / Type checking / attributes
Next Topic:Handeling errors in dsl
Goto Forum:
  


Current Time: Fri Apr 26 23:13:58 GMT 2024

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

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

Back to the top