/** {@inheritDoc} */ public Sentence<S> parse() throws SourceCodeException { return parser.parse(); }
/** {@inheritDoc} */ public void setTokenSource(Source<Token> tokenSource) { parser.setTokenSource(tokenSource); }
/** {@inheritDoc} */ public void setOperator(String operatorName, int priority, OpSymbol.Associativity associativity) { parser.setOperator(operatorName, priority, associativity); }
libParser.setTokenSource(tokenSource); Sentence<Clause> sentence = libParser.parse();
libParser.setTokenSource(tokenSource); Sentence<Clause> sentence = libParser.parse();
/** * Consults an input stream, reading first order logic clauses from it, and inserting them into the resolvers * knowledge base. * * @param stream The input stream to consult. * * @throws SourceCodeException If any code read from the input stream fails to parse, compile or link. */ public void consultInputStream(InputStream stream) throws SourceCodeException { // Create a token source to read from the specified input stream. Source<Token> tokenSource = TokenSource.getTokenSourceForInputStream(stream); getParser().setTokenSource(tokenSource); // Consult the type checking rules and add them to the knowledge base. while (true) { Sentence<S> sentence = getParser().parse(); if (sentence == null) { break; } getCompiler().compile(sentence); } }
/** {@inheritDoc} */ public void setTokenSource(Source<Token> tokenSource) { parser.setTokenSource(tokenSource); }
/** {@inheritDoc} */ public Sentence<S> parse() throws SourceCodeException { return parser.parse(); }
/** {@inheritDoc} */ public void setOperator(String operatorName, int priority, OpSymbol.Associativity associativity) { parser.setOperator(operatorName, priority, associativity); }
/** * Consults an input stream, reading first order logic clauses from it, and inserting them into the resolvers * knowledge base. * * @param stream The input stream to consult. * * @throws SourceCodeException If any code read from the input stream fails to parse, compile or link. */ public void consultInputStream(InputStream stream) throws SourceCodeException { // Create a token source to read from the specified input stream. Source<Token> tokenSource = TokenSource.getTokenSourceForInputStream(stream); getParser().setTokenSource(tokenSource); // Consult the type checking rules and add them to the knowledge base. while (true) { Sentence<S> sentence = getParser().parse(); if (sentence == null) { break; } getCompiler().compile(sentence); } }
/** * Creates a resolution engine for the prolog interpreter, allowing the default components to be overriden with a * specified set of components. * * @param parser The parser to use. * @param interner The interner to use. * @param compiler The compiler to use. * @param resolver The resolver to use. */ public PrologEngine(Parser<Clause, Token> parser, VariableAndFunctorInterner interner, LogicCompiler<Clause, PrologCompiledClause, PrologCompiledClause> compiler, Resolver<PrologCompiledClause, PrologCompiledClause> resolver) { super(parser, interner, compiler, resolver); parser.setTokenSource(TokenSource.getTokenSourceForInputStream(System.in)); }
parser.setTokenSource(TokenSource.getTokenSourceForString(termText)); Sentence<Clause> sentence = parser.parse(); clauses.add(sentence);
/** Creates a resolution engine for the prolog interpreter. */ public PrologEngine() { interner = new VariableAndFunctorInternerImpl("Prolog_Variable_Namespace", "Prolog_Functor_Namespace"); parser = new SentenceParser(interner); compiler = new PrologCompiler(interner); resolver = new PrologResolver(interner); parser.setTokenSource(TokenSource.getTokenSourceForInputStream(System.in)); compiler.setCompilerObserver(chainedObserver); }
parser.setTokenSource(TokenSource.getTokenSourceForInputStream(System.in));