/** * Parses statements and print the parse tree to the console for quick interactive testing of the parser. * * @param args The command line arguments. */ public static void main(String[] args) { try { SimpleCharStream inputStream = new SimpleCharStream(System.in, null, 1, 1); PrologParserTokenManager tokenManager = new PrologParserTokenManager(inputStream); Source<Token> tokenSource = new TokenSource(tokenManager); PrologParser parser = new PrologParser(tokenSource, new VariableAndFunctorInternerImpl("Prolog_Variable_Namespace", "Prolog_Functor_Namespace")); while (true) { // Parse the next sentence or directive. Object nextParsing = parser.clause(); console.info(nextParsing.toString()); } } catch (Exception e) { console.log(Level.SEVERE, e.getMessage(), e); System.exit(1); } }
/** * Parses statements and print the parse tree to the console for quick interactive testing of the parser. * * @param args The command line arguments. */ public static void main(String[] args) { try { SimpleCharStream inputStream = new SimpleCharStream(System.in, null, 1, 1); PrologParserTokenManager tokenManager = new PrologParserTokenManager(inputStream); Source<Token> tokenSource = new TokenSource(tokenManager); PrologParser parser = new PrologParser(tokenSource, new VariableAndFunctorInternerImpl("Prolog_Variable_Namespace", "Prolog_Functor_Namespace")); while (true) { // Parse the next sentence or directive. Object nextParsing = parser.clause(); console.info(nextParsing.toString()); } } catch (Exception e) { console.log(Level.SEVERE, e.getMessage(), e); System.exit(1); } }
new VariableAndFunctorInternerImpl("Prolog_Variable_Namespace", "Prolog_Functor_Namespace"); PrologCompiler compiler = new PrologCompiler(interner); PrologResolver resolver = new PrologResolver(interner);
/** 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); }