Example #1
0
 public VGDLNode(string content, int indent, int lineNumber, VGDLNode parent = null)
 {
     this.children   = new List <VGDLNode>();
     this.content    = content;
     this.indent     = indent;
     this.lineNumber = lineNumber;
     if (parent != null)
     {
         parent.insert(this);
     }
 }
Example #2
0
 public void insert(VGDLNode node)
 {
     if (indent < node.indent)
     {
         if (children.Count > 0 && children[0].indent != node.indent)
         {
             Debug.Log("child indentation: " + children[0].indent + " vs node indentation: " + node.indent);
             throw new Exception("[Line " + node.lineNumber.ToString() + "] child indentations must match (tabs are expanded to 4 spaces by default)");
         }
         children.Add(node);
         node.parent = this;
     }
     else
     {
         if (parent == null)
         {
             throw new Exception("Root node too indented?");
         }
         parent.insert(node);
     }
 }