01: /*
02: *Author: Chris Seguin
03: *
04: *This software has been developed under the copyleft
05: *rules of the GNU General Public License. Please
06: *consult the GNU General Public License for more
07: *details about use and distribution of this software.
08: */
09: package org.acm.seguin.pretty;
10:
11: import net.sourceforge.jrefactory.parser.Token;
12:
13: /**
14: * Parses a javadoc comment
15: *
16: * @author Chris Seguin
17: * @author Mike Atkinson
18: * @created June 10, 2002
19: */
20: public class JavadocTokenizer extends Tokenizer {
21: private Token lookahead = null;
22:
23: /**
24: * Constructor for the JavadocTokenizer object
25: *
26: * @paraminit Description of Parameter
27: */
28: public JavadocTokenizer(String init) {
29: super (init);
30: }
31:
32: /**
33: * Description of the Method
34: *
35: * @return Description of the Returned Value
36: */
37: public Token next() {
38: if (lookahead != null) {
39: Token t = lookahead;
40: lookahead = null;
41: return t;
42: }
43: Token token = super .next();
44: if (token.image.equals("//")) {
45: StringBuffer buf = new StringBuffer(token.image);
46: while (true) {
47: Token nextToken = super .next();
48: if (nextToken.kind == NEWLINE) {
49: lookahead = nextToken;
50: Token t = new Token();
51: t.kind = WORD;
52: t.image = buf.toString();
53: return t;
54: } else {
55: buf.append(nextToken.image);
56: }
57: }
58: }
59: return token;
60: }
61: }
|