syntax-tree-accessors #2

Merged
sashakoshka merged 22 commits from syntax-tree-accessors into main 2022-09-05 08:52:09 -06:00
3 changed files with 57 additions and 0 deletions
Showing only changes of commit ded0ce58ec - Show all commits

37
parser/accessors.go Normal file
View File

@ -0,0 +1,37 @@
package parser
// Kind returns the section's kind (SectionKindType).
func (section TypeSection) Kind () (kind SectionKind) {
kind = SectionKindType
return
}
// Kind returns the section's kind (SectionKindObjt).
func (section ObjtSection) Kind () (kind SectionKind) {
kind = SectionKindObjt
return
}
// Kind returns the section's kind (SectionKindEnum).
func (section EnumSection) Kind () (kind SectionKind) {
kind = SectionKindEnum
return
}
// Kind returns the section's kind (SectionKindFace).
func (section FaceSection) Kind () (kind SectionKind) {
kind = SectionKindFace
return
}
// Kind returns the section's kind (SectionKindData).
func (section DataSection) Kind () (kind SectionKind) {
kind = SectionKindData
return
}
// Kind returns the section's kind (SectionKindFunc).
func (section FuncSection) Kind () (kind SectionKind) {
kind = SectionKindFunc
return
}

View File

@ -3,6 +3,8 @@ package parser
import "git.tebibyte.media/arf/arf/lexer"
import "git.tebibyte.media/arf/arf/infoerr"
// TODO: parser must ensure that these names are unique
// parse body parses the body of an arf file, after the metadata header.
func (parser *ParsingOperation) parseBody () (err error) {
for {

View File

@ -18,6 +18,24 @@ type SyntaxTree struct {
funcSections map[string] *FuncSection
}
// SectionKind differentiates Section interfaces.
type SectionKind int
const (
SectionKindType = iota
SectionKindObjt
SectionKindEnum
SectionKindFace
SectionKindData
SectionKindFunc
)
// Section can be any kind of section. You can find out what type of section it
// is with the Kind method.
type Section interface {
Kind () (kind SectionKind)
}
// Identifier represents a chain of arguments separated by a dot.
type Identifier struct {
locatable