From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: Ada type (yacc)YYSTYPE is ?
Date: 1999/01/18
Date: 1999-01-18T00:00:00+00:00 [thread overview]
Message-ID: <F5rKKy.93t.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 77qu4d$jt8@lotho.delphi.com
tmoran@bix.com wrote:
: YACC is designed with a C 'union' type as a typeless, semantic
: token information holder variable. What's a good way in Ada to
: handle that, hopefully with some help from Ada type checking?
: One obvious one is a variant record. Any better ideas?
A variant record (with a default for the discriminant) is certainly the
most obvious choice.
For Ada 95, an access type to a classwide type is another possible solution,
using type extension to accommodate the various types to be stored on
the parse stack. However, the downside of a access-to-classwide is
that you have to worry about storage reclamation, whereas the variant
record can be used directly as the component on the array used to
implement the parse stack.
A simple reclamation scheme for the access-to-classwide solution is
to have each type extension maintain its own free list, and a dispatching
operation to add an object back onto its free list when no longer
needed (you will probably want to add a "next" link into the root type
of the class for linking onto the free list).
On the other hand, if the parse actions are building up an abstract
syntax tree anyway, then you would be allocating the AST nodes
on the heap, and these might as well be your parse stack items.
--
-Tucker Taft stt@averstar.com http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.) Burlington, MA USA
next prev parent reply other threads:[~1999-01-18 0:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-01-16 0:00 Ada type (yacc)YYSTYPE is ? tmoran
1999-01-17 0:00 ` Steven Hovater
1999-01-18 0:00 ` dennison
1999-01-18 0:00 ` Tom Moran
1999-01-19 0:00 ` dennison
1999-01-18 0:00 ` Tucker Taft [this message]
1999-01-18 0:00 ` Tom Moran
1999-01-19 0:00 ` Andrew W. Reynolds
1999-01-19 0:00 ` Tom Moran
1999-01-19 0:00 ` rdt
1999-01-19 0:00 ` Martin C. Carlisle
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox