package parser
import "git.tebibyte.media/arf/arf/types"
import "git.tebibyte.media/arf/arf/lexer"
// parseData parses a data section.
func (parser *ParsingOperation) parseDataSection () (
section *DataSection,
err error,
) {
err = parser.expect(lexer.TokenKindName)
if err != nil { return }
section = &DataSection { location: parser.token.Location() }
err = parser.nextToken(lexer.TokenKindPermission)
section.permission = parser.token.Value().(types.Permission)
err = parser.nextToken(lexer.TokenKindName)
section.name = parser.token.Value().(string)
err = parser.nextToken(lexer.TokenKindColon)
err = parser.nextToken()
section.what, err = parser.parseType()
if parser.token.Is(lexer.TokenKindNewline) {
section.value, err = parser.parseInitializationValues(0)
} else {
section.value, err = parser.parseArgument()
err = parser.expect(lexer.TokenKindNewline)
}
return