,ll 6.6
,cs 10
,pl 66
,lm 0.2,0.5
,pn 3
,ju
,hd
,ce
OmegaSoft 6809 Cross Pascal Language Handbook (V1.0)
,,
,ft

,ce 1
4-##
,,
,ce
OmegaSoft 6809 Cross Pascal Language Handbook (V1.0)

,ce
PASCAL PROGRAM STRUCTURE

PROGRAM HEADING

The PROGRAM line must be the first line of a program. An identifier follows the word PROGRAM and this identifier is truncated to 8 characters and used as the starting address label for the program. This identifier is also truncated to 7 characters with a preceding period and is used as the label for the assembler "idnt" directive. This identifier has no further significance in the Pascal program. 

Following this identifier may be a list of standard I/O devices and device variable names. If any of the standard I/O devices are to be used in the program, then you must list them here. 

If any device variable names are listed, then their relative position corresponds to a position within the command line. Using the program heading and variable declarations that follow :

     program Test (data, report, error_file) ;
       var
         error_file, data, report : text ;

then if the program is called with the command line :

     test jones jreport jerror

then the default filename for data will be jones, for report will be jreport, and for error_file will jerror. For additional information on options available for the standard I/O devices see the section on compilation options.

Following the optional list of identifiers is a semicolon, the outer block, and the program is terminated by a period.

program heading = Program identifier [( identifier
                  {, identifier})] ; block .

 
     program      identifier      (      identifier      )      ;

                                              ,

 
                  block       .


BLOCK

The block contains the declaration part and execution part. All data items referenced in the execution part must be defined in the declaration part of the same or an enclosing block.

block = {(label-declaration | constant-declaration |
        type-declaration | variable-declaration)}
        {(procedure-declaration | function-declaration)}
        begin [statement {; statement}] end
,pg
,ce
PASCAL PROGRAM STRUCTURE



 
                          label declaration


 
                         constant declaration


 
                           type declaration


 
                         variable declaration


 
                        procedure declaration


 
                         function declaration



 
          begin             statement            end

                                ;


LEXICAL LEVELS

Each block is at a specific lexical level. This lexical level is assigned by the compiler and is used to determine the code required at runtime to access variables. The first lexical level defined is the outer (program) block and is level one. Procedures and functions defined immediately within the program block are at lexical level two. Procedures and functions defined within lexical level two are at lexical level three, etc.

Constants, types, variables, and parameters carry the lexical level of the procedure (or program) they are defined in. When accessing a variable the difference between the current lexical level and the lexical level that the variable is defined at affects the amount of code (and time) required. The smallest amount of code is required for accessing local variables (those that are defined in the same block as the access).

A procedure defined at lexical level "N" may call a procedure defined within its block at lexical level "N + 1". A procedure defined at lexical level "N" may also call any procedure at a lower lexical level in an enclosing block. This is shown in the following example.
,pg
,ce
PASCAL PROGRAM STRUCTURE


Program A (output) ;   { lex level 1 }
  var
    va : integer ;

  Procedure B (pb : integer) ; { lex level 2 }
    var
      vb : integer ;

    Procedure C (pc : integer) ; { lex level 3 }
      var
        vc : integer ;
      Begin
        { procedures B and C may be called }
        { pc and vc can be accessed with one instruction }
        { va, pb, and vb can be accessed with two instructions }
      End;

    Begin { B }
      { procedures B and C may be called }
      { pb and vb can be accessed with one instruction }
      { va can be accessed with two instructions }
    End;

  Procedure D (pd : integer) ; { lex level 2 }
    var
      vd : integer ;

    Procedure E (pe : integer) ; { lex level 3 }
      var
        ve : integer ;

      Procedure F (pf : integer) ; { lex level 4 }
        var
          vf : integer ;
        Begin 
          { procedures B, D, E, and F may be called }
          { pf and vf can be accessed with one instruction }
          { va, pe, and ve can be accessed with two instructions }
          { pd and vd can be accessed with three instructions }
        End;

      Begin { E }
        { procedures B, D, E, and F may be called }
        { pe and ve can be accessed with one instruction }
        { va, pd, and vd can be accessed with two instructions }
      End;

    Begin { D }
      { procedures B, D, and E may be called }
      { pd and vd can be accessed with one instruction }
      { va can be accessed with two instructions }
    End;

  Begin { A }
    { procedures B and D may be called }
    { va can be accessed with one instruction }
  End.

Note that due to actions by the optimizer, fewer instructions than indicated above may be needed, this is especially true of accessing global variables from inside procedures.

,ce
CHARACTER SET

OmegaSoft Pascal uses the American Standard Code for Information Interchange (ASCII) character set. Of the ASCII character set the following characters are used :

* The upper and lowercase letters A through Z and a through z
* The numbers 0 through 9
* The special characters space ! # $ % ' ( ) * + , - . / : ; < =
  > @ [ ] ^ _ { }
* The carriage return (hex 0D) for terminating lines of input

Upper and lower case characters are equivalent except in character and string constants.

The maximum source line length is 120 characters, compilation will terminate if a source line is longer than this amount.
