[antlr-interest] Re: caching AST and parsed information
daniel_raichle
daniel.raichle at etas.de
Thu Jan 22 01:05:51 PST 2004
Ok, that's right it won't help if I'm parsing the .c files which still
contain macros. I didn't think abaout that.
But the other approach sounds very interesting. How would I have to
change the lexer so that reads through the whole section and builds
the checksum before passing the tokens to the parser? What about
typedefs in this section, would I have to cache the symbol table, too?
Thank you for your help!
Daniel
--- In antlr-interest at yahoogroups.com, mzukowski at y... wrote:
> 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 e...]
> 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