Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Antlr equivalent to the '&' operator
Antlr equivalent to the '&' operator [message #883606] Fri, 08 June 2012 22:41 Go to next message
Nicolas  Lalevée is currently offline Nicolas LalevéeFriend
Messages: 14
Registered: July 2009
Junior Member
I made a plugin with Xtext to create a DSL for Apache Ant. I love the result. Xtext is amazing how simple it is to make an editor from a grammar. Congrats to the developers.

I wanted then to use the generated parser to be used by Ant. I made it work, that's nice. But I find the parser quite slow to load. On my icore7, almost 1 second just to load the parser without having parsed anything. And 1s is slow for a command line utility. I did some profiling and as far as I could understand, it's guice and Ecore which are eating most of the load time.

Since Xtext is grammar is very close to the Antlr one, I rewrote the grammar into a vanilla Antlr one and generated a parser. The load time is then as fast as anyone would expect, just few millis to load some classes. This is duplicating the grammar, but I can deal with it.

Well almost deal with it and here come my question. In my Xtext grammar I used the very useful operator '&'. But I don't know how to do in Antlr. Does anyone have some hint for me ?


OT: the Ant DSL is checked in there: svn.apache.org/repos/asf/ant/sandbox/antdsl/
Re: Antlr equivalent to the '&' operator [message #884221 is a reply to message #883606] Sun, 10 June 2012 13:24 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
Nicolas,

Antlr does not support the unordered group concept natively. You'll have
to do it manually with predicates, post processing of the generated
parser code and such things. I'd recommend to stick with Xtext. You may
want to use a minimal module for the parser that is used to create an
injector. This should speed things up.

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

Am 09.06.12 00:41, schrieb Nicolas alevée:
> I made a plugin with Xtext to create a DSL for Apache Ant. I love the
> result. Xtext is amazing how simple it is to make an editor from a
> grammar. Congrats to the developers.
>
> I wanted then to use the generated parser to be used by Ant. I made it
> work, that's nice. But I find the parser quite slow to load. On my
> icore7, almost 1 second just to load the parser without having parsed
> anything. And 1s is slow for a command line utility. I did some
> profiling and as far as I could understand, it's guice and Ecore which
> are eating most of the load time.
>
> Since Xtext is grammar is very close to the Antlr one, I rewrote the
> grammar into a vanilla Antlr one and generated a parser. The load time
> is then as fast as anyone would expect, just few millis to load some
> classes. This is duplicating the grammar, but I can deal with it.
>
> Well almost deal with it and here come my question. In my Xtext grammar
> I used the very useful operator '&'. But I don't know how to do in
> Antlr. Does anyone have some hint for me ?
>
>
> OT: the Ant DSL is checked in there:
> svn.apache.org/repos/asf/ant/sandbox/antdsl/
>
Re: Antlr equivalent to the '&' operator [message #885294 is a reply to message #884221] Tue, 12 June 2012 18:58 Go to previous messageGo to next message
Nicolas  Lalevée is currently offline Nicolas LalevéeFriend
Messages: 14
Registered: July 2009
Junior Member
What do you mean by "minimal module for the parser" ?
All I do is:
        Injector guiceInjector = new AntDSLStandaloneSetup().createInjectorAndDoEMFRegistration();
        IParser parser = guiceInjector.getInstance(IParser.class);

Re: Antlr equivalent to the '&' operator [message #886096 is a reply to message #885294] Thu, 14 June 2012 08:29 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
Hi Nicolas,

this will initialize the injector with all the available runtime
bindings. I assume that you don't need all that stuff thus you could use
a reduced guice module to create an injector. But that'll depend on your
use case and language implementation.

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

Am 12.06.12 20:58, schrieb Nicolas Lalevée:
> What do you mean by "minimal module for the parser" ?
> All I do is:
>
> Injector guiceInjector = new
> AntDSLStandaloneSetup().createInjectorAndDoEMFRegistration();
> IParser parser = guiceInjector.getInstance(IParser.class);
>
>
Re: Antlr equivalent to the '&' operator [message #886101 is a reply to message #886096] Thu, 14 June 2012 08:46 Go to previous messageGo to next message
Nicolas  Lalevée is currently offline Nicolas LalevéeFriend
Messages: 14
Registered: July 2009
Junior Member
I already tried to bypass guice and instanciate manually the minimum set of required beans.
See http :// svn.apache.org/repos/asf/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/ParserCreator.java
(By the way I would love have seen some proper setter rather than hacking via java introspection)

But instead of 1s to load, it took about 600/700ms. Still a lot slower than a pure antlr parser.

On the other hand, reproducing the behavior of the '&' operator seems a real pain, I may revisit my speed requirement, or the need for the '&' operator.
Re: Antlr equivalent to the '&' operator [message #886122 is a reply to message #886101] Thu, 14 June 2012 09:33 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
Did you profile where the time is lost with your ParserCreator approach?

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

Am 14.06.12 10:46, schrieb Nicolas Lalevée:
> I already tried to bypass guice and instanciate manually the minimum set
> of required beans.
> See http ://
> svn.apache.org/repos/asf/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/ParserCreator.java
>
> (By the way I would love have seen some proper setter rather than
> hacking via java introspection)
>
> But instead of 1s to load, it took about 600/700ms. Still a lot slower
> than a pure antlr parser.
>
> On the other hand, reproducing the behavior of the '&' operator seems a
> real pain, I may revisit my speed requirement, or the need for the '&'
> operator.
Re: Antlr equivalent to the '&' operator [message #886125 is a reply to message #886122] Thu, 14 June 2012 09:40 Go to previous messageGo to next message
Nicolas  Lalevée is currently offline Nicolas LalevéeFriend
Messages: 14
Registered: July 2009
Junior Member
I did. Most of the time spent was in loading some Ecore stuff, I don't remember where exactly.
Re: Antlr equivalent to the '&' operator [message #886135 is a reply to message #886125] Thu, 14 June 2012 09:57 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
I see - probably the EPackage initialization. There is not much what you
can do about that - besides refactoring your package (if that would be
feasible).

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

Am 14.06.12 11:40, schrieb Nicolas Lalevée:
> I did. Most of the time spent was in loading some Ecore stuff, I don't
> remember where exactly.
Previous Topic:Trying to include templates.xml in xtext plugin
Next Topic:Problem migrating Standalone generator to 2.3
Goto Forum:
  


Current Time: Tue Oct 20 18:01:54 GMT 2020

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

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

Back to the top