Compile and Run v6 (Capstone)
Compile and Run v6 (Capstone)
Connect the full v6 compiler pipeline (modules + static types) and execute the program.
Function signature
func CompileAndRun(src string) (Value, error)
Pipeline requirements
Your function must:
- Lex source into tokens (
Lex) - Parse tokens into a program AST (
Parse) - Run semantic analysis (
Analyze) - Compile modules to bytecode (
CompileModules) - Link modules into a single program (
Link) - Encode to BC2 text (
Encode) - Decode back to bytecode (
Decode) - Execute in the VM (
Runon a new VM)
Return the final VM result.
Error handling
- If lexing or parsing fails, return that error.
- If semantic analysis returns errors, return the first error as
error. - If linking, decoding, or execution fails, return that error.
Notes
- Type annotations and function signatures are required in v6.
- The helper functions and types are provided in this file.
- Keep the implementation readable.
Run tests to see results
No issues detected