Updated documentation
This commit is contained in:
parent
63d72c8d22
commit
fd64bc6358
@ -28,7 +28,7 @@ Builds an executable from `examples/hello` and runs it.
|
|||||||
|
|
||||||
- [Chat](https://matrix.to/#/#community:akyoto.dev)
|
- [Chat](https://matrix.to/#/#community:akyoto.dev)
|
||||||
- [Donate](https://buy.stripe.com/4gw7vf5Jxflf83m7st)
|
- [Donate](https://buy.stripe.com/4gw7vf5Jxflf83m7st)
|
||||||
- [Todo](/docs/todo.md)
|
- [Todo](todo.md)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
### [main.go](/main.go)
|
### [cli/Main.go](cli/Main.go)
|
||||||
|
|
||||||
Entry point. It simply calls `cli.Main` which we can use for testing.
|
Entry point.
|
||||||
|
|
||||||
### [src/cli/Main.go](/src/cli/Main.go)
|
|
||||||
|
|
||||||
The command line interface expects a command like `build` as the first argument.
|
The command line interface expects a command like `build` as the first argument.
|
||||||
Commands are implemented as functions in the [src/cli](src/cli) directory.
|
Commands are implemented as functions in the [cli](cli) directory.
|
||||||
Each command has its own set of parameters.
|
Each command has its own set of parameters.
|
||||||
|
|
||||||
### [src/cli/Build.go](/src/cli/Build.go)
|
### [cli/Build.go](cli/Build.go)
|
||||||
|
|
||||||
The build command creates a new `Build` instance with the given directory and calls the `Run` method.
|
The build command creates a new `Build` instance with the given directory and calls the `Run` method.
|
||||||
|
|
||||||
@ -37,7 +35,7 @@ Adding the `-v` or `--verbose` flag shows verbose compiler information:
|
|||||||
q build examples/hello -v
|
q build examples/hello -v
|
||||||
```
|
```
|
||||||
|
|
||||||
### [src/build/Build.go](/src/build/Build.go)
|
### [build/Build.go](build/Build.go)
|
||||||
|
|
||||||
The `Build` type defines all the information needed to start building an executable file.
|
The `Build` type defines all the information needed to start building an executable file.
|
||||||
The name of the executable will be equal to the name of the build directory.
|
The name of the executable will be equal to the name of the build directory.
|
||||||
@ -57,16 +55,16 @@ 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.
|
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.
|
The final assembler resolves label addresses, optimizes the performance and generates the specific x86-64 machine code from the generic instruction set.
|
||||||
|
|
||||||
### [src/core/Function.go](/src/core/Function.go)
|
### [core/Function.go](core/Function.go)
|
||||||
|
|
||||||
This is the "heart" of the compiler.
|
This is the "heart" of the compiler.
|
||||||
Each function runs `f.Compile` which organizes the source code into an abstract syntax tree that is then compiled via `f.CompileAST`.
|
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.
|
You can think of AST nodes as the individual statements in your source code.
|
||||||
|
|
||||||
### [src/ast/Parse.go](/src/ast/Parse.go)
|
### [ast/Parse.go](ast/Parse.go)
|
||||||
|
|
||||||
This is what generates the AST from tokens.
|
This is what generates the AST from tokens.
|
||||||
|
|
||||||
### [src/expression/Parse.go](/src/expression/Parse.go)
|
### [expression/Parse.go](expression/Parse.go)
|
||||||
|
|
||||||
This is what generates expressions from tokens.
|
This is what generates expressions from tokens.
|
Loading…
Reference in New Issue
Block a user