private static void DumpTree(CommonTree r, int ind) { Console.Write(new string('\t', ind)); Console.WriteLine(r.ToString()); if (r.Children != null) { foreach (CommonTree t in r.Children) { DumpTree(t, ind + 1); } } }
public static string GetLocalNodeId(this CommonTree node) { return((node.Parent != null ? $"[{node.GetIndexForTypeInParent()}]" : string.Empty) + $"({node.Type}){node.ToString()}"); }
/// <summary>Gets the text represented by common tree.</summary> /// <param name="commonTree">The common tree.</param> /// <param name="defaultText">The default text.</param> /// <returns>The text represented by common tree.</returns> public static string TextOrDefault(this CommonTree commonTree, string defaultText = null) { return(commonTree != null?commonTree.ToString() : defaultText); }