Previous | Contents | Index |
The keywords BYTE, WORD, LONGWORD, QUADWORD, and OCTAWORD declare storage units of 8, 16, 32, 64, and 128 bits, respectively, to represent signed integer data.
You may also specify the keyword UNSIGNED with any of these data types to indicate unsigned integer data.
It is also possible to specify the keyword SIGNED.
The keywords INTEGER_BYTE, INTEGER_WORD, INTEGER_LONG and INTEGER_QUAD are synonyms for BYTE, WORD, LONGWORD, QUADWORD, respectively, although some back ends treat INTEGER_QUAD and QUADWORD different (C, FORTRAN and PL/I). The keyword INTEGER is also synonym for LONGWORD and INTEGER_LONG.
The keywords INTEGER_HW and HARDWARE_INTEGER describe integer data types whose size depends on the underlying hardware. If the qualifier /VAX is specified, they are 4 bytes wide, and if /ALPHA is specified, they are 8 bytes wide.
The integer data types have the following syntax:
BYTE [ UNSIGNED | SIGNED ] INTEGER_BYTE [ UNSIGNED | SIGNED ] WORD [ UNSIGNED | SIGNED ] INTEGER_WORD [ UNSIGNED | SIGNED ] LONGWORD [ UNSIGNED | SIGNED ] INTEGER_LONG [ UNSIGNED | SIGNED ] INTEGER [ UNSIGNED | SIGNED ] QUADWORD [ UNSIGNED | SIGNED ] INTEGER_QUAD [ UNSIGNED | SIGNED ] OCTAWORD [ UNSIGNED | SIGNED ] INTEGER_HW [ UNSIGNED | SIGNED ] HARDWARE_INTEGER [ UNSIGNED | SIGNED ] |
The following are examples of the LONGWORD and BYTE data types used in an ITEM declaration:
ITEM foo LONGWORD UNSIGNED; ITEM bar BYTE; |
A HP SDL expression evaluates to an arithmetic value and can consist of any of the following syntax elements:
Prefix | Interpretation | Valid Characters |
---|---|---|
%X | Hexadecimal | 0 - 9, A - F |
%O | Octal | 0 - 7 |
%B | Binary | 0 and 1 |
%A 1 | ASCII value | Any ASCII character (see Appendix C) |
Operator | Meaning |
---|---|
unary - | Arithmetic negation |
* | Arithmetic multiplication |
/ | Arithmetic division |
+ | Arithmetic addition |
- | Arithmetic subtraction |
@ | Logical shift--x@y shifts the value of x to the right y places; if y is negative, the value of x is shifted y places to the left |
& | Logical AND |
! | Logical OR |
The following is an example of an expression used in a CONSTANT declaration, which appears in the context of an AGGREGATE declaration:
CONSTANT foo EQUALS %Ag + 72 / (#abc * boo + .); |
A comment that is local to the HP SDL source file is not written to the output file. Local comments begin with the left brace ({) and extend to the end of the line. They can appear anywhere within the source file (not necessarily within a module) where white space (a space, tab, or carriage return) is allowed. The following is an example of a local comment:
{Assigning the value 255 to #max_args. |
Comments appearing on lines by themselves are typically written to the output file as separate comment lines. Comments appearing at the end of a line are output at the end of the corresponding target source line, if possible.
Output comments begin with a slash and an asterisk (/*) and terminate at the end of the current line. They can appear in the following contexts:
The following is an example of an output comment:
/* Get Job/Process Information System Service. |
The INCLUDE statement specifies that the contents of an external file are to be incorporated in the HP SDL input file directly following the INCLUDE statement. The INCLUDE statement has the following syntax:
INCLUDE "file-spec"; |
"file-spec"
Is any valid VMS file specification enclosed in quotation marks (" "). An INCLUDE statement cannot appear embedded within an AGGREGATE declaration, but can appear anywhere else within the module. If a directory is not included in the file specification, the current default directory is used.
When HP SDL encounters an INCLUDE statement, it stops reading from the
current file and reads the statements in the included file. When it
reaches the end of the included file, HP SDL resumes translation with
the source statement immediately following the INCLUDE statement.
3.7 READ Statement
The READ statement allows a .SDI intermediate file to be included in an SDL source, without causing it to be emitted to the output stream. Apart from these two differences, its operation is similar to INCLUDE.
The READ statement allows previously-compiled definitions, such as constants and user-defined types, to be used by the current compilation, without affecting the language output. The READ statement has the following syntax:
READ "file-spec" ; |
3.8.1 Conditional SDL Compilation using the IFLANGUAGE statement
This feature allows a section of SDL source code to be conditionally
compiled, depending on whether output is being generated for a
particular language or not.
The syntax for conditional compilation has the format:
IFLANGUAGE language-name [ language-name ... ] . . . [ELSE ; . . . ] END_IFLANGUAGE [ language-name [ language-name ... ] ] ; |
Note the following:
In the following example, SDL generates a translation of the ITEM statement if output is being generated for Pascal, Ada, or FORTRAN. For other languages, SDL does not generate a translation of the ITEM statement.
IFLANGUAGE PASCAL ADA FORTRAN ; ITEM foo LONGWORD; END_IFLANGUAGE PASCAL ADA FORTRAN; |
3.8.2 Conditional SDL Compilation using the IFSYMBOL statement
This feature allows a section of SDL source code to be conditionally
compiled, depending on symbols specified with the command line
qualifier /SYMBOLS.
The syntax for conditional compilation has the format:
IFSYMBOL symbol-name ; . . . { ELSE_IFSYMBOL symbol-name ; . . . } [ELSE ; . . . ] END_IFSYMBOL ; |
Note the following:
With the following example:
IFSYMBOL s1; <sdl code 1> END_IFSYMBOL; IFSYMBOL s2; <sdl code 2> ELSE_IFSYMBOL s3; <sdl code 3> ELSE; <sdl code 4> END_IFSYMBOL; |
$ SDL/LANG=<LANGUAGE>/SYMBOLS=(S1=0,S2=0,S3=0) <FILE-SPEC> |
produces
<sdl code 4> |
$ SDL/LANG=<LANGUAGE>/SYMBOLS=(S1=1,S2=0,S3=0) <FILE-SPEC> |
produces
<sdl code 1> <sdl code 4> |
$ SDL/LANG=<LANGUAGE>/SYMBOLS=(S1=1,S2=1,S3=x) <FILE-SPEC> |
produces
<sdl code 1> <sdl code 2> |
$ SDL/LANG=<LANGUAGE>/SYMBOLS=(S1=1,S2=0,S3=1) <FILE-SPEC> |
produces
<sdl code 1> <sdl code 3> |
3.9 Text Pass-through
Text pass-through allows literal text to be passed through to the
output language file without translation. It is normally used in
conjunction with conditional compilation for a specific target
language. The purpose is to allow language-specific constructs, which
cannot be represented in SDL, to be emitted.
The syntax for text pass-through is:
LITERAL; Any number of lines to be passed directly to the output stream without translation END_LITERAL; |
Note the following:
Literal text is processed identically in all back ends. The literal text is merely written directly to the output file.
The following is an example of text pass-through for the C language.
IFLANGUAGE CC LITERAL #define ctext "This appears in C language output only" END_LITERAL END_IFLANGUAGE CC |
The DECLARE statement allows you to declare a data item of a type that you define, which may be unknown in the current SDL compilation. When you use DECLARE, the type is made known when the target language source is compiled.
The DECLARE statement uses the SIZEOF clause to allow you to specify the size of the user-defined data type being declared. The parameter you specify in the SIZEOF clause may be a built-in SDL data type, a user-defined type defined in the current SDL compilation, or an expression.
The DECLARE statement has the following syntax:
DECLARE user-type SIZEOF { data-type } [ PREFIX prefix-string ] { user-type } [ TAG tag-string ] { ( expression ) } |
user-type
Represents the unknown data type name you wish to declare.SIZEOF
A clause that must be appended to user-type. The SIZEOF clause may be specified in several ways, as shown, to indicate the size of the user-defined type being declared.data-type
Represents either a built-in SDL data type, a user-defined type that is known at SDL compile time, or a data type that has been sized by a previous SIZEOF clause.user-type
Represents a user-defined data type.( expression )
Represents an expression. If specified, the expression must specify the number of bytes to be reserved for this data type. If the data type is dimensioned, the SIZEOF clause must specify the size of a single element. When you specify an expression, always enclose it in parentheses, as shown in this syntax.
Notes:
DECLARE type SIZEOF ADDRESS (CHARACTER); ITEM type ADDRESS (bar SIZEOF LONGWORD); |
DECLARE type SIZEOF ADDRESS (bar SIZEOF LONGWORD); |
Examples
A database contains information on a number of forests in a region, each of which contains a number of different types of trees. The definition of the tree structure is held in a different SDL file from the other definitions. When the second SDL file is compiled, the composition of the tree structure is unknown --- the definitions will only come together when the output files are included in a compilation in the target language.
The following shows the two SDL files and the corresponding output in C.
TREE1.SDL:
AGGREGATE tree STRUCTURE TYPEDEF; flink ADDRESS (tree); blink ADDRESS (tree); height LONGWORD; age LONGWORD; END; |
TREE2.SDL:
DECLARE tree SIZEOF (16); AGGREGATE forest STRUCTURE TYPEDEF; oak tree; ash tree; elm tree; confirs tree DIMENSION 6; END; ITEM tree_pointer ADDRESS (tree); ITEM tree_storage tree DIMENSION 1000; ITEM region forest DIMENSION 4; { No SIZEOF, since 'forest' defined here} |
TREE1.H:
typedef struct _tree { _tree *flink; _tree *blink; long int height; long int age; } tree; |
TREE2.H:
typedef struct _forest { tree oak; tree ash; tree elm; tree conifers[6]; } forest; tree *tree_pointer; tree tree_storage[1000]; forest region[4]; |
Note that the SIZEOF information is discarded by C, but is used by other languages, such as HP MACRO.
Previous | Next | Contents | Index |