Compile and Run v3 (Capstone)
Compile and Run v3 (Capstone)
Connect the full v3 compiler pipeline 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 to bytecode (
Compile) - 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 decoding or execution fails, return that error.
Notes
- The helper functions and types are provided in this file.
- Keep the implementation readable.
Run tests to see results
No issues detected