Mako/compiler/compile.go
2025-05-07 09:45:50 -05:00

22 lines
516 B
Go

package compiler
import (
"git.sharkk.net/Sharkk/Mako/parser"
"git.sharkk.net/Sharkk/Mako/types"
)
// CompileSource compiles source code to bytecode
func CompileSource(source string) (*types.Function, []*types.MakoError) {
// Parse the source code into an AST
p := parser.New(source)
statements := p.Parse()
// Create a compiler for the main (global) scope
compiler := New("script", nil)
// Compile the statements to bytecode
function, errors := compiler.Compile(statements)
return function, errors
}