Scanner.java 785 B

123456789101112131415161718192021222324252627282930
  1. package jplag.cpp;
  2. import java.io.File;
  3. import jplag.Parser;
  4. public class Scanner extends Parser implements CPPTokenConstants {
  5. private String actFile;
  6. private jplag.Structure struct;
  7. public jplag.Structure scan(File dir, String files[]) {
  8. struct = new jplag.Structure();
  9. errors = 0;
  10. CPPScanner scanner = null;// will be initialized in Method scanFile
  11. for (int i = 0; i < files.length; i++) {
  12. actFile = files[i];
  13. getProgram().print(null, "Scanning file " + files[i] + "\n");
  14. if (!CPPScanner.scanFile(dir, files[i], scanner, this))
  15. errors++;
  16. struct.addToken(new CPPToken(FILE_END, actFile, 1));
  17. }
  18. this.parseEnd();
  19. return struct;
  20. }
  21. public void add(int type, Token token) {
  22. struct.addToken(new CPPToken(type, actFile, token.beginLine));
  23. }
  24. }