From a31c975c9dee9135dfe36af64dfdc686b36db534 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 29 Sep 2022 11:02:37 -0400 Subject: [PATCH] Func section tostrings and parses output values properly --- parser/func.go | 21 +++++++++++++-------- parser/tree-tostring.go | 3 +++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/parser/func.go b/parser/func.go index 5b61ace..d7f9405 100644 --- a/parser/func.go +++ b/parser/func.go @@ -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 } } } } diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index c0bef0e..ad5e786 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -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 }