Eridu is a fully fledged C-Like programming language featuring various abstract data types, functions as first-class citizens, and multi-paradigm functionality, written from scratch in C , targeting x86 AT&T Assembly.
Testing and benchmarking was performed using a custom Python framework written from scratch as shown in sections 6. and 8. of the thesis in which a formal description of Eridu can also be found.
π Thesis
π Code Examples
π Project Description
π¬ The reader is advised to look at section 8. regarding performance evaluation in the attached thesis to get an overview of the viability of the language as well as comparisons to C and C++ with regards to run-time and scalability metrics.
To use the compiler, the following command can be run:
$ ./path/to/compiler < ./path/to/file.erd
From here, the newly created output.s
file can be constructed into a runnable by using gcc
. Here it is important to note that the -no-pie
flag for GCC is required when using strings.
We advice the reader to test the following examples:
$ ./build/compiler < ./examples/generic_vehicle_simulator.erd
$ gcc -no-pie output.s
$ ./a.out
$ ./build/compiler < ./examples/iterator.erd
$ gcc -no-pie output.s
$ ./a.out
define int * map(int * arr, int size, <int> callable <int> func) {
int i = 0;
int * new_arr = allocate(int, size);
while(i < size) {
new_arr[i] = func(arr[i]);
i = i + 1;
};
return new_arr;
};
define int * filter(int * arr, int size, <int> callable <int> cond) {
int i = 0;
int j = 0;
int * new_arr = allocate(int, size);
while(i < size) {
if(cond(arr[i]) == 1) {
new_arr[j] = arr[i];
j = j + 1;
};
i = i + 1;
};
return realloc(new_arr, size, j);
};
struct Iterator = {
char ** values,
int size,
int current,
<str> callable <struct Iterator *> next,
};
// Create dummy data
str * names = allocate(str, 5);
names[0] = "Michael";
names[1] = "Peter";
names[2] = "Hamurabe";
names[3] = "Wolfeschlegelsteinhausenberger";
names[4] = "Jackson";
struct Iterator * iter = create_iterator(names, 5);
// Test "next larger" iterator, starting from "Michael"
iter.next = _next_larger;
next = iter.next;
iter.current = 0;
str b = next(iter);
print(b); // Hamurabe
b = next(iter);
print(b); // Wolfeschlegelsteinhausenberger
It is possible to compile Eridu from source, by navigating to the ./dev/src
folder and running make
. Verbose output from the compilation process such as Abstract Syntax Tree structures or the code generation process can be exposed by using make debug
instead.
$ cd ./dev/src && make
Tests can be run using our testing framework Gula, to use this framework, Python 3.8 and the numpy package is required. To see the help menu, use the command:
$ python3 ./tests/gula.py -help
And for a complete test pass:
$ python3 ./tests/gula.py -src ../build -path ./tests -verbose
Benchmarking can be performed using our benchmarking framework Utu by running the following command:
$ python3 ./benchmarks/utu.py -src ./build -path . -verbose
Too see all the available options, run:
$ python3 ./benchmarks/utu.py -help