modified readme and removed debug code

This commit is contained in:
cozis
2022-01-22 03:40:27 +01:00
parent e4d6663879
commit 6b983cbafd
2 changed files with 29 additions and 26 deletions
+28
View File
@@ -11,3 +11,31 @@ The interpreter is fully functional, but lots of built-in functions that one wou
## Implementation overview ## 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. 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 <filename>
```
or you can run strings by doing:
```sh
location/of/noja -c <string>
```
-25
View File
@@ -103,36 +103,11 @@ static int parse_args(Options *opts, int argc, char **argv, Error *error)
return i; return i;
} }
#include "buildvalue.h"
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
Error error; Error error;
Error_Init(&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. // Parse command line options.
Options opts; Options opts;