Simplified file structure

This commit is contained in:
2024-08-07 19:39:10 +02:00
parent 1b13539b22
commit 66569446b1
219 changed files with 453 additions and 457 deletions

View File

@ -0,0 +1,51 @@
package core
import (
"git.akyoto.dev/cli/q/src/ast"
)
// CompileASTNode compiles a node in the AST.
func (f *Function) CompileASTNode(node ast.Node) error {
switch node := node.(type) {
case *ast.Assert:
f.Fold(node.Condition)
return f.CompileAssert(node)
case *ast.Assign:
f.Fold(node.Expression)
return f.CompileAssign(node)
case *ast.Call:
f.Fold(node.Expression)
_, err := f.CompileCall(node.Expression)
return err
case *ast.Define:
f.Fold(node.Expression)
return f.CompileDefinition(node)
case *ast.If:
f.Fold(node.Condition)
return f.CompileIf(node)
case *ast.Loop:
return f.CompileLoop(node)
case *ast.Return:
for _, value := range node.Values {
f.Fold(value)
}
return f.CompileReturn(node)
case *ast.Switch:
for _, c := range node.Cases {
f.Fold(c.Condition)
}
return f.CompileSwitch(node)
default:
panic("unknown AST type")
}
}