From 925f55788f538820c57bf5936952ee813a1bba20 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Fri, 16 Sep 2022 12:27:13 -0400 Subject: [PATCH] Fixed the hanging thing --- parser/parser.go | 18 ++++++++++++++++++ parser/type-notation.go | 12 ++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/parser/parser.go b/parser/parser.go index 2520af9..b64f89c 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -166,3 +166,21 @@ func (parser *ParsingOperation) skipIndentLevel (indent int) (err error) { if err != nil { return } } } + +// skipWhitespace skips over newlines and indent tokens. +func (parser *ParsingOperation) skipWhitespace () (err error) { + for { + isWhitespace := + parser.token.Is(lexer.TokenKindIndent) || + parser.token.Is(lexer.TokenKindNewline) + + if !isWhitespace { + break + } + + err = parser.nextToken() + if err != nil { return } + } + + return +} diff --git a/parser/type-notation.go b/parser/type-notation.go index f12bf96..2788a73 100644 --- a/parser/type-notation.go +++ b/parser/type-notation.go @@ -111,8 +111,8 @@ func (parser *ParsingOperation) parseBasicDefaultValue () ( } () for { - if parser.token.Is(lexer.TokenKindIndent) { continue } - if parser.token.Is(lexer.TokenKindNewline) { continue } + err = parser.skipWhitespace() + if err != nil { return } if parser.token.Is(lexer.TokenKindGreaterThan) { break } value, err = parser.parseArgument() @@ -139,8 +139,8 @@ func (parser *ParsingOperation) parseObjectDefaultValueAndMembers () ( var attributes ObjectDefaultValues for { - if parser.token.Is(lexer.TokenKindIndent) { continue } - if parser.token.Is(lexer.TokenKindNewline) { continue } + err = parser.skipWhitespace() + if err != nil { return } if parser.token.Is(lexer.TokenKindRParen) { break } err = parser.expect(lexer.TokenKindDot) @@ -200,8 +200,8 @@ func (parser *ParsingOperation) parseObjectDefaultValue () ( var attributes ObjectDefaultValues for { - if parser.token.Is(lexer.TokenKindIndent) { continue } - if parser.token.Is(lexer.TokenKindNewline) { continue } + err = parser.skipWhitespace() + if err != nil { return } if parser.token.Is(lexer.TokenKindRParen) { break } err = parser.expect(lexer.TokenKindDot)