,--.
,---,. ,--/ /| ,----..
,' .' | ,---,': / ' / / \
,---.' | : : '/ / | : :
| | .' | ' , . | ;. /
: : : ' | / . ; /--`
: | |-, | ; ; ; | ;
| : ;/| : ' \ | : |
| | .' | | ' . | '___
' : ' ' : |. \ ' ; : .'|
| | | | | '_\.' ' | '/ :
| : \ ' : | | : /
| | ,' ; |,' \ \ .'
`----' '---' `---`
Fkclang is a simple interpreter and programming language implemented in Go.
- c-like syntax
- support integer, boolean, string, array, map, function type
- arithmetical expression
- if-else statement
- built-in functions
- high-level function
- import module
- closure
First, you need to install Go and set the environment variables. Then you can clone the project and build it.
go build
when you run the command, you will get an executable file named fkclang.
You can run fkclang in two ways:
- Run the interpreter directly
./fkclang
- Run the interpreter with file called main.fkc
./fkclang main.fkc
in the main.fkc file, you can import other modules. For example:
import "std.fkc"
// use std.fkc's sort function
print(std.sort([3, 2, 1], 1));
// declare variable with initialization
cong a = 1;
// assign value
set a = 2;
set a = "hello world";
set a = [1, 2, 3];
set a = {a: 1, b: 2};
set a = fk(x) {
-> x + 1;
};
cong a = [1, 2, 3];
print(a[0]); // -> 1
// print
print(1); // -> 1
// len
print(len([1, 2, 3])); // -> 3
to see more built-in functions, you can check the evaluator/builtins.go
file.
cong fib = fk(n) {
if (n < 2) {
-> n;
} else {
-> fib(n - 1) + fib(n - 2);
}
}
fib(4); // -> 3
cong twice = fk(f, x) {
-> f(f(x));
}
cong addTwo = fk(x) {
-> x + 2;
}
twice(addTwo, 2); // -> 6
to see more examples, you can check the std.fkc
file.
- import module
- float number
- match syntax
- for loop (maybe difficult)