01: package org.acm.seguin.pmd.cpd;
02:
03: import java.io.IOException;
04: import java.io.LineNumberReader;
05: import java.io.Reader;
06: import java.util.ArrayList;
07: import java.util.List;
08: import org.acm.seguin.pmd.PMD;
09:
10: public class PHPTokenizer implements Tokenizer {
11:
12: public void tokenize(SourceCode tokens, Tokens tokenEntries,
13: Reader input) throws IOException {
14: List lines = new ArrayList();
15: StringBuffer sb = new StringBuffer();
16: LineNumberReader r = new LineNumberReader(input);
17: String currentLine;
18: int lineCount = 0;
19: int count = 0;
20: while ((currentLine = r.readLine()) != null) {
21: lines.add(currentLine);
22: sb.append(currentLine);
23: sb.append(PMD.EOL);
24: for (int i = 0; i < currentLine.length(); i++) {
25: char tok = currentLine.charAt(i);
26: if (!Character.isWhitespace(tok) && tok != '{'
27: && tok != '}' && tok != ';') {
28: count++;
29: tokenEntries.add(new TokenEntry(
30: String.valueOf(tok), count, tokens
31: .getFileName(), lineCount));
32: }
33: }
34: lineCount++;
35: }
36: tokens.setCode(lines);
37: tokenEntries.add(TokenEntry.EOF);
38: }
39: }
|