"PL/0

From Wikipedia, the free encyclopedia

This article is about the programming language introduced by Niklaus Wirth. For the subset of a programming language from IBM, see PL/I.

PL/0 is a programming language, intended as an educational programming language, that is similar to but much simpler than Pascal, a general-purpose 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 1976. 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 make writing real applications in this language impractical, it helps the compiler remain compact and simple."
Код:
{$A-}
  PROGRAM PL0;
  {PL0 COMPILER WITH CODE GENERATION}
LABEL
  99;
CONST
  NORW=13;  {# OF RESERVED WORDS}
  TXMAX=100; {LENGTH OF IDENTIFIER TABLE}
  NMAX=14; {MAX NUMBER OF DIGITS IN NUMBERS}
  AL=10;  {LENGTH OF IDENTIFIERS}
  AMAX=2047; {MAXIMUM ADDRESS}
  LEVMAX=3; {MAX DEPTH OF BLOCK NESTING}
  CXMAX=200; {SIZE OF CODE ARRAY}

TYPE
  SYMBOL=(NUL, IDENT, NUMBER, PLUS, MINUS, TIMES, SLASH, ODDSYM,
	  EQL, NEQ, LSS, LEQ, GTR, GEQ, LPAREN, RPAREN, COMMA, SEMICOLON,
	  PERIOD, BECOMES, BEGINSYM, ENDSYM, IFSYM, THENSYM,
	  WHILESYM,WRITESYM,READSYM, DOSYM, CALLSYM, CONSTSYM, VARSYM, PROCSYM);
..............