Add dereference parsing #17

Merged
sashakoshka merged 7 commits from parse-dereferences into main 2022-10-11 11:37:40 -06:00
2 changed files with 23 additions and 3 deletions
Showing only changes of commit 1cd7511ced - Show all commits

View File

@ -133,6 +133,9 @@ func (argument Argument) ToString (indent int, breakLine bool) (output string) {
case ArgumentKindList:
output += argument.value.(List).ToString(indent, breakLine)
case ArgumentKindDereference:
output += argument.value.(Dereference).ToString(indent)
case ArgumentKindIdentifier:
output += doIndent (
@ -276,6 +279,16 @@ func (behavior FaceBehavior) ToString (indent int) (output string) {
return
}
func (dereference Dereference) ToString (indent int) (output string) {
output += "{"
output += dereference.argument.ToString(indent, false)
if dereference.offset != 0 {
output += fmt.Sprint(" ", dereference.offset)
}
output += "}"
return
}
func (phrase Phrase) ToString (indent int, ownLine bool) (output string) {
if ownLine {
output += doIndent(indent)

View File

@ -97,10 +97,8 @@ const (
ArgumentKindList
// {name}
ArgumentKindDereference
// {name 23}
ArgumentKindSubscript
ArgumentKindDereference
// name.name
// name.name.name
@ -220,6 +218,15 @@ type FaceSection struct {
FaceBehavior
}
// Dereference represents a pointer dereference or array subscript.
type Dereference struct {
locatable
valuable
// if a simple dereference was parsed, this should just be zero.
offset int
}
// PhraseKind determines what semantic role a phrase plays.
type PhraseKind int