syntax-tree-accessors #2
37
parser/accessors.go
Normal file
37
parser/accessors.go
Normal 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
|
||||
}
|
@ -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 {
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user