Did the same thing but with permissions

This commit is contained in:
Sasha Koshka 2022-09-03 23:03:09 -04:00
parent 3f7c779e2b
commit e0a04e68e3
4 changed files with 25 additions and 13 deletions

View File

@ -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,

View File

@ -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
}

View File

@ -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

View File

@ -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.