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; }
protected ReasoningEntity(Parser parser) { Parser = parser; SymbolTable = Parser.SymbolTable; QueryTerminal = MakeQuery("terminal"); QueryNext = MakeQuery("next", "?x"); Random = new Random(); }
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); }
public Lexer(TextReader input, SymbolTable symbolTable) { _in = input; _symbolTable = symbolTable; _lineNumber = 0; _bufferedTokens = new Stack<int>(2); _markedCharacter = NoMark; }
private GdlVariable(SymbolTable symTab, int token) : base(symTab) { token_ = token; }
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(); } } }
public abstract void PrintToStream(StreamWriter target, SymbolTable symtab);
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(); }
public override string ToString(SymbolTable symtab) { return symtab[Token]; }
public override void PrintToStream(StreamWriter target, SymbolTable symtab) { target.Write("(not "); Negated.PrintToStream(target, symtab); target.Write(")"); }
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(')'); }
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); }
public override string ToString(SymbolTable symtab) { return "?var" + _varName; }
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(); }
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]; }
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(')'); }