grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bison error handling


From: Marco Gerards
Subject: Bison error handling
Date: Wed, 02 Nov 2005 19:25:46 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Hi,

Hopefully any of you have either a clue about bison or an idea how to
solve this problem.

What happens now is that during parsing memory is allocated.  If
everything is parsed there is a set of malloc'ed memory all pointing
to each other, etc.

The main problem is in case of a syntax error.  In that case all of
the state should be released (free all memory structures).  But I have
no idea how to do that;  yyparse just returns an error.  I need a way
to make bison return a valid structure so I can check if parsing
failed and release all of the memory.

One solution to this problem is making a big list of all memory
allocated while scanning and parsing.  When parsing fails you just
free all of this memory.  Otherwise everything is freed when the
datastructures are about to be de-allocated.

But I prefer a solution using bison stuff, otherwise I'll just use the
solution I described above.

--
Marco





reply via email to

[Prev in Thread] Current Thread [Next in Thread]