[antlr-interest] caching AST and parsed information

mzukowski at yci.com mzukowski at yci.com
Wed Jan 21 11:48:31 PST 2004


This is certainly possible.  Of course this won't help much if your .c files
actually use the macros defined in the temp.h file.  But it's easy to write
a rule that parses the #include and then builds a whole copy of the
previously parsed tree.  

Another approach would be to recognize the #file directives and do something
smart like parse and checksum the whole section contributed by  "temp.h"
When lexing the next file first just read thru and checksum the section and
if it already exists just use it out of the cache (from the parser--just
pass a special token back from the lexer which represents the whole section
and which the parser will replace with the cached tree.)

Monty

-----Original Message-----
From: daniel_raichle [mailto:daniel.raichle at etas.de] 
Sent: Tuesday, January 20, 2004 1:38 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] caching AST and parsed information

Hi,

I am using antlr to instrument multiple (small) C-files automatically
with Monty's C-grammar.

Now I have the problem that all of my C-files include a file called
"temp.h" in which some macros are defined and which includes some
other project specific .h-files and some standard .h-files (eg.
stdio.h, math.h, ...). Because of the macros and typedefs in the
project-specific .h-files I am using a preprocessor before parsing
with antlr and I am getting very large files because of all the
includes, mainly the standard .h-files. Therefore parsing those files
is very slow.

Now my thoughts are: as all of my C-files only include this single
.h-file, I could possibly parse the temp.h file first and then cache
all the informations, antlr has parsed up to this point. After that I
could parse my c-files directly without using a preprocessor before
and ignoring the #include "temp.h"-directive.

How could I do that? Is this possible with antlr?

Thanks,
Daniel Raichle


 

Yahoo! Groups Links

To visit your group on the web, go to:
 http://groups.yahoo.com/group/antlr-interest/

To unsubscribe from this group, send an email to:
 antlr-interest-unsubscribe at yahoogroups.com

Your use of Yahoo! Groups is subject to:
 http://docs.yahoo.com/info/terms/ 


 

Yahoo! Groups Links

To visit your group on the web, go to:
 http://groups.yahoo.com/group/antlr-interest/

To unsubscribe from this group, send an email to:
 antlr-interest-unsubscribe at yahoogroups.com

Your use of Yahoo! Groups is subject to:
 http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list