Parser can now ToString data sections properly

This commit is contained in:
Sasha Koshka 2022-08-16 16:37:20 -04:00
parent 5c23c59c92
commit 5e2d8c9955
1 changed files with 14 additions and 4 deletions

View File

@ -30,7 +30,7 @@ func (tree *SyntaxTree) ToString (indent int) (output string) {
output += doIndent(indent, "---\n") output += doIndent(indent, "---\n")
for _, require := range tree.dataSections { for _, require := range tree.dataSections {
output += require.ToString(1) output += require.ToString(indent)
} }
return return
} }
@ -165,6 +165,8 @@ func (argument *Argument) ToString (indent int, breakLine bool) (output string)
case ArgumentKindOperator: case ArgumentKindOperator:
// TODO // TODO
} }
if breakLine { output += "\n" }
return return
} }
@ -176,8 +178,16 @@ func (section *DataSection) ToString (indent int) (output string) {
section.name, ":", section.name, ":",
section.what.ToString()) section.what.ToString())
// TODO: print out initialization values. if there is only one of them, if len(section.value) == 0 {
// keep it on the same line. if there are more than one, give each its output += "\n"
// own line. } else if len(section.value) == 1 {
output += " " + section.value[0].ToString(0, false)
output += "\n"
} else {
output += "\n"
for _, argument := range(section.value) {
output += argument.ToString(indent + 1, true)
}
}
return return
} }