Fixed the hanging thing

This commit is contained in:
Sasha Koshka 2022-09-16 12:27:13 -04:00
parent 5b627f8995
commit 925f55788f
2 changed files with 24 additions and 6 deletions

View File

@ -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
}

View File

@ -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)