Guide to the HP Structure Definition Language


Previous Contents Index


Chapter 3
HP SDL Language Elements

This chapter describes the function and syntax of the following HP SDL language elements that compose the HP SDL declarations described in Chapter 4:

The following can also be used within a MODULE declaration; although they are not HP SDL language elements (see Section 3.4 through Section 3.6):

The space, tab, or carriage return character delimits the language elements, and a semicolon (;) terminates each declaration. In MODULE and AGGREGATE declarations, the semicolon also terminates separate parts of the declaration.

Appendix B shows language translation summaries of all the HP SDL language elements.

3.1 Names

A HP SDL name can be either a user-specified local symbol name that is not translated to the output file or a user-specified source program identifier that is translated to the output file. Names are composed of upper- and lowercase letters (A - Z, a - z), numbers (0 - 9), the dollar sign ($), and the underscore (_). Specifying a name is subject to the following rules:

  1. Local symbol names must begin with a pound sign (#).
  2. Source program identifiers must begin with an alphabetic character (A - Z, a - z), a dollar sign ($), or an underscore (_).
  3. Source program identifiers that are reserved HP SDL keywords or that contain invalid HP SDL characters must be enclosed in quotation marks (" "). (For more information on reserved HP SDL keywords, see Section 3.2.)
  4. HP SDL passes all source program identifiers to the output file in the same case in which they are defined.

3.1.1 Local Symbol Names

A local symbol name is known only within a HP SDL source file and cannot be translated directly to the output file. A local symbol name can be assigned a value anywhere within a source file, but must begin with the pound sign (#). A local symbol is declared when it is first assigned a value. This value can be any valid expression (see Section 3.3). If you reference a local symbol before assigning it a value, HP SDL displays an error message and does not produce an output file. A local symbol assignment has the following syntax:

#local-name = expression; 

#local-name

Is any valid HP SDL name.

expression

Is any valid HP SDL expression resulting in a longword integer value.

Signed integer longword data types are described in Section 3.2.3.9.

The following are examples of local symbol assignments:


#max_args = 255; 
#counter = #counter + 1; 

The values of these local symbols may be referenced by subsequent declarations, as shown in the following example:


CONSTANT block_node_size EQUALS #max_args + #counter; 

3.1.2 Source Program Identifiers

Source program identifiers (identifiers) specify declaration names, AGGREGATE member names, and ENTRY parameter names that are passed to the output file. Optional user-specified prefixes and tags can be appended to these identifiers. If a prefix is specified without a tag, HP SDL concatenates a default tag (corresponding to the data type) to the identifier in the output file. ( Section 3.2.2.2 describes the PREFIX and TAG keyword options.) The identifier block_node_size in the following example names the CONSTANT declaration:


CONSTANT block_node_size EQUALS #max_args + #counter; 

To avoid compilation errors, each reference to a particular HP SDL identifier must be a case-sensitive match because an identifier is passed to the output file in the same case in which it appears in the source file. You can use reserved HP SDL keywords and characters that are not valid in identifiers if you enclose them in quotation marks (" "). For example:


ITEM "length" LONGWORD; 

This declaration produces the identifier length, which is a reserved HP SDL keyword typically used to specify the length of a bit-string or character-string data type (see Section 3.2.3.3 and Section 3.2.3.5).

3.2 Keywords

Reserved HP SDL keywords are used to specify the following:

You can use keywords as identifiers if they are enclosed in quotation marks (" "). For example:


ITEM "length" LONGWORD; 

This declaration produces the identifier length, which names this particular ITEM declaration. The length identifier is a reserved HP SDL keyword that is typically used to specify the length of a bit-string or character-string data type (see Section 3.2.3.3 and Section 3.2.3.5).

Reserved HP SDL keywords can be entered in either upper- or lowercase letters, but they cannot be truncated.

The following sections describe the format and function of each of the reserved HP SDL keywords.

3.2.1 Declaration Keywords

Table 3-1 alphabetically lists and defines the keywords for the declarations described in detail in Chapter 4.

Table 3-1 Keywords That Identify or End Declarations
Keyword Definition
AGGREGATE Declaration that produces a structure or union body
CONSTANT Declaration of a named constant
END Delimiter for the end of an aggregate body
END_MODULE Delimiter for the end of a module
ENTRY Declaration of an entry
ITEM Declaration of an item
MODULE Declaration of a module
STRUCTURE Declaration that is a type of aggregate or subaggregate
UNION Declaration that is a type of aggregate or subaggregate

3.2.2 Declaration Modifier Keywords

Table 3-2 lists and defines other keywords that are used in declarations. The prefix and tag, storage class, and array keywords have special functions that are described in detail in the sections following Table 3-2. All the other keywords defined in Table 3-2 are described in greater detail in Chapter 4.

Table 3-2 Keywords Used in Declarations
MODULE Declaration
Keyword Description
IDENT Optional keyword used to pass information describing the MODULE declaration to the output file
ITEM Declaration
Keyword Description
ALIGN, NOALIGN, BASEALIGN Optional keywords used to specify alignment; see Section 3.2.2.3
COMMON and GLOBAL Optional keywords used to specify common and global storage; see Section 3.2.2.4
DIMENSION Optional keyword used to specify that the ITEM declaration is an array; see Section 3.2.2.7
PREFIX Optional keyword used to concatenate a user-defined prefix to ITEM names, AGGREGATE member names, and named constants; see Section 3.2.2.2
TAG Optional keyword used to override the default OpenVMS code assigned to a name and to assign a user-defined tag instead; see Section 3.2.2.2
AGGREGATE Declaration
Keyword Description
COMMON, GLOBAL, BASED, TYPEDEF Optional keywords used to specify common, global, or based storage, or a TYPEDEF; see Section 3.2.2.4
DIMENSION Optional keyword used to specify that the AGGREGATE declaration is an array; see Section 3.2.2.7
FILL Optional keyword used to indicate whether the associated aggregate or member occurs only as a fill to force byte alignment on the following member or aggregate, respectively
MARKER Optional keyword used to assign a user-defined prefix to the aggregate name; see Section 3.2.2.2
ORIGIN Optional keyword used to define the beginning of an aggregate with respect to an aggregate member
PREFIX Optional keyword used to concatenate a user-defined prefix to AGGREGATE member names, ITEM names, and named constants; see Section 3.2.2.2
TAG Optional keyword used to override the default OpenVMS code assigned to a name and to assign a user-defined tag instead; see Section 3.2.2.2
CONSTANT Declaration
Keyword Description
COUNTER Optional keyword that saves the last assigned value in a local symbol declaration for subsequent use
EQUALS Required keyword used in assigning the value to the first named constant
STRING Optional keyword specified immediately after EQUALS to indicate the definition of a string constant.
INCREMENT Optional keyword used to specify constants with incremental values
PREFIX Optional keyword used to concatenate a user-defined prefix to aggregate member names and named constants; see Section 3.2.2.2
TAG Optional keyword used to override the default OpenVMS code assigned to a name and to assign a user-defined tag instead; see Section 3.2.2.2
TYPENAME Optional keyword used only by the HP Ada and Kednos PL/I back ends to specify a user-defined data type name; see Section 3.2.2.1
ENTRY Declaration
Parameter-Passing Mechanism Keywords Description
DESCRIPTOR Optional parameter-passing mechanism keyword used to specify that a parameter must be passed BY DESCRIPTOR
REFERENCE Optional parameter-passing mechanism keyword used to specify that a parameter must be passed BY REFERENCE; REFERENCE is the default
RTL_STR_DESC Optional parameter-passing mechanism keyword used to specify that a parameter must be passed by any of the classes of string descriptors
VALUE Optional parameter-passing mechanism keyword used to specify that the parameter must be passed BY immediate VALUE
Parameter Mode Keywords Description
IN Parameter description keyword used to indicate that a parameter is an input parameter; can be used with OUT to indicate that the parameter is both an input and an output parameter; IN is the default
OUT Parameter description keyword used to indicate that a parameter is an output parameter; can be used with IN to indicate that the parameter is both an input and an output parameter
Other Parameter Modifier Keywords Description
DEFAULT Optional parameter description keyword used to specify a default parameter value
DIMENSION Optional keyword used to specify that the parameter is an array; see Section 3.2.2.7
LIST Optional parameter description keyword used to indicate that the routine may be called with one or more parameters of the type being described
NAMED Optional parameter description keyword used only by the HP Ada back end to name the parameter
OPTIONAL Optional parameter description keyword used to specify that the parameter may or may not appear in the sequence of parameters using the entry point name
TYPENAME Optional parameter description keyword used only by the HP Ada and Kednos PL/I back ends to specify a user-defined data type name; see Section 3.2.2.1
Entry Return Value Keywords Description
NAMED Optional keyword used to specify the name of the parameter (in a HP Ada IMPORT_VALUED_PROCEDURE) into which the return value is returned
RETURNS Optional keyword used to specify the data type returned by the external entry
TYPENAME Optional keyword used only by the HP Ada and Kednos PL/I back ends to specify a user-defined name that is the data type returned by the external entry; see Section 3.2.2.1
Entry Description Keywords Description
ALIAS Optional keyword used to indicate an alternate internal name that can be used to designate the entry point
LINKAGE Optional keyword used only by the HP MACRO back end to indicate that a special call macro will be used in the expansion of the entry macro
PARAMETER Optional keyword used to describe the parameters of the external entry
VARIABLE Optional keyword used to indicate that the entry point can be invoked with a variable number of parameters; see also the LIST parameter modifier keyword

3.2.2.1 User-Specified TYPENAME keyword

The TYPENAME keyword is used to specify a data type name that is not a HP SDL data type. Depending on which back end is specified, this name may or may not override the HP SDL data type. The HP Ada and Kednos PL/I back ends use these data type names as parameter data types, as return value data types, and as CONSTANT declaration data types. The TYPENAME keyword has the following syntax:

TYPENAME name 

The HP Ada language translation (as a result of processing the HP SDL source file EXAMPLE.SDL in SDL$EXAMPLES) shows an example of the TYPENAME keyword. The following is an example of the TYPENAME keyword on each of the parameters in an ENTRY declaration:


 
ENTRY SYS$FAO 
   ALIAS $FAO 
   PARAMETER (CHARACTER DESCRIPTOR NAMED CTRSTR IN TYPENAME CHARDESC, 
       WORD UNSIGNED NAMED OUTLEN OUT DEFAULT 0 TYPENAME NUMBER, 
       CHARACTER DESCRIPTOR NAMED OUTBUF OUT TYPENAME CHARDESC, 
       LONGWORD VALUE NAMED P1 OPTIONAL LIST TYPENAME VARIES) 
   RETURNS LONGWORD TYPENAME CONDVALU; 

3.2.2.2 PREFIX, MARKER, and TAG Keywords

User-defined prefixes, markers, and tags are optional character strings that help to uniquely identify the names associated with a particular facility or system. When the /SUPPRESS qualifier is specified on the command line, the inclusion of prefixes and/or tags on output symbol names is suppressed. See Section 2.2 for a description of the /SUPPRESS qualifier.

PREFIX Keyword

The PREFIX option may be specified on an AGGREGATE, subaggregate, CONSTANT, or ITEM declaration to cause HP SDL to concatenate a user-specified prefix and the name specified in the declaration.

When you specify a prefix for an aggregate, HP SDL concatenates the prefix and the name of each member or named constant declared within the aggregate. The name of the aggregate itself is not altered by the use of the PREFIX option. The PREFIX option has the following syntax:

PREFIX prefix-string 

prefix-string

Is a 0- to 32-character string that can be any valid HP SDL identifier.

If you specify the PREFIX option, HP SDL constructs the identifier of each member by concatenating the prefix, a tag, an underscore, and the member name.

You can override a prefix that is currently in effect by specifying a new prefix for a particular aggregate member. If this member happens to be a subaggregate, the new prefix is applied to all the members of that subaggregate. Otherwise, if no prefix is specified for the subaggregate, all subaggregate members are assigned the same prefix as that specified on the level-1 aggregate.

MARKER Keyword

You can use the MARKER keyword to assign a user-defined prefix to the aggregate name. The MARKER option has the following syntax:

MARKER marker-string 

marker-string

Is a 0- to 32-character string that can be any valid HP SDL name that may or may not be enclosed in quotation marks (" ") and may be null.

TAG Keyword

The TAG option overrides the default tags that HP SDL uses in forming identifiers. You can specify tags for CONSTANT, ITEM, and AGGREGATE declarations and aggregate members. The tag that you specify, however, affects only the outer-level identifier. For example, a tag you supply in an AGGREGATE declaration affects only the aggregate name; if you wish to change all the tags in an aggregate, you must do it on a member-by-member basis. The TAG option has the following syntax:

TAG tag-string 

tag-string

Is a 0- to 32-character string specifying the tag to use in forming the name. If the TAG option is not specified, HP SDL uses a default code based on the data type of the name.

If you specify the TAG option, HP SDL appends the tag-string, which may be null (" "), and an underscore character (_) to the current prefix-string. A tag consisting of a single underscore character produces a single underscore character in any resulting identifier.

The following is an example of the PREFIX, TAG, and MARKER keywords:


AGGREGATE operator STRUCTURE MARKER doowop$ PREFIX beebop$ TAG shoo; 
 flink ADDRESS; 
 blink WORD; 
END; 

Table 3-3 shows the default tags that HP SDL uses when the TAG option is not specified on an aggregate member.

Table 3-3 Default Tags Used by HP SDL
Data Type Default Tag
CONSTANT K
BYTE [UNSIGNED] B
WORD [UNSIGNED] W
LONGWORD [UNSIGNED] L
QUADWORD Q
OCTAWORD O
F_FLOATING F
D_FLOATING D
G_FLOATING G
H_FLOATING H
F_FLOATING COMPLEX FC
D_FLOATING COMPLEX DC
G_FLOATING COMPLEX GC
H_FLOATING COMPLEX HC
DECIMAL P
BITFIELD V for BITFIELD offset
  S for BITFIELD size 1
  M for BITFIELD mask 1
CHARACTER T
ADDRESS A
STRUCTURE R
UNION R


1Identifiers with size and mask (if MASK is specified) tags are generated regardless of whether a PREFIX or TAG option is specified.

The following example shows the use of a user-specified prefix on an AGGREGATE declaration:


Previous Next Contents Index