src/share/classes/com/sun/tools/javac/parser/Lexer.java

changeset 1113
d346ab55031b
parent 581
f2fdd52e4e87
child 1144
9448fe783fd2
equal deleted inserted replaced
1112:b4021c520e40 1113:d346ab55031b
23 * questions. 23 * questions.
24 */ 24 */
25 25
26 package com.sun.tools.javac.parser; 26 package com.sun.tools.javac.parser;
27 27
28 import com.sun.tools.javac.util.*; 28 import com.sun.tools.javac.parser.Tokens.*;
29 import com.sun.tools.javac.util.Position.LineMap; 29 import com.sun.tools.javac.util.Position.LineMap;
30 30
31 /** 31 /**
32 * The lexical analyzer maps an input stream consisting of ASCII 32 * The lexical analyzer maps an input stream consisting of ASCII
33 * characters and Unicode escapes into a token sequence. 33 * characters and Unicode escapes into a token sequence.
38 * deletion without notice.</b> 38 * deletion without notice.</b>
39 */ 39 */
40 public interface Lexer { 40 public interface Lexer {
41 41
42 /** 42 /**
43 * Has a @deprecated been encountered in last doc comment? 43 * Consume the next token.
44 * This needs to be reset by client with resetDeprecatedFlag.
45 */ 44 */
46 boolean deprecatedFlag(); 45 void nextToken();
47
48 void resetDeprecatedFlag();
49 46
50 /** 47 /**
51 * Returns the documentation string of the current token. 48 * Return current token.
52 */ 49 */
53 String docComment(); 50 Token token();
54 51
55 /** 52 /**
56 * Return the last character position of the current token. 53 * Return the last character position of the previous token.
57 */ 54 */
58 int endPos(); 55 Token prevToken();
56
57 /**
58 * Splits the current token in two and return the first (splitted) token.
59 * For instance '<<<' is splitted into two tokens '<' and '<<' respectively,
60 * and the latter is returned.
61 */
62 Token split();
59 63
60 /** 64 /**
61 * Return the position where a lexical error occurred; 65 * Return the position where a lexical error occurred;
62 */ 66 */
63 int errPos(); 67 int errPos();
72 * positions in the input. 76 * positions in the input.
73 * 77 *
74 * @return a LineMap 78 * @return a LineMap
75 */ 79 */
76 LineMap getLineMap(); 80 LineMap getLineMap();
77
78 /**
79 * Returns a copy of the input buffer, up to its inputLength.
80 * Unicode escape sequences are not translated.
81 */
82 char[] getRawCharacters();
83
84 /**
85 * Returns a copy of a character array subset of the input buffer.
86 * The returned array begins at the <code>beginIndex</code> and
87 * extends to the character at index <code>endIndex - 1</code>.
88 * Thus the length of the substring is <code>endIndex-beginIndex</code>.
89 * This behavior is like
90 * <code>String.substring(beginIndex, endIndex)</code>.
91 * Unicode escape sequences are not translated.
92 *
93 * @param beginIndex the beginning index, inclusive.
94 * @param endIndex the ending index, exclusive.
95 * @throws IndexOutOfBounds if either offset is outside of the
96 * array bounds
97 */
98 char[] getRawCharacters(int beginIndex, int endIndex);
99
100 /**
101 * Return the name of an identifier or token for the current token.
102 */
103 Name name();
104
105 /**
106 * Read token.
107 */
108 void nextToken();
109
110 /**
111 * Return the current token's position: a 0-based
112 * offset from beginning of the raw input stream
113 * (before unicode translation)
114 */
115 int pos();
116
117 /**
118 * Return the last character position of the previous token.
119 */
120 int prevEndPos();
121
122 /**
123 * Return the radix of a numeric literal token.
124 */
125 int radix();
126
127 /**
128 * The value of a literal token, recorded as a string.
129 * For integers, leading 0x and 'l' suffixes are suppressed.
130 */
131 String stringVal();
132
133 /**
134 * Return the current token, set by nextToken().
135 */
136 Token token();
137
138 /**
139 * Sets the current token.
140 */
141 void token(Token token);
142 } 81 }

mercurial