当前位置: 首页>>代码示例>>C#>>正文


C# StringBuffer.AppendTerm方法代码示例

本文整理汇总了C#中StringBuffer.AppendTerm方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuffer.AppendTerm方法的具体用法?C# StringBuffer.AppendTerm怎么用?C# StringBuffer.AppendTerm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringBuffer的用法示例。


在下文中一共展示了StringBuffer.AppendTerm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToStringEx

    private string ToStringEx(ListDictionary sqlVarNames)
    {
      StringBuffer sb;
      int n;

      if (this is Cut)
        return "!";
      else if (!hasValue)
      {
        if (sqlVarNames == null)
        {
          if (this is NamedVar)
            return ((NamedVar)this).Name;
          else
            return ("_" + varNo);
        }
        else
        {
          string colName = (string)sqlVarNames[varNo];
          if (colName == null) PrologIO.Error("Unbound variable not allowed in where-part of persistent predicate call");
          return (colName);
        }
      }
      else if (isUnified)
        return LinkEnd.ToStringEx(sqlVarNames);
      else if (IsString)
      {
        if (sqlVarNames == null)
          return "\"" + functor + "\"";
        else // SQL
          return "'" + functor + "'";
      }
      else if (this == NULLLIST)
        return "[]";
      else if (IsList && arity == 2)
      {
        Term t;
        sb = new StringBuffer("[" + args[0].ToStringEx(sqlVarNames));
        t = args[1];
        while (t.Arity == 2 && t.IsList)
        {
          sb.Append("," + t.Arg(0).ToStringEx(sqlVarNames));
          t = t.Arg(1);
        }

        if (t.IsList)
          sb.Append("]");
        else
          sb.Append("|" + t.ToStringEx(sqlVarNames) + "]");
        return sb.ToString();
      }
      else if (functor == Parser.CURL)
      {
        if (arity == 0)
          return "{}";
        else
        {
          Term t;
          sb = new StringBuffer("{" + args[0].ToStringEx(sqlVarNames));
          t = args[1];
          while (t.Arity == 2)
          {
            sb.Append("," + t.Arg(0).ToStringEx(sqlVarNames));
            t = t.Arg(1);
          }
          sb.Append("}");
        }
      }
      else if (functor == NUMVAR && arity == 1 && Arg(0).IsInteger && (n = (int)Arg(0).ExprValue.AsNumber) >= 0)
      {
        int m = n / 26;
        n = n % 26;
        sb = new StringBuffer("ABCDEFGHIJKLMNOPQRSTUVWXYZ".Substring(n, 1) + ((m == 0) ? "" : m.ToString()));
      }
      else if (functor == Parser.COMMA && arity == 2)
        sb = new StringBuffer("(" + args[0].ToStringEx(sqlVarNames) + "," + args[1].ToStringEx(sqlVarNames) + ")");
      else
      {
        sb = new StringBuffer();

        if (arity == 0)
        {
          if (oDescr == null)
            sb.Append(functor);
          else // functors which are actually operators are parenthesized
            sb.Append("(" + functor + ")");
        }
        else
        {
          if (oType == OType.xfx || oType == OType.xfy || oType == OType.yfx)
          {
            if (precedence < args[0].Precedence ||
                 (precedence == args[0].Precedence && (oType == OType.xfx || oType == OType.yfx)))
              sb.AppendPackedTerm(args[0], sqlVarNames);
            else
              sb.AppendTerm(args[0], sqlVarNames);

            sb.Append(functor);

            if (precedence < args[1].Precedence ||
//.........这里部分代码省略.........
开发者ID:adesproject,项目名称:ADES,代码行数:101,代码来源:Term.cs


注:本文中的StringBuffer.AppendTerm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。