The Go Compiler is a project aimed at translating Go source code into an intermediate bytecode representation that can be executed by a custom-built virtual machine. This project demystifies the process of writing compilers and virtual machines, making it accessible for developers to understand and implement these complex systems.
Currently extending the programming language designed in Writing An Compiler In Go by Thorsten Ball.
- Lexical Analysis: Tokenizes the source code into meaningful symbols.
- Parsing: Converts token sequences into an abstract syntax tree (AST).
- Semantic Analysis: Ensures the AST adheres to the rules of the Go language.
- Code Generation: Translates the AST into bytecode for the virtual machine.
- Error Handling: Provides detailed error messages for lexical, syntactic, and semantic errors.
- Optimization: Performs basic optimizations on the bytecode for better performance.
- Go 1.13+
- Let Statements: Define identifiers using the
let
keyword. - If Expressions: Conditional expressions using
if
andelse
. - Function Literals: Define functions with parameters and block statements.
- Integer Literals: Support for integer operations.
- Boolean Literals: Support for boolean values and expressions.
- Grouped Expressions: Use parentheses to group expressions.
- Array Literals: Create and manipulate arrays.
- Hash Literals: Create and access hash maps.