Scanner.java 926 B

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