Implemented token splitting as a generator
This commit is contained in:
parent
3ffcfa0084
commit
f31ea5e825
4 changed files with 39 additions and 60 deletions
|
@ -96,30 +96,24 @@ func scanFunctionSignature(file *fs.File, tokens token.List, i int, delimiter to
|
|||
|
||||
outputTokens := tokens[typeStart:typeEnd]
|
||||
|
||||
err := outputTokens.Split(func(tokens token.List) error {
|
||||
function.Output = append(function.Output, core.NewParameter(tokens))
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, i, err
|
||||
for param := range outputTokens.Split {
|
||||
function.Output = append(function.Output, core.NewParameter(param))
|
||||
}
|
||||
}
|
||||
|
||||
parameters := tokens[paramsStart:paramsEnd]
|
||||
|
||||
err := parameters.Split(func(tokens token.List) error {
|
||||
if len(tokens) == 0 {
|
||||
return errors.New(errors.MissingParameter, file, parameters[0].Position)
|
||||
for param := range parameters.Split {
|
||||
if len(param) == 0 {
|
||||
return nil, i, errors.New(errors.MissingParameter, file, parameters[0].Position)
|
||||
}
|
||||
|
||||
if len(tokens) == 1 {
|
||||
return errors.New(errors.MissingType, file, tokens[0].End())
|
||||
if len(param) == 1 {
|
||||
return nil, i, errors.New(errors.MissingType, file, param[0].End())
|
||||
}
|
||||
|
||||
function.Input = append(function.Input, core.NewParameter(tokens))
|
||||
return nil
|
||||
})
|
||||
function.Input = append(function.Input, core.NewParameter(param))
|
||||
}
|
||||
|
||||
return function, i, err
|
||||
return function, i, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue