Added basic ToString method to TypeSection
This commit is contained in:
parent
5c2a7aeb07
commit
9fd3fb1263
@ -46,6 +46,11 @@ func (tree *SyntaxTree) ToString (indent int) (output string) {
|
||||
|
||||
output += doIndent(indent, "---\n")
|
||||
|
||||
typeSectionKeys := sortMapKeysAlphabetically(tree.typeSections)
|
||||
for _, name := range typeSectionKeys {
|
||||
output += tree.typeSections[name].ToString(indent)
|
||||
}
|
||||
|
||||
dataSectionKeys := sortMapKeysAlphabetically(tree.dataSections)
|
||||
for _, name := range dataSectionKeys {
|
||||
output += tree.dataSections[name].ToString(indent)
|
||||
@ -246,3 +251,20 @@ func (section *DataSection) ToString (indent int) (output string) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (section *TypeSection) ToString (indent int) (output string) {
|
||||
output += doIndent (
|
||||
indent,
|
||||
"type ",
|
||||
section.permission.ToString(), " ",
|
||||
section.name, ":",
|
||||
section.what.ToString())
|
||||
|
||||
if section.defaultValue.value == nil {
|
||||
// TODO: print out members
|
||||
} else {
|
||||
output += " " + section.defaultValue.ToString(0, false)
|
||||
output += "\n"
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -176,8 +176,9 @@ type TypeSection struct {
|
||||
location file.Location
|
||||
name string
|
||||
|
||||
what Type
|
||||
permission types.Permission
|
||||
what Type
|
||||
permission types.Permission
|
||||
defaultValue Argument
|
||||
// this should be 1 dimensional for now.
|
||||
members map[string] TypeMember
|
||||
members map[string] TypeMember
|
||||
}
|
||||
|
Reference in New Issue
Block a user