Minilang contains three types: int for representing integers, bool for representing truth values and void for denoting lack of type.
| type | → | int | bool | void |
There are literals for representing Boolean and integer values.
| literal | → | boolean‑literal | integer‑literal |
| boolean‑literal | → | true | false |
| integer‑literal | → | digit‑sequence |
| digit‑sequence | → | [0-9]+ |
A Minilang identifier can contain non-ASCII letters also. Minilang source files are expected to be UTF-8 encoded for this to work.
| identifier | → | Unicode identifier |
The grammar productions
| primary‑expression | → | literal | identifier | ( expression ) |
| postfix‑expression | → | primary‑expression ( ( expression‑list? ) )* |
| expression‑list | → | expression ( , expression )* |
| unary‑expression | → | unary‑op unary‑expression | postfix‑expression |
| unary‑op | → | + | - | ! |
| multiplicative‑expression | → | unary‑expression (multiplicative‑op unary‑expression )* |
| multiplicative‑op | → | * | / | % |
| additive‑expression | → | multiplicative‑expression (additive‑op multiplicative‑expression )* |
| additive‑op | → | + | - |
| relational‑expression | → | additive‑expression (relational‑op additive‑expression )* |
| relational‑op | → | < | > | <= | >= |
| equality‑expression | → | relational‑expression (equality‑op relational‑expression )* |
| equality‑op | → | == | != |
| expression | → | equality‑expression |
There are statements for sequence, choice and repetition, and for creating and assigning variables.
| statement | → | if‑statement | while‑statement | return‑statement | compound‑statement | construction‑statement | assignment‑statement |
| if‑statement | → | if ( expression ) statement ( else statement )? |
| while‑statement | → | while ( expression ) statement |
| return‑statement | → | return expression? |
| compound‑statement | → | { statement* } |
| construction‑statement | → | type identifier = expression ; |
| assignment‑statement | → | identifier = expression ; |
Minilang functions can take parameters, do simple computations and return a result.
| function | → | type identifier ( parameter‑list? ) compound‑statement |
| parameter‑list | → | parameter ( , parameter )* |
| parameter | → | type identifier |
A minilang source file consists of a sequence of functions.
| source‑file | → | function* |