Antlr and jet2 integration [message #16028] |
Tue, 15 May 2007 21:18 |
Eclipse User |
|
|
|
Originally posted by: ymo.noemail.com
hi.
Is it possible to make jet2 parse an antlr tree/AST . I would like to be
able to use the antlr java grammar to parse/visit the AST. This way i can
genrate code based on the input model which is java code.
1) Is there a similar easier way of accomplishing the same thing ? i don't
want to parse annotations. but the full AST.
2) if i want to go the antlr way what do i have to do.
btw jet2 is by far the most flexible tool i have seen so far. its just sad
that it has so much dependence on eclipse.
Thanks for your great work and help.
|
|
|
Re: Antlr and jet2 integration [message #16111 is a reply to message #16028] |
Thu, 17 May 2007 13:11 |
Paul Elder Messages: 849 Registered: July 2009 |
Senior Member |
|
|
Hi:
In theory, it is possible for JET to parse an ANTLR AST. In particular,
JET's XPath engine can be extended by implementing 'inspectors', which maps
a particular meta-model onto the XPath 1.0 data model.
1) Inspectors may be registered via an extension point
(org.eclipse.jet.modelInspectors), or API
(org.eclipse.jet.xpath.inspector.InspectorManager.registor)
2) Inspectors are for specific types (and subtypes).
3) Inspectors that handle implement INodeInspector, or, if they map to XPath
Element, IElementInspector.
I'm not familiar with antlr's ASTs, but a quick look at the Java doc
suggests that starting with an IElementInspector for antlr.AST would be a
good first step.
A word of warning. I view the Inspector APIs as immature. I have only
implemented a handful of these (XML DOM, EMF, Eclipse Resources). I would
certainly be interested to giving you support and encouragement.
Another alternative would be to serialize the AST to XML (I notice
antlr.BaseAST has some XMLSerialize methods), and then invoke JET on that
via JET2Platform.runTransformOnString().
As for making JET more independent of Eclipse, I think I'll start a separate
thread... I'd appreciate your comments.
Paul
"ymo" <ymo@noemail.com> wrote in message
news:26e59486d3a489a5fce0023de3fc5945$1@www.eclipse.org...
> hi.
>
> Is it possible to make jet2 parse an antlr tree/AST . I would like to be
> able to use the antlr java grammar to parse/visit the AST. This way i can
> genrate code based on the input model which is java code.
> 1) Is there a similar easier way of accomplishing the same thing ? i don't
> want to parse annotations. but the full AST.
>
> 2) if i want to go the antlr way what do i have to do.
>
> btw jet2 is by far the most flexible tool i have seen so far. its just sad
> that it has so much dependence on eclipse.
>
> Thanks for your great work and help.
>
|
|
|
Powered by
FUDForum. Page generated in 0.03132 seconds