public void Add(ParseTree child) { child.Parent = this; Children.Add(child); }
static string ChildToXML(ParseTree tree, string currentTab) { StringBuilder str = new StringBuilder(); str.AppendLine(string.Format( "{2}<{0}{1}>", tree.Label, (tree.Symbol.IsTerminal) ? " " + SymbolAttributesToXMLString(tree.Symbol.Attributes) : "", currentTab )); foreach (var child in tree.Children) str.AppendLine(ChildToXML(child, currentTab + tab)); str.AppendLine(string.Format("{1}</{0}>", tree.Label, currentTab)); return str.ToString(); }
public static ParseTree FromSymbol(Symbol symbol) { ParseTree tree = new ParseTree(new Symbol(symbol.Name, symbol.Type)); return tree; }
static string ChildToString(ParseTree tree, string currentTab) { StringBuilder str = new StringBuilder(); str.AppendLine(string.Format( "{0}{1}\t{2}", currentTab, tree.Label, (tree.Symbol.IsTerminal)?tree.Symbol.Attributes.ToString():"" )); foreach (var child in tree.Children) str.AppendLine(ChildToString(child, currentTab + tab)); return str.ToString(); }