Parser parses function outputs

This commit is contained in:
Sasha Koshka 2022-09-29 02:29:35 -04:00
parent 5f0e4697b5
commit 290f8799cf
2 changed files with 20 additions and 4 deletions

View File

@ -171,7 +171,7 @@ func (parser *ParsingOperation) parseFuncArguments (
if err != nil { return }
case lexer.TokenKindLessThan:
output := Declaration { }
output := FuncOutput { }
output.location = parser.token.Location()
// get name
@ -189,10 +189,26 @@ func (parser *ParsingOperation) parseFuncArguments (
into.outputs = append(into.outputs, output)
parser.expect(lexer.TokenKindNewline)
// skip newline if it is there
if parser.token.Is(lexer.TokenKindNewline) {
parser.nextToken()
// if we have exited the output, break
if !parser.token.Is(lexer.TokenKindIndent) { break }
if parser.token.Value().(int) != 2 { break }
err = parser.nextToken()
if err != nil { return }
}
// if default value exists, get it
if !parser.token.Is(lexer.TokenKindBinaryAnd) {
output.argument, err = parser.parseArgument()
}
err = parser.expect(lexer.TokenKindNewline)
if err != nil { return }
err = parser.nextToken()
if err != nil { return }
}
}
}

View File

@ -268,7 +268,7 @@ type FuncSection struct {
receiver *Declaration
inputs []Declaration
outputs []Declaration
outputs []FuncOutput
root Block
external bool