Restructured type definitions to use a node tree

This commit is contained in:
Sasha Koshka
2022-08-18 23:38:32 -04:00
parent 717474a59e
commit 69aaae8f14
4 changed files with 27 additions and 23 deletions

View File

@@ -253,22 +253,30 @@ func (section *DataSection) ToString (indent int) (output string) {
}
func (section *TypeSection) ToString (indent int) (output string) {
output += doIndent (
indent,
"type ",
section.permission.ToString(), " ",
section.name, ":",
section.inherits.ToString())
output += section.root.ToString(indent, true)
return
}
func (node TypeNode) ToString (indent int, isRoot bool) (output string) {
doIndent(indent)
if isRoot {
output += "type "
}
if section.defaultValue.value == nil {
if len(section.members) > 0 {
output += node.permission.ToString() + " "
output += node.name + ":"
output += node.what.ToString()
if node.defaultValue.value == nil {
if len(node.children) > 0 {
// TODO: print out members
} else {
output += "\n"
}
} else {
output += " " + section.defaultValue.ToString(0, false)
output += " " + node.defaultValue.ToString(0, false)
output += "\n"
}
return
}