Iterator actually advances now
This commit is contained in:
parent
b2cc45abec
commit
ed4c9aa0d2
@ -29,8 +29,7 @@ func (analyzer AnalysisOperation) analyzeArgument (
|
|||||||
) {
|
) {
|
||||||
switch inputArgument.Kind() {
|
switch inputArgument.Kind() {
|
||||||
case parser.ArgumentKindNil:
|
case parser.ArgumentKindNil:
|
||||||
panic (
|
panic("invalid state: attempt to analyze nil argument")
|
||||||
"invalid state: attempt to analyze nil argument")
|
|
||||||
|
|
||||||
case parser.ArgumentKindPhrase:
|
case parser.ArgumentKindPhrase:
|
||||||
// TODO
|
// TODO
|
||||||
@ -41,10 +40,7 @@ func (analyzer AnalysisOperation) analyzeArgument (
|
|||||||
case parser.ArgumentKindSubscript:
|
case parser.ArgumentKindSubscript:
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
case parser.ArgumentKindObjectDefaultValues:
|
case parser.ArgumentKindList:
|
||||||
// TODO
|
|
||||||
|
|
||||||
case parser.ArgumentKindArrayDefaultValues:
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
case parser.ArgumentKindIdentifier:
|
case parser.ArgumentKindIdentifier:
|
||||||
@ -67,11 +63,6 @@ func (analyzer AnalysisOperation) analyzeArgument (
|
|||||||
|
|
||||||
case parser.ArgumentKindRune:
|
case parser.ArgumentKindRune:
|
||||||
outputArgument = RuneLiteral(inputArgument.Value().(rune))
|
outputArgument = RuneLiteral(inputArgument.Value().(rune))
|
||||||
|
|
||||||
case parser.ArgumentKindOperator:
|
|
||||||
panic (
|
|
||||||
"invalid state: attempt to analyze operator argument " +
|
|
||||||
"directly")
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,33 @@ type TypeSection struct {
|
|||||||
sectionBase
|
sectionBase
|
||||||
what Type
|
what Type
|
||||||
complete bool
|
complete bool
|
||||||
|
// TODO: do not add members from parent type. instead have a member
|
||||||
|
// function to discern whether this type contains a particular member,
|
||||||
|
// and have it recurse all the way up the family tree. it will be the
|
||||||
|
// translator's job to worry about what members are placed where.
|
||||||
|
members []ObjectMember
|
||||||
|
}
|
||||||
|
|
||||||
|
// ObjectMember is a member of an object type.
|
||||||
|
type ObjectMember struct {
|
||||||
|
name string
|
||||||
|
|
||||||
|
// even if there is a private permission in another module, we still
|
||||||
|
// need to include it in the semantic analysis because we need to know
|
||||||
|
// how many members objects have.
|
||||||
|
permission types.Permission
|
||||||
|
|
||||||
|
what Type
|
||||||
|
}
|
||||||
|
|
||||||
|
func (member ObjectMember) ToString (indent int) (output string) {
|
||||||
|
output += doIndent (
|
||||||
|
indent,
|
||||||
|
member.name, " ",
|
||||||
|
member.permission.ToString(),
|
||||||
|
"\n")
|
||||||
|
output += member.what.ToString(indent + 1)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToString returns all data stored within the type section, in string form.
|
// ToString returns all data stored within the type section, in string form.
|
||||||
@ -26,7 +53,8 @@ func (analyzer AnalysisOperation) analyzeTypeSection () (
|
|||||||
inputSection := analyzer.currentSection.(parser.TypeSection)
|
inputSection := analyzer.currentSection.(parser.TypeSection)
|
||||||
if inputSection.Permission() == types.PermissionReadWrite {
|
if inputSection.Permission() == types.PermissionReadWrite {
|
||||||
err = inputSection.NewError (
|
err = inputSection.NewError (
|
||||||
"rw permission not understood in this context, try ro",
|
"read-write (rw) permission not understood in this " +
|
||||||
|
"context, try read-only (ro)",
|
||||||
infoerr.ErrorKindError)
|
infoerr.ErrorKindError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package analyzer
|
package analyzer
|
||||||
|
|
||||||
import "git.tebibyte.media/arf/arf/types"
|
// import "git.tebibyte.media/arf/arf/types"
|
||||||
import "git.tebibyte.media/arf/arf/parser"
|
import "git.tebibyte.media/arf/arf/parser"
|
||||||
import "git.tebibyte.media/arf/arf/infoerr"
|
import "git.tebibyte.media/arf/arf/infoerr"
|
||||||
|
|
||||||
@ -21,28 +21,6 @@ const (
|
|||||||
TypeKindObject
|
TypeKindObject
|
||||||
)
|
)
|
||||||
|
|
||||||
// ObjectMember is a member of an object type.
|
|
||||||
type ObjectMember struct {
|
|
||||||
name string
|
|
||||||
|
|
||||||
// even if there is a private permission in another module, we still
|
|
||||||
// need to include it in the semantic analysis because we need to know
|
|
||||||
// how many members objects have.
|
|
||||||
permission types.Permission
|
|
||||||
|
|
||||||
what Type
|
|
||||||
}
|
|
||||||
|
|
||||||
func (member ObjectMember) ToString (indent int) (output string) {
|
|
||||||
output += doIndent (
|
|
||||||
indent,
|
|
||||||
member.name, " ",
|
|
||||||
member.permission.ToString(),
|
|
||||||
"\n")
|
|
||||||
output += member.what.ToString(indent + 1)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Type represents a description of a type. It must eventually point to a
|
// Type represents a description of a type. It must eventually point to a
|
||||||
// TypeSection.
|
// TypeSection.
|
||||||
type Type struct {
|
type Type struct {
|
||||||
@ -57,14 +35,6 @@ type Type struct {
|
|||||||
// of whatever the type is. even if the type is a variable length array.
|
// of whatever the type is. even if the type is a variable length array.
|
||||||
// because literally why not.
|
// because literally why not.
|
||||||
length uint64
|
length uint64
|
||||||
|
|
||||||
// this is only applicable for a TypeKindObject where new members are
|
|
||||||
// defined.
|
|
||||||
// TODO: do not add members from parent type. instead have a member
|
|
||||||
// function to discern whether this type contains a particular member,
|
|
||||||
// and have it recurse all the way up the family tree. it will be the
|
|
||||||
// translator's job to worry about what members are placed where.
|
|
||||||
members []ObjectMember
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToString returns all data stored within the type, in string form.
|
// ToString returns all data stored within the type, in string form.
|
||||||
|
@ -69,8 +69,6 @@ func (parser *ParsingOperation) parseTypeSection () (
|
|||||||
section.members = append(section.members, member)
|
section.members = append(section.members, member)
|
||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseTypeSectionMember parses a type section member variable.
|
// parseTypeSectionMember parses a type section member variable.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
:arf
|
:arf
|
||||||
---
|
---
|
||||||
|
|
||||||
type basicInt:Int:<5>
|
type ro basicInt:Int 5
|
||||||
|
@ -39,7 +39,7 @@ func (iterator Iterator[VALUE_TYPE]) Value () (value VALUE_TYPE) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Next advances the iterator by 1.
|
// Next advances the iterator by 1.
|
||||||
func (iterator Iterator[VALUE_TYPE]) Next () {
|
func (iterator *Iterator[VALUE_TYPE]) Next () {
|
||||||
iterator.index ++
|
iterator.index ++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user