Implemented struct parser

This commit is contained in:
2025-02-04 14:41:04 +01:00
parent fc1b970f7f
commit 51e3c1ba0e
19 changed files with 388 additions and 252 deletions

View File

@ -6,13 +6,15 @@ import (
"git.akyoto.dev/cli/q/src/core"
"git.akyoto.dev/cli/q/src/errors"
"git.akyoto.dev/cli/q/src/fs"
"git.akyoto.dev/cli/q/src/types"
)
// Compile waits for the scan to finish and compiles all functions.
func Compile(files <-chan *fs.File, functions <-chan *core.Function, errs <-chan error) (Result, error) {
func Compile(files <-chan *fs.File, functions <-chan *core.Function, structs <-chan *types.Type, errs <-chan error) (Result, error) {
result := Result{}
allFiles := make([]*fs.File, 0, 8)
allFunctions := map[string]*core.Function{}
allTypes := map[string]*types.Type{}
for functions != nil || files != nil || errs != nil {
select {
@ -25,6 +27,14 @@ func Compile(files <-chan *fs.File, functions <-chan *core.Function, errs <-chan
function.Functions = allFunctions
allFunctions[function.UniqueName] = function
case typ, ok := <-structs:
if !ok {
structs = nil
continue
}
allTypes[typ.Name] = typ
case file, ok := <-files:
if !ok {
files = nil