| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
<html> |
| 16 |
<head> |
| 17 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 18 |
<meta http-equiv="Content-Language" content="en-us"> |
| 19 |
<title>enumerated</title> |
| 20 |
</head> |
| 21 |
<body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258"> |
| 22 |
<table align="left" border="0" cellspacing="0" cellpadding="0" valign=top> |
| 23 |
<tr> |
| 24 |
<td width=105 height=40><a href="https://projects.eclipse.org/projects/tools.titan"><img src="../images/titan_transparent.gif" border=0 width=105 height=40 align="left" alt="Titan"></a></td> |
| 25 |
</tr> |
| 26 |
</table> |
| 27 |
<table border="0" align="right" cellpadding="0" cellspacing="0"> |
| 28 |
<tr> |
| 29 |
<td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td> |
| 30 |
<td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td> |
| 31 |
<td><a href="../info/enum2int.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td> |
| 32 |
<td><a href="../info/error.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td> |
| 33 |
</tr> |
| 34 |
</table> |
| 35 |
<p><br clear="all"> |
| 36 |
</p> |
| 37 |
<hr> |
| 38 |
<h1>enumerated</h1> |
| 39 |
<hr align="left" width="75%"> |
| 40 |
<p>The keyword denotes a structured type which can take only a distinct named set of values. It cannot be parameterized. |
| 41 |
<ul> |
| 42 |
<li>Enumerated types are never compatible with other basic or structured types.</li> |
| 43 |
<li>For each enumeration without an assigned integer value, the system successively associates an integer number in the textual order of the enumerations, starting at the left-hand side, |
| 44 |
beginning with zero, by step 1 and skipping any number occupied in any of the enumerations with a manually assigned value. These values are only used by the system to allow the use of relational |
| 45 |
operators.</li> |
| 46 |
<li>Operations on enumeration are restricted to assignment, equivalence and ordering operators</li> |
| 47 |
</ul> |
| 48 |
<p>Related keywords:</p> |
| 49 |
<ul> |
| 50 |
<li><a href="type.html"><font face="Courier New" color="#003258" size="4"><b>type</b></font></a> </li> |
| 51 |
<li><a href="address.html"><font face="Courier New" color="#003258" size="4"><b>address</b></font></a></li> |
| 52 |
</ul> |
| 53 |
<hr align="left" width="50%"> |
| 54 |
<div align="center"> |
| 55 |
<center> |
| 56 |
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4"> |
| 57 |
<tr> |
| 58 |
<td width="100%"> |
| 59 |
<h3 align="center"><font face="Courier New" color="#003258" size="5"><b>type enumerated</b></font> (<i>identifier </i> |<font face="Courier New" color="#003258" size="5"> <b>address</b></font>)<font |
| 60 |
face="Courier New" color="#003258" size="5"><b>{</b></font><br> |
| 61 |
<i>enumeration_identifier</i> [<font face="Courier New" color="#003258" size="5"><b>(</b></font><i>integer</i> <font face="Courier New" color="#003258" size="5"><b>)</b></font>] [<font |
| 62 |
face="Courier New" color="#003258" size="5"><b>,</b></font> <i>enumeration_identifier</i> [<font face="Courier New" color="#003258" size="5"><b>(</b></font><i>integer</i> <font |
| 63 |
face="Courier New" color="#003258" size="5"><b>)</b></font>]] <font face="Courier New" color="#003258" size="5"><b>};</b></font></h3> |
| 64 |
</td> |
| 65 |
</tr> |
| 66 |
</table> |
| 67 |
</center> |
| 68 |
</div> |
| 69 |
<ul> |
| 70 |
<li> |
| 71 |
<p>The <a href="type.html"><font face="Courier New" color="#003258" size="4"><b>type</b></font></a> keyword introduces the type definition.</p> |
| 72 |
</li> |
| 73 |
<li> |
| 74 |
<p><i>identifier</i> is the name used to refer to the enumeration. Must begin with a letter, may contain letters, numbers and underscore characters.</p> |
| 75 |
</li> |
| 76 |
<li> |
| 77 |
<p><a href="address.html"><font face="Courier New" color="#003258" size="4"><b>address</b></font></a> is a user defined type to allow addressing specific entities inside the |
| 78 |
System Under Test.</p> |
| 79 |
</li> |
| 80 |
<li> |
| 81 |
<p><i>enumeration_identifier</i> identifies the elements of the enumeration. The identifiers must be unique within the same enumeration</p> |
| 82 |
</li> |
| 83 |
<li> |
| 84 |
<p><i>integer</i> is the value optionally assigned to the enumeration element.</p> |
| 85 |
</li> |
| 86 |
</ul> |
| 87 |
<hr align="left" width="50%"> |
| 88 |
<p>Example 1: |
| 89 |
<p><font face="Courier New">type enumerated Example {tisdag, fredag, onsdag};</font> |
| 90 |
<p>The enumeration called Example consists of three elements. The number 0 is assigned to the first one (tisdag), the number 1 to "fredag" and number 2 to the last element (onsdag).</p> |
| 91 |
<p>Example 2: |
| 92 |
<p><font face="Courier New">type enumerated Examplf {tisdag (2), fredag (-5), onsdag};</font> |
| 93 |
<p>The enumeration called Examplf consists of three elements. Note, that the same element names may be used as in example 1 because they must be unique only within the same enumeration. The |
| 94 |
optional integer value determines the value assigned to the element name. Thus, "tisdag" has the value 2, "fredag" the value -5 and onsdag has been assigned the value zero. (The |
| 95 |
first free value from 0 upwards is assigned to elements without the optional integer value.)</p> |
| 96 |
<p>Example 3: |
| 97 |
<p><font face="Courier New">type enumerated address {first_entity, second_entity};</font> |
| 98 |
<p>There are two entities in the system under test (SUT). We can refer to the first one using the element name "first_entity" whereas the other entity is addressed by the element name |
| 99 |
"second_entity".</p> |
| 100 |
<hr align="left" width="25%"> |
| 101 |
<p><a HREF="../info/BNF.html#enumdef">BNF definition</a> of <font face="Courier New"> enumerated</font></p> |
| 102 |
</body> |
| 103 |
</html> |