Created Section interface
This commit is contained in:
parent
899f4815bc
commit
ded0ce58ec
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/lexer"
|
||||||
import "git.tebibyte.media/arf/arf/infoerr"
|
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.
|
// parse body parses the body of an arf file, after the metadata header.
|
||||||
func (parser *ParsingOperation) parseBody () (err error) {
|
func (parser *ParsingOperation) parseBody () (err error) {
|
||||||
for {
|
for {
|
||||||
|
@ -18,6 +18,24 @@ type SyntaxTree struct {
|
|||||||
funcSections map[string] *FuncSection
|
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.
|
// Identifier represents a chain of arguments separated by a dot.
|
||||||
type Identifier struct {
|
type Identifier struct {
|
||||||
locatable
|
locatable
|
||||||
|
Reference in New Issue
Block a user