1
Below the way Bisonc++ may use a polymorphic semantic value is described. The
2
described method is a direct result of a suggestion initially brought forward
3
by Dallas A. Clement in September 2007.
1
Bisonc++ may use polymorphic semantic values. How this is realized is covered
2
in this section. The described method is a direct result of a suggestion
3
initially brought forward by Dallas A. Clement in September 2007.
5
One may wonder why a tt(union) is still used by Bisonc++ as bf(C++) offers
5
One may wonder why tt(union)s are still used by Bisonc++, as bf(C++) offers
6
6
inherently superior constructs to combine multiple types into one type. The
7
bf(C++) way to combine types into one type is by defining a polymorphic base
8
class and a series of derived classes implementing the alternative data
9
types. Bisonc++ supports the tt(union) approach (and the unrestricted unions
10
with C++0x) for various (e.g., backward compatibility)
11
reasons. bi(Bison) and bi(bison++) both support the tt(%union) directive.
7
support by C++11 for unrestricted unions may result in tt(union)s being
8
re-evaluated, but bf(C++) traditionally offers a good alternative for the use
9
of tt(union)s: a polymorphic base class and a series of derived classes
10
implementing the alternative data types.
13
An alternative to using a tt(union) is using a polymorphic base class. Such a
14
class is developed below (the class tt(Base)). As it is a polymorphic
15
base class it has the following characteristics:
12
Below, a polymorphic base class (the class tt(Base)) is developed. As it is a
13
polymorphic base class it has the following characteristics:
17
15
it() Its destructor is virtual (and has a default implementation);
18
16
it() Objects of the derived classes may be obtained from a