syntax-tree-accessors #2

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

View File

@ -195,3 +195,40 @@ func (section FaceSection) Behaviors () (iterator types.Iterator[FaceBehavior])
iterator = types.NewIterator(section.behaviors)
return
}
// Kind returns what kind of phrase it is.
func (phrase Phrase) Kind () (kind PhraseKind) {
kind = phrase.kind
return
}
// ArgumentsLength returns the amount of arguments in the phrase.
func (phrase Phrase) ArgumentsLength () (length int) {
length = len(phrase.arguments)
return
}
// Argument returns the argument at index.
func (phrase Phrase) Argument (index int) (argument Argument) {
argument = phrase.arguments[index]
return
}
// ReturnsToLength returns the amount of things the phrase returns to.
func (phrase Phrase) ReturnsToLength () (length int) {
length = len(phrase.returnsTo)
return
}
// ReturnTo returns the thing alskdjaslkdjsa whatever i dont even know wtf.
func (phrase Phrase) ReturnTo (index int) (returnTo Argument) {
returnTo = phrase.returnsTo[index]
return
}
// Block returns the block under the phrase, if it is a control flow statement.
func (phrase Phrase) Block () (block Block) {
block = phrase.block
return
}

View File

@ -239,7 +239,7 @@ type FaceSection struct {
permissionable
inherits Identifier
behaviors map[string] FaceBehavior
behaviors map[string] FaceBehavior
}
// PhraseKind determines what semantic role a phrase plays.
@ -267,6 +267,8 @@ type Phrase struct {
location file.Location
command Argument
arguments []Argument
// TODO: this is wack. it should be named after a plural noun like,
// returnees or something. accessor methods should beupdated to match.
returnsTo []Argument
kind PhraseKind