Grammar
program = <function>*
A program is made up of zero or more functions.
function = function <identifier> ( <identifier>* ) do <statement>* end
A function begins with the function keyword, an identifier as its name, open parenthesis, zero or more identifiers for its parameters, close parenthesis, the do keyword, zero or more statements, and an end keyword.
statement = <declare-statement> | <input-statement> | <output-statement>> | <set-statement> | <if-statement> | <while-statement> | <run-statement> | <return-statement>
A statement is either a declare, input, output, set, if, while, run or return statement.
declare-statement = declare <identifier>*;
The declare statement (used to declare local variables) begins with the 'declare' keyword, followed by zero or more identifiers. Each identifier represents the name of a variable being declared.
input-statement = input <input-data-type> <identifier>;
The input statement (used to receive input from the program's user through the runtime's standard input) begins with the 'input' keyword, followed by an input data type, then an identifier where the user's input is to be stored.
output-statement = output <output-data-type> <expression>;
The output statement (used to display output using the runtime's standard output) begins with the 'output' keyword, followed by an output data type, then an expression whose value is to be displayed.
set-statement = set <identifier> = <expression>;
The set statement (used to assign a value to a variable) begins with with the 'set' keyword, followed by an identifier that identifies the variable where the value is to be stored, then an expression whose value is to be stored in the variable.
if-statement = if <expression> then <statement>* (else <statement>*)? end
The if statement begins with the keyword 'if', followed by an expression, then the keyword 'then'. This is followed by zero or more statements. Optionally, one can add an else clause by writing the 'else' keyword, followed by zero or more statements. There can only be one else clause. The if statement is terminated by the 'end' keyword.
while-statement = while <expression> do <statement>* end
The while statement begins with the keyword 'while', followed by an expression, then the keyword do. This is followed by zero or more statements that form the body of the loop. Then you terminate the statement with the 'end' keyword.
run-statement = run <identifier> ( <expression>* );
The run statement begins with the keyword 'run', followed by an identifier that represents the name of the function that is to be executed, then open parentheses, zero or more expressions as arguments to the function, then lastly, close parentheses and a semi-colon.
return-statement = return <expression>;
The return statement begins with the keyword return, followed by an expression and a semi-colon.
expression = <unary-expression> | <binary-expression> | <literal-expression> | <symbol-expression> | <call-expression>
unary-expression = <unary-operator> <expression>
binary-expression = <expression> <binary-operator> <expression>
literal-expression = [0-9]+
symbol-expression = <identifier>
call-expression = <identifier> ( <expression>* );
identifier = [A-Za-z_][A-Za-z_0-9]*
An identifier begins with a letter or underscore, followed by zero or more letters, digits and underscores.
unary-operator = [ ! - ]
binary-operator = [ + - * / ^ % & | ]