Related articles |
---|
Initialise tokens in bison/flex rupp@fzi.de (Torsten Rupp) (2002-03-09) |
Re: Initialise tokens in bison/flex haberg@matematik.su.se (2002-03-11) |
Re: Initialise tokens in bison/flex {spamtrap}@qeng-ho.org (Maneki Neko) (2002-03-17) |
Re: Initialise tokens in bison/flex clint@0lsen.net (Clint Olsen) (2002-03-17) |
Re: Initialise tokens in bison/flex chrisd@reservoir.com (2002-03-17) |
From: | Maneki Neko <{spamtrap}@qeng-ho.org> |
Newsgroups: | comp.compilers |
Date: | 17 Mar 2002 22:29:08 -0500 |
Organization: | The foot bone's connected to the ankle bone, etc ... |
References: | 02-03-046 |
Keywords: | yacc |
Posted-Date: | 17 Mar 2002 22:29:08 EST |
Torsten Rupp <rupp@fzi.de> writes:
> Does anybody know how I can handle resource allocation/free resources
> in tokens for bison/flex? E. g. allocate a dynamic array when scanning
> a token and free this memory after the last usage.
> [lex, yacc, and their variants don't handle this very well, particularly
> if you try to do error recovery. My usual approach is to chain all the
> allocated storage together, then zip through after each parse and give
> it all back. -John]
Rather than tie oneself in knots to manage memory, use a garbage
collector. If you're absolutely tied down to C, use Hans Boehm's
conservative garbage collector, which often drops in with no extra
work.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.