home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / interpre / pl / pl.txt < prev    next >
Text File  |  1989-12-16  |  2KB  |  37 lines

  1.   PL is a Pascal-like language with parallel assignments and guarded commands.
  2.  
  3.   A parallel assignment looks like this:
  4.                 i,m := 1,n
  5. meaning i:=1 and m:=n, they must be the same variable type.
  6.  
  7.   A guarded command looks like this:
  8.         if found -> write x,i; []
  9.           ~found -> write x;
  10.         fi
  11. guarded commands are also used in the do, od statement.
  12.  
  13. There are three boolean operators: "~" is "not", "&" is "and, and "|" is "or".
  14.  
  15. The operators are in 4 classes, shown below in increasing precedence:
  16.            Primary Operators: & |
  17.          Relational Operators: < = >
  18.          Adding Operators: + -
  19.          Multiplying Operators: * / \ ("\" is Modulo)
  20.          Not Operator: ~
  21.  
  22.     Even though the PL compiler/interpreter is divided into 3 separate modules: the scanner, the parser, and the interpreter, it can be combined into 1 program, and thus be considered a single pass compiler with no backtracking.  The compiling method is called "recursive descent" compiling.
  23.  
  24.     All of the PL program examples included here contain errors, with the exception of the LINEAR.PL, which is a linear search program, you input 10 numbers, and then re-enter a number and it returns the number and the location in the array where it was found. If not found it just returns the number entered.
  25.  
  26.     Comments in PL are preceded by a "$" and extend to the end of the current line.  The compiler looks for the keyword "End" and "." for the end of a source code listing, and a "^Z" for the end of a file.
  27.  
  28.     The major challenge in designing a compiler is error recovery, and that is why the majority of pl programs include here are incorrect.
  29.  
  30.     There are three rules to error recovery:
  31.         1. The compiler must be error free.
  32.         2. The compilation must always terminate (gracefully), no matter what the input looks like.
  33.         3. The compiler must find as many errors as possible during a single compilation.
  34.  
  35.  
  36.     This compiler was written for a class in compiler design at Humboldt State University - Math 434, taken in the Fall of 1986, and led by Dr. Howard Stauffer.  The compiler project is introduced and outlined in:
  37.   "Brinch Hansen on Pascal Compilers", written by Per Brinch Hansen, published by Prentice Hall, 1985.