Wirthless Level 0 (WL0) is the first iteration of the [Wirthless] programming language. It consists of three statement types and can manage up to 26 variables, but it can do little else.
Below is the language specification in Wirthless's augmented [BNF].
var := [A-Z] num := 0 | -?[1-9][0-9]* str := '"' ( [^\\"] | '\\' . )* '"'
program := (statement ';')* statement := assignment | print | read assignment := var '=' expr | string expr := expr [+-] term term := term [*/%] factor factor := var | num | '(' expr ')' print := "print" value-list value-list := value ( ',' value )* value := string | num | expr read := "read" var
The assignment operator evalutes its right operand and stores the value in the variable specified by its left operand. Unlike most other languages, assignment is not an expression; thus, a form such as "A = B = C" is not well-formed. The right operand may either be a string or an expression.
The plus and minus operators respectively add and subtract their operands. These operators are left-associative. Addition and subtraction have the following properties in WL0:
The multiple, divide, and modulo operators respectively multiply, divide, and take the remainder of their operands. These operators are left-associative. Multiplication has the following properties in WL0:
Division has the following properties in WL0:
The modulo operator has the following properties in WL0:
The print keyword contatenates its operands in the order they appear and prints the result to standard output. The print keyword is right-associative.
The read keyword reads the next line from standard input and stores it in its operand. The value is coerced to a number if possible; otherwise, it is stored as a string.
WL0 is a context-free language and specifically violates the pumping lemma for regular languages because its grouping operator. Because of its limited storage and lack of mechanism for looping, WL0 is not [Turing Complete]; as such, there are certain programs it is not capable of expressing.
WL0 is featured in the following units of [Developing A Programming Language]: