Refactored code structure

This commit is contained in:
Eduard Urbach 2024-07-03 11:39:24 +02:00
parent 9e52e2dd1c
commit fd6e874b44
Signed by: eduard
GPG key ID: 49226B848C78F6C8
54 changed files with 583 additions and 450 deletions

View file

@ -83,22 +83,30 @@ Each function will then be translated to generic assembler instructions.
All the functions that are required to run the program will be added to the final assembler.
The final assembler resolves label addresses, optimizes the performance and generates the specific x86-64 machine code from the generic instruction set.
### [src/build/Function.go](src/build/Function.go)
### [src/build/core/Function.go](src/build/core/Function.go)
This is the "heart" of the compiler.
Each function runs `f.Compile()` which organizes the source code into instructions that are then compiled via `f.CompileInstruction`.
You can think of instructions as the individual lines in your source code, but instructions can also span over multiple lines.
Each function runs `f.Compile` which organizes the source code into an abstract syntax tree that is then compiled via `f.CompileAST`.
You can think of AST nodes as the individual statements in your source code.
### [src/build/ast/Parse.go](src/build/ast/Parse.go)
This is what generates the AST from tokens.
### [src/build/expression/Parse.go](src/build/expression/Parse.go)
This is what generates expressions from tokens.
## Tests
```shell
go test -coverpkg=./...
go test ./... -v
```
## Benchmarks
```shell
go test -bench=. -benchmem
go test ./tests -bench=. -benchmem
```
## License