private static void WriteTree(SyntaxTreeNode node, StringBuilder treeBuilder, int depth = 0) { if (node == null) { return; } if (depth > 1) { WriteIndent(treeBuilder, depth); } if (depth > 0) { treeBuilder.Append("|-- "); } treeBuilder.AppendLine(ConvertEscapseSequences(node.ToString())); if (node.IsBlock) { foreach (SyntaxTreeNode child in ((Block)node).Children) { WriteTree(child, treeBuilder, depth + 1); } } }
internal static ClickHouseType ParseClickHouseType(SyntaxTreeNode node) { if (node.ChildNodes.Count == 0 && SimpleTypes.TryGetValue(node.Value, out var typeInfo)) { return(typeInfo); } if (ParameterizedTypes.ContainsKey(node.Value)) { return(ParameterizedTypes[node.Value].Parse(node, ParseClickHouseType)); } throw new ArgumentException("Unknown type: " + node.ToString()); }
internal static void Visit(SyntaxTreeNode root, Node node) { node.Content = Normalize(root.ToString()); node.Start = root.Start.AbsoluteIndex; node.Length = root.Length; if (root is Block block) { foreach (var child in block.Children) { var n = new Node(); node.Children.Add(n); Visit(child, n); } } }
private void WriteNode(int indent, SyntaxTreeNode node) { var content = node.ToString().Replace("\r", "\\r") .Replace("\n", "\\n") .Replace("{", "{{") .Replace("}", "}}"); if (indent > 0) { content = new String('.', indent * 2) + content; } WriteTraceLine(content); var block = node as Block; if (block != null) { foreach (SyntaxTreeNode child in block.Children) { WriteNode(indent + 1, child); } } }