All TL09 lexical elements (a.k.a. tokens) are separated by spaces and should match one of the categories below.
If the definition of a lexical element is in quotes, then it is meant to match exactly, the contained string. Otherwise, it is a regular expression. Square brackets in regular expressions are used as an abbreviation for matching ranges of letters. For example, [0-9] matches any digit, and [a-zA-Z] matches any English letter in capital or lower case.
Numbers, Literals, and Identifiers:
Symbols and Operators:
Keywords:
Built-in Procedures:
<program> ::= PROGRAM ident <declarations> BEGIN <statementSequence> END
<declarations> ::= VAR ident AS <type> SC <declarations>
| ε
<type> ::= INT | BOOL
<statementSequence> ::= <statement> SC <statementSequence>
| ε
<statement> ::= <assignment>
| <ifStatement>
| <whileStatement>
| <writeInt>
<assignment> ::= ident ASGN <expression>
| ident ASGN READINT
<ifStatement> ::= IF <expression> THEN <statementSequence> <elseClause> END
<elseClause> ::= ELSE <statementSequence>
| ε
<whileStatement> ::= WHILE <expression> DO <statementSequence> END
<writeInt> ::= WRITEINT <expression>
<expression> ::= <simpleExpression>
| <simpleExpression> OP4 <simpleExpression>
<simpleExpression> ::= <term> OP3 <term>
| <term>
<term> ::= <factor> OP2 <factor>
| <factor>
<factor> ::= ident
| num
| boollit
| LP <expression> RP