Added types

This commit is contained in:
Eduard Urbach 2024-08-05 18:47:24 +02:00
parent 60a920734d
commit 188b85fdce
Signed by: eduard
GPG key ID: 49226B848C78F6C8
33 changed files with 113 additions and 92 deletions

View file

@ -1,6 +1,7 @@
package scanner
import (
"fmt"
"os"
"path/filepath"
@ -153,8 +154,20 @@ func (s *Scanner) scanFile(path string, pkg string) error {
return errors.New(errors.ExpectedFunctionParameters, file, tokens[i].Position)
}
// Return type
if i < len(tokens) && tokens[i].Kind == token.ReturnType {
for i < len(tokens) && tokens[i].Kind != token.BlockStart {
i++
}
}
// Function definition
for i < len(tokens) {
if tokens[i].Kind == token.ReturnType {
i++
continue
}
if tokens[i].Kind == token.BlockStart {
blockLevel++
i++
@ -207,17 +220,18 @@ func (s *Scanner) scanFile(path string, pkg string) error {
name := tokens[nameStart].Text(contents)
body := tokens[bodyStart:i]
function := core.NewFunction(pkg, name, file, body)
parameters := tokens[paramsStart:paramsEnd]
count := 0
err := expression.EachParameter(parameters, func(tokens token.List) error {
if len(tokens) != 1 {
return errors.New(errors.NotImplemented, file, tokens[0].Position)
if len(tokens) < 2 {
return errors.New(errors.MissingType, file, tokens[0].End())
}
name := tokens[0].Text(contents)
dataType := tokens[1].Text(contents)
fmt.Println(dataType)
register := x64.CallRegisters[count]
uses := token.Count(function.Body, contents, token.Identifier, name)