Guide to VAX SCAN

*HyperReader

  CONTENTS

  Title Page

  Copyright Page

  Preface

  1      Introduction to VAX SCAN

  1.1     Understanding VAX SCAN

  1.2     Using VAX SCAN
    1.2.1      Creating a Pattern
    1.2.2      Creating Replacement Text
      1.2.2.1      Capturing Matched Text
      1.2.2.2      Constructing Replacement Text
      1.2.2.3      Reporting Replacement Text

  1.3     Getting Started with VAX SCAN
    1.3.1      Flow of Control in a VAX SCAN Program
    1.3.2      Token Building
    1.3.3      Picture Matching
    1.3.4      Input and Output Stream Forms
    1.3.5      VAX SCAN Variables
    1.3.6      VAX SCAN Trees

  1.4     Processing Text with VAX SCAN
    1.4.1      Filters
    1.4.2      Translators
    1.4.3      Extractors/Analyzers
    1.4.4      Preprocessors

  2      VAX SCAN Application Development

  2.1     Creating and Editing VAX SCAN Programs
    2.1.1      VAX Text Processing Utility
    2.1.2      VAX Language-Sensitive Editor

  2.2     Compiling, Linking, and Running Programs
    2.2.1      SCAN Command
    2.2.2      LINK Command
    2.2.3      RUN Command

  3      Elements of the VAX SCAN Language

  3.1     Program Form

  3.2     Character Set

  3.3     Names

  3.4     Keywords

  3.5     Literals
    3.5.1      Integer Literals
    3.5.2      Boolean Literals
    3.5.3      Pointer and Treeptr Literals
    3.5.4      String Literals
      3.5.4.1      Quoted String Literal
      3.5.4.2      Control Character Literals
      3.5.4.3      Special Character Literals
      3.5.4.4      Hexadecimal Character Literals

  3.6     Operators and Delimiters

  3.7     Spaces, Tabs, Comments, and Form Feeds

  4      Program Structure

  4.1     Statement Structure

  4.2     Macro Structure

  4.3     Procedure Structure

  4.4     Module Structure

  4.5     Scope

  5      Picture-Matching Statements

  5.1     SET Statement

  5.2     TOKEN Statement
    5.2.1      TOKEN Operators
    5.2.2      TOKEN Attributes
    5.2.3      Interaction of Tokens

  5.3     GROUP Statement

  5.4     Macros
    5.4.1      Macro Picture
      5.4.1.1      Alternation Operator ( | )
      5.4.1.2      Concatenation
      5.4.1.3      Repetition Operator ( . . . )
      5.4.1.4      List Operator ( \ )
      5.4.1.5      Optional Brackets ( [ ] )
      5.4.1.6      Operator Precedence
    5.4.2      TRIGGER and SYNTAX Attributes
    5.4.3      EXPOSE Attribute
    5.4.4      Picture Variables
    5.4.5      Interaction of Macros
      5.4.5.1      Criteria for Activating Trigger Macros
      5.4.5.2      Failure of Picture Matching
    5.4.6      Error Recovery
      5.4.6.1      Error Recovery Procedures
      5.4.6.2      Error Recovery Hints
    5.4.7      Macro Body

  6      Input and Output Streams

  6.1     Input and Output Stream Form
    6.1.1      File as Input or Output Stream
    6.1.2      String as Input or Output Stream
    6.1.3      Procedure as Input or Output Stream

  6.2     VAX SCAN Literals in the Input Stream

  6.3     VAX SCAN Literals in the Output Stream

  6.4     Redefining the VAX SCAN Literals

  6.5     The Width of the Input and Output Streams

  7      Variables

  7.1     Integer Variables

  7.2     Boolean Variables

  7.3     String Variables

  7.4     Fill Variables

  7.5     Pointer Variables

  7.6     Tree Variables

  7.7     Treeptr Variables

  7.8     Record Variables

  7.9     Overlay Variables

  7.10    File Variables

  8      Declaration of Variables

  8.1     Specification of Variable Type

  8.2     DECLARE Statement

  8.3     TYPE Statement

  8.4     CONSTANT Statement

  9      Procedures

  9.1     PROCEDURE Declaration
    9.1.1      Parameters
    9.1.2      Passing Mechanisms

  9.2     EXTERNAL PROCEDURE Declaration

  9.3     FORWARD PROCEDURE Declaration

  10     Expressions

  10.1    Operators
    10.1.1     Substring Operator
    10.1.2     Arithmetic Operators
    10.1.3     Concatenation
    10.1.4     Relational Operators
    10.1.5     Logical Operators

  10.2    References
    10.2.1     Scalar Reference
    10.2.2     Record Reference
    10.2.3     Tree Reference
    10.2.4     Function Reference
    10.2.5     Built-In Function Reference
    10.2.6     Pointer Reference

  10.3    Expression Operator Precedence

  11     Built-In Facilities

  11.1    Built-In Tokens
    11.1.1     ANY Built-In Token
    11.1.2     COLUMN Built-In Token
    11.1.3     FIND Built-In Token
    11.1.4     INSTANCE Built-In Token
    11.1.5     NOTANY Built-In Token
    11.1.6     SEQUENCE Built-In Token
    11.1.7     SKIP Built-In Token

  11.2    Built-In Functions
    11.2.1     Tree Traversing Built-In Functions
      11.2.1.1     TREEPTR Built-In Function
      11.2.1.2     EXISTS Built-In Function
      11.2.1.3     FIRST Built-In Function
      11.2.1.4     LAST Built-In Function
      11.2.1.5     NEXT Built-In Function
      11.2.1.6     PRIOR Built-In Function
      11.2.1.7     VALUE Built-In Function
      11.2.1.8     VALUEPTR Built-In Function
      11.2.1.9     SUBSCRIPT Built-In Function
    11.2.2     String Built-In Functions
      11.2.2.1     INDEX Built-In Function
      11.2.2.2     LENGTH Built-In Function
      11.2.2.3     LOWER Built-In Function
      11.2.2.4     UPPER Built-In Function
      11.2.2.5     MEMBER Built-In Function
      11.2.2.6     TRIM Built-In Function
    11.2.3     Conversion Built-In Functions
      11.2.3.1     INTEGER Built-In Function
      11.2.3.2     STRING Built-In Function
      11.2.3.3     POINTER Built-In Function
    11.2.4     Mathematical Built-In Functions
      11.2.4.1     ABS Built-In Function
      11.2.4.2     MAX Built-In Function
      11.2.4.3     MIN Built-In Function
      11.2.4.4     MOD Built-In Function
    11.2.5     Other Built-In Functions
      11.2.5.1     ENDFILE Built-In Function
      11.2.5.2     TIME Built-In Function

  12     Executable Statements

  12.1    Labels

  12.2    Assignment Statements
    12.2.1     Assigning to a Substring
    12.2.2     Assigning to a Record or Overlay (Record Compatibility)

  12.3    CALL Statement

  12.4    GOTO Statement

  12.5    CASE Statement

  12.6    IF Statement

  12.7    WHILE Statement

  12.8    FOR Statement

  12.9    RETURN Statement

  12.10  START SCAN Statement
    12.10.1    INPUT FILE Clause
    12.10.2    INPUT PROCEDURE Clause
    12.10.3    INPUT STRING Clause
    12.10.4    OUTPUT FILE Clause
    12.10.5    OUTPUT PROCEDURE Clause
    12.10.6    OUTPUT STRING Clause
    12.10.7    INPUT WIDTH Clause
    12.10.8    OUTPUT WIDTH Clause
    12.10.9    DATA STACK Clause

  12.11  STOP SCAN Statement

  12.12  ANSWER Statement
    12.12.1    TRIGGER Attribute

  12.13  FAIL Statement

  12.14  OPEN Statement

  12.15  CLOSE Statement

  12.16  READ Statement

  12.17  WRITE Statement

  12.18  ALLOCATE Statement

  12.19  FREE Statement

  12.20  PRUNE Statement

  13     Directive Statements

  13.1    LIST Directive

  13.2    INCLUDE Directive

  13.3    REDEFINE Directive

  14     V AX/VMS Run-Time Library Routines and System Services

  14.1    VMS Run-Time Library Routines

  14.2    System Services Routines

  14.3    Calling System Routines from VAX SCAN
    14.3.1     Determine the Type of Call (Procedure or Function)
    14.3.2     Declare the Arguments
    14.3.3     Declare the System Routine
    14.3.4     Include Symbol Definitions
    14.3.5     Call the Routine or Service
      14.3.5.1     Calling a System Routine in a Function Call
      14.3.5.2     Calling a System Routine in a Subroutine Call
    14.3.6     Check the Condition Value
    14.3.7     Locate the Result
      14.3.7.1     Function Results
      14.3.7.2     Subroutine Results

  14.4    Examples

  14.5    For Additional Information

  15     Error Messages and HELP

  15.1    Error Messages

  15.2    Accessing VAX SCAN HELP

  16     Debugging VAX SCAN Programs

  16.1    Activating the VMS Debugger

  16.2    VAX SCAN Symbolic Debugging
    16.2.1     VAX SCAN Elements Available for Debugging
      16.2.1.1     Names
      16.2.1.2     Line Numbers
    16.2.2     Controlling Program Execution
      16.2.2.1     Breakpoints and Tracepoints
      16.2.2.2     Break on Event and Trace on Event
      16.2.2.3     Watchpoints
    16.2.3     Examining and Depositing
      16.2.3.1     STRING Variables
      16.2.3.2     FILL Variables
      16.2.3.3     POINTER Variables
      16.2.3.4     TREE and TREEPTR Variables
      16.2.3.5     RECORD and OVERLAY Variables

  16.3    Sample Debugging Session

  A   VAX SCAN Control Characters

  B   Syntax Diagrams

  B.1     Executable Statements
    B.1.1     ALLOCATE-statement
    B.1.2     ANSWER-statement
    B.1.3     Assignment-statement
    B.1.4     CALL-statement
    B.1.5     CASE-statement
    B.1.6     CLOSE-statement
    B.1.7     FAIL-statement
    B.1.8     FOR-statement
    B.1.9     FREE-statement
    B.1.10    GOTO-statement
    B.1.11    IF-statement
    B.1.12    OPEN-statement
    B.1.13    PRUNE-statement
    B.1.14    READ-statement
    B.1.15    RETURN-statement
    B.1.16    START-SCAN-statement
    B.1.17    STOP-SCAN-statement
    B.1.18    WHILE-statement
    B.1.19    WRITE-statement

  B.2     Types
    B.2.1     OVERLAY-type
    B.2.2     RECORD-type
    B.2.3     TREE-type

  B.3     Declarations
    B.3.1     CONSTANT-declaration
    B.3.2     EXTERNAL-declaration
    B.3.3     FORWARD-declaration
    B.3.4     GROUP-declaration
    B.3.5     MACRO-declaration
    B.3.6     MODULE-declaration
    B.3.7     PROCEDURE-declaration
    B.3.8     SET-declaration
    B.3.9     TOKEN-declaration
    B.3.10    TYPE-declaration
    B.3.11    Variable-declaration

  B.4     Directives
    B.4.1     INCLUDE-directive
    B.4.2     LIST-directive
    B.4.3     REDEFINE-directive

  C   VAX SCAN Keywords

  D   VAX SCAN File Support

  E   DEC Multinational Character Set

  F   Optional Programming Productivity Tools

  F.1     Getting Started with the VAX Language-Sensitive Editor

  F.2     Commands for Tokens and Placeholders

  F.3     Creating and Editing Code
    F.3.1      Editing a New File
    F.3.2      Editing an Existing File
    F.3.3      Defining Aliases
    F.3.4      Using the Compiler Interface
      F.3.4.1      The COMPILE Command
      F.3.4.2      The REVIEW Command
      F.3.4.3      REVIEW Mode
    F.3.5      LSE Command Line
    F.3.6      Editor Command Line Qualifiers
    F.3.7      Keypad Functions

  F.4     Using the VAX Language-Sensitive Editor with VAX SCAN

  F.5     Sample Editing Session
    F.5.1      Module and Token Declarations
    F.5.2      Macros
    F.5.3      Creating a MAIN Procedure
    F.5.4      Creating a Function
    F.5.5      Variable Declarations
    F.5.6      Control Structures

  F.6     VAX Language-Sensitive Editor Tokens and Placeholders for VAX SCAN

  F.7      Using the VAX Source Code Analyzer
    F.7.1      Multimodular Development
    F.7.2      Setting Up an SCA Environment
      F.7.2.1      Creating an SCA Library
      F.7.2.2      Generating Data Analysis Files
      F.7.2.3      Loading Data Analysis Files into a Local Library
      F.7.2.4      Selecting an SCA Library
    F.7.3      Using SCA for Cross-Referencing

  EXAMPLES

  1-1        Search and Replace Macro

  1-2        CHANGE_TIMES Program

  1-3        Variable Declaration Placement

  1-4        Declaring a TREE Structure

  1-5        Assigning TREE Values

  2-1        VAX Language-Sensitive Editor Program

  4-1        VAX SCAN Macro

  4-2        VAX SCAN Procedure

  4-3        VAX SCAN Module

  4-4        Scope

  5-1        SET Declarations

  5-2        TOKEN Declarations

  5-3        Alternation

  5-4        Concatenation

  5-5        Repetition

  5-6        List

  5-7        MACRO Interaction

  5-8        Picture Variables

  5-9        Tree Subscripts and Repetition

  5-10       List Operator

  5-11       MACRO Scope

  5-12       Error Context

  5-13       Error Recovery Procedure

  5-14       Error Recovery Packet

  6-1        String as Input Stream

  6-2        Procedure as Input Stream

  6-3        Special VAX SCAN Characters in Input Stream

  6-4        Linked List in Input Stream

  7-1        Integer Variable

  7-2        Boolean Variable

  7-3        String Variables

  7-4        Fill Variable

  7-5        Pointer Variables

  7-6        Tree Traversing

  7-7        Tree Traversing Using TREEPTR

  7-8        Record Variables

  7-9        Record Variable Component Names

  7-10       Comparison of a Record Variable with an Overlay Variable

  7-11       Use of Overlay Variables

  7-12       File Variables

  8-1        Variable Declarations

  8-2        User-Defined Type Declaration

  8-3        User-Defined Variable Type

  8-4        Multiple Reference of User-Defined Type

  8-5        Local Constant Declarations

  8-6        Global Constant Declarations

  8-7        External Constant Declarations

  8-8        Naming Literal Constants

  9-1        Procedure Subroutine

  9-2        Procedure Function

  9-3        Procedure Invocation

  9-4        Parameter Passing in Procedures

  9-5        EXTERNAL PROCEDURE Declarations

  9-6        FORWARD PROCEDURE Declaration

  10-1       Creating New Values with Expressions

  10-2       Logical Operators

  10-3       Logical Operators Used with Integer Operands

  10-4       Variable References

  10-5       Scalar Variable Reference

  10-6       Record Reference

  10-7       Tree Reference

  10-8       Passing a Tree as a Parameter

  10-9       Function Reference

  10-10      Built-In Function Reference

  10-11      Pointer Reference

  10-12      Pointer to Dynamically Allocated Storage

  11-1       Use of FIND Built-In Token

  11-2       Use of INSTANCE Built-In Token

  11-3       Use of NOTANY Built-In Token

  11-4       Use of SEQUENCE Built-In Token

  11-5       Use of SKIP Built-In Token

  11-6       Tree Traversing Code Example

  11-7       Use of TREEPTR Built-In Function

  11-8       Using Built-In Functions to Traverse a Tree

  11-9       Use of Tree Built-In Functions

  11-10      Use of POINTER Built-In Function

  11-11      Use of ENDFILE Built-In Function

  11-12      Use of TIME Built-In Function

  12-1       Program Labels

  12-2       Assignment Statements

  12-3       Substring Assignment

  12-4       Assigning to a Record

  12-5       Record Compatibility

  12-6       CALL Statement

  12-7       GOTO Statement

  12-8       CASE Statement

  12-9       IF . . . THEN . . . ELSE Statement

  12-10      WHILE Statement

  12-11      FOR Loop

  12-12      RETURN Statement

  12-13      File as Input Stream

  12-14      Procedure as Input Stream

  12-15      String as Input Stream

  12-16      File as Output Stream

  12-17      Procedure as Output Stream

  12-18      String Variable as Output Stream

  12-19      ANSWER Statement

  12-20      ANSWER Attribute Program Segment

  12-21      Using EXPOSE to Enable ANSWER Rechecking

  12-22      Using TRIGGER Attribute to Enable ANSWER Rechecking

  12-23      FAIL Statement

  12-24      OPEN Statement

  12-25      READ Statement with PROMPT

  12-26      Use of ENDFILE with READ Statement

  12-27      WRITE Statement

  12-28      ALLOCATE Statement

  12-29      FREE Statement

  13-1       LIST Directive

  13-2       REDEFINE Directive

  14-1       VAX SCAN Program Calling LIB$FIND_FILE

  14-2       VAX SCAN Program Calling SYS$FILESCAN

  FIGURES

  1-1        VAX SCAN Application Flow

  1-2        VAX SCAN Module Structure

  1-3        Token Stream

  1-4        Nesting of Program Blocks

  1-5        TREE Structure

  1-6        Sample TREE

  4-1        Program Structure

  5-1        The Hierarchy of SCAN Language Constructs

  5-2        TOKEN Mapping

  5-3        UNIVERSAL TOKEN Building

  7-1        Tree Diagram

  7-2        Modified Tree Diagram

  7-3        Keyword Tree

  7-4        Overlay Storage

  10-1       Use of Substring Operators

  10-2       Use of Arithmetic Operators

  10-3       Results of Concatenation

  10-4       Use of Relational Operators

  11-1       Tree Structure

  11-2       Tree References

  11-3       Use of EXISTS Built-In Function

  11-4       Use of FIRST Built-In Function

  11-5       Use of LAST Built-In Function

  11-6       Use of NEXT Built-In Function

  11-7       Use of PRIOR Built-In Function

  11-8       Use of VALUE Built-In Function

  11-9       Use of VALUEPTR Built-In Function

  11-10      Use of SUBSCRIPT Built-In Function

  11-11      Use of INDEX Built-In Function

  11-12      Use of LENGTH Built-In Function

  11-13      Use of LOWER Built-In Function

  11-14      Use of UPPER Built-In Function

  11-15      Use of MEMBER Built-In Function

  11-16      Use of TRIM Built-In Function

  11-17      Use of INTEGER Built-In Function

  11-18      Use of STRING Built-In Function

  11-19      Use of ABS Built-In Function

  11-20      Use of MAX Built-In Function

  11-21      Use of MIN Built-In Function

  11-22      Use of MOD Built-In Function

  12-1       Estimation of Buffer Size for DATA STACK

  12-2       PRUNE Statement

  16-1       Structure of VOTER Tree

  F-1        Initial Screen Display

  F-2        VAX Language-Sensitive Editor Keypad Layout for VT100 Series Terminals

  F-3        VAX Language-Sensitive Editor Keypad Layout for VT200 Series Terminals

  F-4        Expansion of Initial String

  F-5        First Placeholder

  F-6        TOKEN Selected

  F-7        Pattern Provided for Token

  F-8        MACRO Expanded

  F-9        Macro Picture Created

  F-10       ANSWER Expanded

  F-11       Macro Completed

  F-12       PROCEDURE expanded

  F-13       Ready to Create Main Procedure Body

  F-14       START Expanded

  F-15       INPUT FILE Selected

  F-16       OUTPUT FILE Selected

  F-17       Beginning of Module

  F-18       PROCEDURE expanded

  F-19       Adding Parameters to a Procedure

  F-20       Parameter Added

  F-21       Ready to Create the Procedure Body

  F-22       DECLARE expanded

  F-23       INTEGER_TYPE Selected

  F-24       FOR expanded

  F-25       LENGTH Built-In Function

  F-26       Limit Added to FOR Loop

  F-27       MEMBER Built-In Function

  F-28       Condition of IF Statement

  F-29       RETURN Expanded

  F-30       Completed Module

  TABLES

  1 Conventions Table

  1-1        Picture Segments and Their Meanings

  3-1        Character Set

  3-2        Equivalent Symbols

  3-3        Reserved Keywords

  3-4        Unreserved Keywords

  3-5        Control Characters

  3-6        Special VAX SCAN Characters

  3-7        Delimiters

  5-1        SET Operator Precedence

  5-2        TOKEN Operator Precedence

  5-3        GROUP Operator Precedence

  5-4        Picture Operators

  5-5        Picture Variable Contents

  5-6        Error Recovery Packet Meaning

  7-1        Record Variable Initial Value

  7-2        File Variable Operations

  9-1        Procedure Parameter Types

  9-2        Parameter-Passing Mechanisms

  10-1       Expression Operators

  10-2       Substring Operator Forms

  10-3       Substring Operator Restrictions

  10-4       Relational Operator Rules

  10-5       Logical Operators

  10-6       Pointer Reference Meanings

  10-7       Expression Operator Precedence

  11-1       Built-In Tokens

  11-2       Built-In Functions

  11-3       Integer Conversion Results

  11-4       String Conversion Results

  12-1       VAX SCAN Executable Statements

  12-2       Assignment Statement Requirements

  12-3       Assignment Operand Restrictions

  12-4       Case Values

  12-5       START SCAN Options

  12-6       READ Statement Target Variables

  12-7       Initialization Value for Variable Types

  13-1       VAX SCAN Directive Statements

  13-2       Listing Options

  13-3       VAX SCAN Special Characters

  14-1       VMS Run-Time Library Facilities

  14-2       Groups of VMS System Services

  14-3       VMS Data Structures

  14-4       Default Passing Mechanisms in VAX SCAN

  14-5       Overriding the Default Passing Mechanism

  16-1       DEBUG Command Qualifiers

  A-1        VAX SCAN Control Characters

  C-1        Reserved Keywords

  C-2        Unreserved Keywords

  D-1        FDL Description for VAX SCAN Input File

  D-2        FDL Description for VAX SCAN Output File

  E-1        DEC Multinational Character Set

  F-1        Editor Command Line Qualifiers

  F-2        Default Editor Keypad Functions

  F-3        Editor Line Mode Commands

  F-4        LSE Navigation Commands