EBNF of PL/0
The book covers the making of a compiler for the language PL/0. PL/0 is a subset of Modula-2 or Pascal which is comparable to BASIC in power. But then with TYPE checking and the lot. The EBNF formulation of the language PL/0 is:
| 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 ")". |
This definition is on page 33 of the PDF.
As will be clear, this definition is incomplete. Number need to be declared as well.
Additions
Below is an overview of the additional EBNF rules required for a full definition.
| ident | = | letter {letter | digit} |
| number | = | digit { digit } |
| letter | = | { "a" | "b" | ... | "y" | "z" | "A" | "B" | ... | "Y" | "Z" } |
| digit | = | { "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" } |
Page created on 1 September 2007 and
Page equipped with FroogleBuster technology