Dependencies are:
llvmenv
, which you can install with cargo install llvm
libssl-dev
on Debian or openssl
on Arch LinuxOther things I needed on Ubuntu 18:
lib32z1-dev
, available through apt
To build, follow these setup instructions and run:
cargo build
See Thread with programs that compile and run.
Write your program:
# test.vam
fun three returning i32 = 3;
apply three
Run it:
cargo run --bin vamc ./test.vam && lli ./test.o
Since the MVP will only deal with integers, I can skip implementing type-checking because everything is an i32
. Perhaps I will need to implement a type for functions.
It should include:
i32
The following program should compile and run:
let first: i32 = 20;
let second: i32 = 22;
fun sum of a: i32 and b: i32 returning i32 = + a b;
fun sum_with_brackets of a: i32 and b: i32 returning i32 = { + a b };
apply sum first second; # 42
apply sum 10 12; # 22
apply sum { 10 } 10; # 20
apply sum { + 2 2 } 5; # 9
Vampa is case-sensitive and uses the Unicode character set.
# An inline comment
#[
# Hey there
# This is my block comment
#
# #[
# # This is a nested block comment
# # Hey there
# #]
#]
{}
for blocks:
let
let poem = "The revery alone will do, if bees are few";
of
to initiate a list of arguments, and and
to separate arguments, and then =
to start the body of the function, which can have a body {}
or a body without brackets# Using a body without brackets
fun sum of first_number and second_number = + first_number second_number;
# Using a body with brackets, implicitly returning the last expression
fun sum of first_number and second_number = { + first_number second_number };
apply
and arguments in function calls are delimited with spaces:let aggregate = apply sum 5 7;
let aggregate = apply sum 5 { sum 7 8 };
:
, must be placed next to the identifier they refer to, and can be used:
let poem: string = "The revery alone will do, if bees are few";
fun sum of first: i32 and second: i32 returning i32 = + first second;
type
keyword.type Uuid = string;
[]
:type Five[T] = [5 of T];
true
and false
Length | Signed | Unsigned |
---|---|---|
8-bit | i8 | u8 |
16-bit | i16 | u16 |
32-bit | i32 | u32 |
64-bit | i64 | u64 |
128-bit | i128 | u128 |
arch | isize | usize |
f32
f64
true
false
It's four bytes in size.
char
string
[char, i32]
: a tuple of a char
and an i32
[5 of char]
: an array of length 5 containing char
sThese are used in prefix position and can be combined using curly brackets {}
to indicate precedence explicitly.
+
-
/
%
*
and
apply
fun
let
of
returning
type