syntax-tree-accessors #2

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

View File

@ -42,9 +42,8 @@ func (parser *ParsingOperation) parseArgument () (argument Argument, err error)
return return
} }
declaration := Declaration { declaration := Declaration { }
what: what, declaration.what = what
}
declaration.setName(identifier.trail[0]) declaration.setName(identifier.trail[0])
declaration.setLocation(argument.Location()) declaration.setLocation(argument.Location())

View File

@ -43,3 +43,18 @@ func (trait nameable) Name () (name string) {
func (trait *nameable) setName (name string) { func (trait *nameable) setName (name string) {
trait.name = name trait.name = name
} }
// typeable allows a node to have a type.
type typeable struct {
what Type
}
// Type returns the type of the node.
func (trait typeable) Type () (what Type) {
return trait.what
}
// setType sets the type of the node.
func (trait *typeable) setType (what Type) () {
}

View File

@ -309,7 +309,7 @@ func (section *TypeSection) ToString (indent int) (output string) {
"type ", "type ",
section.permission.ToString(), " ", section.permission.ToString(), " ",
section.name, ":", section.name, ":",
section.inherits.ToString()) section.what.ToString())
isComplexInitialization := isComplexInitialization :=
section.defaultValue.kind == ArgumentKindObjectInitializationValues || section.defaultValue.kind == ArgumentKindObjectInitializationValues ||

View File

@ -62,7 +62,7 @@ type Type struct {
type Declaration struct { type Declaration struct {
locatable locatable
nameable nameable
what Type typeable
} }
// ObjectInitializationValues represents a list of object member initialization // ObjectInitializationValues represents a list of object member initialization
@ -150,8 +150,8 @@ type Argument struct {
type DataSection struct { type DataSection struct {
locatable locatable
nameable nameable
typeable
what Type
permission types.Permission permission types.Permission
value Argument value Argument
} }