Compile and Run (Capstone)
Compile and Run (Capstone)
Connect the full 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 BC1 text (
Encode) - Decode back to bytecode (
Decode) - Execute in the VM (
Run)
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