Compiler Construction: This OCaml program is a compiler tool for my special language.
$ make build
This will install core
and menhir
using opam
first if they are not already installed, then build the compiler.
$ make test
This will run all test files existing in the tests
directory. If the filename contains a string in the format .e_VALUE.
, it will output the test actual value and expect it to be the same as VALUE
.
My language uses c-style syntax, inspired by Javascript.
main (params) {
0;
}
To return a value from a function, just add it as the last expression in the function.
/*
This is a multiline ..
.. comment!
*/
some_code(); /* inline comment */
let x = 5;
let x = 5;
let y = (x + 5) / 2;
Available Operators: +
-
*
/
<=
<
>=
>
==
!=
&&
||
!
. You can use brackets to prioritize expressions.
let x = 5;
x = 10;
const ENVIRONMENT = 1;
sum(x, y);
print x;
dump(x);
dump(x + 3);
dump(x, y);
let x = read_int();
while (i < max) {
do_something();
i = i + 1;
}
if (i > 0) {
do_something();
} else {
do_something_else();
}
(let z = x + y; if (z = 0) { x } else { y }) = 7;
Put parentheses around expressions to ensure they are parsed into a sequence.