|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sun.tools.javac.parser.Scanner
public class Scanner
The lexical analyzer maps an input stream consisting of ASCII characters and Unicode escapes into a token sequence.
This is NOT part of any API supported by Sun Microsystems. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
| Nested Class Summary | |
|---|---|
static class |
Scanner.CommentStyle
|
static class |
Scanner.Factory
A factory for creating scanners. |
| Field Summary | |
|---|---|
private boolean |
allowHexFloats
Allow hex floating-point literals. |
private int |
bp
|
private char[] |
buf
The input buffer, index of next chacter to be read, index of one past last character in buffer. |
private int |
buflen
|
private char |
ch
The current character. |
protected boolean |
deprecatedFlag
Has a @deprecated been encountered in last doc comment? this needs to be reset by client. |
private int |
endPos
Character position just after the last character of the token. |
private int |
eofPos
|
private int |
errPos
The position where a lexical error occurred; |
private static boolean |
hexFloatsWork
|
private Keywords |
keywords
The keyword table. |
private Log |
log
The log to be used for error reporting. |
private Name |
name
The name of an identifier or token: |
private Names |
names
The name table. |
private int |
pos
The token's position, 0-based offset from beginning of text. |
private int |
prevEndPos
The last character position of the previous token. |
private int |
radix
The radix of a numeric literal token. |
private char[] |
sbuf
A character buffer for literals. |
private static boolean |
scannerDebug
|
private int |
sp
|
(package private) static boolean |
surrogatesSupported
Are surrogates supported? |
private Token |
token
The token, set by nextToken(). |
private int |
unicodeConversionBp
The buffer index of the last converted unicode character |
| Constructor Summary | |
|---|---|
private |
Scanner(Scanner.Factory fac)
Common code for constructors. |
protected |
Scanner(Scanner.Factory fac,
char[] input,
int inputLength)
Create a scanner from the input array. |
protected |
Scanner(Scanner.Factory fac,
java.nio.CharBuffer buffer)
Create a scanner from the input buffer. |
| Method Summary | |
|---|---|
private void |
convertUnicode()
Convert unicode escape; bp points to initial '\' character (Spec 3.3). |
private void |
dch()
For debugging purposes: print character. |
boolean |
deprecatedFlag()
Has a @deprecated been encountered in last doc comment? This needs to be reset by client with resetDeprecatedFlag. |
private int |
digit(int base)
Convert an ASCII digit from its base (8, 10, or 16) to its value. |
java.lang.String |
docComment()
Returns the documentation string of the current token. |
int |
endPos()
Return the last character position of the current token. |
int |
errPos()
Return the position where a lexical error occurred; |
void |
errPos(int pos)
Set the position where a lexical error occurred; |
Position.LineMap |
getLineMap()
Build a map for translating between line numbers and positions in the input. |
char[] |
getRawCharacters()
Returns a copy of the input buffer, up to its inputLength. |
char[] |
getRawCharacters(int beginIndex,
int endIndex)
Returns a copy of a character array subset of the input buffer. |
private static boolean |
hexFloatsWork()
|
private boolean |
isSpecial(char ch)
Return true if ch can be part of an operator. |
private void |
lexError(int pos,
java.lang.String key,
java.lang.Object... args)
Report an error at the given position using the provided arguments. |
private void |
lexError(java.lang.String key,
java.lang.Object... args)
Report an error at the current token position using the provided arguments. |
Name |
name()
Return the name of an identifier or token for the current token. |
void |
nextToken()
Read token. |
int |
pos()
Return the current token's position: a 0-based offset from beginning of the raw input stream (before unicode translation) |
int |
prevEndPos()
Return the last character position of the previous token. |
protected void |
processComment(Scanner.CommentStyle style)
Called when a complete comment has been scanned. |
protected void |
processLineTerminator()
Called when a line terminator has been processed. |
protected void |
processWhiteSpace()
Called when a complete whitespace run has been scanned. |
private void |
putChar(char ch)
Append a character to sbuf. |
int |
radix()
Return the radix of a numeric literal token. |
void |
resetDeprecatedFlag()
|
private void |
scanChar()
Read next character. |
private void |
scanCommentChar()
Read next character in comment, skipping over double '\' characters. |
private void |
scanDocComment()
Scan a documention comment; determine if a deprecated tag is present. |
private void |
scanFraction()
Read fractional part of floating point number. |
private void |
scanFractionAndSuffix()
Read fractional part and 'd' or 'f' suffix of floating point number. |
private void |
scanHexExponentAndSuffix()
Read fractional part of hexadecimal floating point number. |
private void |
scanHexFractionAndSuffix(boolean seendigit)
Read fractional part and 'd' or 'f' suffix of floating point number. |
private void |
scanIdent()
Read an identifier. |
private void |
scanLitChar()
Read next character in character or string literal and copy into sbuf. |
private void |
scanNumber(int radix)
Read a number. |
private void |
scanOperator()
Read longest possible sequence of special characters and convert to token. |
private char |
scanSurrogates()
Scan surrogate pairs. |
java.lang.String |
stringVal()
The value of a literal token, recorded as a string. |
private static boolean |
surrogatesSupported()
|
Token |
token()
Return the current token, set by nextToken(). |
void |
token(Token token)
Sets the current token. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static boolean scannerDebug
private Token token
private boolean allowHexFloats
private int pos
private int endPos
private int prevEndPos
private int errPos
private Name name
private int radix
protected boolean deprecatedFlag
private char[] sbuf
private int sp
private char[] buf
private int bp
private int buflen
private int eofPos
private char ch
private int unicodeConversionBp
private final Log log
private final Names names
private final Keywords keywords
private static final boolean hexFloatsWork
static final boolean surrogatesSupported
| Constructor Detail |
|---|
private Scanner(Scanner.Factory fac)
protected Scanner(Scanner.Factory fac,
java.nio.CharBuffer buffer)
protected Scanner(Scanner.Factory fac,
char[] input,
int inputLength)
inputLength < input.length or
input[input.length -1] is a white space character.
fac - the factory which created this Scannerinput - the input, might be modifiedinputLength - the size of the input.
Must be positive and less than or equal to input.length.| Method Detail |
|---|
private static boolean hexFloatsWork()
private void lexError(int pos,
java.lang.String key,
java.lang.Object... args)
private void lexError(java.lang.String key,
java.lang.Object... args)
private int digit(int base)
private void convertUnicode()
private void scanChar()
private void scanCommentChar()
private void putChar(char ch)
private void dch()
private void scanLitChar()
private void scanHexExponentAndSuffix()
private void scanFraction()
private void scanFractionAndSuffix()
private void scanHexFractionAndSuffix(boolean seendigit)
private void scanNumber(int radix)
radix - The radix of the number; one of 8, 10, 16.private void scanIdent()
private static boolean surrogatesSupported()
private char scanSurrogates()
private boolean isSpecial(char ch)
private void scanOperator()
private void scanDocComment()
public java.lang.String stringVal()
stringVal in interface Lexerpublic void nextToken()
nextToken in interface Lexerpublic Token token()
token in interface Lexerpublic void token(Token token)
token in interface Lexerpublic int pos()
pos in interface Lexerpublic int endPos()
endPos in interface Lexerpublic int prevEndPos()
prevEndPos in interface Lexerpublic int errPos()
errPos in interface Lexerpublic void errPos(int pos)
errPos in interface Lexerpublic Name name()
name in interface Lexerpublic int radix()
radix in interface Lexerpublic boolean deprecatedFlag()
deprecatedFlag in interface Lexerpublic void resetDeprecatedFlag()
resetDeprecatedFlag in interface Lexerpublic java.lang.String docComment()
docComment in interface Lexerpublic char[] getRawCharacters()
getRawCharacters in interface Lexer
public char[] getRawCharacters(int beginIndex,
int endIndex)
beginIndex and
extends to the character at index endIndex - 1.
Thus the length of the substring is endIndex-beginIndex.
This behavior is like
String.substring(beginIndex, endIndex).
Unicode escape sequences are not translated.
getRawCharacters in interface LexerbeginIndex - the beginning index, inclusive.endIndex - the ending index, exclusive.
IndexOutOfBounds - if either offset is outside of the
array boundsprotected void processComment(Scanner.CommentStyle style)
protected void processWhiteSpace()
protected void processLineTerminator()
public Position.LineMap getLineMap()
getLineMap in interface Lexer
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||