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 .