PL/0 |
There are at least two programming langages known as PL/0. One is a subset of IBM s general-purpose programming language programming language PL/I.
The other PL/0 is a simplified version of the general-purpose programming language Pascal programming language, intended as an educational programming language. It serves as an example of how to construct a Compiler. It was originally introduced in the book, Algorithms + Data Structures = Programs , by Niklaus Wirth in 1975. It features quite limited language constructs: there are no real numbers, very few basic arithmetic operations and no control-flow constructs other than if and while blocks. While these limitations makes writing real applications in this language impractical, it helps the compiler remain compact and simple.
The example is used in a book by Niklaus Wirth called Compilerbau .
The following is the syntax rules of the model language defined in Extended Backus-Naur form:
program = block .
block = [ CONST ident = number { , ident = number} ; ] [ VAR ident { , ident} ; ] { PROCEDURE ident ; block ; } statement .
statement = [ ident := expression | CALL ident | ident | ! expression | BEGIN statement { ; statement } END | IF condition THEN statement | WHILE condition DO statement ]. condition = ODD expression | expression ( = | # | = ) expression . expression = [ + | - ] term { ( + | - ) term}. term = factor {( * | / ) factor} factor = ident | number | ( expression ) .
The following example is taken from [http://www.ntecs.de/old-hp/uu9r/lang/html/pl0.en.html].
VAR x, squ;
PROCEDURE square; BEGIN squ := x * x END;
BEGIN x := 1; WHILE x|
|