diff --git a/parser/enum.go b/parser/enum.go index 80577a7..228c9f0 100644 --- a/parser/enum.go +++ b/parser/enum.go @@ -4,6 +4,7 @@ import "git.tebibyte.media/arf/arf/types" import "git.tebibyte.media/arf/arf/lexer" import "git.tebibyte.media/arf/arf/infoerr" +// parseEnumSection parses an enumerated type section. func (parser *ParsingOperation) parseEnumSection () ( section *EnumSection, err error, diff --git a/parser/node-traits.go b/parser/node-traits.go index d0e2df0..29e64ce 100644 --- a/parser/node-traits.go +++ b/parser/node-traits.go @@ -1,6 +1,7 @@ package parser import "git.tebibyte.media/arf/arf/file" +import "git.tebibyte.media/arf/arf/types" import "git.tebibyte.media/arf/arf/infoerr" // locatable allows a tree node to have a location. @@ -21,7 +22,8 @@ func (trait locatable) NewError ( ) ( err infoerr.Error, ) { - return infoerr.NewError(trait.location, message, kind) + err = infoerr.NewError(trait.location, message, kind) + return } // nameable allows a tree node to have a name. @@ -41,5 +43,16 @@ type typeable struct { // Type returns the type of the node. func (trait typeable) Type () (what Type) { - return trait.what + what = trait.what + return +} + +// permissionable allows a node to have a permission. +type permissionable struct { + permission types.Permission +} + +func (trait permissionable) Permission () (permission types.Permission) { + permission = trait.permission + return } diff --git a/parser/tree.go b/parser/tree.go index bf99c55..d726cbf 100644 --- a/parser/tree.go +++ b/parser/tree.go @@ -1,7 +1,6 @@ package parser import "git.tebibyte.media/arf/arf/file" -import "git.tebibyte.media/arf/arf/types" // SyntaxTree represents an abstract syntax tree. It covers an entire module. It // can be expected to be syntactically correct, but it might not be semantically @@ -151,9 +150,9 @@ type DataSection struct { locatable nameable typeable + permissionable - permission types.Permission - value Argument + value Argument } // TypeSection represents a blind type definition. @@ -161,8 +160,8 @@ type TypeSection struct { locatable nameable typeable + permissionable - permission types.Permission defaultValue Argument } @@ -171,9 +170,9 @@ type ObjtMember struct { locatable nameable typeable + permissionable bitWidth uint64 - permission types.Permission defaultValue Argument } @@ -181,9 +180,9 @@ type ObjtMember struct { type ObjtSection struct { locatable nameable + permissionable inherits Identifier - permission types.Permission members []ObjtMember } @@ -199,9 +198,9 @@ type EnumSection struct { locatable nameable typeable + permissionable - permission types.Permission - members []EnumMember + members []EnumMember } // FaceBehavior represents a behavior of an interface section. @@ -217,9 +216,9 @@ type FaceBehavior struct { type FaceSection struct { locatable nameable + permissionable inherits Identifier - permission types.Permission behaviors map[string] FaceBehavior } @@ -270,7 +269,7 @@ type FuncOutput struct { type FuncSection struct { locatable nameable - permission types.Permission + permissionable receiver *Declaration inputs []Declaration diff --git a/parser/type.go b/parser/type.go index cacc3b0..5c484f2 100644 --- a/parser/type.go +++ b/parser/type.go @@ -2,7 +2,6 @@ package parser import "git.tebibyte.media/arf/arf/types" import "git.tebibyte.media/arf/arf/lexer" -// import "git.tebibyte.media/arf/arf/infoerr" // parseTypeSection parses a blind type definition, meaning it can inherit from // anything including primitives, but cannot define structure.