Re: bison and valgrind
- From: "Alex Fraser" <me@xxxxxxxxxxx>
- Date: Thu, 29 Mar 2007 17:32:01 +0100
"Chris Uppal" <chris.uppal@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:xn0f4a48hc3wwkg000@xxxxxxxxxxxxxxxxxxxx
Rob Thorpe wrote:
The normal way of using bison is to use it to produce a parse tree.
You write code in the actions that builds up a tree out of nodes, you
only need one or two different types of node. In the actions all that
happens is memory allocation. Then the parser completes and passes
the parse-tree to the next compiler pass. Cleanup is only done after
the parser has completed.
Worth checking what happens if the parser detects a syntax error. [...]
Any time parsing is aborted, or (I think) error recovery is activated, some
nodes may have been allocated but never attached to the tree. References to
these nodes will be lost, and in the absence of garbage collection, that is
obviously a potential problem. Fortunately, it is not a hard problem to
solve: keep the nodes in another data structure (if all nodes are the same
type, a linked list would work). Then you can trivially clean up after
yyparse() returns.
Apart from such cases, I'd imagine that Bison-generated parsers are
naturally leak-free, assuming the the programmer (the Bison user) has
taken normal care.
I would imagine so, too.
Alex
.
- References:
- bison and valgrind
- From: Allan Adler
- Re: bison and valgrind
- From: Rob Thorpe
- Re: bison and valgrind
- From: Chris Uppal
- bison and valgrind
- Prev by Date: Re: bison and valgrind
- Next by Date: computing the moment of inertia
- Previous by thread: Re: bison and valgrind
- Next by thread: Re: bison and valgrind
- Index(es):
Relevant Pages
|