IBM
Contents Index Previous Next



Input and Output of Data Types


The syntax of literals of the predefined data types is in most cases obvious and follows the SDL definition of literals. There are, however, some extensions that are described below. As an option, it is also possible to use the ASN.1 syntax for values. On input the monitor system can manage both value notations, while there are commands in the monitor to select the type of output to be produced (SDL-Value-Notation and ASN1-Value-Notation).

Integer, Natural Values

The format of integers conforms exactly with the SDL and the ASN.1 standard, that is, an integer consists of a sequence of digits, possibly preceded by a `+' or `-'. However, with the command Define-Integer-Output-Mode it is possible to define the base of integers on output (decimal, hexadecimal, octal), which also affects how they may be entered. Hexadecimal values are preceded with "0x", and octal values are preceded with `0' (a zero).

Boolean Values

Boolean values are entered (and printed) as true and false, using upper or lower case letters. Abbreviation is allowed on input. In ASN.1 mode the value is printed in capital letters (TRUE, FALSE).

Real Values

The SDL literal syntax of real values has been extended to include the E-notation for exponents, in the same way as in many programming languages.

Example 327 : Real Values in SDL Syntax

The real number 1.4527 * 1024 can be written 1.4527E24

The real number 4.46 * 10-4 can be written 4.46E-4

The syntax for real values in ASN.1 is easiest described by an example:

Example 328 : Real Values in ASN.1 Syntax

{mantissa 23456, base 10, exponent -3}

This is the value 23.456.

Time, Duration Values

The format for Time and Duration values follows the SDL standards, i.e. real values without E-notation, with one extension. On input time values can either be absolute or relative to NOW. If the time value is given without a sign an absolute time value is assumed, while if a plus or minus sign precedes the value, a value relative to NOW is assumed.

Example 329 : Time Values in SDL Syntax

123.5 is interpreted as 123.5

+5.5 is interpreted as NOW + 5.5

-8.0 is interpreted as NOW - 8.0

Character Values

Character values are entered and printed according to the SDL standard, including the literals for the non-printable characters.

Example 330 : Character Values in SDL Syntax

'a', '3', '''', ' ', NUL, DEL

On input, the quotes may be omitted for all characters except ` ' (space) and `[`. A `should be entered as `'''.

Charstring Values

Charstring values can be entered and printed according to the SDL standard, that is, a single quote ( ' ) followed by a number of characters followed by a single quote. Any quote (') within a charstring has to be given twice. On output a non-printable character within a charstring is printed as a single quote followed by the character literal followed by a single quote.

The ASN.1 syntax for Charstring is similar to the SDL syntax. The delimiter character ` (single quote) is however replaced by the character " (double quote).

Example 331 : Charstring Values in SDL Syntax

''

An empty string

'abc'

A string of three characters

'a'NUL'c'

The second character is NUL

PId Values

Apart from the value null, which is a valid PId value, a PId value consists of two parts, the name of the process type and an instance number, which is an integer greater than 0.

The first process instance of a process type that is created will have instance number 1, the second that is created will have instance number 2, and so on. The syntax is Name:No, where Name is the process name and No is the instance number.

On input the process name and the instance number may, as an alternative, be separated by one or more spaces, if the command parameter is a PId value. In the same circumstances the instance number is not necessary (and will not be prompted for) if there is only one process instance of the process type. If, however, the command parameter is a unit that might be a process type or a process instance, only a colon (`:') is allowed between the process name and the instance number and the colon must follow directly after the process type name. Examples of such situations are the unit parameter in Set-Trace and Signal-Log.

On output a PId value may be followed by a plus sign (`+'), which indicates that the process instance is dead; that is, has executed a stop action. The plus sign is chosen as it is reminiscent of the `' character.

Bit

The Bit sort contains two values, 0 and 1. This syntax is used for input and output.

Bit_String

For Bit_String values the following syntax is used:

'0110'B

The characters between the two single quotes must be 0 or 1. On input the syntax for Octet_String, see below, can also be used.

Octet

The syntax used for an octet value is two HEX digits. Examples:

00   46   F2   a1   CC

The characters 0-9, a-f, and A-F are allowed.

Octet_String

The syntax for Octet_String is the following

'3A6F'H

Each pair of two HEX values in the string is treated as an Octet value. If there is an odd number of characters an extra 0 is inserted last in the string.

Object_Identifier

The sort Object_Identifier is in SDL treated as a String(Natural). This means that the syntax, in case SDL value notation is used, will be:

(. 2, 3, 11 .)

On input the items in the list should be separated by a comma and/or spaces - tabs. If ASN.1 value notation has been selected, the syntax will be:

{ 2 3 11 }

On input the items in the list should be separated by a comma and/or spaces - tabs.

Enumerated Values

Types that in SDL are defined as an enumeration of possible values can be entered and printed using the literals of the SDL data type definition. On input, the literals can be abbreviated as long as they are unique.

STRUCT Values

A struct value is entered and printed as the two characters "(." followed by a list of components followed by the two characters ".)". The components should, on input, be separated by a comma and/or a number of spaces (or carriage returns or tabs). Example:

(. 23, true, 'a' .)

If ASN.1 syntax is used, the component names will also be present. Example:

{ Comp1 2, Comp2 TRUE, Comp3 'a' }

On input the components using ASN.1 syntax may come in any order. Components not given any value will have the value 0, whatever that means for the data type.

On input the components using ASN.1 syntax may come in any order.

Optional components that are not present, will not be printed. In SDL syntax that means an empty position between two commas.

#UNION Values

A #UNION value uses, in SDL value notation, the same syntax as a struct value. However, only the tag value and the active component is printed. In ASN.1 value notation, #UNION values use the Choice value syntax described below.

Choice Values

The syntax for a choice value is ComponentName:ComponentValue. If, for example, a choice contains a component C1 of type integer, then

C1:11

is a valid choice value.

#UNIONC Values

The syntax for a #UNIONC value is ! ComponentName ComponentValue or -> ComponentName ComponentValue. If, for example, a #UNIONC contains a component C1 of type integer, then

! C1 11

is a valid #UNIONC value. However, this syntax will not be used when printing, since the value contains no tag and hence it is not possible to know which component to use.

Array Values

An array value is entered and printed as "(:" followed by a list of components followed by a ":)". The components should, on input, be separated by a comma and/or a number of spaces (or carriage returns or tabs). Note that there should also be a space between the last component and the terminating ":)". In ASN.1 syntax, `{' and `}' are used as delimiters.

There are two syntaxes for array components depending on the implementation that the SDL to C Compiler has selected for the array implementation. This selection is described in Array. These easiest way to determine which syntax to use on input is to look at a variable of the array sort.

For simple arrays the second syntax is also accepted. If the first syntax is used for simple arrays it is not mandatory to enter all values for the array components; by entering ":)" or "}" the rest of the components are set to a "null" value (i.e. the computer's memory for the value is set to 0).

String Values

A string value starts with "(." and ends with ".)". The components of the string is then enumerated, separated with commas. Example:

(. 1, 3, 6, 37 .)

On input the commas can be replaced by one or more spaces (or carriage returns or tabs). In ASN.1 syntax, `{' and `}' are used as delimiters instead of "(." and ".)".

Powerset Values

A powerset value starts with a `[' and ends with a `]'. The elements in the powerset is then enumerated, separated with commas. Example:

[ 1, 3, 6, 37 ]

On input the commas can be replaced by one or more spaces (or carriage returns or tabs).

Bag Values

A bag value starts with a `{' and ends with a `}'. The elements in the bag is then enumerated, separated with commas. Example:

{ 1, 3, 6, 37 }

On input the commas can be replaced by one or more spaces (or carriage returns or tabs). If the same value occurs more than once, then this value is in SDL syntax not enumerated several times. Instead, the number of occurrences is indicated after the value. Example

{ 1, 3:4, 6:2, 37 }

This is identical to

{ 1, 3, 3, 3, 3, 6, 6, 37 }

In ASN.1 syntax, each member is given explicitly according to the last example. On input items are separated by comma and/or one or more spaces. It is also allowed to mention the same value several times, with or without a number of items each time.

Ref Values

There are two possible syntaxes for Ref values. Either the pointer address as a HEX value, or the value of the data area referenced by the pointer. The value Null is printed as Null in both syntaxes. In the monitor system two commands are available to determine the syntax to be used (REF-Address-Notation and REF-Value-Notation). On input both syntaxes are allowed independently of what syntax that has been selected.

Example of the address notation:

HEX(23A20020)

In the value notation the keyword new() is used to indicate a reference to a value. If, for example, the following data types are available in SDL

newtype Str struct
  data integer;
  next StrRef;
endnewtype;

newtype StrRef Ref(Str)
endnewtype;

then a value of the StrRef type can look like the examples below:

Null
new( (. 1, Null .) )
new( (. 1, new( (. 2, Null .) ) .) )

The last example is a linked list with two elements. To handle recursive data structures, e.g. graphs, a special syntax is used: old n, where n is an integer. Example:

new( (. 1, new( (. 2, old 1 .) ) .) )

The notation old 1 in the example above means a reference to the same data area as the first new() notation refers to. So here we have two structs with next pointers referring to the other struct value. Old n would refer to the n:th new() seen from the left of the expression.

The same applies for Own and ORef values.


http://www.ibm.com/rational
Contents Index Previous Next