Guide to the HP Structure Definition Language


Previous Contents Index


Chapter 2
Creating, Editing, and Processing a HP SDL Source File

This chapter describes how to create a HP SDL source file using the recommended HP Language-Sensitive Editor (LSE) text editor and how to process your source file using the SDL command and all its qualifiers.

You can use any text editor to create your source file, including EDT and TPU/EVE. LSE offers the advantages of being layered on TPU and of giving you the option of selecting either an EDT- or EVE-style keypad. In addition, LSE increases your productivity as a programmer by providing you with HP SDL language-specific templates to help you write your HP SDL source code.

Section 2.1.1 describes how to use the LSE templates to enter source code. Section 2.1.2 provides a tutorial to get you started using the LSE templates to write HP SDL source code. Section 2.1.3 describes how to compile your source code and use split-screen mode to review your .LIS and output files from within the LSE editing environment.

Section 2.2 describes the SDL command and the uses of the SDL command qualifiers.

For more information on the advanced features of LSE, see the Guide to HP Language-Sensitive Editor and HP Source Code Analyzer.

2.1 Creating a HP SDL Source File with LSE

To invoke LSE, issue the LSEDIT command followed by a file name with an .SDL file type at the DCL prompt. For example:


$ LSEDIT USER.SDL

Note

If you are unable to access HP SDL or LSE support for HP SDL, contact your system manager to ensure that they are installed on your system.

Section 2.1.1 describes how to enter source code using LSE, and Section 2.1.2 provides a tutorial on using the LSE templates to generate HP SDL source code. Section 2.1.3 describes LSE's compiler interface features.

2.1.1 Entering Source Code Using Placeholders and Tokens

LSE simplifies the tasks of developing and maintaining software systems. LSE provides the functions of a traditional text editor, plus these additional powerful features: language-specific placeholders and tokens, aliases, comment and indentation control, and templates for subroutine libraries.

Placeholders are markers in the source code that indicate locations where you can provide program text. Placeholders help you to supply the appropriate syntax in a given context. Generally, you do not need to type placeholders; rather, they are inserted for you by LSE.

Placeholders are either optional or required. Required placeholders, which are delimited by braces ({}), represent places in the source code where you must provide program text. Optional placeholders, which are delimited by brackets ([]), represent places in the source code where you can either provide additional constructs or delete the placeholder.

The following table describes the three types of LSE placeholders.
Type of Placeholder Description
Terminal Provides text that describes valid replacements for the placeholder
Nonterminal Expands into additional language constructs
Menu Provides a list of options corresponding to the placeholder

You can move forward or backward from placeholder to placeholder. In addition, you can delete or expand placeholders as needed. Section 2.1.2 shows examples of expanding placeholders.

Tokens typically represent keywords in HP SDL. When expanded, tokens provide additional language constructs. You can type tokens directly into the buffer. Generally, you use tokens when you want to add language constructs and there are no placeholders in an existing program. For example, typing AGGREGATE and issuing the EXPAND (CTRL/E) command causes a template for an AGGREGATE declaration to appear on your screen. You can also use tokens to bypass long menus in cases where expanding a placeholder, such as {statement}, will result in a lengthy menu.

You can use tokens to insert text when editing an existing file by typing the name for a function or keyword and pressing CTRL/E.

LSE commands allow you to manipulate tokens and placeholders. The following table shows the LSE commands and their default key bindings.
Command Key Binding Function
EXPAND [CTRL/E] Expands a placeholder
UNEXPAND [PF1]- [CTRL/E] Reverses the effect of the most recent placeholder expansion
GOTO PLACEHOLDER/FORWARD [CTRL/N] Moves the cursor to the next placeholder
GOTO PLACEHOLDER/REVERSE [CTRL/P] Moves the cursor to the previous placeholder
ERASE PLACEHOLDER/FORWARD [CTRL/K] Erases a placeholder
UNERASE PLACEHOLDER [PF1]- [CTRL/K] Restores the most recently erased placeholder
None []<downarrow symbol> Moves the indicator down through a menu
None []<uparrow symbol> Moves the indicator up through a menu
None { [ENTER]} or Selects a menu option
  { [RETURN]}  

You can display a list of all defined tokens and placeholders, or a particular token or placeholder, with the LSE commands SHOW TOKEN and SHOW PLACEHOLDER. To copy the listed information into a separate file, first issue the appropriate SHOW command to put the list into the $SHOW buffer. Then issue the following commands:


LSE> GOTO BUFFER $SHOW
LSE> WRITE filename

To obtain a hard copy of the list, use the PRINT command at DCL level to print the file you created.

2.1.2 Getting Started with the LSE Templates for HP SDL

This section provides a tutorial on using some common tokens and placeholders to write HP SDL source code. The tutorial shows expansions of the following HP SDL declarations and language elements:

Example 2-1 shows the sample HP SDL source file described in Chapter 1. You will be creating this sample source file in the following tutorial. The numbered callouts in the example correspond to the source code you will be entering in each step.

Following each step, intermediate and resulting screen displays highlight the source code you just entered.

As you step through the tutorial, refer to Section 2.1.1 for the commands that manipulate tokens and placeholders. You can also access online help by typing HELP at the LSE> prompt.

Remember that braces ({}) enclose required placeholders; brackets ([]) enclose optional placeholders. When you erase an optional placeholder, LSE also deletes any associated text before and after that placeholder.

Example 2-1 Creating a Sample HP SDL Source File Using LSE

 
MODULE opr_descriptor IDENT "Version 2.0";(1)
 
/* define constants and node structure for operators;(2)
 
#max_args = 10;(3)
 
CONSTANT (fixed_binary,floating,char,untyped) EQUALS 1 INCREMENT 1;(4)
 
AGGREGATE operator STRUCTURE 
    PREFIX "opr_";(5)
 
    flink ADDRESS;(6)
    blink ADDRESS; 
    opcount WORD; 
    optype CHARACTER LENGTH 1; 
    id WORD; 
    operands LONGWORD(7) DIMENSION 0:#max_args-1;(8)
 
END operator; 
 
#opsize = .;(9)
 
CONSTANT opr_node_size EQUALS #opsize / 2;(10)
 
ITEM current_node_ptr ADDRESS GLOBAL;(11)
 
END_MODULE opr_descriptor; 

Before starting the tutorial, invoke LSE and create a new HP SDL source file. The initial string, [module]...;, appears at the top of the screen. Expand the initial string by pressing CTRL/E, and the following appears on your screen:


[copyright-statement] 
MODULE {module-name} [ident-string]; 
[statement]...; 
END_MODULE [module-name]; 
[module]...; 

You may expand the [copyright-statement] placeholder, but for the purposes of this tutorial, it has been deleted by pressing CTRL/K.

  1. Move to the required placeholder {module-name} by pressing CTRL/N and type opr_descriptor. Then move to the optional placeholder [ident-string]. As you move the cursor, notice that LSE inserts the opr_descriptor module name for the END_MODULE name as well. Expand [ident-string] and type Version 2.0 over the resulting placeholder "[ident-text]". Your screen will look as follows:


  2. Move to the placeholder [statement] and press CTRL/E. LSE displays a menu of options. Press the down arrow (<downarrow symbol>) key to move the pointer to the menu option {output-comment} and press RETURN. Type define constants and node structure for operators over the placeholder [TBS]. Your screen will look as follows:


  3. Move to the placeholder [statement] and press CTRL/E. LSE displays a menu of options. Press the down arrow (<downarrow symbol>) key to move the pointer to the menu option {local-assignment} and press RETURN. Type max_args over the current placeholder {local-symbol}. Move to the placeholder {expression} and type the value 10. Your screen will looks as follows:

  4. Move to the placeholder [statement] and press CTRL/E. Press RETURN to select the menu option {constant-declaration} displayed on your screen. Your screen will look as follows:


    Press CTRL/E to expand the current placeholder {constant-definition}. Press the down arrow (<downarrow symbol>) key to move the pointer to the menu option "([constant-name]...) EQUALS {CONSTANT-expression} [increment-expression]" and press RETURN. Your screen will look as follows:


    Type fixed_binary, floating, char, and untyped over the current placeholder [constant-name]. Press CTRL/K to delete the last occurrence of the placeholder [constant-name]. Move to the placeholder {CONSTANT-expression} and type the value 1. Move to the placeholder [increment-expression] and press CTRL/E. Move to the resulting placeholder {expression} and type the value 1. Your screen will look as follows:
    Move to the three optional placeholders [prefix-declaration], [tag-declaration], and [counter-declaration] and delete each of them by pressing CTRL/K.


  5. Expand the current placeholder [statement]. Press the down arrow (<downarrow symbol>) key to move the pointer to the menu option {aggregate-declaration} and press RETURN. Your screen will look as follows:


    Move to the placeholder {aggregate-name} and type operator.
    Move to the placeholder {aggregate_type} and press CTRL/E. Press RETURN to select the menu option "STRUCTURE" displayed on your screen.
    Press CTRL/E to expand the current placeholder [aggregate-options]. Press RETURN to select the menu option {member-options} : PREFIX, TAG, OR DIMENSION displayed on your screen. Press RETURN again to select the new menu option {PREFIX-DECLARATION} : PREFIX.
    Type "opr_" over the current placeholder {prefix_string}. Your screen will look as follows:

  6. Move to the placeholder [aggregate-options] and press CTRL/K to delete it. Expand the current placeholder [member-declaration]. Press RETURN to select the menu option {member-name} {member-type} [member-options] displayed on your screen. Your screen will look as follows:


    Type the first member name flink over the current placeholder {member-name}. Move to the placeholder {member-type} and press CTRL/E. Press the down arrow (<downarrow symbol>) key to move the pointer to the menu option {address-declaration} : Address (pointer) datatype declaration and press RETURN. Press RETURN again to select the menu option "ADDRESS". Your screen will look as follows:

  7. Delete the current placeholder [member-options]. The cursor is now on the current placeholder [member-declaration]. Follow the steps described in the previous paragraph for the blink, opcount, optype, id, and operands members shown on each line in the example callout . Note the differences in syntax required for some of the member names. Your screen will look as follows:

  8. Press CTRL/E to expand the current placeholder [member-options]. Press the down arrow (<downarrow symbol>) key to select the menu option {dimension-declaration}. Press RETURN again to select the menu option "DIMENSION [lower-bound] {upper-bound}". Your screen will look as follows:


    Press CTRL/E to expand the current placeholder [lower-bound]. Expand the resulting current placeholder {bound-specifier} and type 0 over the resulting current placeholder {expression}:. Move to the placeholder {upper-bound} and press CTRL/E. Type #max_args-1; over the resulting current placeholder {expression}. Your screen will look as follows:
    Move to the optional placeholders [member-options] and [member-declaration] and press CTRL/K to delete each of them.


  9. Expand the current placeholder [statement]. Press the down arrow (<downarrow symbol>) key to move the pointer to the menu option {local-assignment} and press RETURN. Your screen will look as follows:


    Type opsize over the current placeholder {local-symbol}. Move to the placeholder {expression} and press CTRL/E. Press the down arrow (<downarrow symbol>) key to move the pointer to the menu option {offset-location-symbol} and press RETURN. Press RETURN again to select the new menu option {origin-byte-offset-symbol}. Your screen will look as follows:


  10. Expand the current placeholder [statement]. Press RETURN to select the menu option {constant-declaration} displayed at the top of the screen. Press CTRL/E to expand the current placeholder {constant-definition}. Press RETURN to select the menu option "{constant-name} EQUALS {CONSTANT-expression}". Your screen will look as follows:


    Type opr_node_size over the current placeholder {constant-name}. Move to the placeholder {CONSTANT-expression} and press CTRL/E. Press the down arrow (<downarrow symbol>) key to move the pointer to the menu option {expression} / {expression} and press RETURN. Type the expression #opsize over the resulting current placeholder {expression}. Move to the next placeholder {expression} and type the value 2. Your screen will look as follows:
    Move to the three optional placeholders [prefix-declaration], [tag-declaration], and [counter-declaration] and delete each of them by pressing CTRL/K.


  11. Expand the current placeholder [statement]. Press the down arrow (<downarrow symbol>) key to move the pointer to the menu option {item-declaration} and press RETURN. Your screen will look as follows:
    Type current_node_ptr over the current placeholder {item-name}. Move to the placeholder {item-data-type} and press CTRL/E. Select the menu option {address-declaration} and then press RETURN to select the menu option "ADDRESS". Press CTRL/E to expand the current placeholder [storage-class]. Move to the menu option "GLOBAL" and press RETURN. Press CTRL/K to delete the current placeholder [item-options]. Move to the placeholders [statement] and [module] and press CTRL/K to delete them.

Your resulting screen display should be the HP SDL source file shown in Example 2-1.

2.1.3 Compiling Source Code

You can compile your source code, review compilation errors, and view your output file without leaving the editing session by using the LSE command COMPILE with the SDL command and the /LIST qualifier. If you enter only the COMPILE command, a DCL command that invokes the HP SDL compiler is issued in a subprocess. For example:


LSE> COMPILE
STARTING COMPILATION: SDL/PARSE/LIST USER.SDL
COMPILATION OF BUFFER USER.SDL COMPLETED

The compiler generates a .LIS file of compile-time diagnostic information that you can review by entering the following command:


LSE> GOTO FILE USER.LIS

You have the option of entering split-screen mode first by typing the LSE command CHANGE WINDOW_MODE and then the GOTO FILE USER.LIS command. This allows you to view and compare your compilation errors in one window and then return to the other window to correct your source code.

To generate an output file from within LSE, you must use the COMPILE command with the SDL command as follows:


LSE> COMPILE SDL/LIST/LANG=BASIC
STARTING COMPILATION: SDL/LIST/LANG=BASIC USER.SDL
COMPILATION OF BUFFER USER.SDL COMPLETED

You can then view your output file from within LSE by issuing the following command:


LSE> GOTO FILE USER.BAS

LSE supports all of the HP SDL compiler's command qualifiers as well as user-supplied command procedures. You can specify DCL qualifiers, such as /LIBRARY, when invoking the compiler from LSE.

Section 2.2 describes how to process a HP SDL source file using the SDL command and all its qualifiers.

Note

HP SDL does not support the LSE command REVIEW. The HP SDL-generated .LIS file, which you can view from within LSE, gives you the capability to review compilation errors.


Previous Next Contents Index