syntax-tree-accessors #2
@ -186,12 +186,12 @@ func (parser *ParsingOperation) parseFuncArguments (
|
||||
err = parser.nextToken()
|
||||
if err != nil { return }
|
||||
|
||||
output.defaultValue, err =
|
||||
output.value, err =
|
||||
parser.parseInitializationValues(1)
|
||||
into.outputs = append(into.outputs, output)
|
||||
if err != nil { return }
|
||||
} else {
|
||||
output.defaultValue, err =
|
||||
output.value, err =
|
||||
parser.parseArgument()
|
||||
into.outputs = append(into.outputs, output)
|
||||
if err != nil { return }
|
||||
|
@ -52,7 +52,19 @@ type permissionable struct {
|
||||
permission types.Permission
|
||||
}
|
||||
|
||||
// Permission returns the permision of the node.
|
||||
func (trait permissionable) Permission () (permission types.Permission) {
|
||||
permission = trait.permission
|
||||
return
|
||||
}
|
||||
|
||||
// valuable allows a node to have an argument value.
|
||||
type valuable struct {
|
||||
value Argument
|
||||
}
|
||||
|
||||
// Value returns the value argument of the node.
|
||||
func (trait valuable) Value () (value Argument) {
|
||||
value = trait.value
|
||||
return
|
||||
}
|
||||
|
@ -109,11 +109,11 @@ func (parser *ParsingOperation) parseObjtMember () (
|
||||
err = parser.nextToken()
|
||||
if err != nil { return }
|
||||
|
||||
member.defaultValue,
|
||||
member.value,
|
||||
err = parser.parseInitializationValues(1)
|
||||
if err != nil { return }
|
||||
} else {
|
||||
member.defaultValue, err = parser.parseArgument()
|
||||
member.value, err = parser.parseArgument()
|
||||
if err != nil { return }
|
||||
|
||||
err = parser.expect(lexer.TokenKindNewline)
|
||||
|
@ -312,16 +312,16 @@ func (section *TypeSection) ToString (indent int) (output string) {
|
||||
section.what.ToString())
|
||||
|
||||
isComplexInitialization :=
|
||||
section.defaultValue.kind == ArgumentKindObjectInitializationValues ||
|
||||
section.defaultValue.kind == ArgumentKindArrayInitializationValues
|
||||
section.value.kind == ArgumentKindObjectInitializationValues ||
|
||||
section.value.kind == ArgumentKindArrayInitializationValues
|
||||
|
||||
if section.defaultValue.value == nil {
|
||||
if section.value.value == nil {
|
||||
output += "\n"
|
||||
} else if isComplexInitialization {
|
||||
output += "\n"
|
||||
output += section.defaultValue.ToString(indent + 1, true)
|
||||
output += section.value.ToString(indent + 1, true)
|
||||
} else {
|
||||
output += " " + section.defaultValue.ToString(0, false)
|
||||
output += " " + section.value.ToString(0, false)
|
||||
output += "\n"
|
||||
}
|
||||
return
|
||||
@ -339,16 +339,16 @@ func (member ObjtMember) ToString (indent int) (output string) {
|
||||
}
|
||||
|
||||
isComplexInitialization :=
|
||||
member.defaultValue.kind == ArgumentKindObjectInitializationValues ||
|
||||
member.defaultValue.kind == ArgumentKindArrayInitializationValues
|
||||
member.value.kind == ArgumentKindObjectInitializationValues ||
|
||||
member.value.kind == ArgumentKindArrayInitializationValues
|
||||
|
||||
if member.defaultValue.value == nil {
|
||||
if member.value.value == nil {
|
||||
output += "\n"
|
||||
} else if isComplexInitialization {
|
||||
output += "\n"
|
||||
output += member.defaultValue.ToString(indent + 1, true)
|
||||
output += member.value.ToString(indent + 1, true)
|
||||
} else {
|
||||
output += " " + member.defaultValue.ToString(0, false)
|
||||
output += " " + member.value.ToString(0, false)
|
||||
output += "\n"
|
||||
}
|
||||
|
||||
@ -473,8 +473,8 @@ func (block Block) ToString (indent int) (output string) {
|
||||
|
||||
func (funcOutput FuncOutput) ToString () (output string) {
|
||||
output += funcOutput.Declaration.ToString()
|
||||
if funcOutput.defaultValue.kind != ArgumentKindNil {
|
||||
output += " " + funcOutput.defaultValue.ToString(0, false)
|
||||
if funcOutput.value.kind != ArgumentKindNil {
|
||||
output += " " + funcOutput.value.ToString(0, false)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -161,8 +161,7 @@ type TypeSection struct {
|
||||
nameable
|
||||
typeable
|
||||
permissionable
|
||||
|
||||
defaultValue Argument
|
||||
valuable
|
||||
}
|
||||
|
||||
// ObjtMember represents a part of an object type definition.
|
||||
@ -171,9 +170,9 @@ type ObjtMember struct {
|
||||
nameable
|
||||
typeable
|
||||
permissionable
|
||||
valuable
|
||||
|
||||
bitWidth uint64
|
||||
defaultValue Argument
|
||||
}
|
||||
|
||||
// ObjtSection represents an object type definition.
|
||||
@ -190,7 +189,7 @@ type ObjtSection struct {
|
||||
type EnumMember struct {
|
||||
locatable
|
||||
nameable
|
||||
value Argument
|
||||
valuable
|
||||
}
|
||||
|
||||
// EnumSection represents an enumerated type section.
|
||||
@ -262,7 +261,7 @@ type Block []Phrase
|
||||
// that it can have a default value.
|
||||
type FuncOutput struct {
|
||||
Declaration
|
||||
defaultValue Argument
|
||||
valuable
|
||||
}
|
||||
|
||||
// FuncSection represents a function section.
|
||||
|
@ -38,10 +38,10 @@ func (parser *ParsingOperation) parseTypeSection () (
|
||||
err = parser.nextToken()
|
||||
if err != nil { return }
|
||||
|
||||
section.defaultValue, err = parser.parseInitializationValues(0)
|
||||
section.value, err = parser.parseInitializationValues(0)
|
||||
if err != nil { return }
|
||||
} else {
|
||||
section.defaultValue, err = parser.parseArgument()
|
||||
section.value, err = parser.parseArgument()
|
||||
if err != nil { return }
|
||||
|
||||
err = parser.expect(lexer.TokenKindNewline)
|
||||
|
Reference in New Issue
Block a user