This commit is contained in:
parent
3717a61414
commit
320e023d74
9 changed files with 45 additions and 21 deletions
|
@ -32,6 +32,8 @@ var errs = []struct {
|
|||
{"MissingParameter.q", scanner.MissingParameter},
|
||||
{"MissingParameter2.q", scanner.MissingParameter},
|
||||
{"MissingParameter3.q", scanner.MissingParameter},
|
||||
{"MissingParameter4.q", scanner.MissingParameter},
|
||||
{"MissingParameter5.q", scanner.MissingParameter},
|
||||
{"MissingType.q", scanner.MissingType},
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ func scanSignature(file *fs.File, tokens token.List, i int, delimiter token.Kind
|
|||
return nil, i, errors.New(InvalidFunctionDefinition, file, tokens[i].Position)
|
||||
}
|
||||
|
||||
return nil, i, nil
|
||||
return nil, i, errors.New(InvalidFunctionDefinition, file, tokens[i].Position)
|
||||
}
|
||||
|
||||
if groupLevel > 0 {
|
||||
|
@ -98,7 +98,10 @@ func scanSignature(file *fs.File, tokens token.List, i int, delimiter token.Kind
|
|||
return nil, i, errors.New(MissingType, file, param[0].End())
|
||||
}
|
||||
|
||||
function.Input = append(function.Input, core.NewParameter(param))
|
||||
function.Input = append(function.Input, &core.Parameter{
|
||||
Name: param[0].String(file.Bytes),
|
||||
TypeTokens: param[1:],
|
||||
})
|
||||
}
|
||||
|
||||
if typeStart != -1 {
|
||||
|
@ -109,8 +112,30 @@ func scanSignature(file *fs.File, tokens token.List, i int, delimiter token.Kind
|
|||
|
||||
outputTokens := tokens[typeStart:typeEnd]
|
||||
|
||||
if len(outputTokens) == 0 {
|
||||
return nil, i, errors.New(MissingParameter, file, tokens[typeStart].Position)
|
||||
}
|
||||
|
||||
errorPos := token.Position(typeStart)
|
||||
|
||||
for param := range outputTokens.Split {
|
||||
function.Output = append(function.Output, core.NewParameter(param))
|
||||
if len(param) == 0 {
|
||||
return nil, i, errors.New(MissingParameter, file, errorPos)
|
||||
}
|
||||
|
||||
if len(param) == 1 {
|
||||
function.Output = append(function.Output, &core.Parameter{
|
||||
Name: "",
|
||||
TypeTokens: param,
|
||||
})
|
||||
} else {
|
||||
function.Output = append(function.Output, &core.Parameter{
|
||||
Name: param[0].String(file.Bytes),
|
||||
TypeTokens: param[1:],
|
||||
})
|
||||
}
|
||||
|
||||
errorPos = param[len(param)-1].End() + 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
1
src/scanner/testdata/errors/MissingParameter4.q
vendored
Normal file
1
src/scanner/testdata/errors/MissingParameter4.q
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
f() -> {}
|
1
src/scanner/testdata/errors/MissingParameter5.q
vendored
Normal file
1
src/scanner/testdata/errors/MissingParameter5.q
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
f() -> (int,) {}
|
Loading…
Add table
Add a link
Reference in a new issue