Removed the horrendus "ArgumentKindObjectInitializationValues" name
This commit is contained in:
parent
389c9a313c
commit
ba3825287d
@ -126,7 +126,7 @@ func (member TypeMember) BitWidth () (width uint64) {
|
||||
}
|
||||
|
||||
// Values returns an iterator for the initialization values.
|
||||
func (values ObjectInitializationValues) Sections () (
|
||||
func (values ObjectDefaultValues) Sections () (
|
||||
iterator types.Iterator[Argument],
|
||||
) {
|
||||
iterator = types.NewIterator(values.attributes)
|
||||
@ -134,13 +134,13 @@ func (values ObjectInitializationValues) Sections () (
|
||||
}
|
||||
|
||||
// Length returns the amount of values.
|
||||
func (values ArrayInitializationValues) Length () (length int) {
|
||||
func (values ArrayDefaultValues) Length () (length int) {
|
||||
length = len(values.values)
|
||||
return
|
||||
}
|
||||
|
||||
// Item returns the value at index.
|
||||
func (values ArrayInitializationValues) Value (index int) (value Argument) {
|
||||
func (values ArrayDefaultValues) Value (index int) (value Argument) {
|
||||
value = values.values[index]
|
||||
return
|
||||
}
|
||||
|
@ -12,21 +12,21 @@ import "git.tebibyte.media/arf/arf/infoerr"
|
||||
// (parser *ParsingOperation) parseDefaultMemberValue
|
||||
// (parser *ParsingOperation) parseMemberDeclaration
|
||||
|
||||
// parseInitializationValues starts on the line after a data section, or a set
|
||||
// parsedefaultValues starts on the line after a data section, or a set
|
||||
// phrase. It checks for an indent greater than the indent of the aforementioned
|
||||
// data section or set phrase (passed through baseIndent), and if there is,
|
||||
// it parses initialization values.
|
||||
func (parser *ParsingOperation) parseInitializationValues (
|
||||
func (parser *ParsingOperation) parsedefaultValues (
|
||||
baseIndent int,
|
||||
) (
|
||||
initializationArgument Argument,
|
||||
argument Argument,
|
||||
err error,
|
||||
) {
|
||||
// check if line is indented one more than baseIndent
|
||||
if !parser.token.Is(lexer.TokenKindIndent) { return }
|
||||
if parser.token.Value().(int) != baseIndent + 1 { return }
|
||||
|
||||
initializationArgument.location = parser.token.Location()
|
||||
argument.location = parser.token.Location()
|
||||
|
||||
err = parser.nextToken()
|
||||
if err != nil { return }
|
||||
@ -35,31 +35,31 @@ func (parser *ParsingOperation) parseInitializationValues (
|
||||
|
||||
// object initialization
|
||||
parser.previousToken()
|
||||
var initializationValues ObjectInitializationValues
|
||||
initializationValues, err = parser.parseObjectInitializationValues()
|
||||
initializationArgument.kind = ArgumentKindObjectInitializationValues
|
||||
initializationArgument.value = initializationValues
|
||||
var values ObjectDefaultValues
|
||||
values, err = parser.parseObjectdefaultValues()
|
||||
argument.kind = ArgumentKindObjectDefaultValues
|
||||
argument.value = values
|
||||
|
||||
} else {
|
||||
|
||||
// array initialization
|
||||
parser.previousToken()
|
||||
var initializationValues ArrayInitializationValues
|
||||
initializationValues, err = parser.parseArrayInitializationValues()
|
||||
initializationArgument.kind = ArgumentKindArrayInitializationValues
|
||||
initializationArgument.value = initializationValues
|
||||
var values ArrayDefaultValues
|
||||
values, err = parser.parseArrayDefaultValues()
|
||||
argument.kind = ArgumentKindArrayDefaultValues
|
||||
argument.value = values
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// parseObjectInitializationValues parses a list of object initialization
|
||||
// parseObjectdefaultValues parses a list of object initialization
|
||||
// values until the indentation level drops.
|
||||
func (parser *ParsingOperation) parseObjectInitializationValues () (
|
||||
initializationValues ObjectInitializationValues,
|
||||
func (parser *ParsingOperation) parseObjectdefaultValues () (
|
||||
defaultValues ObjectDefaultValues,
|
||||
err error,
|
||||
) {
|
||||
initializationValues.attributes = make(map[string] Argument)
|
||||
defaultValues.attributes = make(map[string] Argument)
|
||||
|
||||
baseIndent := 0
|
||||
begin := true
|
||||
@ -70,7 +70,7 @@ func (parser *ParsingOperation) parseObjectInitializationValues () (
|
||||
indent := parser.token.Value().(int)
|
||||
|
||||
if begin == true {
|
||||
initializationValues.location = parser.token.Location()
|
||||
defaultValues.location = parser.token.Location()
|
||||
baseIndent = indent
|
||||
begin = false
|
||||
}
|
||||
@ -87,7 +87,7 @@ func (parser *ParsingOperation) parseObjectInitializationValues () (
|
||||
name := parser.token.Value().(string)
|
||||
|
||||
// if the member has already been listed, throw an error
|
||||
_, exists := initializationValues.attributes[name]
|
||||
_, exists := defaultValues.attributes[name]
|
||||
if exists {
|
||||
err = parser.token.NewError (
|
||||
"duplicate member \"" + name + "\" in object " +
|
||||
@ -107,15 +107,15 @@ func (parser *ParsingOperation) parseObjectInitializationValues () (
|
||||
err = parser.nextToken(lexer.TokenKindIndent)
|
||||
if err != nil { return }
|
||||
|
||||
value, err = parser.parseInitializationValues(baseIndent)
|
||||
initializationValues.attributes[name] = value
|
||||
value, err = parser.parsedefaultValues(baseIndent)
|
||||
defaultValues.attributes[name] = value
|
||||
if err != nil { return }
|
||||
|
||||
} else {
|
||||
|
||||
// parse as normal argument
|
||||
value, err = parser.parseArgument()
|
||||
initializationValues.attributes[name] = value
|
||||
defaultValues.attributes[name] = value
|
||||
if err != nil { return }
|
||||
|
||||
err = parser.expect(lexer.TokenKindNewline)
|
||||
@ -128,10 +128,10 @@ func (parser *ParsingOperation) parseObjectInitializationValues () (
|
||||
return
|
||||
}
|
||||
|
||||
// parseArrayInitializationValues parses a list of array initialization values
|
||||
// until the indentation lexel drops.
|
||||
func (parser *ParsingOperation) parseArrayInitializationValues () (
|
||||
initializationValues ArrayInitializationValues,
|
||||
// parseArrayDefaultValues parses a list of array initialization values until
|
||||
// the indentation lexel drops.
|
||||
func (parser *ParsingOperation) parseArrayDefaultValues () (
|
||||
defaultValues ArrayDefaultValues,
|
||||
err error,
|
||||
) {
|
||||
baseIndent := 0
|
||||
@ -143,7 +143,7 @@ func (parser *ParsingOperation) parseArrayInitializationValues () (
|
||||
indent := parser.token.Value().(int)
|
||||
|
||||
if begin == true {
|
||||
initializationValues.location = parser.token.Location()
|
||||
defaultValues.location = parser.token.Location()
|
||||
baseIndent = indent
|
||||
begin = false
|
||||
}
|
||||
@ -169,8 +169,8 @@ func (parser *ParsingOperation) parseArrayInitializationValues () (
|
||||
var argument Argument
|
||||
argument, err = parser.parseArgument()
|
||||
if err != nil { return }
|
||||
initializationValues.values = append (
|
||||
initializationValues.values,
|
||||
defaultValues.values = append (
|
||||
defaultValues.values,
|
||||
argument)
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ func (declaration Declaration) ToString () (output string) {
|
||||
return
|
||||
}
|
||||
|
||||
func (attributes ObjectInitializationValues) ToString (
|
||||
func (attributes ObjectDefaultValues) ToString (
|
||||
indent int,
|
||||
) (
|
||||
output string,
|
||||
@ -106,7 +106,7 @@ func (attributes ObjectInitializationValues) ToString (
|
||||
value := attributes.attributes[name]
|
||||
|
||||
output += doIndent(indent, ".", name)
|
||||
if value.kind == ArgumentKindObjectInitializationValues {
|
||||
if value.kind == ArgumentKindObjectDefaultValues {
|
||||
output += "\n"
|
||||
output += value.ToString(indent + 1, true)
|
||||
} else {
|
||||
@ -117,7 +117,7 @@ func (attributes ObjectInitializationValues) ToString (
|
||||
return
|
||||
}
|
||||
|
||||
func (values ArrayInitializationValues) ToString (
|
||||
func (values ArrayDefaultValues) ToString (
|
||||
indent int,
|
||||
) (
|
||||
output string,
|
||||
@ -143,14 +143,14 @@ func (argument Argument) ToString (indent int, breakLine bool) (output string) {
|
||||
indent,
|
||||
breakLine)
|
||||
|
||||
case ArgumentKindObjectInitializationValues:
|
||||
case ArgumentKindObjectDefaultValues:
|
||||
// this should only appear in contexts where breakLine is true
|
||||
output += argument.value.(ObjectInitializationValues).
|
||||
output += argument.value.(ObjectDefaultValues).
|
||||
ToString(indent)
|
||||
|
||||
case ArgumentKindArrayInitializationValues:
|
||||
case ArgumentKindArrayDefaultValues:
|
||||
// this should only appear in contexts where breakLine is true
|
||||
output += argument.value.(ArrayInitializationValues).
|
||||
output += argument.value.(ArrayDefaultValues).
|
||||
ToString(indent)
|
||||
|
||||
case ArgumentKindIdentifier:
|
||||
@ -263,8 +263,8 @@ func (section DataSection) ToString (indent int) (output string) {
|
||||
section.what.ToString())
|
||||
|
||||
isComplexInitialization :=
|
||||
section.value.kind == ArgumentKindObjectInitializationValues ||
|
||||
section.value.kind == ArgumentKindArrayInitializationValues
|
||||
section.value.kind == ArgumentKindObjectDefaultValues ||
|
||||
section.value.kind == ArgumentKindArrayDefaultValues
|
||||
|
||||
if !isComplexInitialization && section.value.value != nil {
|
||||
output += " " + section.value.ToString(0, false)
|
||||
@ -311,8 +311,8 @@ func (section TypeSection) ToString (indent int) (output string) {
|
||||
section.what.ToString())
|
||||
|
||||
isComplexInitialization :=
|
||||
section.value.kind == ArgumentKindObjectInitializationValues ||
|
||||
section.value.kind == ArgumentKindArrayInitializationValues
|
||||
section.value.kind == ArgumentKindObjectDefaultValues ||
|
||||
section.value.kind == ArgumentKindArrayDefaultValues
|
||||
|
||||
if !isComplexInitialization && section.value.value != nil {
|
||||
output += " " + section.value.ToString(0, false)
|
||||
@ -342,8 +342,8 @@ func (section EnumSection) ToString (indent int) (output string) {
|
||||
output += doIndent(indent + 1, member.name)
|
||||
|
||||
isComplexInitialization :=
|
||||
member.value.kind == ArgumentKindObjectInitializationValues ||
|
||||
member.value.kind == ArgumentKindArrayInitializationValues
|
||||
member.value.kind == ArgumentKindObjectDefaultValues ||
|
||||
member.value.kind == ArgumentKindArrayDefaultValues
|
||||
|
||||
if member.value.value == nil {
|
||||
output += "\n"
|
||||
@ -398,8 +398,8 @@ func (phrase Phrase) ToString (indent int, ownLine bool) (output string) {
|
||||
output += "[" + phrase.command.ToString(0, false)
|
||||
for _, argument := range phrase.arguments {
|
||||
isInitializationValue :=
|
||||
argument.kind == ArgumentKindObjectInitializationValues ||
|
||||
argument.kind == ArgumentKindArrayInitializationValues
|
||||
argument.kind == ArgumentKindObjectDefaultValues ||
|
||||
argument.kind == ArgumentKindArrayDefaultValues
|
||||
if isInitializationValue {
|
||||
initializationValues = argument
|
||||
} else if argument.kind == ArgumentKindDeclaration {
|
||||
@ -446,8 +446,8 @@ func (funcOutput FuncOutput) ToString (indent int) (output string) {
|
||||
output += doIndent(indent + 1, "< ", funcOutput.Declaration.ToString())
|
||||
|
||||
isComplexInitialization :=
|
||||
funcOutput.value.kind == ArgumentKindObjectInitializationValues ||
|
||||
funcOutput.value.kind == ArgumentKindArrayInitializationValues
|
||||
funcOutput.value.kind == ArgumentKindObjectDefaultValues ||
|
||||
funcOutput.value.kind == ArgumentKindArrayDefaultValues
|
||||
|
||||
if !isComplexInitialization && funcOutput.value.value != nil {
|
||||
output += " " + funcOutput.value.ToString(0, false)
|
||||
|
@ -94,16 +94,15 @@ type Declaration struct {
|
||||
typeable
|
||||
}
|
||||
|
||||
// ObjectInitializationValues represents a list of object member initialization
|
||||
// ObjectDefaultValues represents a list of object member initialization
|
||||
// attributes.
|
||||
type ObjectInitializationValues struct {
|
||||
type ObjectDefaultValues struct {
|
||||
locatable
|
||||
attributes map[string] Argument
|
||||
}
|
||||
|
||||
// ArrayInitializationValues represents a list of attributes initializing an
|
||||
// array.
|
||||
type ArrayInitializationValues struct {
|
||||
// ArrayDefaultValues represents a list of elements initializing an array.
|
||||
type ArrayDefaultValues struct {
|
||||
locatable
|
||||
values []Argument
|
||||
}
|
||||
@ -128,10 +127,10 @@ const (
|
||||
|
||||
// .name value
|
||||
// but like, a lot of them
|
||||
ArgumentKindObjectInitializationValues
|
||||
ArgumentKindObjectDefaultValues
|
||||
|
||||
// value value...
|
||||
ArgumentKindArrayInitializationValues
|
||||
ArgumentKindArrayDefaultValues
|
||||
|
||||
// name.name
|
||||
// name.name.name
|
||||
|
Reference in New Issue
Block a user