                    Facilis Implementation Manual

Version 0.20                                              File: FACILIS.IM
                                                          Updated: 15 Feb 85



INTRODUCTION

   Facilis is implemented in Turbo Pascal, an excellent commercial compiler
sold by Borland International.  You must have Turbo to compile the Facilis
source files; it is not capable of compiling itself.
   The source code is contained in three files:
               FACILIS.PAS  -  main program
               BLOCK.PAS    -  an include file
               INTERPRT.PAS -  an include file
   The implementation exploits certain non-standard features of Turbo, such
as the MEM array, and utilizes the segment:offset addressing of the 8088.
Modifications may be required to compile under a different Pascal compiler
or for a different processor.  Also, version 0.20 has been modifed with
an assembly level jump table to speed up run time execution.
   This implementation was done on an IBMPC running the PC-DOS version of
Turbo.  However, it makes no explicit calls to DOS, and should compile
under the CP/M-86 version of Turbo with little or no change.



COMPILING THE COMPILER

   The source files may be placed on any drive(s).  A RAM drive is recommended
to save wear on your disks.  Turbo expects to find BLOCK.PAS and INTERPRT.PAS
on the logged drive.  To override this assumption, you can place explicit drive
specifiers in the {$I include directives within FACILIS.PAS.
   Run Turbo.  From the main menu, enter FACILIS.PAS as the Main file.
Go to the Options menu and choose the Com option.  (Because it uses overlays,
Facilis cannot be compiled in memory.)  Quit to the main menu and Compile.
   Compilation results in two files: FACILIS.COM and an overlay file,
FACILIS.000.  These files will be written to the drive that FACILIS.PAS is
loaded from, not necessarily the logged drive.  These are big files.  Allow
enough space or you will get an error writing to disk, aborting compilation.




SYNTAX DIAGRAMS

(All words in caps are required key words)


program
                              +----------->----------------------+
                              |                                  |
---> PROGRAM ---> identifier -+-> ( ---> identifier list ---> ) -+-> ; ---+
                                                                          |
          +-------------------------------------------------------------<-+
          |
          +--> block ------> .


block

--+---> CONST ---+---> identifier --------> = ---> constant ---> ; ---+
  |              ^                                                    |
  +-<------------+--------------------------------------------------<-+
  |
  +---> TYPE ----+---> identifier --------> = ---> type -------> ; ---+
  |              ^                                                    |
  +-<------------+--------------------------------------------------<-+
  |
  +---> VAR ---------> identifier list ---> : ---> type -------> ; ---+
  |                                                                   |
  +-<---------------------------------------------------------------<-+
  |
  v
  |
  +-+-> PROCEDURE ---> identifier --------> formal parameter list  ---+
  | ^                                                                 |
  v |                                                                 |
  +-+-<----------- ; <------- block <---------- ; <-------------------+
  |                                                                   |
  +---> FUNCTION ----> identifier ----> formal parameter list ---+    ^
  |                                                              |    |
  |       +-<----------------------------------------------------+    |
  |       |                                                           |
  |       +---> : ----------> type identifier ---------------------->-+
  |
  +---> BEGIN -------> statement sequence -----> END ----->


type

--+-----------------------> type identifier --------------------------------+->
  |                                                                         |
  +--> ARRAY --> [ -+> constant --> .. --> constant -+> ] --> OF --> type --+
  |                 |                                |                      |
  |                 +--------------  , <-------------+                      |
  |                                                                         |
  |              +->-------------------------------------->-+               |
  |              |                                          |               |
  +--> RECORD ---+-+-> identifier list ---> : ---> type -+--+-> END ------>-+
                   |                                     |
                   +----------------------- ; <----------+


formal parameter list

  +->--------------------------------------------------------------------->-+
  |                                                                         |
--+-> ( -+-+->-------+--> identifier list --> : --> type identifier -+-> ) -+->
         | |         |                                               |
         | +-> VAR --+                                               |
         |                                                           |
         +-<--------------------------------- ; <--------------------+


identifier list

-----------------+--->  identifier  ----+---------------------------->------->
                 |                      |
                 +--------- , <---------+


identifier

-----------------> letter -----+--->-----------+--------------------->------->
                               ^               |
                               +--- letter <---+
                               |               |
                               +--- digit  <---+
                               |               |
                               +----  _  <-----+


statement sequence

-----------------+--->  statement   ----+---------------------------->------->
                 ^                      |
                 +--------- ; <---------+


statement

--+--+-> variable -------------+--> := ---------> expression ------------->-+->
  |  |                         |                                            |
  |  +-> function identifier --+                                            |
  |                                                                         |
  +----> procedure identifier ----+---> actual parameter list ---+-------->-+
  |                               |                              |          |
  |                               +--->--------------------------+          |
  |                                                                         |
  +----> BEGIN ------> statement sequence ------> END -------------------->-+
  |                                                                         |
  |                                              +->---------------------->-|
  |                                              |                          |
  +--> IF --> expression --> THEN --> statement -+-> ELSE --> statement -->-+
  |                                                                         |
  |                            +--->-------------------------------+        |
  |                            |                                   |        |
  +-> CASE -> expression -> OF +-+-> constant +-> : -> statement +-+-> END -+
  |                              |            |                  |          |
  |                              +----- , <---+                  |          |
  |                              |                               |          |
  |                              +--------------- ; <------------+          |
  |                                                                         |
  +----> WHILE ----> expression ------> DO ------> statement ------------->-+
  |                                                                         |
  +----> REPEAT ---> statement sequence ---> UNTIL ---> expression ------->-+
  |                                                                         |
  +----> FOR ------> variable identifier ---> := ---> expression --+        |
  |                                                                |        |
  |    +----<----------------------------------------------------<-+        |
  |    |                                                                    |
  |    +--+-> TO -------+--> expression ---> DO ---> statement ----------->-+
  |       |             |                                                   |
  |       +-> DOWNTO ---+                                                   |
  |                                                                         |
  +---->------------------------------------------------------------------>-+


expression

---> simple expression --+---+---+---+---+---+------------------------->-+-->
                         |   |   |   |   |   |                           |
                         v   v   v   v   v   v                           |
                         =   <>  <   >   >=  <=                          |
                         |   |   |   |   |   |                           |
                         +---+---+---+---+---+--> simple expression --->-+


simple expression

---+-->-----+--> term ----+--->-----------------+----+----+---------->------>
   |        |             |                     |    |    |
   +--> + --+             |                     v    v    v
   |        |             |                     +    -    OR
   +--> - --+             |                     |    |    |
                          +---- term <----------+----+----+


term

------> factor -----------+--->------------+----+----+----+----+----->------>
                          |                |    |    |    |    |
                          |                v    v    v    v    v
                          |                *    /   DIV  MOD  AND
                          |                |    |    |    |    |
                          +--- factor <----+----+----+----+----+


factor

---+--> unsigned constant --------------------------------------------->-+-->
   |                                                                     |
   +--> variable ------------------------------------------------------>-+
   |                                                                     |
   +--> function identifier ------> actual parameter list ------------->-+
   |                                                                     |
   +--> ( -------> expression ----> ) --------------------------------->-+
   |                                                                     |
   +--> NOT -----> factor --------------------------------------------->-+


actual parameter list

------> ( ------+---> expression ---+------> ) ---------------------->------>
                |                   |
                +-------- , <-------+


variable

----> variable identifier ---+----+--->------------------------------>------->
                             |    |
                             |    +---> [ --+--> expression --+--> ] --+
                             ^    |         |                 |        |
                             |    |         +------- , <------+        |
                             |    |                                    |
                             |    +---> . -----> field identifier -->--+
                             |                                         |
                             +---<----------------------------------<--+


constant

---+---+-->-----+-----+---> unsigned number ---------------->-+------>------>
   |   |        |     |                                       |
   |   +--> + --+     |                                       |
   |   |        |     +---> constant identifier ------------>-+
   |   +--> - --+                                             |
   |                                                          |
   +----------------------> literal string ----------------->-+


unsigned constant

---+------> constant identifier ---------------------------->-+------>------>
   |                                                          |
   +------> unsigned number -------------------------------->-+
   |                                                          |
   +------> literal string --------------------------------->-+


literal string

-------> ' -----+----------->----------+-----> ' ------------>-------------->
                |                      |
                +-----> character -----+
                |                      |
                +-----------<----------+


unsigned number

---> unsigned integer ---+--->----------------------------------+->-+------->
                         |                                      |   |
                         +---> . ----> unsigned integer --+--->-+   |
                         |                                |         |
                         v                                |         |
                         +---<-------------------------<--+         |
                         |                                          |
                         +---> E --+-->-----+-> unsigned integer ->-+
                                   |        |
                                   +--> + --+
                                   |        |
                                   +--> - --+

unsigned number

------------------------+-----> digit -----+------------------------->------>
                        |                  |
                        +-----<------------+



RESERVED WORDS

The following symbols are reserved and cannot be used as identifiers:

    AND         DOWNTO      IF          OR          THEN
    ARRAY       ELSE        IN          PACKED      TO
    BEGIN       END         LABEL       PROCEDURE   TYPE
    CASE        FILE        MOD         PROGRAM     UNTIL
    CONST       FOR         NIL         RECORD      VAR
    DIV         FUNCTION    NOT         REPEAT      WHILE
    DO          GOTO        OF          SET         WITH



OPERATION CODES

These are shown in the list file when the T option is selected.
Operations take zero, one, or two operands: x represents an 8-bit operand,
usually a level number; y represents a 16-bit quantity, such as an address
or an integer.

Code          Action
  0  x  y  Load address
  1  x  y  Load value
  2  x  y  Load indirect
  3  x  y  Update DISPLAY
  4          not used
  5          not used
  6          not used
  7     y  Concatenate
  8     y  Standard functions
  9     y  Add y to the element on top of the stack
 10     y  Jump to y (unconditional)
 11     y  Jump to y if stack top false
 12     y  Jump to y (case table) and select entry
 13     y  Entry in case table ... NOT EXECUTABLE
 14     y  For loop entry test - UP
 15     y  For loop retry test - UP
 16     y  For loop entry test - DOWN
 17     y  For loop retry test - DOWN
 18     y  Mark stack
 19     y  Call user procedure
 20     y  Indexed fetch (element size > 1)
 21     y  Indexed fetch
 22     y  Load block
 23     y  Copy block
 24     y  Load literal
 25     y  Load real
 26     y  Float
 27     y  Read (y denotes type .. 1 integer, 2 real, 4 char)
 28     y  Write string
 29     y  Write - default field widths
 30     y  Write - defined field widths
 31     y  Assign string (of length 1) to char
 32     y  Relation operators for strings

 33-130      not used

131        Halt
132        Exit procedure
133        Exit function
134        Fetch
135        Not
136        - integer (unary)
137        Write real - defined field
138        Store
139        Real =
140        Real <>
141        Real <
142        Real <=
143        Real >
144        Real >=
145        Integer =
146        Integer <>
147        Integer <
148        Integer <=
149        Integer >
150        Integer >=
151        Or
152        + integer
153        - integer
154        + real
155        - real
156        And
157        * integer
158        Div
159        Mod
160        * real
161        /
162        Readln
163        Writeln
164        - real (unary)
165        Index string
166        Assign string temporary to string
167        Convert array to string
168        Assign character to string
169        Assign string to string
170        Write string
171        Write string temporary
172        Value parameter - string
173        Value parameter - string temporary
174        Convert string to array
175        Convert string temporary to array
176        Write string - defined field
177        Write string temporary - defined field

178-255     not used


array
176        Write string - defi