[antlr-interest] A newbie's question

Aki Niimura akineko at gmail.com
Tue Mar 17 22:48:39 PDT 2009


Hello Jim,

Thank you for your reply and thank you for letting me know that somebody has
done the enhancement I would like to do.
I would like to re-invent a wheel if I don't need to do.
I will try to contact the author to see if he can share the code.

I agree that not having an AST is going to be pain.
I needed to resort to quite messy stuff when I used Flex/Bison (two-step
approach) to write a proprietary compiler.

Thank you!
Aki-


On Tue, Mar 17, 2009 at 9:11 PM, Jim Idle <jimi at temporal-wave.com> wrote:

> Aki Niimura wrote:
> > Hello Michael,
> >
> > Thank you for your prompt response.
> > I'm trying to write a C Interpreter (with special hooks).
> > I originally tried to use existing open-source C Interpreter, such as
> > CINT.
> > But I decided to re-invent a wheel because I need to insert special
> hooks.
> >
> > I would like to use a grammar file, C.g, that is available on the
> > ANTLR web site.
> > The updated version of C.g, which is verified with Python target is
> > also available from FishEye.
> > I created (1) and (2) using the C.g.
> >
> > I prefer three step approach as it separates parser grammar and
> > application specific actions.
> >
> > The C.g grammar is fairly complex and written by somebody else.
> > So, creating (3) Tree grammar is not an easy task for me.
> There was a gentleman posting here who had improved that C.g grammar to
> include all the GNU C extensions (bar just a few) and generated an AST,
> with a tree parser. I don't know if he has it ready for publication yet,
> but perhaps this might prompt a response.
>
> It was:
>
> AUTHOR: Jan Obdrzalek, 2007-2009
>        Jiri Slaby (modifications), 2008-2009
>        Typedef handling taken from C.g distributed with ANTLR v3,  (c)
> Terence Parr and Jim Idle
>
> And I am hoping he received my updates for his parser.
>
> >
> > In such sense, I agree with your suggestion inserting my application
> > specific stuff into the C.g and not to create (3) step.
> > The code would look very messy but it is probably easier for me to
> > figure out where to insert.
> But if you want to do loops and things, then not having an AST is going
> to be a pain.
>
> Shaping the tree is much more time consuming than writing the tree
> parser that walks the resulting AST.
>
> Jim
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090317/4b38dc34/attachment.html 


More information about the antlr-interest mailing list