|
1 /* |
|
2 * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Sun designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Sun in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 * have any questions. |
|
24 */ |
|
25 |
|
26 package com.sun.tools.javac.parser; |
|
27 |
|
28 import com.sun.tools.javac.util.*; |
|
29 import com.sun.tools.javac.util.Position.LineMap; |
|
30 |
|
31 /** |
|
32 * The lexical analyzer maps an input stream consisting of ASCII |
|
33 * characters and Unicode escapes into a token sequence. |
|
34 * |
|
35 * <p><b>This is NOT part of any API supported by Sun Microsystems. |
|
36 * If you write code that depends on this, you do so at your own risk. |
|
37 * This code and its internal interfaces are subject to change or |
|
38 * deletion without notice.</b> |
|
39 */ |
|
40 public interface Lexer { |
|
41 |
|
42 /** |
|
43 * Has a @deprecated been encountered in last doc comment? |
|
44 * This needs to be reset by client with resetDeprecatedFlag. |
|
45 */ |
|
46 boolean deprecatedFlag(); |
|
47 |
|
48 void resetDeprecatedFlag(); |
|
49 |
|
50 /** |
|
51 * Returns the documentation string of the current token. |
|
52 */ |
|
53 String docComment(); |
|
54 |
|
55 /** |
|
56 * Return the last character position of the current token. |
|
57 */ |
|
58 int endPos(); |
|
59 |
|
60 /** |
|
61 * Return the position where a lexical error occurred; |
|
62 */ |
|
63 int errPos(); |
|
64 |
|
65 /** |
|
66 * Set the position where a lexical error occurred; |
|
67 */ |
|
68 void errPos(int pos); |
|
69 |
|
70 /** |
|
71 * Build a map for translating between line numbers and |
|
72 * positions in the input. |
|
73 * |
|
74 * @return a LineMap |
|
75 */ |
|
76 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 } |