Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Deploy lightweight parser/serializer
Deploy lightweight parser/serializer [message #735351] Tue, 11 October 2011 15:14 Go to next message
Bryce Brinkley is currently offline Bryce BrinkleyFriend
Messages: 8
Registered: October 2011
Junior Member
Hello everybody.

After some research I finally found out how to parse and serialize my DSL files. I wrote two simple static methods which do the job. The code looks like this:
@SuppressWarnings("restriction")
   public static String serializePar(Model model) {
      Injector in = new ParStandaloneSetup().createInjectorAndDoEMFRegistration();
      Serializer serializer = in.getInstance(Serializer.class);
      return serializer.serialize(model, SaveOptions.newBuilder().format().getOptions());
   }

   public static Model parsePar(File f) {
      try {
         Injector in = new ParStandaloneSetup().createInjectorAndDoEMFRegistration();

         IParser parser = in.getInstance(ParParser.class);
         IParseResult result = parser.parse(new FileReader(f));
         Iterable<INode> errors = result.getSyntaxErrors();

         Iterator<INode> i = errors.iterator();
         if (i.hasNext()) {
            System.out.println("ERROR: " + i.toString());
            return null;
         }

         return (Model) result.getRootASTElement();
      } catch (Exception e) {
         return null;
      }
   }


I created a jar file which provides access to the methods above. After exporting the jar in Eclipse (runnable jar, extract required libs) I ended up with a 15.7MB file. I tried to strip it down and compress everything (with yguard), but it's still more than 7MB. Our whole software used to be less than 5MB before; including all graphics and libraries.
I am wondering if the jar really needs all these dependencies and if it might be possible to make it smaller. At the moment the jar still includes a lot of overhead like png logos, about files, html, templates and probably heaps of unused code.

Does anybody have experience with deploying minimal parsers/serializers? Maybe I could remove dependencies by using other serializer methods?

Thanks for you help!

B
Re: Deploy lightweight parser/serializer [message #739390 is a reply to message #735351] Mon, 17 October 2011 12:25 Go to previous message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
Depending on the size of your DSL and how often it changes, it might be worthwhile to use an Xtend2 template to do the serialization and just pack the compiled-to-Java version of the template with its dependencies (mostly org.eclipse.xtext.xtend2.lib and its dependencies).

Previous Topic:Defaulting with Xtext
Next Topic:Xtext and CNF (Common Navigator Framework)
Goto Forum:
  


Current Time: Fri Apr 26 16:14:57 GMT 2024

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

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

Back to the top