Exemple #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;
        }
Exemple #2
0
        protected ReasoningEntity(Parser parser)
        {
            Parser = parser;
            SymbolTable = Parser.SymbolTable;

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

            Random = new Random();
        }
Exemple #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);
        }
Exemple #4
0
        public Lexer(TextReader input, SymbolTable symbolTable)
        {
            _in = input;

            _symbolTable = symbolTable;
            _lineNumber = 0;

            _bufferedTokens = new Stack<int>(2);

            _markedCharacter = NoMark;
        }
Exemple #5
0
 private GdlVariable(SymbolTable symTab, int token)
     : base(symTab)
 {
     token_ = token;
 }
Exemple #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();
         }
     }
 }
Exemple #7
0
 public abstract void PrintToStream(StreamWriter target, SymbolTable symtab);
Exemple #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();
        }
Exemple #9
0
 public override string ToString(SymbolTable symtab)
 {
     return symtab[Token];
 }
Exemple #10
0
 public override void PrintToStream(StreamWriter target, SymbolTable symtab)
 {
     target.Write("(not ");
     Negated.PrintToStream(target, symtab);
     target.Write(")");
 }
Exemple #11
0
        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(')');
        }
Exemple #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);
        }
Exemple #13
0
 public override string ToString(SymbolTable symtab)
 {
     return "?var" + _varName;
 }
Exemple #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();
        }
Exemple #15
0
 internal Parser()
 {
     _symbolTable = new SymbolTable();
     InitSymbolTable();
 }
 /**
  * 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];
 }
Exemple #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(')');
        }