src/main/java/logic/is/power/tptp_parser/tptp_tester.java
/** Parses the file <strong> fileName </strong> and checks the results semantically.
     *  If <strong> includeDir </strong> != null, included files are parsed recursively
     *  as soon as they appear.
     */
Parses the file  fileName  and checks the results semantically.
If  includeDir  != null, included files are parsed recursively
as soon as they appear.
Parses the file fileName and checks the results semantically . If includeDir ! = null included files are parsed recursively as soon as they appear .
private 
    static 
    void parseAndCheck(String fileName,
                       String includeDir,
                       SimpleTptpParserOutput outputManager,
                       LinkedList<SimpleTptpParserOutput.TopLevelItem> results,
                       int recursionDepth) 
    throws Exception
  {
    FileInputStream in = new FileInputStream(fileName);
    TptpLexer lexer = new TptpLexer(new DataInputStream(in));
    TptpParser parser = new TptpParser(lexer);
    for (SimpleTptpParserOutput.TopLevelItem item = 
           (SimpleTptpParserOutput.TopLevelItem)parser.topLevelItem(outputManager);
         item != null;
         item = (SimpleTptpParserOutput.TopLevelItem)parser.topLevelItem(outputManager))
      {
        if (includeDir != null &&
            item.getKind() == TptpParserOutput.TptpInput.Kind.Include)
          {                    
            if (recursionDepth >= 1024)
              throw new Exception("Too many nested include directives (depth > 1024) " +
                                  "in " + fileName + ", line " + item.getLineNumber() + ".");
            String relativeIncludeFileName = 
              ((SimpleTptpParserOutput.IncludeDirective)item).getFileName();
            relativeIncludeFileName = 
              relativeIncludeFileName.substring(1,
                                                relativeIncludeFileName.length() - 1);
            String includeFileName =  
              includeDir + "/" + relativeIncludeFileName;
            parseAndCheck(includeFileName,
                          includeDir,
                          outputManager,
                          results,
                          recursionDepth + 1);
          }
        else
          {
            /* Minimal semantic analysis: check that no symbol is used
               both as a predicate and as a function or constant, and that 
               no symbol is used with different arities.
               checkSemantically(item) will throw 
               java.lang.Exception(<error description>) if something is wrong 
               with the item.
            */             
            checkSemantically(item,fileName);
            results.add(item);
          };
      };
    in.close();
  }
private static void parseAndCheck ( String fileName , String includeDir , SimpleTptpParserOutput outputManager , LinkedList < SimpleTptpParserOutput . TopLevelItem > results , int recursionDepth ) throws Exception { FileInputStream in = new FileInputStream ( fileName ) ; TptpLexer lexer = new TptpLexer ( new DataInputStream ( in ) ) ; TptpParser parser = new TptpParser ( lexer ) ; for ( SimpleTptpParserOutput . TopLevelItem item = ( SimpleTptpParserOutput . TopLevelItem ) parser . topLevelItem ( outputManager ) ; item != null ; item = ( SimpleTptpParserOutput . TopLevelItem ) parser . topLevelItem ( outputManager ) ) { if ( includeDir != null && item . getKind ( ) == TptpParserOutput . TptpInput . Kind . Include ) { if ( recursionDepth >= 1024 ) throw new Exception ( "Too many nested include directives (depth > 1024) " + "in " + fileName + ", line " + item . getLineNumber ( ) + "." ) ; String relativeIncludeFileName = ( ( SimpleTptpParserOutput . IncludeDirective ) item ) . getFileName ( ) ; relativeIncludeFileName = relativeIncludeFileName . substring ( 1 , relativeIncludeFileName . length ( ) - 1 ) ; String includeFileName = includeDir + "/" + relativeIncludeFileName ; parseAndCheck ( includeFileName , includeDir , outputManager , results , recursionDepth + 1 ) ; } else { /* Minimal semantic analysis: check that no symbol is used
               both as a predicate and as a function or constant, and that 
               no symbol is used with different arities.
               checkSemantically(item) will throw 
               java.lang.Exception(<error description>) if something is wrong 
               with the item.
            */ checkSemantically ( item , fileName ) ; results . add ( item ) ; } ; } ; in . close ( ) ; }
Parses the file <strong> fileName </strong> and checks the results semantically.
Parses the file <strong > fileName < / strong > and checks the results semantically .
//DEBUG         System.out.println(item); // The file name has to be truncated because it is quoted