Fixed data section parsing

This commit is contained in:
Sasha Koshka 2022-09-27 18:42:00 -04:00
parent 93bc742339
commit 6c70e9c50d

View File

@ -35,28 +35,37 @@ func (parser *ParsingOperation) parseDataSection () (
return return
} }
err = parser.expect(lexer.TokenKindNewline) // see if value exists
if err != nil { return } if parser.token.Is(lexer.TokenKindNewline) {
err = parser.nextToken() parser.nextToken()
if err != nil { return } // if we have exited the member, return
if !parser.token.Is(lexer.TokenKindIndent) { return }
// check if data is external if parser.token.Value().(int) != 1 { return }
if parser.token.Is(lexer.TokenKindIndent) &&
parser.token.Value().(int) == 1 {
err = parser.nextToken(lexer.TokenKindName) err = parser.nextToken()
if err != nil { return } if err != nil { return }
}
// check if external
if parser.token.Is(lexer.TokenKindName) {
if parser.token.Value().(string) == "external" { if parser.token.Value().(string) == "external" {
section.external = true section.external = true
err = parser.nextToken(lexer.TokenKindNewline) err = parser.nextToken(lexer.TokenKindNewline)
if err != nil { return } if err != nil { return }
err = parser.nextToken() err = parser.nextToken()
if err != nil { return } if err != nil { return }
return return
} }
parser.previousToken()
} }
// get value
section.argument, err = parser.parseArgument()
err = parser.expect(lexer.TokenKindNewline)
if err != nil { return }
err = parser.nextToken()
if err != nil { return }
return return
} }