Implemented struct parser

This commit is contained in:
Eduard Urbach 2025-02-04 14:41:04 +01:00
parent 00e7216256
commit 30940f0100
Signed by: eduard
GPG key ID: 49226B848C78F6C8
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