The entirety of phrase command parsing is in one function

This function is also responsible for setting a kind attribute on
the phrase. This will make the semantic analyzer's job easier.
This commit is contained in:
2022-09-03 15:49:47 -04:00
parent 7bde082f36
commit 977ecba78c
2 changed files with 62 additions and 26 deletions

View File

@@ -223,6 +223,24 @@ type FaceSection struct {
behaviors map[string] FaceBehavior
}
// PhraseKind determines what semantic role a phrase plays.
type PhraseKind int
const (
PhraseKindCall = iota
PhraseKindCallExternal
PhraseKindOperator
PhraseKindSet
PhraseKindDefer
PhraseKindIf
PhraseKindElseIf
PhraseKindElse
PhraseKindSwitch
PhraseKindCase
PhraseKindWhile
PhraseKindFor
)
// Phrase represents a function call or operator. In ARF they are the same
// syntactical concept.
type Phrase struct {
@@ -231,7 +249,9 @@ type Phrase struct {
arguments []Argument
returnsTo []Argument
// only applicable for
kind PhraseKind
// only applicable for control flow phrases
block Block
}