示例#1
0
        public virtual void Print(EnumNode node, StringBuilder sb, PrintOption opt, params object[] values)
        {
            sb.Append(opt.MakeIndentSpace());

            sb.AppendFormat("enum {0}\n", node.Name);
            sb.Append(opt.MakeIndentSpace());
            sb.Append("{\n");

            int maxNameLength = 0;

            if (node.Value.Count > 0)
            {
                maxNameLength = node.Value.Select(x => x.Name.Length).Max();
            }


            var subopt = new PrintOption(opt);

            foreach (var n in node.Child)
            {
                n.PrintVisit(this, sb, subopt, maxNameLength);
            }

            sb.Append(opt.MakeIndentSpace());
            sb.Append("}\n");
        }
示例#2
0
        public virtual void Print(FileNode node, StringBuilder sb, PrintOption opt, params object[] values)
        {
            if (opt.AutoGenHeader)
            {
                sb.AppendLine("// Generated by ProtoTool, DO NOT MODIFIED!");
            }

            foreach (var n in node.Child)
            {
                n.PrintVisit(this, sb, opt, values);
            }
        }
示例#3
0
        public virtual void Print(EnumValueNode node, StringBuilder sb, PrintOption opt, params object[] values)
        {
            var maxNameLength = (int)values[0];

            sb.Append(opt.MakeIndentSpace());

            sb.Append(node.Name.PadRight(maxNameLength));

            if ((!node.NumberIsAutoGen || opt.ShowAllEnumNumber))
            {
                sb.AppendFormat(" = {0}", node.Number);
            }

            var commentSpace = " ".PadLeft(Math.Max(3 - node.Number.ToString().Length, 1));

            sb.Append(commentSpace);

            if (!string.IsNullOrEmpty(node.TrailingComment))
            {
                sb.AppendFormat("//{0}", node.TrailingComment);
            }

            sb.Append("\n");
        }
示例#4
0
 public virtual void Print(EOLNode node, StringBuilder sb, PrintOption opt, params object[] values)
 {
     sb.Append("\n");
 }
示例#5
0
 public virtual void Print(CommentNode node, StringBuilder sb, PrintOption opt, params object[] values)
 {
     sb.AppendFormat("{0}//{1}\n", opt.MakeIndentSpace(), node.Comment);
 }
示例#6
0
        public bool        AutoGenHeader;      // 显示文件头

        public PrintOption(PrintOption parent)
        {
            this = (PrintOption)parent.MemberwiseClone();

            Indent = parent.Indent + 1;
        }