32 lines
545 B
Go
32 lines
545 B
Go
package core
|
|
|
|
import (
|
|
"git.akyoto.dev/cli/q/src/build/ast"
|
|
)
|
|
|
|
// CompileASTNode compiles a node in the AST.
|
|
func (f *Function) CompileASTNode(node ast.Node) error {
|
|
switch node := node.(type) {
|
|
case *ast.Assign:
|
|
return f.CompileAssign(node)
|
|
|
|
case *ast.Call:
|
|
return f.CompileCall(node.Expression)
|
|
|
|
case *ast.Define:
|
|
return f.CompileDefinition(node)
|
|
|
|
case *ast.Return:
|
|
return f.CompileReturn(node)
|
|
|
|
case *ast.If:
|
|
return f.CompileIf(node)
|
|
|
|
case *ast.Loop:
|
|
return f.CompileLoop(node)
|
|
|
|
default:
|
|
panic("unknown AST type")
|
|
}
|
|
}
|