diff --git a/README.md b/README.md index bc9ae4e..9d53485 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,32 @@ I wrote it on a linux machine, but there should be very few places where a linux The interpreter is fully functional, but lots of built-in functions that one would expect still need to be implemented. Unfortunately, I feel like this requires much more work than what it's worth at the moment. ## Implementation overview -The architecture is pretty much the same as CPython. The source code is executed by compilig it to bytecode. The bytecode is much more high level than what the CPU understands, it's more like a serialized version of the AST. For example, some bytecode instructions refer to variables by names, which means the compiler does very little static analisys. Memory is managed by a garbage collector that moves and compacts allocations. \ No newline at end of file +The architecture is pretty much the same as CPython. The source code is executed by compilig it to bytecode. The bytecode is much more high level than what the CPU understands, it's more like a serialized version of the AST. For example, some bytecode instructions refer to variables by names, which means the compiler does very little static analisys. Memory is managed by a garbage collector that moves and compacts allocations. + +More detailed explanations are provided alongside the code. + +## Build + +To build it, just run: +```sh +$ ./build.sh +``` +it will create a `build` folder where the interpreter's executable will be generated. + +You may need to give executable permissions to the script. You can do so with by running: + +```sh +$ chmod +x build.sh +``` + +## Usage + +You can run files by doing: +```sh +location/of/noja +``` + +or you can run strings by doing: +```sh +location/of/noja -c +``` \ No newline at end of file diff --git a/src/main.c b/src/main.c index 9acbe9a..c291510 100644 --- a/src/main.c +++ b/src/main.c @@ -103,36 +103,11 @@ static int parse_args(Options *opts, int argc, char **argv, Error *error) return i; } -#include "buildvalue.h" - int main(int argc, char **argv) { Error error; Error_Init(&error); - { - Heap *heap = Heap_New(-1); - - if(heap == NULL) - { - fprintf(stderr, "ERROR: Failed to create heap.\n"); - return -1; - } - - Object *o = buildValue(heap, &error, "[${ return 3*1; }, $i, {}, {${return 'name';}: $s, ${return 'name';}: [$s]}]", 4, "Francesco", "Giovanni"); - - if(o == NULL) - { - fprintf(stderr, "ERROR: %s.\n", error.message); - return -1; - } - - Object_Print(o, stdout); - - Heap_Free(heap); - } - - // Parse command line options. Options opts;