diff --git a/parser/func.go b/parser/func.go index feb5d13..b42fe0e 100644 --- a/parser/func.go +++ b/parser/func.go @@ -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 } diff --git a/parser/node-traits.go b/parser/node-traits.go index 29e64ce..4a3f66e 100644 --- a/parser/node-traits.go +++ b/parser/node-traits.go @@ -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 +} diff --git a/parser/objt.go b/parser/objt.go index 8e40715..ca72df4 100644 --- a/parser/objt.go +++ b/parser/objt.go @@ -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) diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index 6ef1978..ebd080d 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -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 } diff --git a/parser/tree.go b/parser/tree.go index d726cbf..98cf23e 100644 --- a/parser/tree.go +++ b/parser/tree.go @@ -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. diff --git a/parser/type.go b/parser/type.go index 5c484f2..a00c8e7 100644 --- a/parser/type.go +++ b/parser/type.go @@ -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)