示例#1
0
        public static string ToSdlString(this SdlTag tag, bool isRoot = true)
        {
            var builder = new StringBuilder();

            SdlAstToTextConverter.WriteInto(builder, tag, isRoot);
            return(builder.ToString());
        }
示例#2
0
 public void VisitCloseBlock()
 {
     if (this._parentStack.Count == 1)
     {
         throw new SdlException("Stray '}'. We are not inside an open block (started by '{').");
     }
     this._currentNode = null;
     this._parentStack.Pop();
 }
示例#3
0
        public static void WriteInto(StringBuilder builder, SdlTag tag, bool isRootNode = true, int indent = 0)
        {
            if (isRootNode)
            {
                foreach (var child in tag.Children)
                {
                    WriteInto(builder, child, false, indent);
                }
                return;
            }

            builder.Append(' ', indent * 4);

            if (tag.QualifiedName != SdlTokenPusher.ANONYMOUS_TAG_NAME)
            {
                builder.Append(tag.QualifiedName);
                builder.Append(' ');
            }

            foreach (var value in tag.Values)
            {
                WriteInto(builder, value);
            }

            foreach (var kvp in tag.Attributes)
            {
                WriteInto(builder, kvp.Value);
            }

            if (tag.Children.Count == 0)
            {
                builder.Append('\n');
                return;
            }

            builder.Append("{\n");

            foreach (var child in tag.Children)
            {
                WriteInto(builder, child, false, indent + 1);
            }

            builder.Append(' ', indent * 4);
            builder.Append("}\n");
        }
示例#4
0
 public void VisitStartTag(ReadOnlySpan <char> qualifiedName)
 {
     this._currentNode = new SdlTag(qualifiedName.ToString());
     this._parentStack.Peek().Children.Add(this._currentNode);
 }