PL / 0

from Wikipedia, the free encyclopedia

PL / 0 is a simplified programming language . It serves as a pattern to the book compiler of Niklaus Wirth to show how to make a compiler. The language can only deal with numerical values ​​and is not intended to be actually used. PL / 0 is also a subset of the PL / I programming language from IBM .

The syntax rules of the model language in EBNF :

 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 ")" .

Web links