Abstract Syntax Notation
Some Examples
Used as integer is used in any programming language. Optionally, a name may
be associated with some particular integer values.
For example
ColorType ::= INTEGER
{
red (0)
white (1)
blue (2)
}
This defines a type called ColorType. Items of type ColorType can take integer
values. The names red, white, and blue are recognized as meaning 0, 1, and 2
respectively.
An ordered sequence of bit values, written as either a binary or hexadecimal
string. A name may be associated with the individual bit positions. Think of
it as an organized collection of boolean values.
For example:
StateLocations ::= BITSTRING
{alaska (0)
alabama (1)
colorado (2)
connecticut (3)
delaware (4)
...
}
Bit string lengths must be divisible by 4 to be written as a string of
hexadecimal characters, so this states example would have to be padded with
two extra positions. A company with branches in colorado and connecticut only
would be described by a variable of type StateLocations having value
'3000000000000'H or '001100000......"B
An ordered sequence of zero or more octets. Similar to bitstring, but always
in blocks of eight bits. Individual bits are not named. Values are represented
either as binary or hexadecimal strings.
For example:
badCharacter ::= OCTETSTRING
A special type that indicates an information object that is a node
on an object identifier tree managed by international standards
organizations. The value of an item of type OBJECTIDENTIFIER is a
string of numbers describing branches in this naming tree.
Enumerated types allow values that are specific integers. This slight
modification of the INTEGER example illustrates:
ColorType ::= ENUMERATED
{
red (0)
white (1)
blue (2)
}
Unlike in the INTEGER example, variables declared to be of this
ColorType can only take the values 0, 1, 2. The values red, white,
and blue are equivalent to the numeric values.
Several different Character String types are available, including
- NumericString
- PrintableString
- IA5String (The 8-bit ASCII code)
The SEQUENCE type is an ordered list of zero of more component types.
This is the type called "record" in some languages, and called
"struct" in c.
For example:
AirlineFlight ::= SEQUENCE
{
airline IA5String,
flight NumericString,
seats SEQUENCE
{
maximum INTEGER,
occupied INTEGER,
vacant INTEGER,
},
airport SEQUENCE
{
origin IA5String,
stop1 [0] IA5String OPTIONAL,
stop2 [1] IA5String OPTIONAL,
destination IA5String
},
crewsize ENUMEATED
{
six (6),
eight (8),
ten (10)
},
cancel BOOLEAN DEFAULT FALSE
}
[ Villanova Homepage
| CSC Homepage
| CSC Faculty
| CSC 4900 page
]
Lillian N. (Boots) Cassel
Department of Computing Sciences
Villanova University
Villanova, PA 19085-1699
+1 610 519 7341
cassel@vill.edu