[antlr-interest] A newbie's question

Jim Idle jimi at temporal-wave.com
Tue Mar 17 21:11:50 PDT 2009


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


More information about the antlr-interest mailing list