Func section tostrings and parses output values properly

This commit is contained in:
Sasha Koshka 2022-09-29 11:02:37 -04:00
parent 7374de2633
commit a31c975c9d
2 changed files with 16 additions and 8 deletions

View File

@ -186,29 +186,34 @@ func (parser *ParsingOperation) parseFuncArguments (
if err != nil { return }
output.what, err = parser.parseType()
if err != nil { return }
into.outputs = append(into.outputs, output)
// 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 }
exited :=
!parser.token.Is(lexer.TokenKindIndent) ||
parser.token.Value().(int) != 2
if exited {
into.outputs = append(into.outputs, output)
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()
}
// get default value
output.argument, err = parser.parseArgument()
into.outputs = append(into.outputs, output)
if err != nil { return }
err = parser.expect(lexer.TokenKindNewline)
if err != nil { return }
err = parser.nextToken()
if err != nil { return }
}
}
}

View File

@ -379,10 +379,13 @@ func (phrase Phrase) ToString (indent int, ownLine bool) (output string) {
func (funcOutput FuncOutput) ToString (indent int) (output string) {
output += doIndent(indent + 1)
output += "< " + funcOutput.Declaration.ToString()
// why is it always nil??? WHY???
if funcOutput.argument.kind != ArgumentKindNil {
output += " " + funcOutput.argument.ToString(indent, false)
}
output += "\n"
print(funcOutput.argument.ToString(0, true))
return
}