VAXELN Pascal Language Reference Manual

*HyperReader

  CONTENTS

  Title Page

  Copyright Page

  Preface

  1      Introduction

  1.1     Overview of VAXELN Pascal
    1.1.1      Program Structure
    1.1.2      Declarations
    1.1.3      Data Types
    1.1.4      Constants, Variables, and Expressions
    1.1.5      Executable Statements
    1.1.6      Routines

  1.2     Lexical Elements
    1.2.1      Character Set
    1.2.2      Special Symbols
      1.2.2.1      Delimiters
      1.2.2.2      Operators
    1.2.3      Reserved Words
    1.2.4      Identifiers

  1.3     Spaces and Comments

  1.4     %INCLUDE

  1.5     Lines and Line Numbers

  2      Program Structure

  2.1     Program Structure Overview

  2.2     Compilation Units

  2.3     Modules
    2.3.1      Module Headers
    2.3.2      EXPORT Headers
    2.3.3      IMPORT Headers
    2.3.4      INCLUDE Headers
    2.3.5      Exported Symbols and the Linker

  2.4     Program Block
    2.4.1      Program Arguments

  2.5     Process Blocks
    2.5.1      Process Block Arguments
    2.5.2      Calling Conventions for Process Blocks

  2.6     Interrupt Service Routines

  2.7     Routine Bodies
    2.7.1      Routine Body Activation, Stack Frames, and Termination
    2.7.2      UNDERFLOW and NOUNDERFLOW Attributes

  2.8     Scope of Declarations
    2.8.1      Block Structure
    2.8.2      Definition of Scopes
      2.8.2.1      Routine Parameters
      2.8.2.2      Extent Parameters
      2.8.2.3      Field Names
      2.8.2.4      Names Established by the WITH Statement
      2.8.2.5      Module Names
    2.8.3      Order of Declarations - Circularity

  3      Declarations

  3.1     Label Declarations

  3.2     Constant Declarations

  3.3     Type Declarations

  3.4     Variable Declarations
    3.4.1      READONLY Attribute for Variables
    3.4.2      VALUE Attribute
    3.4.3      EXTERNAL Attribute

  4      Data Types

  4.1     Ordinal Types
    4.1.1      INTEGER Data Type
      4.1.1.1      Internal Representation of INTEGER Data
    4.1.2      CHAR Data Type
      4.1.2.1      Internal Representation of CHAR Data
    4.1.3      BOOLEAN Data Type
      4.1.3.1      Internal Representation of BOOLEAN Values
    4.1.4      Enumerated Types
      4.1.4.1      Internal Representation of Enumerated Data
    4.1.5      Subrange Types

  4.2     Real Types
    4.2.1      REAL Data Type
      4.2.1.1      Internal Representation of REAL Data
    4.2.2      DOUBLE Data Type
      4.2.2.1      Internal Representation of DOUBLE Data

  4.3     Structured Data Types
    4.3.1      Record Types
      4.3.1.1      Record Type Definitions
      4.3.1.2      Operations on Records
      4.3.1.3      Records with Variants
      4.3.1.4      Allocating Records with Selected Variants
      4.3.1.5      Internal Representation of Records
      4.3.1.6      POS Attribute
    4.3.2      Array Types
      4.3.2.1      Array Type Definitions
      4.3.2.2      Declaration of Arrays with Varying Extents
      4.3.2.3      Array Operations
      4.3.2.4      Internal Representation of Arrays
      4.3.2.5      Packed Arrays
    4.3.3      Set Types
      4.3.3.1      Set Type Definitions
      4.3.3.2      Internal Representation of Sets
      4.3.3.3      Packed Sets
    4.3.4      File Types
      4.3.4.1      File Type Definitions
      4.3.4.2      Restrictions on File Variables
      4.3.4.3      Internal Representation of File Data

  4.4     Flexible Types
    4.4.1      STRING Data Type
      4.4.1.1      Internal Representation of STRING Data
      4.4.1.2      Strings and the Data Type CHAR
    4.4.2      VARYING_STRING Data Type
      4.4.2.1      Internal Representation of VARYING_STRING Data
    4.4.3      BYTE_DATA Data Type
    4.4.4      Flexible Type Definitions
    4.4.5      Bound Flexible Types
    4.4.6      Flexible Type Examples
    4.4.7      Extent Expressions

  4.5     Pointer Types
    4.5.1      Pointer Type Definitions
    4.5.2      Internal Representation of Pointers
    4.5.3      ANYTYPE Data Type

  4.6     LARGE_INTEGER Data Type
    4.6.1      Internal Representation of LARGE_INTEGER Data

  4.7     Queue Data Types
    4.7.1      QUEUE_ENTRY Data Type
    4.7.2      QUEUE_POSITION Data Type

  4.8     System Data Types
    4.8.1      PROCESS Data Type
      4.8.1.1      Internal Representation of PROCESS Values
      4.8.1.2      PROCESS Data Type Example
    4.8.2      SEMAPHORE Data Type
      4.8.2.1      Internal Representation of SEMAPHORE Values
      4.8.2.2      SEMAPHORE Data Type Example
    4.8.3      MUTEX Data Type
      4.8.3.1      Internal Representation of Mutexes
      4.8.3.2      MUTEX Data Type Example
    4.8.4      AREA Data Type
      4.8.4.1      Internal Representation of AREA Values
      4.8.4.2      AREA Data Type Example
    4.8.5      AREA_LOCK_VARIABLE Data Type
      4.8.5.1      Internal Representation of AREA_LOCK_VARIABLE Values
      4.8.5.2      AREA_LOCK_VARIABLE Data Type Example
    4.8.6      EVENT Data Type
      4.8.6.1      Internal Representation of EVENT Values
      4.8.6.2      EVENT Data Type Example
    4.8.7      MESSAGE Data Type
      4.8.7.1      Internal Representation of MESSAGE Values
      4.8.7.2      MESSAGE Data Type Example
    4.8.8      PORT Data Type
      4.8.8.1      Internal Representation of PORT Values
      4.8.8.2      PORT Data Type Example
    4.8.9      NAME Data Type
      4.8.9.1      Internal Representation of NAME Values
      4.8.9.2      NAME Data Type Example
    4.8.10     DEVICE Data Type
      4.8.10.1     Internal Representation of DEVICE Values
      4.8.10.2     DEVICE Data Type Example

  4.9     Type Equivalence
    4.9.1      Ordinal Types
    4.9.2      Record Types
    4.9.3      Array Types
    4.9.4      Set Types
    4.9.5      File Types
    4.9.6      Flexible Types
    4.9.7      Predeclared Flexible Types
    4.9.8      Pointer Types
    4.9.9      Predeclared Nonflexible Types

  4.10    Data Representation
    4.10.1     Boundary Requirement
    4.10.2     Data Size
    4.10.3     Packed Data
    4.10.4     Data Size Attributes
      4.10.4.1     BIT Attribute
      4.10.4.2     BYTE Attribute
      4.10.4.3     WORD Attribute
      4.10.4.4     LONG Attribute
    4.10.5     ALIGNED Attribute

  5      Constants

  5.1     Literal Constants
    5.1.1      Literal Integer Constants
      5.1.1.1      Decimal Integers
      5.1.1.2      Binary, Octal, and Hexadecimal Integers
    5.1.2      Literal Floating-Point Constants
    5.1.3      Literal Character Constants
    5.1.4      Literal String Constants
      5.1.4.1      Nonprinting Characters in Constants

  5.2     Named Constants

  5.3     Limited Ordinal Constants

  5.4     Initializers
    5.4.1      Constant Initializers
    5.4.2      Concatenated String Constants
    5.4.3      Set Initializers
    5.4.4      NIL
    5.4.5      ZERO Function
    5.4.6      Aggregate Initializers
    5.4.7      Effects of Initializers

  5.5     Predeclared Named Constants
    5.5.1      Predeclared Enumerated Types

  6      Variables

  6.1     Variable References
    6.1.1      Indexed Variable References
    6.1.2      Field References
    6.1.3      Pseudovariable References
    6.1.4      Indirect Variable References
    6.1.5      Buffer Variable References
    6.1.6      Typecast Variable References
    6.1.7      Addressability of Variable References

  6.2     Storage Allocation

  6.3     Using Variables for Interprocess Data Sharing

  7      Expressions and Operators

  7.1     Expression Syntax
    7.1.1      Factors
    7.1.2      Terms
    7.1.3      Simple Expressions
    7.1.4      Expressions
    7.1.5      Operator Precedence and Associativity
      7.1.5.1      Precedence
      7.1.5.2      Associativity

  7.2     Side Effects in Expressions

  7.3     Arithmetic Operators
    7.3.1      Operands of Different Types
    7.3.2      Overflow and Underflow
    7.3.3      Addition, Subtraction, Multiplication, Sign Inversion, and Identity
    7.3.4      Exponentiation
    7.3.5      Division
    7.3.6      Modulus

  7.4     Boolean Operators

  7.5     Relational Operators
    7.5.1      Equality (=) and Inequality (<>)
    7.5.2      Other Relational Operators (<, >, <=, >=)
    7.5.3      Set Membership (IN)

  7.6     Set Operators
    7.6.1      Set Constructors

  7.7     Concatenation Operator for Strings

  8      Pascal Statements

  8.1     Statement Syntax
    8.1.1      Labels

  8.2     Assignment Statement
    8.2.1      Assignment Compatibility

  8.3     Null Statement

  8.4     Compound Statement

  8.5     Conditional Statements
    8.5.1      CASE Statement
    8.5.2      IF Statement

  8.6     Repetitive Statements
    8.6.1      FOR Statement
    8.6.2      REPEAT Statement
    8.6.3      WHILE Statement

  8.7     WITH Statement

  8.8     GOTO Statement

  8.9     Procedure Calls

  9      Procedures and Functions

  9.1     Procedure and Function Declarations
    9.1.1      Procedure and Function Headings
    9.1.2      Parameter Lists
      9.1.2.1      Value Parameters
      9.1.2.2      Variable Parameters
      9.1.2.3      Procedural Parameters
    9.1.3      Function Result
    9.1.4      Directives
      9.1.4.1      SEPARATE Directive
      9.1.4.2      EXTERNAL Directive
      9.1.4.3      FORWARD Directive
      9.1.4.4      PROCEDURE_TYPE and FUNCTION_TYPE Directives
    9.1.5      Inline Procedures and Functions
      9.1.5.1      Restrictions on Inline Procedures and Functions

  9.2     Procedure and Function Calls
    9.2.1      Argument Lists
    9.2.2      Calls to Predeclared Routines

  9.3     Parameters and Argument Passing
    9.3.1      Variable Parameters
      9.3.1.1      Type Compatibility for Variable Parameters and Arguments
    9.3.2      Value Parameters
      9.3.2.1      READONLY Value Parameters
      9.3.2.2      Type Compatibility for Value Parameters and Arguments
      9.3.2.3      Argument Copying and Use of READONLY
    9.3.3      Procedural Parameters
      9.3.3.1      Compatibility for Procedural Parameters and Arguments
    9.3.4      Conformant Parameters
      9.3.4.1      Conformance Rules
      9.3.4.2      ISO Conformant Extents
    9.3.5      Optional Variable and Procedural Parameters
    9.3.6      LIST Parameters

  9.4     Calling Conventions
    9.4.1      Procedures
      9.4.1.1      Variable Parameter
      9.4.1.2      Procedural Parameter
      9.4.1.3      Value Parameter
    9.4.2      Function Results
    9.4.3      Conformant Parameters
    9.4.4      REFERENCE Attribute

  10     Input and Output

  10.1    Files
    10.1.1     File Component Types
    10.1.2     File States - Open and Closed
      10.1.2.1     Opening Files
      10.1.2.2     Closing Files
    10.1.3     File Modes - Inspection and Generation
    10.1.4     Buffer Variables
    10.1.5     Current Position

  10.2    Internal Files

  10.3    Text Files
    10.3.1     Text Files in Inspection Mode
    10.3.2     Text Files in Generation Mode

  10.4    File Operations

  10.5    Terminal I/O
    10.5.1     Handling Delayed Access to Terminal I/O
    10.5.2     Redirecting Terminal I/O
    10.5.3     Pascal I/O Exception Handling

  11     Queues

  11.1    Declaring a Queue Header

  11.2    Declaring Queue Entries

  11.3    Initializing a Queue

  11.4    Inserting and Removing Queue Entries

  11.5    Clearing a Queue
    11.5.1     Walking Through a Queue

  12     Exception Handlers

  12.1    EXCEPTION_HANDLER Function Type
    12.1.1     Exception Arguments and Types
      12.1.1.1     Signal Arguments
      12.1.1.2     Mechanism Arguments
      12.1.1.3     Additional Arguments
    12.1.2     Exception Handler Examples

  12.2    Exception-Handler Operations

  12.3    Exception Names and Status Values

  13     VAXELN Pascal Routines

  13.1    Summary of VAXELN Pascal Routines

  13.2    VAXELN Pascal Routine Calls

  ABS

  ADDRESS

  ARCTAN

  ARGUMENT

  ARGUMENT_LIST_LENGTH

  BIN

  CHR

  CLOSE

  CONVERT

  COS

  DISPOSE

  EOF

  EOLN

  EXP

  FIND

  FIND_FIRST_BIT_CLEAR

  FIND_FIRST_BIT_SET

  FIND_MEMBER

  FIND_NONMEMBER

  FLUSH

  GET

  GET_CONTROL_KEY

  HEX

  INDEX

  INVOKE

  LENGTH

  LN

  LOCATE

  MOVE_PSL

  NEW

  OCT

  ODD

  OPEN

  ORD

  PACK

  PAGE

  PRED

  PRESENT

  PROBE_READ

  PROBE_WRITE

  PROGRAM_ARGUMENT

  PROGRAM_ARGUMENT_COUNT

  PUT

  READ

  READLN

  RESET

  REWRITE

  ROUND

  SIN

  SIZE

  SQR

  SQRT

  SUBSTR

  SUCC

  TOTAL_ARGUMENT_COUNT

  TRANSLATE_STRING

  TRUNC

  UNPACK

  WRITE

  WRITELN

  XOR

  ZERO

  14     Developing VAXELN Pascal Programs

  14.1    Compiling VAXELN Pascal Programs

  14.2    Using Qualifiers to Control the Compiler
    14.2.1     Enabling Assertion and Range Checking (/CHECK)
    14.2.2     Generating a Cross-Reference Listing (/CROSS_REFERENCE)
    14.2.3     Including Debugging Information in the Object Module (/DEBUG)
    14.2.4     Suppressing the Generation of an Export Symbol Table (/NOEXPORT)
    14.2.5     Using G_Floating Format (/G_FLOATING)
    14.2.6     Including Modules in the Compilation (/INCLUDE)
    14.2.7     Disabling the INLINE Attribute (/NOINLINE)
    14.2.8     Including Object Module Libraries in the Compilation (/LIBRARY)
    14.2.9     Generating and Suppressing a Listing File (/LIST, /NOLIST)
    14.2.10    Including Machine Code in the Listing File (/MACHINE_CODE)
    14.2.11    Including a Storage Map in the Listing File (/MAP)
    14.2.12    Including an Object Module in the Compilation (/MODULE)
    14.2.13    Naming and Suppressing the Object File (/OBJECT)
    14.2.14    Disabling Compiler Optimizations (/NOOPTIMIZE)
    14.2.15    Specifying Items for Inclusion in the Listing File (/SHOW)
    14.2.16    Specifying the Level of Version Consistency Checking (/VALIDATE)
    14.2.17    Disabling Warning Messages (/NOWARNINGS)

  14.3    Managing Modules
    14.3.1     Including Modules in a Compilation
    14.3.2     Module Dependencies and Consistency Checking

  14.4    Linking VAXELN Pascal Programs

  A   Attributes

  B   VAX Language-Sensitive Editor

  B.1     Entering Source Code
    B.1.1     EXPAND Command
    B.1.2     GOTO PLACEHOLDER Command
    B.1.3     ERASE PLACEHOLDER Command

  B.2     Getting Started
    B.2.1     Editing a New File
    B.2.2     Editing an Existing File

  B.3     Aliases

  B.4     Compiler Interface
    B.4.1     COMPILE Command
    B.4.2     REVIEW Command

  B.5     Editor Command Line

  B.6     Editor Command Line Qualifiers

  B.7     Keypad Functions

  B.8     Commands

  B.9     Using the VAX Language-Sensitive Editor with VAXELN Pascal
    B.9.1     Examples
      B.9.1.1      Initial Expansions
      B.9.1.2      TYPE Definition
      B.9.1.3      FOR Statement
      B.9.1.4      OPEN Statement
    B.9.2     VAXELN Pascal Tokens and Placeholders

  C   Syntax Summary

  D   Compiler Errors

  D.1     Types of Errors that Occur During System Development

  D.2     Compiler Error Detection

  D.3     Warning-Level Errors

  FIGURES

  2-1        VAXELN Pascal Program Structure

  2-2        Nested Block Structure

  4-1        Internal Representation of REAL

  4-2        G_Floating Representation

  4-3        D_Floating Representation

  4-4        Row-Major Order

  4-5        Internal Representation of a File Variable

  4-6        STRING(n) Representation

  4-7        VARYING_STRING(n) Representation

  4-8        LARGE_INTEGER Representation

  9-1        A VAX Argument List

  10-1       Structure of a File

  10-2       Structure of a Text File

  11-1       An Empty Queue

  11-2       A 1-Entry Queue

  11-3       A 2-Entry Queue

  B-1        Display of Initial Placeholder Expansion

  B-2        Language-Sensitive Editor Keypad Layout for VT100 Series

  B-3        Language-Sensitive Editor Keypad Layout for VT200 and VT300 Series

  TABLES

  1-1        Delimiters

  1-2        Operators

  1-3        Reserved Words

  4-1        Character Set

  5-1        ZERO Function Initialization

  5-2        Predeclared Enumerated Types

  7-1        Arithmetic Operators

  7-2        Boolean Operators

  7-3        Relational Operators

  7-4        Set Operators

  8-1        Assignment Compatibility

  10-1       File Operations

  12-1       Types of Exceptions

  12-2       Exception-Handler Operations

  13-1       VAXELN Pascal Routines

  14-1       EPASCAL Qualifiers

  14-2       VAXELN Run-Time Libraries for Pascal Programming

  A-1        VAXELN Pascal Attributes

  B-1        Editor Command Line Qualifiers

  B-2        Default Editor Functions

  B-3        Editor Line-Mode Commands