예제 #1
0
        public static GdlVariable GetGdlVariable(SymbolTable symTab, int token)
        {
            if (varMap.ContainsKey(token))
                return varMap[token];

            GdlVariable var = new GdlVariable(symTab, token);
            varMap[token] = var;
            return var;
        }
예제 #2
0
        protected ReasoningEntity(Parser parser)
        {
            Parser = parser;
            SymbolTable = Parser.SymbolTable;

            QueryTerminal = MakeQuery("terminal");
            QueryNext = MakeQuery("next", "?x");

            Random = new Random();
        }
예제 #3
0
        public static void Initialise(GdlList description)
        {
            SymbolTable = Parser.SymbolTable;

            GameInformation = new MetaGdl(Parser).ExamineGdl(description);

            var expressions = new List<Expression>();
            expressions.AddRange(GameInformation.GetRules());
            expressions.AddRange(GameInformation.GetAllGrounds());
            Prover = new AimaProver(expressions);
        }
예제 #4
0
파일: Lexer.cs 프로젝트: druzil/nggp-base
        public Lexer(TextReader input, SymbolTable symbolTable)
        {
            _in = input;

            _symbolTable = symbolTable;
            _lineNumber = 0;

            _bufferedTokens = new Stack<int>(2);

            _markedCharacter = NoMark;
        }
예제 #5
0
 private GdlVariable(SymbolTable symTab, int token)
     : base(symTab)
 {
     token_ = token;
 }
예제 #6
0
 public string ToString(SymbolTable symtab)
 {
     using (var stream = new MemoryStream())
     {
         using (var writer = new StreamWriter(stream))
         {
             PrintToStream(writer, symtab);
             writer.Flush();
             stream.Seek(0, SeekOrigin.Begin);
             return (new StreamReader(stream)).ReadToEnd();
         }
     }
 }
예제 #7
0
 public abstract void PrintToStream(StreamWriter target, SymbolTable symtab);
예제 #8
0
        public override string ToString(SymbolTable symtab)
        {
            var sb = new StringBuilder();

            sb.Append('(');
            sb.Append(symtab[FunctionName]);

            if (Arguments.Length > 0)
                sb.Append(' ');

            // Print all but the last argument
            int i;
            for (i = 0; i < Arguments.Length - 1; i++)
            {
                sb.Append(Arguments[i].ToString(symtab));
                sb.Append(' ');
            }

            // Print the last argument
            sb.Append(Arguments[i].ToString(symtab));

            sb.Append(')');

            return sb.ToString();
        }
예제 #9
0
 public override string ToString(SymbolTable symtab)
 {
     return symtab[Token];
 }
예제 #10
0
 public override void PrintToStream(StreamWriter target, SymbolTable symtab)
 {
     target.Write("(not ");
     Negated.PrintToStream(target, symtab);
     target.Write(")");
 }
예제 #11
0
파일: Fact.cs 프로젝트: druzil/nggp-base
        public override void PrintToStream(StreamWriter target, SymbolTable symtab)
        {
            target.Write('(');
            target.Write(symtab[RelationName]);

            if (Terms.Length > 0)
            {
                target.Write(' ');
                int i;
                for (i = 0; i < Terms.Length - 1; i++)
                {
                    target.Write(Terms[i].ToString(symtab));
                    target.Write(' ');
                }
                target.Write(Terms[i].ToString(symtab));
            }

            target.Write(')');
        }
예제 #12
0
        public override void PrintToStream(StreamWriter target, SymbolTable symtab)
        {
            if (Conjuncts.Length == 0)
                return;

            target.Write("Rule body: ");
            int i;
            for (i = 0; i < Conjuncts.Length - 1; i++)
            {
                Conjuncts[i].PrintToStream(target, symtab);
                target.Write(" & ");
            }
            Conjuncts[i].PrintToStream(target, symtab);
        }
예제 #13
0
 public override string ToString(SymbolTable symtab)
 {
     return "?var" + _varName;
 }
예제 #14
0
        public string ToString(SymbolTable symtab)
        {
            var sb = new StringBuilder();
            sb.Append("{ ");

            var keys = Substitutions.Keys;

            foreach (TermVariable tv in keys)
            {
                sb.Append(tv.ToString(symtab));
                sb.Append(" <- ");
                sb.Append(GetMapping(tv).ToString(symtab));
                sb.Append(". ");
            }

            sb.Append("}");
            return sb.ToString();
        }
예제 #15
0
파일: Parser.cs 프로젝트: druzil/nggp-base
 internal Parser()
 {
     _symbolTable = new SymbolTable();
     InitSymbolTable();
 }
예제 #16
0
 /**
  * Create a processor that will rename relations to the value of 'relName'.
  *
  * @param relName The relation name to set relations to.
  * @param symTable The symbol table to look up the string name in.
  */
 public RelationNameProcessor(string relName, SymbolTable symTable)
 {
     _relName = symTable[relName];
 }
예제 #17
0
        public override void PrintToStream(StreamWriter target, SymbolTable symtab)
        {
            target.Write("(or ");

            int i;
            for (i = 0; i < _sentences.Length - 1; i++)
            {
                _sentences[i].PrintToStream(target, symtab);
                target.Write(' ');
            }
            _sentences[i].PrintToStream(target, symtab);

            target.Write(')');
        }