From 5b627f8995411d7a865c1817c68efea11fccb678 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Fri, 16 Sep 2022 12:16:23 -0400 Subject: [PATCH] wow it hangs --- parser/data.go | 28 ++++++++++++++++++++-------- parser/tree-tostring.go | 4 ++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/parser/data.go b/parser/data.go index 22fcdfb..313a909 100644 --- a/parser/data.go +++ b/parser/data.go @@ -35,16 +35,28 @@ func (parser *ParsingOperation) parseDataSection () ( return } - // check if data is external - if parser.token.Is(lexer.TokenKindName) && - parser.token.Value().(string) == "external" { + err = parser.expect(lexer.TokenKindNewline) + if err != nil { return } + err = parser.nextToken() + if err != nil { return } - section.external = true - err = parser.nextToken(lexer.TokenKindNewline) + // check if data is external + if parser.token.Is(lexer.TokenKindIndent) && + parser.token.Value().(int) == 1 { + + err = parser.nextToken(lexer.TokenKindName) if err != nil { return } - err = parser.nextToken() - if err != nil { return } - return + if parser.token.Value().(string) == "external" { + + section.external = true + err = parser.nextToken(lexer.TokenKindNewline) + if err != nil { return } + err = parser.nextToken() + if err != nil { return } + return + } + + parser.previousToken() } return } diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index 497272e..07e19b7 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -128,7 +128,7 @@ func (what Type) ToString (indent int) (output string) { output += what.defaultValue.ToString(indent, true) } else { output += ":<" - output += what.defaultValue.ToString(indent, true) + output += what.defaultValue.ToString(indent, false) output += ">\n" } } @@ -269,7 +269,7 @@ func (argument Argument) ToString (indent int, breakLine bool) (output string) { func (section DataSection) ToString (indent int) (output string) { output += doIndent ( indent, - "type ", + "data ", section.permission.ToString(), " ", section.name, ":", section.what.ToString(indent), "\n")