001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.tools.javac.parser;
027:
028: import com.sun.tools.javac.util.*;
029: import com.sun.tools.javac.util.Position.LineMap;
030:
031: /**
032: * The lexical analyzer maps an input stream consisting of ASCII
033: * characters and Unicode escapes into a token sequence.
034: *
035: * <p><b>This is NOT part of any API supported by Sun Microsystems.
036: * If you write code that depends on this, you do so at your own risk.
037: * This code and its internal interfaces are subject to change or
038: * deletion without notice.</b>
039: */
040: @Version("@(#)Lexer.java 1.8 07/05/05")
041: public interface Lexer {
042:
043: /**
044: * Has a @deprecated been encountered in last doc comment?
045: * This needs to be reset by client with resetDeprecatedFlag.
046: */
047: boolean deprecatedFlag();
048:
049: void resetDeprecatedFlag();
050:
051: /**
052: * Returns the documentation string of the current token.
053: */
054: String docComment();
055:
056: /**
057: * Return the last character position of the current token.
058: */
059: int endPos();
060:
061: /**
062: * Return the position where a lexical error occurred;
063: */
064: int errPos();
065:
066: /**
067: * Set the position where a lexical error occurred;
068: */
069: void errPos(int pos);
070:
071: /**
072: * Build a map for translating between line numbers and
073: * positions in the input.
074: *
075: * @return a LineMap
076: */
077: LineMap getLineMap();
078:
079: /**
080: * Returns a copy of the input buffer, up to its inputLength.
081: * Unicode escape sequences are not translated.
082: */
083: char[] getRawCharacters();
084:
085: /**
086: * Returns a copy of a character array subset of the input buffer.
087: * The returned array begins at the <code>beginIndex</code> and
088: * extends to the character at index <code>endIndex - 1</code>.
089: * Thus the length of the substring is <code>endIndex-beginIndex</code>.
090: * This behavior is like
091: * <code>String.substring(beginIndex, endIndex)</code>.
092: * Unicode escape sequences are not translated.
093: *
094: * @param beginIndex the beginning index, inclusive.
095: * @param endIndex the ending index, exclusive.
096: * @throws IndexOutOfBounds if either offset is outside of the
097: * array bounds
098: */
099: char[] getRawCharacters(int beginIndex, int endIndex);
100:
101: /**
102: * Return the name of an identifier or token for the current token.
103: */
104: Name name();
105:
106: /**
107: * Read token.
108: */
109: void nextToken();
110:
111: /**
112: * Return the current token's position: a 0-based
113: * offset from beginning of the raw input stream
114: * (before unicode translation)
115: */
116: int pos();
117:
118: /**
119: * Return the last character position of the previous token.
120: */
121: int prevEndPos();
122:
123: /**
124: * Return the radix of a numeric literal token.
125: */
126: int radix();
127:
128: /**
129: * The value of a literal token, recorded as a string.
130: * For integers, leading 0x and 'l' suffixes are suppressed.
131: */
132: String stringVal();
133:
134: /**
135: * Return the current token, set by nextToken().
136: */
137: Token token();
138:
139: /**
140: * Sets the current token.
141: */
142: void token(Token token);
143: }
|