This repository has been archived on 2024-02-27. You can view files and clone it, but cannot push or open issues or pull requests.
arf/parser/body.go

43 lines
1.1 KiB
Go
Raw Normal View History

2022-08-14 20:38:57 -06:00
package parser
import "git.tebibyte.media/sashakoshka/arf/lexer"
import "git.tebibyte.media/sashakoshka/arf/infoerr"
2022-08-14 20:38:57 -06:00
// parse body parses the body of an arf file, after the metadata header.
func (parser *ParsingOperation) parseBody () (err error) {
for {
err = parser.expect(lexer.TokenKindName)
2022-08-15 13:09:07 -06:00
if err != nil { return }
sectionType := parser.token.Value().(string)
switch sectionType {
case "data":
var section *DataSection
section, err = parser.parseDataSection()
if parser.tree.dataSections == nil {
parser.tree.dataSections =
make(map[string] *DataSection)
}
parser.tree.dataSections[section.name] = section
if err != nil { return }
case "type":
2022-08-18 15:39:19 -06:00
var section *TypeSection
section, err = parser.parseTypeSection()
if parser.tree.typeSections == nil {
parser.tree.typeSections =
make(map[string] *TypeSection)
}
parser.tree.typeSections[section.name] = section
if err != nil { return }
case "face":
case "enum":
case "func":
default:
err = parser.token.NewError (
"unknown section type \"" + sectionType + "\"",
infoerr.ErrorKindError)
return
2022-08-15 13:09:07 -06:00
}
2022-08-14 20:38:57 -06:00
}
}