IBM
Contents Index Previous Next



Translation of ASN.1 to SDL


This section describes the detailed translation rules from ASN.1 to SDL that are implemented in the ASN.1 Utilities. The translation rules all conform to Z.105, except for the cases described in Restrictions to Z.105.

General

Note:

Since named numbers, named bits, and integer values are all mapped to integer synonyms, the same name should not be used more than once, because this will lead to name conflicts in SDL.

Keywords substitution

ASN.1 generators can be configured to be sensitive to a certain number of identifiers. There is a special text file named `asn1util_kwd.txt' that contains a list of identifiers and a list of their substitution during mapping. By default this file is used to configure target languages keywords substitution. It can be edited to get another functionality or another set of keywords to be replaced.

`asn1util_kwd.txt' should contain pairs of identifiers where the first one is the identifier from original ASN.1 specification that will be replaced by the second identifier during generation. `asn1util_kwd.txt' should conform to the following syntax:

Example 33 Configuration file syntax

<identifier1>   <identifier1 substitution>
<identifier2>   <identifier2 substitution>
	      ...
<identifierN>   <identifierN substitution>

ASN.1 Utility reads the first configuration file it finds. It searches for the `asn1util_kwd.txt' file first in the current folder, then in the home folder and finally in the installation. If a configuration file named `asn1util_kwd.txt' is put in the home folder or in the current working folder, it will override the default configuration file from the installation. The configuration file to be used can also be specified in the Analyze dialog or from the command line with the `-K' option (see Command-Line Interface).

Figure 164 : Keywords substitution

`asn1util_kwd.txt' is always present in the installation and it is configured to replace keywords from SDL, TTCN, C and C++ languages: the ASN.1 identifier name, that is a keyword in SDL, TTCN or C++, is replaced by name_SDL_KEYWORD, name_TTCN_KEYWORD or name_CPP_KEYWORD to avoid syntax errors in the target languages (see Appendix A: List of recognized keywords). If an original ASN.1 identifier has been modified, a warning message is reported. See ERROR 2077 ASN.1 identifier #1 is a keyword, it will be replaced by #2).

Note: Keywords recognition

ASN.1 in case-sensitive language and target language keywords are also recognized in case-sensitive mode. If generated SDL is analyzed in case-insensitive mode, there could still be keyword problems left. For example, ASN.1 contains the type named Start and it will not be recognized to be an SDL keyword, because the keyword start will be compared, but in case-insensitive mode Start is still a keyword in SDL, which will result in syntax errors.

Example 34 Keywords default substitution

For these ASN.1 definitions:


CASE ::= ENUMERATED { upper, lower }

T ::= SEQUENCE {
	 int INTEGER,
	 explicit BOOLEAN,
	 case     CASE,
	 signal   INTEGER
}

value1 T ::= {
	 int 5,
	 explicit TRUE,
	 case lower,
	 signal 27 }

With default keywords substitution file the following SDL is generated:

newtype CASE_TTCN_KEYWORD
  literals upper,lower
  operators
    ordering;
endnewtype;

newtype T struct
  int_CPP_KEYWORD  Integer;
  explicit_CPP_KEYWORD  Boolean;
  case_CPP_KEYWORD  CASE_TTCN_KEYWORD;
  signal_SDL_KEYWORD  Integer;
endnewtype;

synonym value1 T = (. 5, true, lower, 27 .);

A configuration file allows the user to control the set of keywords to be replaced. Removing lines with TTCN keywords, for example, will switch off TTCN keywords sensitivity. Providing an empty configuration file will result in switching off keywords substitution completely.

Module

Note:

On UNIX, the -b option disables generation of package/endpackage, interface and use clauses. Files that have been generated this way can be included in SDL with the #INCLUDE directive, see Including PR Files.

Example 35

MyModule DEFINITIONS ::= BEGIN 

EXPORTS A, b, C;
IMPORTS X, Y, z FROM SomeModule { iso 3 0 8 }
... 
END

is mapped to

package MyModule;
interface newtype A, synonym b, newtype C;
use SomeModule / newtype X, newtype Y, synonym z;
...
endpackage;

Joining modules

Mapping for ASN.1 original module structure can be changed by applying joining module functionality. Several ASN.1 modules can be generated into one SDL package, if ASN.1 modules are arranged into groups in the Organizer. Joining modules can also be controlled from the command line (see Command-Line Interface).

Figure 165 : Joining modules

Joining means throwing away all import/export clauses and module headers and generating all module bodies into one big package with the name specified in the Organizer or command line interface.

When joining definitions from several ASN.1 modules into one SDL package, names in the resulting SDL package change according to the following rules:

Example 36

M1
DEFINITIONS ::=
BEGIN

IMPORTS S2 FROM M2;

T ::= SET OF SEQUENCE { a S2 }
S1 ::= IA5String

END

M2
DEFINITIONS ::=
BEGIN

T ::= SEQUENCE OF SEQUENCE OF M1.S1
S2 ::= BOOLEAN

END

without joining applied ASN.1 modules M1 and M2 are mapped to

use M2/
  newtype S2;
package M1; /*#ASN.1 'M1'*/

newtype T
   Bag(T_INLINE_0)
endnewtype;

newtype T_INLINE_0 /*#SYNT*/ struct
  a  S2;
endnewtype;

syntype S1 = IA5String endsyntype;

endpackage M1;

package M2; /*#ASN.1 'M2'*/

newtype T
   String (T_INLINE_0, emptystring)
endnewtype;

newtype T_INLINE_0 /*#SYNT*/
   String (<<package M1>>S1, emptystring)
endnewtype;

syntype S2 = Boolean endsyntype;

endpackage M2;

with joining to package Join-Package applied ASN.1 modules are mapped to

package Join_Package; /*#ASN.1 'Join_Package'*/

newtype M1_T
  Bag(M1_T_INLINE_0)
endnewtype;
newtype M1_T_INLINE_0 /*#SYNT*/ struct
  a  S2;
endnewtype;
syntype S1 = IA5String endsyntype;

newtype M2_T
   String (M2_T_INLINE_0, emptystring)
endnewtype;
newtype M2_T_INLINE_0 /*#SYNT*/
   String (<<package Join_Package>>S1, emptystring)
endnewtype;
syntype S2 = Boolean endsyntype;

endpackage Join_Package;

General Type and Value Assignment

A type assignment is mapped to a newtype or a syntype, depending on the type on the right-hand side of the `::='. Tags are ignored. An ASN.1 value assignment is mapped to a synonym.

Example 37

T1 ::= INTEGER
T2 ::= [APPLICATION 28] T1
a BOOLEAN ::= TRUE

is mapped to

syntype T1 = Integer endsyntype;
syntype T2 = T1 endsyntype;
synonym a Boolean = True;

Inline types naming

The ASN.1 language can use type definitions inside composite types, which are called inline types. Inline types are not allowed in SDL. In SDL, only named types can be used in a composite type. Implicit names are assigned to ASN.1 inline types and they are referenced by this name in SDL.

Implicit names for generated SDL have the following syntax: <parent_definition_name>_INLINE_<counter>, where parent_definition_name is either the name of the parent type or the name of the parent value, depending on if inline type exists in type or value assignment construct in ASN.1.

Example 38

T1 ::= SEQUENCE {
        a SET OF INTEGER,
        b CHOICE { x BIT STRING,
                   y OCTET STRING },
        c ENUMERATED { sat, sun } }

For type T the following inline types will be 
generated to SDL

newtype T1 struct
  a  T1_INLINE_0;
  b  T1_INLINE_1;
  c  T1_INLINE_2;
endnewtype;

newtype T1_INLINE_0 /*#SYNT*/
   Bag(Integer)
endnewtype;

newtype T1_INLINE_1 /*#SYNT*/ choice
  x  Bit_string;
  y  Octet_string;
endnewtype;

newtype T1_INLINE_2 /*#SYNT*/
  literals sat,sun
  operators
    first: T1_INLINE_2 -> T1_INLINE_2;
    last:  T1_INLINE_2 -> T1_INLINE_2;
    succ:  T1_INLINE_2 -> T1_INLINE_2;
    pred:  T1_INLINE_2 -> T1_INLINE_2;
    num:   T1_INLINE_2 -> Integer;
    ordering;

  <operator definitions>

endnewtype;

Example 39


T2 SEQUENCE OF INTEGER ::= { {1,1} | {2,2} }

For T2 the following inline types will be generated 
to SDL

newtype T2 /*#SYNT*/
   String (Integer, emptystring)
   constants ((. 1, 1 .)), ((. 2, 2 .))
endnewtype;

Example 40


val BIT STRING ( SIZE(3) ) ::= `101'B

synonym val val_INLINE_0 = bitstr('101');

syntype val_INLINE_0 = Bit_string constants size (3) 
endsyntype;

Note:

SDL inline names can change if you change within the parent type or value in the ASN.1 specification, the counter can differ. If these names are used within an SDL system, then you must update the SDL system.

Boolean, NULL, and Real

BOOLEAN, NULL and REAL are mapped to the corresponding SDL types. Value notations for these types are mapped as follows
ASN.1 type ASN.1 value Corresponding SDL value
ANY



not supported (conform Z.105)

BOOLEAN

TRUE

FALSE

True

False

NULL

NULL

NULL

REAL

0

PLUS-INFINITY

MINUS-INFINITY

{ mantissa 31416, 
base 10, exponent 
-4 }

0.0

PLUS_INFINITY

MINUS_INFINITY

3.1416

If a REAL value has an exponent bigger than 1000 and if the mantissa is not zero, then it is mapped to PLUS_INFINITY or MINUS_INFINITY. If a REAL value has an exponent less than -1000, then it is mapped to 0.

Bit String

BIT STRING is mapped to the Z.105-specific type Bit_string. Named bits are mapped to integer synonyms. Values for bit strings are mapped to hexstr/bitstr expressions.

Example 41

B ::= BIT STRING { bit0(0), bit23(23) }

b1 BIT STRING ::= `011 1110'B
b2 BIT STRING ::= `3AFC'H

is mapped to

syntype B = Bit_string endsyntype; 
synonym bit0 Integer = 0; 
synonym bit23 Integer = 23;

synonym b1 Bit_string = bitstr(`0110 1110');
synonym b2 Bit_string = hexstr(`3AFC');

Note:

Bit_string, as opposed to most other string types in SDL, has indices starting with 0!

Type Bit is a Z.105 specific type with literals 0 and 1, and with boolean operators.

Available operators:

bitstr    : Charstring             -> Bit_string;
     /* converts a Charstring consisting of `0' and
        `1'-s to a Bit_string */
hexstr    : Charstring             -> bit_string;
     /* converts a Charstring consisting of
        hexadecimal characters to a bit_string */
"not"     : Bit_string             -> Bit_string;
"and"     : Bit_string, Bit_string -> Bit_string;
"or"      : Bit_string, Bit_string -> Bit_string;
"xor"     : Bit_string, Bit_string -> Bit_string;
"=>"      : Bit_string, Bit_string -> Bit_string;
     /* bitwise logical operators */
mkstring  : Bit                    -> Bit_string;
length    : Bit_string             -> Integer;
first     : Bit_string             -> Bit;
last      : Bit_string             -> Bit;
"//"      : Bit_string, Bit_string -> Bit_string;
extract   : Bit_string, Integer    -> Bit;
modify!   : Bit_string, Integer, Bit-> Bit_string;
substring : Bit_string, Integer, Integer ->
                                      Bit_string;
     /* normal String operators, except that index
        starts with 0; 
        see also Sequence of Types */

Character Strings

PrintableString, NumericString, VisibleString, and IA5String (i.e. all ASN.1 character string types with character sets that are a subset of ASCII) are mapped to syntypes of SDL Charstring. Values for these strings are mapped to corresponding Charstring synonyms in SDL.

The same operators as for Charstring are available for these types, and values of these types can be assigned freely to each other without need for conversion operators.

For example, in SDL an IA5String value can be assigned to a NumericString variable (given that the IA5String only contains numeric characters).

Choice Types

A CHOICE type is mapped to the choice-construct that is described in more detail in Choice.

Example 42

C ::= CHOICE {
        a INTEGER, 
        b BOOLEAN} 

c C ::= a:7

is mapped to

newtype C choice
   a Integer; 
   b Boolean;
endnewtype;

synonym c C = a:7

The operators that are available for a CHOICE type are (assuming that C is defined as in Example 42 above):

aextract!       : C -> Integer;
     /* e.g. c!a returns 7 */
bextract!       : C -> Boolean;
     /* but c!b gives dynamic error! */
amake!          : Integer -> C;
bmake! : Boolean -> C;
     /* build choice value, e.g. in SDL
        it is possible to write b:True */
amodify!        : C, Integer -> C;
     /* e.g. var!a := -5 */
bmodify!        : C, Boolean -> C;
presentextract! : C -> xxx;
     /* returns the selected field.
        xxx is an anonymous type with values a and 
b.
        E.g. c!present gives a */

Enumerated Types

An ENUMERATED type is mapped to a newtype with a set of literals plus some operators. By default only ordering operators are generated, use command line option -e to get the rest. The list of literals that is generated is reordered in accordance with the associated integer values.

Example 43

N ::= ENUMERATED { yellow(5), red(0), blue(6) }

is mapped to (only signature of operators shown)

newtype N 
  literals red, yellow, blue 
  /* note that the literals have been reordered! */
operators
   ordering;
   first: N -> N;
   last: N -> N;
   succ: N -> N;
   pred: N -> N;
   num: N -> Integer;
 endnewtype, 

The operators that are available for an ENUMERATED type are (assuming that N is defined as in Example 43 above):

num : N -> Integer;
     /* num(yellow)=5, num(red)=0, num(blue)=6 */
"<" : N, N -> Boolean;
"<=": N, N -> Boolean;
">" : N, N -> Boolean;
">=": N, N -> Boolean;
    /* comparison based on num, i.e. red < yellow */
pred: N -> N;
succ: N -> N;
     /* predecessor/successor based on num, i.e.
        succ(red)=yellow, succ(yellow)=blue, 
        pred(red) gives a dynamic error */
first: N -> N;
last : N -> N;
     /* first/last element based on num, i.e.
        first(red)=red, last(red)=blue */

Integer

INTEGER is mapped to the SDL Integer type, and ASN.1 integer values are mapped to corresponding SDL values.

Named numbers are mapped to synonyms.

Example 44

A ::= INTEGER { a(5), b(7) }

is mapped to

syntype A = Integer endsyntype; 
synonym a Integer = 5; 
synonym b Integer = 7;

Object Identifier

OBJECT IDENTIFIER is mapped to the Z.105-specific type Object_Identifier. The normal String operators are available for Object_Identifier, listed also in Sequence of Types. Indices start as usual with 1.

Octet String

OCTET STRING is mapped to the Z.105-specific type Octet_string. Octet_string is based on type Octet. This type is further described in SDL Predefined Types. The mapping for the octet string value notation to SDL is identical to bit strings, see Bit String.

Note:

Octet_string, has indices starting with 1.

Operators available:

bitstr      : Charstring       -> Octet_string;
hexstr      : Charstring       -> Octet_string;
     /* conversion from Charstring to Octet_string,
        see also Bit String*/
bit_string  : Octet_string     -> Bit_string;
octet_string: Bit_string       -> Octet_string;
     /* conversion operators 
        Octet_string <-> Bit_string */
mkstring    : Octet            -> Octet_string;
length      : Octet_string     -> Integer;
first       : Octet_string     -> Octet;
last        : Octet_string     -> Octet;
"//"        : Octet_string, Octet_string ->
                                       Octet_string;
extract!    : Octet_string, Integer -> Octet;
modify!     : Octet_string, Integer, Octet ->
                                       Octet_string;
substring   : Octet_string, Integer, Integer ->
                                       Octet_string;
     /* normal String operators, see also
        Sequence of Types */

Sequence/Set Types

SEQUENCE and SET are both mapped to SDL struct. From an SDL point of view there is no difference between SEQUENCE and SET. In order to support optional and default components, SDL has been extended with corresponding concepts.

Note:

Optional and default fields in struct are both non-standardized extensions to SDL.

Values are mapped to the "(. ... .)" construct (= Make! operator). Values for optional and default components are not supported. Instead, SDL tasks should be used to assign optional and default components.

Example 45

S ::= SEQUENCE { 
        a INTEGER OPTIONAL, 
        b BOOLEAN, 
        c IA5String DEFAULT "xyz" }

s S ::= { b TRUE }

is mapped to

newtype S struct
   a Integer optional;
   b Boolean;
   c IA5String := `xyz';
endnewtype;

synonym s S = (. True .);

The operators that are available for a SEQUENCE or SET type are (assuming that S is defined as in Example 45 above):

make!    : Boolean -> S;
     /* builds a value for S */
aextract!: S -> Integer;
bextract!: S -> Boolean;
cextract!: S -> IA5String;
   /* Extract operators. Note that aextract! gives
      dynamic error if the field has not been set */
amodify! : S, Integer -> S;
bmodify! : S, Boolean -> S;
cmodify! : S, IA5String -> S;
     /* Modify operators change one component 
        in a Sequence/Set */
apresent : S -> Boolean;
     /* gives True if component a has been assigned 
        a value, e.g. aPresent(s) = False */

Sequence of Types

SEQUENCE OF is mapped to the String generator. Values are mapped to corresponding synonyms.

Example 46

S ::= SEQUENCE OF INTEGER
s1 S ::= { 3, 2, 5 }
s2 S ::= {}

is mapped to

newtype S 
   String (Integer, Emptystring) 
endnewtype;

synonym s1 S = (. 3, 2, 5 .);
synonym s2 S = (. .);

The normal String operators are available for Sequence types. Indices start at 1.

The operators that are available for a SEQUENCE OF type are (assuming that S is defined as in Example 46 above):

mkstring  : Integer             -> S;
     /* make a sequence of one item */
length    : S                   -> Integer;
     /* returns number of elements in sequence */
first     : S                   -> Integer;
     /* returns first element in sequence */
last      : S                   -> Integer;
     /* returns last element in sequence
"//"      : S, S                -> S;
     /* returns concatenation of two sequences */
extract!  : S, Integer          -> Integer;
     /* returns the indexed element */
modify!   : S, Integer, Integer -> S;
     /* modify the indexed element */
substring : S, Integer, Integer -> S;
     /* Substring(S, i, l) returns substring of S
        of length l, starting at index i */
make!     : * Integer           -> S;
      /* adds the included elements to the string,
       * corresponds to (. .) */
append    : in/out S, Integer;
      /* appends one element to the string */

Set of Types

SET OF is mapped to the Z.105 specific Bag generator. For a more complete description of the Bag generator, see Bag.

Example 47

S ::= SET OF INTEGER
s1 S ::= { 2, 2, 5 }
s2 S ::= {}

is mapped to

newtype S 
   Bag (Integer) 
endnewtype;

synonym s1 S = (. 2, 2, 5 .);
synonym s2 S = (. .);

The operators that are available for a SET OF type are (assuming that S is defined as in Example 47 above):

incl    : Integer, S   -> S;
     /* add an element to the bag */
del     : Integer, S   -> S;
     /* delete one element */
incl    : Integer, in/out S;
del     : Integer, in/out S;
length  : S             -> Integer;
     /* returns number of elements */
take    : S             -> Integer;
     /* return some element from the bag */
take    : S,   Integer  -> Integer;
     /* return the indexed element in the bag */
makebag : Integer      -> S;
     /* build a bag of one element */
"in"    : Integer, S   -> Boolean;
     /* gives true if the element is in the bag */
"<"     : S, S          -> Boolean;
">"     : S, S          -> Boolean;
"<="    : S, S          -> Boolean;
">="    : S, S          -> Boolean;
     /* subset/superset comparison operators */
"and"   : S, S          -> S;
"or"    : S, S          -> S;
     /* intersection/union operators */
make!   : * Integer     -> S;
     /* adds the included elements to the bag,
      * corresponds to (. .) */

Useful Types

The types GeneralizedTime and UTCTime have been defined in terms of ASN.1 as specified in X.680. It follows from their definition in X.680, together with the information about the translation rules given in this chapter, which operators are available in SDL for these types.

Constrained Types

Constrained types are mapped to sdl syntypes of the associated parent sort. Value constraints are mapped to sdl range condition.

When specifying ASN.1 value constraints, several constructs can be used that are not supported in the SDL Suite, such as ALL EXCEPT,INCLUDES <subtype> and value range with MIN or MAX endpoint. Possible values for such a type are computed and mapped to syntype with range condition represented by a sequence of open and closed ranges.

Example 48

    T  ::= INTEGER ( (1..10) EXCEPT 8 )

    T1 ::= INTEGER ( INCLUDES T EXCEPT (3..<6) ) 

is mapped to

   syntype T = Integer
               constants 9 : 10, 1 : 7
   endsyntype;

   syntype T1 = Integer
                constants 9 : 10, 6 : 7, 1 : 2
   endsyntype;

"COMPONENTS OF" and "WITH COMPONENT" constraints are mapped by using extra inline types. If the present constraint is applied to the parent type, then the new type is generated excluding fields marked as ABSENT and including fields marked as PRESENT.

Example 49

T  ::= SEQUENCE {
         a INTEGER,
         b IA5String
}

T1 ::=	 T ( WITH COMPONENTS {
              a (-5..5),
              b (SIZE (7))
} )

is mapped to

newtype T struct
    a  Integer;
    b  IA5String;
endnewtype;
     
newtype T1 struct
    a  T1_INLINE_0;
    b  T1_INLINE_1;
endnewtype;
     
syntype T1_INLINE_0 = Integer constants -5 : 5
endsyntype;

syntype T1_INLINE_1 = IA5String constants size(7)
endsyntype;

Example 50

T  ::= SET OF BIT STRING

T1 ::= T ( WITH COMPONENT (SIZE (5)) )

is mapped to

newtype T
    Bag(Bit_string)
endnewtype;

syntype T1 = T1_INLINE_0 endsyntype;

newtype T1_INLINE_0 /*#SYNT*/
    Bag(T1_INLINE_1)
endnewtype;

syntype T1_INLINE_1 = Bit_string
    constants size (5) 
endsyntype;

Example 51

T ::= SET {
       a INTEGER OPTIONAL,
       b REAL OPTIONAL
}
T1 ::= T ( WITH COMPONENTS {
             a (0..<MAX) PRESENT, 
             b ABSENT
} )

is mapped to

newtype T struct
   a  Integer  optional;
   b  Real  optional;
endnewtype;

newtype T1 struct
    a  T1_INLINE_0;
endnewtype;

syntype T1_INLINE_0 = Integer constants >=0
endsyntype;

Note:

According to ASN.1, the types T and T1 are compatible, because they are derived from each other. In SDL these are different types and values of type T can not be assigned to type T1.

ASN.1 SET OF and SEQUENCE OF types with SIZE or single value constraints are mapped to one SDL type with constraint without introducing any extra inline types.

Example 52

T1 ::= SEQUENCE SIZE (5..15) OF INTEGER

T2 ::= SEQUENCE ( { 1 } | {} ) OF INTEGER

T3 ::= SET (SIZE (MIN .. <100) ) OF BOOLEAN

T4 ::= SET (SIZE (15) | { ''B } ) OF BIT STRING

is mapped to

newtype T1
   String(Integer, emptystring)
   constants size (5 : 15)
endnewtype;

newtype T2
   String(Integer, emptystring)
   constants ((. .)), ((. 1 .))
endnewtype;

newtype T3
   Bag(Boolean)
   constants size (<=99)
endnewtype;

newtype T4
   Bag(Bit_string)
   constants ((. bitstr('') .)), size (15)
endnewtype;

Extensibility

Extensibility was introduced in X.680 (1997). In ASN.1 extensibility is represented with extension markers and extension addition groups, that can be specified inside SET, SEQUENCE, CHOICE, ENUMERATED types and constraints.

Extension markers are not visible in SDL translations. All square brackets are ignored and all components from extension addition groups are translated into SDL as individual fields. All required components from extension additions, individual or from extension addition groups are mapped to optional ones.

Example 53

S1 ::= SET 
{ 
  x [100] INTEGER,
  ... ,
  [[ 
     gr11 REAL 
  ]],
  t BIT STRING,
  [[ 
     gr21 BOOLEAN OPTIONAL, 
     gr22 SET OF INTEGER 
  ]],
  ... ,
  y INTEGER
}

is mapped to SDL

newtype S1 struct
  x  Integer;
  gr11  Real  optional;
  t  Bit_string optional;
  gr21  Boolean  optional;
  gr22  S1_INLINE_1  optional;
  y  Integer;
endnewtype;

newtype S1_INLINE_1 /*#SYNT*/
   Bag(Integer)
endnewtype;

Note:

SDL translation removes the borders of additional groups and makes all required components optional.The semantics for assigning values to types with additional groups are: either the whole addition group ( [[ .... ]] ) is absent, or it is all present unless components inside the group are optional. This is not checked in SDL tools but inconsistency will cause errors in ASN.1 encoding.

Extension markers are ignored in constraints. If both root and additional constraints are present, they are translated to the union constraint.

Example 54

T1 ::= INTEGER ( 1..10 ^ 2..20, ... , 12 )

is mapped to SDL

syntype T1 = Integer constants 12, 2 : 10 
endsyntype;

T2 ::= INTEGER (1 | 3, ... )

is mapped to SDL

syntype T2 = Integer constants 3, 1 endsyntype;

Information from Object Classes, Objects and Object Sets

Object classes, object and objects sets are not translated to SDL. Only types and values are translated to SDL, but it is possible in ASN.1 to use information from object classes, objects and object sets when specifying types and values. This information is translated into SDL.

ObjectClassFieldType

ObjectClassFieldType is a reference to object class and a field in that class. The translation to SDL depends on the kind of field name used.

An open type is defined if the field name references a type field, a variable type value field or variable type value set field. An open type can be any ASN.1 type. Open types are translated to Octet_string types in SDL.

Example 55

OPERATION ::= CLASS {
   &ArgumentType,
   &arg &ArgumentType
}

T1 ::= SEQUENCE { a OPERATION.&ArgumentType }

is translated to SDL

newtype T1 struct
  a  T1_INLINE_0;
endnewtype;

syntype T1_INLINE_0 = Octet_string endsyntype;


T2 ::= OPERATION.&arg

is translated to SDL

syntype T2 = Octet_string endsyntype;

If the field name in the class references a fixed type value or fixed type value set fields, then the fixed type is used when translated to SDL.

Example 56

OPERATION ::= CLASS {
      &ValueSet INTEGER   
   }

T ::= OPERATION.&ValueSet

is translated to SDL

syntype T = Integer endsyntype;

ObjectClassFieldType with table constraint (object set constraint)

Table constraint applied to ObjectClassFieldType restricts the set of possible types or values to those specified in a column of the table. A table corresponds to an object set. The columns of the table correspond to the object class fields and the rows correspond to the objects in the set.

If the field name in ObjectClassFieldType is a type field and constrained with a table, then it is translated to a CHOICE type with fields of the types specified in the table column. The names of the fields in the choice are the same as the names of the types in the column but the first letter is changed from upper case to lower case.

Note: Field names

If the type in the field is inline then the name in the field will be an implicitly generated inline name, like t_INLINE_4.

If the field name in ObjectClassFieldType is a fixed type value or a fixed type value set, then this is translated to a constrained type where only values that are specified in the table column are permitted.

If the field name in ObjectClassFieldType is a variable type value or variable type value set field, then this is translated to a CHOICE type with types, that are constrained to have values specified in the corresponding cell in the same row of the table.

Example 57

OPERATION ::= CLASS {
       &ArgumentType,
       &operationCode INTEGER UNIQUE,
       &ValueSet INTEGER,
       &ArgSet &ArgumentType
   }

The My-Operations object set

Object name &ArgumentType &operationCode &ValueSet &ArgSet

operationA

INTEGER

1

{1 | 2 | 5 .. 8}

{ 111..444 }

operationB

SET OF INTEGER

2

{ 2 .. 8 }

{ {1,2,3} |

{ 888 } }

C1 ::= OPERATION.&ArgumentType ( {My-Operations} )

is translated to SDL

newtype C1 choice
  integer  Integer;
  c1_INLINE_2  C1_INLINE_1;
endnewtype;

newtype C1_INLINE_1 /*#SYNT*/
   Bag(Integer)
endnewtype;


C2 ::= OPERATION.&operationCode ( {My-Operations} )

is translated to SDL

syntype C2 = Integer constants 2, 1 endsyntype;


C3 ::= OPERATION.&ValueSet ( {My-Operations} )

is translated to SDL

syntype C3 = Integer constants 2 : 8, 1, 5 : 8, 2 
endsyntype;


C4 ::= OPERATION.&ArgSet ( {My-Operations} )

is translated to SDL

newtype C4 choice
  c4_INLINE_1  C4_INLINE_1;
  c4_INLINE_1  C4_INLINE_2;
endnewtype;

syntype C4_INLINE_1 = Integer constants 111 : 444 
endsyntype;

syntype C4_INLINE_2 /*#SYNT*/
  Bag(Integer)
  constants ((. 888 .)), ((. 1, 2, 3 .))
endsyntype;

If an open type is constrained by the table for which all type settings are omitted, then it is translated to SDL Octet_string instead of an empty CHOICE type.

Example 58

MY-CLASS ::= CLASS {
       &id INTEGER,
       &OpenType OPTIONAL
   }


The My-Set object set:

Object name &id &OpenType

object1

1

-

object2

2

-

S ::= SEQUENCE {
        id  MY-CLASS.&id({My-Set}),
        val MY-CLASS.&OpenType({My-Set}{@id})
}

is translated to SDL

newtype S struct
  id  S_INLINE_0;
  val  S_INLINE_2;
endnewtype;

syntype S_INLINE_0 = Integer constants 2, 1 
endsyntype;

syntype S_INLINE_2 = Octet_string endsyntype;

TypeFromObject

TypeFromObject is a reference to an object and a type field in that object. This is simply translated to that type in SDL. If the field is optional in the class and not set in the object, then TypeFromObject cannot be translated.

Example 59

OPERATION ::= CLASS {
       &ArgumentType,
       &ResultType 
   }

operationA OPERATION ::= {
      &ArgumentType INTEGER,
       &ResultType BOOLEAN	 
   }

O1 ::= operationA.&ArgumentType

is translated to SDL

syntype O1 = Integer endsyntype;


O2 ::= operationA.&ResultType

is translated to SDL

syntype O2 = Boolean endsyntype;

ValueSetFromObject

ValueSetFromObject is a reference to an object and a field with a set of values in that object. This is translated to a constrained type in SDL, allowing only values from the value set.

Example 60

OPERATION ::= CLASS {
       &ValueSet INTEGER
   }

operationA OPERATION ::= {
       &ValueSet { 1 | 2 | 5..8 } 
  }

V1 ::= operationA.&ValueSet

is translated to SDL

syntype V1 = Integer constants 2, 5 : 8, 1 
endsyntype;

ValueFromObject

ValueFromObject is a reference to an object and a field with a value in that object. This is translated to the same value in SDL.

Example 61

OPERATION ::= CLASS {
      &operationCode INTEGER UNIQUE
   }

operationA OPERATION ::= { &operationCode 1 }

val2 INTEGER ::= operationA.&operationCode

is mapped to SDL

synonym val2 Integer = 1;

CONSTRAINED BY notation

CONSTRAINED BY is treated like a comment and is not translated to SDL.

Parameterization

Wherever a parameterized type or value is used, it is translated to SDL after all dummy references are replaced by the actual parameters. A parameterized value is also translated after all dummy references are replaced by the actual parameters.

Parameterized assignments are ignored when translating to SDL.

Example 62

Container { ElemType, INTEGER : maxelements } ::=
SET SIZE (0..maxelements ) OF ElemType

Intcontainer ::= Container {INTEGER, 25}

is first internally mapped to

Intcontainer ::= SET SIZE( 0..25 ) OF INTEGER

and then translated to SDL. Container is not translated to SDL.


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