WriteString() 공개 메소드

public WriteString ( string s ) : void
s string
리턴 void
예제 #1
0
 private static void SourceFromPredicateInfo(PredicateIndicator p, PredicateInfo predicateInfo, ISOPrologWriter writer)
 {
     foreach (var knowledgeBaseEntry in predicateInfo.Entries)
     {
         var       rule = (KnowledgeBaseRule)knowledgeBaseEntry;
         var       head = new Structure(p.Functor, rule.HeadArgs);
         Structure structure;
         if (rule.BodyGoals == null || rule.BodyGoals.Length == 0)
         {
             structure = head;
         }
         else
         {
             structure = new Structure(Symbol.Implication, head, Commafy(rule.BodyGoals));
         }
         writer.Write(structure);
         writer.WriteString(".\n");
     }
 }
예제 #2
0
        string CaptureStack()
        {
            List<object> result = new List<object>();
            if (this.TokenString != "")
                result.Add(this.TokenString);
            StackFrame s = pStack;
            while (s != null)
            {
                object item;
                switch(s.tokentype)
                {
                    case EOFFILE:
                        item = "end_of_file";
                        break;

                    case OPEN_TOKEN:
                    case OPEN_CT_TOKEN:
                        item = '(';
                        break;

                    case CLOSE_TOKEN:
                        item = ')';
                        break;

                    case OPEN_LIST_TOKEN:
                        item = '[';
                        break;

                    case CLOSE_LIST_TOKEN:
                        item = ']';
                        break;

                    case OPEN_CURLY_TOKEN:
                        item = '{';
                        break;

                    case CLOSE_CURLY_TOKEN:
                        item = '}';
                        break;

                    case HEAD_TAIL_SEPARATOR_TOKEN:
                        item = '|';
                        break;

                    case COMMA_TOKEN:
                        item = ',';
                        break;

                    case END_TOKEN:
                        item = '.';
                        break;

                    default:
                        item = s.term;
                        break;
                }
                result.Insert(0, item);  // okay, so this is technically quadratic, but the stack shouldn't be deep, and this only runs when syntax errors are thrown
                s = s.down;
            }
            StringWriter sw = new StringWriter();
            ISOPrologWriter w = new ISOPrologWriter(sw);
            bool first = true;
            foreach (var t in result)
            {
                if (first)
                    first = false;
                else
                    w.WriteString(" ");
                w.Write(t);
            }

            return sw.ToString();
        }
예제 #3
0
 private static void SourceFromPredicateInfo(PredicateIndicator p, PredicateInfo predicateInfo, ISOPrologWriter writer)
 {
     foreach (var knowledgeBaseEntry in predicateInfo.Entries)
     {
         var rule = (KnowledgeBaseRule)knowledgeBaseEntry;
         var head = new Structure(p.Functor, rule.HeadArgs);
         Structure structure;
         if (rule.BodyGoals == null || rule.BodyGoals.Length == 0)
         {
             structure = head;
         }
         else
         {
             structure = new Structure(Symbol.Implication, head, Commafy(rule.BodyGoals));
         }
         writer.Write(structure);
         writer.WriteString(".\n");
     }
 }