LLVM frontend for yot - a toy language.
cargo install yotc
yotc (path to file)
yotc --help
for more optionsint
and functions must return an int
as well. Comparison operators return 1 or 0
@sum[a, b] {
-> a + b // -> is the return keyword
}
@sum[a, b] -> a + b;
@!print[_, _];
sum(a, b);
@a = 5;
@a;
@b = a + 5;
=
, +
, -
, *
, /
, ==
, !=
, <
, >
, <=
, >=
.
@a = (-b + 5) - 10 / -(5 - -2);
//
and tokens are ignored until the end of the linemain
function entry pointExample
equalsten.yot ``` // External functions @!println[]; @!next_int[];
@plus_five[a] -> a + 5;
@main[] { @input = nextint(); @equalsten = plusfive(input) == 10; println(equalsten);
-> 0;
} ```
io.cc ```
extern "C" { int println(int a) { std::cout << a << std::endl; return 0; }
int next_int() {
int input;
std::cin >> input;
return input;
}
} ```
equals_ten.yot
with yotc equals_ten.yot --output-format=object-file
io.cpp
with g++ io.cc equals_ten.o
to generate an executable