예제 #1
0
파일: Dsl.cs 프로젝트: dreamanlan/DSL
        public static void writeFunctionData(StringBuilder stream, FunctionData data, int indent, bool isLastOfStatement)
        {
            #if FULL_VERSION
            string line = string.Empty;
            if (null != data.Call) {
                line = data.Call.ToScriptString(false) + data.Call.CalcComment();
            }
            if (data.HaveStatement()) {
                if (line.Length > 0) {
                    writeLine(stream, line, indent);
                }
                writeLine(stream, "{", indent);
                ++indent;

                int ct = data.GetStatementNum();
                for (int i = 0; i < ct; ++i) {
                    ISyntaxComponent tempData = data.GetStatement(i);
                    writeSyntaxComponent(stream, tempData, indent);
                }

                --indent;
                if (isLastOfStatement)
                    writeContent(stream, "};", indent);
                else
                    writeContent(stream, "}", indent);
            } else if (data.HaveExternScript()) {
                if (line.Length > 0) {
                    writeLine(stream, line, indent);
                }
                foreach (string cmt in data.Call.Comments) {
                    writeLine(stream, cmt, indent);
                }
                string script = data.GetExternScript();
                if (script.IndexOf('\n') >= 0) {
                    writeLine(stream, "{:", indent);
                } else {
                    writeContent(stream, "{:", indent);
                }
                stream.Append(script);
                if (script.Length>0 && script[script.Length - 1] == '\n') {
                    if (isLastOfStatement)
                        writeContent(stream, ":};", indent);
                    else
                        writeContent(stream, ":}", indent);
                } else {
                    if (isLastOfStatement)
                        stream.Append(":};");
                    else
                        stream.Append(":}");
                }
            } else {
                if (isLastOfStatement)
                    writeContent(stream, line + ";", indent);
                else
                    writeContent(stream, line, indent);
            }
            #endif
        }
예제 #2
0
파일: Dsl.cs 프로젝트: CQiao/DSL
    public static void writeFunctionData(StringBuilder stream, FunctionData data, int indent, bool isLastOfStatement)
    {
#if FULL_VERSION
      string line = "";
      if (null != data.Call)
        line = data.Call.ToScriptString();
      if (data.HaveStatement()) {
        if (line.Length > 0) {
          writeLine(stream, line, indent);
        }
        writeLine(stream, "{", indent);
        ++indent;

        int ct = data.GetStatementNum();
        for (int i = 0; i < ct; ++i) {
          ISyntaxComponent tempData = data.GetStatement(i);
          writeSyntaxComponent(stream, tempData, indent, true);
        }

        --indent;
        if (isLastOfStatement)
          writeLine(stream, "};", indent);
        else
          writeLine(stream, "}", indent);
      } else if (data.HaveExternScript()) {
        if (line.Length > 0) {
          writeLine(stream, line, indent);
        }
        writeContent(stream, "{:", indent);
        stream.Append(data.GetExternScript());
        if (isLastOfStatement)
          stream.AppendLine(":};");
        else
          stream.AppendLine(":}");
      } else {
        if (isLastOfStatement)
          writeLine(stream, line + ";", indent);
        else
          writeLine(stream, line, indent);
      }
#endif
    }