enum bool { false, true };This means you can use `0' and `1' instead of `true' or respectfully `false' too.
'enum' <IDENT> '{' ( <IDENT> ',' )* <IDENT> '};'An example of an enum type is the pseudo definition of the `bool' type. Enumeration Types can be used like Range Types. This means if you have a variable e of type E which is the following Enumeration Type
enum E { one, two, three, four, five };then the predicates e=four and e=3 are equivalent. E can be seen as a Range Type R
enum R { 0..4 };This means the first value (actually `first' in our example) can also be accessed as the number 0 and the last value of an Enumeration Type E can be accessed as
For details about the encoding of Enumeration Types see
the section about Range Types.
'enum' <IDENT> '{' <NUMBER> '..' <NUMBER> '};'The two numbers represent the borders of the closed interval. That means that the first number () should be less than the second () and greater or equal to zero. The elements of the type are the numbers .
When the boolean representation is used then a range type
of size will use
bits to encode a variable of that type.
A Number is represented as the standard
boolean encoding of .
The order of the bits is that the most significant bit comes first
(this is interesting if the boolean representation has to
order variables f.e. if it uses BDD libraries).
<IDENT> '[' <NUMBER> ']'Because we have no `typedef' Arrays can only be defined at three places:
a[0] a[1] a[2]As a future extension (Tue May 7 09:30:22 GMT 1996) we plan to allow the usage of an arbitrary Enumeration or Range Type in the definition of an array. This will enable the user to use variable indices for arrays.
'class' <IDENT> '{' <COMPOUNDS> '};' <COMPOUNDS> ::= ( <COMPOUND> ';' )* <COMPOUND> <COMPOUND> ::= <IDENT> ( <CMPPAR> ',' )* <CMPPAR> <CMPPAR> ::= <IDENT> ( '[' <NUMBER> ']' )?If T is an arbitrary already defined type then the definition
class A { T a; bool b[4], c; T d; };ist equivalent to the definition
class A { T a; bool b[4]; bool c; T d; };and defines a type with four components accessed by the symbols a, b, c and d. If x is defined as A x then the following terms are all valid
x.a x.b x.b[3] x.c x.d
We use an enum type to represent the valid values of the control part of the sender state:
enum ControlStateOfSender { send, wait_for_ack };The sender has to store the data, in case it has to be retransmitted:
enum Data { 0..3 }; // two bit dataThe alternating bit is of type `bool' so that the type for the state of the sender looks like:
class StateOfSender { bool alternating_bit; Data data; ControlStateOfSender state; };We could have defined Data also as
class Data { bool bits[2]; };and with the declaration StateOfSender s the following terms are valid
s.state=send s.data.bits[0]Also we could define
class TwoSenderState { StateOfSender states[2]; };and use
t.states[1].alternating_bitto access the alternating bit of the state of the second sender with the declaration TwoSenderState t.