Parser can now ToString data sections properly
This commit is contained in:
parent
5c23c59c92
commit
5e2d8c9955
@ -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
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user