Re: bison and valgrind
- From: Chris Dollin <chris.dollin@xxxxxx>
- Date: Thu, 29 Mar 2007 10:40:25 +0100
Chris Uppal wrote:
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. I
suspect that the parser (i.e. the Bison input) should probably have
semantic cleanup actions for such errors, or temporary data allocated
before the error was detected may be leaked. (NB: I haven't tested
that, it's just a guess based on my memory of Yacc from years gone by).
At one point we had a tool that parsed a specification language and built
its parse tree; we parsed the input /twice/. Once to find out if it was
syntactically valid, the second (if the first was OK) to build the tree.
I don't think I'd do it that way now -- I'd be more likely to build the
tree with an extra layer of memory-management, if I were using C or a
moral equivalent -- but it had the advantage of being dead easy, working
pretty much straight away, and not wasting effort on building the tree if
there were syntax errors in the input. (I recall that yes, this /did/ make
a difference ...)
--
JUC 2007, submit: http://hpl.hp.com/conferences/juc2007/submission.html
Scoring, bah. If I want scoring I'll go play /Age of Steam/.
Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England
.
- Follow-Ups:
- Re: bison and valgrind
- From: Chris Uppal
- Re: bison and valgrind
- 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: Re:height of a BST by iteration - kindly review my solution
- Previous by thread: Re: bison and valgrind
- Next by thread: Re: bison and valgrind
- Index(es):
Relevant Pages
|