Changed object initialization values to be a map
This commit is contained in:
parent
bb2948d397
commit
eb3fb65c9b
@ -78,21 +78,19 @@ func (declaration *Declaration) ToString () (output string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (attribute *ObjectAttribute) ToString (
|
func (attributes *ObjectAttributes) ToString (
|
||||||
indent int,
|
indent int,
|
||||||
breakLine bool,
|
|
||||||
) (
|
) (
|
||||||
output string,
|
output string,
|
||||||
) {
|
) {
|
||||||
if breakLine {
|
for name, value := range attributes.attributes {
|
||||||
output += doIndent(indent)
|
output += doIndent(indent, ".", name, " ")
|
||||||
}
|
if value.kind == ArgumentKindObjectAttributes {
|
||||||
|
output += "\n"
|
||||||
output += ", " + attribute.name
|
output += value.ToString(indent + 1, true)
|
||||||
if breakLine {
|
|
||||||
output += "\n" + attribute.value.ToString(indent + 1, true)
|
|
||||||
} else {
|
} else {
|
||||||
output += " " + attribute.value.ToString(0, false)
|
output += value.ToString(0, false) + "\n"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -142,12 +140,11 @@ func (argument *Argument) ToString (indent int, breakLine bool) (output string)
|
|||||||
indent,
|
indent,
|
||||||
breakLine))
|
breakLine))
|
||||||
|
|
||||||
case ArgumentKindObjectAttribute:
|
case ArgumentKindObjectAttributes:
|
||||||
|
// this should only appear in contexts where breakLine is true
|
||||||
output += doIndent (
|
output += doIndent (
|
||||||
indent,
|
indent,
|
||||||
argument.value.(*ObjectAttribute).ToString (
|
argument.value.(*ObjectAttributes).ToString (indent))
|
||||||
indent,
|
|
||||||
breakLine))
|
|
||||||
|
|
||||||
case ArgumentKindIdentifier:
|
case ArgumentKindIdentifier:
|
||||||
output += doIndent (
|
output += doIndent (
|
||||||
|
@ -60,12 +60,11 @@ type Declaration struct {
|
|||||||
what Type
|
what Type
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectAttribute represents a notation to initialize object attributes. It
|
// ObjectAttributes represents a list of object member initialization
|
||||||
// contains a name, and the value that the attribute should be initialized to.
|
// attributes.
|
||||||
type ObjectAttribute struct {
|
type ObjectAttributes struct {
|
||||||
location file.Location
|
location file.Location
|
||||||
name string
|
attributes map[string] Argument
|
||||||
value Argument
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Phrase represents a function call or operator. In ARF they are the same
|
// Phrase represents a function call or operator. In ARF they are the same
|
||||||
@ -93,8 +92,9 @@ const (
|
|||||||
// {name 23}
|
// {name 23}
|
||||||
ArgumentKindSubscript
|
ArgumentKindSubscript
|
||||||
|
|
||||||
// , name value
|
// .name value
|
||||||
ArgumentKindObjectAttribute
|
// but like, a lot of them
|
||||||
|
ArgumentKindObjectAttributes
|
||||||
|
|
||||||
// name.name
|
// name.name
|
||||||
// name.name.name
|
// name.name.name
|
||||||
@ -103,7 +103,7 @@ const (
|
|||||||
|
|
||||||
// name:Type
|
// name:Type
|
||||||
// name:{Type}
|
// name:{Type}
|
||||||
// name:{Type ...}
|
// name:{Type ..}
|
||||||
// name:{Type 23}
|
// name:{Type 23}
|
||||||
// etc...
|
// etc...
|
||||||
ArgumentKindDeclaration
|
ArgumentKindDeclaration
|
||||||
|
Reference in New Issue
Block a user