From 3ef1e706b38b8cd0382043b23785fd9443a86de5 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Tue, 23 Aug 2022 13:54:44 -0400 Subject: [PATCH] Added ToString method to face section --- parser/tree-tostring.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index 8c67798..6d96aac 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -353,3 +353,32 @@ func (section *EnumSection) ToString (indent int) (output string) { } return } + +func (section *FaceSection) ToString (indent int) (output string) { + output += doIndent ( + indent, + "face ", + section.permission.ToString(), " ", + section.name, ":", + section.inherits, "\n") + + for _, name := range sortMapKeysAlphabetically(section.behaviors) { + behavior := section.behaviors[name] + output += behavior.ToString(indent + 1) + } + return +} + +func (behavior *FaceBehavior) ToString (indent int) (output string) { + output += doIndent(indent, behavior.name, "\n") + + for _, inputItem := range behavior.inputs { + output += doIndent(indent, "> ", inputItem.ToString(), "\n") + } + + for _, outputItem := range behavior.outputs { + output += doIndent(indent, "< ", outputItem.ToString(), "\n") + } + + return +}