This documentation is not up to date and partially a to-do list (i.e. not everything is implemented).
Compile the compiler with your compiler of choice. Then run the resulting file with two arguments (the input file path and the output file path).
- one statement per line
- no semicolons, etc. needed
- curly brackets make on statement from many (the opening one and closing one have to be in their one line)
- indentation is skipped
-
- (add), - (sub), * (mult), / (float div), // (int div)
- == (equal), != (not equal), < (less then), <= (less then or equal), > (greater then), >= (greater then)
- || (or skip second if first true), | (or), && (and skip second if first false), & (and), ^ (xor), _ (nand)
- cout is used by writing a statement after a << in a line
- cin is used by writing a variable after a >> in a line
- type name = value;
- build in types: int (=long), float (=double), bool (=bool), char (= char), str (=std::string), null
- arrays: build in type followed by [] as often as dimension
- to create a new array: type[]...[] name = type[dim_1]...[dim_n]
- #to create new object: class(parameter)
- if (condition) elif (condition) else
- for (declaration; condtion; increment)
- while (condition)
- foreach (type name in iterable)
- def ret_type name(type_param_1 param_name1, ..., type_param_n param_name1)
- var.len() -> how many items (= var.size())
- var.get(i) -> get i-th element (= var[i])
- var.get_default(i, val) -> =var.get(i) if i-th element exists else val
- var.set(i, val) -> set i-th element (= var[i]=val)
file := block "\0"
block := empty-line* (((statement "\n") | control-struct | function-def) empty-lines*)+
block-with-break := empty-line* (((statement "\n") | "break\n" | control-struct-with-break |
function-def) empty-lines*)+
empty-line := (" " | "\t")* "\n"
statement := (assignment | print | input | b-expression)
control-struct := (for | while | do-while | if)
control-struct-with-break := (for | while | do-while | if-with-break)
for := "for(" assignment ";" b-expression ";" assignment ")\n{\n" block-with-break "}\n"
while := "while(" b-expression ")\n{\n" block-with-break "}\n"
do-while := "do\n{\n" block-with-break "}\nwhile(" b-expression ")\n"
if := "if(" b-expression ")\n{\n" block "}\n" (elif | else)?
elif := "elif(" b-expression ")\n{\n" block "}\n" (elif | else)?
else := "else\n{\n" block "}"
if-with-break := "if(" b-expression ")\n{\n" block-with-break "}\n" (elif | else)?
elif-with-break := "elif(" b-expression ")\n{\n" block-with-break "}\n" (elif | else)?
else-with-break := "else\n{\n" block-with-break "}"
print := "print(" b-expression ")"
input := "input(" variable ")"
function-def := type variable "()\n{\n" block "}\n"
assignment := (type)? variable "=" b-expression
b-expression := b-term (orop b-term)*
b-term := b-factor (andop b-factor)*
b-factor := neqop? (bool-literal | relation)
relation := expression (relop expression)?
expression := term (addop term)*
term := factor (mulop factor)*
factor := addop? (int-literal | variable | "("b-expression")")
orop := "||" | "|" | "^"
andop := "&&" | "&"
neqop := "!"
relop := "==" | "!=" | "<" | "<=" | ">" | ">="
addop := "+" | "-"
mulop := "*" | "/"
int-literal := ([1-9] [0-9]*) | 0
bool-literal := "true" | "false"
variable := ...