APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.tools.javac.parser

public Class Scanner

extends Object
implements Lexer
Class Inheritance
All Implemented Interfaces
com.sun.tools.javac.parser.Lexer
Imports
java.nio.*, java.util.ArrayDeque, .List, .ArrayList, .Queue, com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition, .JCDiagnostic.LintWarning, .Position.LineMap

The lexical analyzer maps an input stream consisting of ASCII characters and Unicode escapes into a token sequence.

This is NOT part of any supported API. 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.

Field Summary

Modifier and TypeField and Description
private final Queue<Tokens.Comment>
docComments

Queue of recently seen documentation comments.

private Tokens.Token
prevToken

The previous token, set by nextToken().

private final List<Tokens.Token>
savedTokens

Buffer of saved tokens (used during lookahead)

private Tokens.Token
token

The token, set by nextToken().

private final JavaTokenizer
protected Tokens

Constructor Summary

AccessConstructor and Description
protected
Scanner(ScannerFactory
the factory which created this Scanner
fac
,
CharBuffer
the input, might be modified Must be positive and less than or equal to input.length.
buf
)

Create a scanner from the input array.

protected
Scanner(ScannerFactory fac, char[] buf, int inputLength)

protected

Method Summary

Modifier and TypeMethod and Description
private void
ensureLookahead(int lookahead)

public int
errPos()

Implements com.sun.tools.javac.parser.Lexer.errPos.

Return the position where a lexical error occurred;

public void
errPos(int pos)

Implements com.sun.tools.javac.parser.Lexer.errPos.

Set the position where a lexical error occurred;

public Queue<Tokens.Comment>
getDocComments()

Implements com.sun.tools.javac.parser.Lexer.getDocComments.

Returns a queue for the documentation comments encountered in a compilation unit.

public Position.LineMap
getLineMap()

Implements com.sun.tools.javac.parser.Lexer.getLineMap.

Build a map for translating between line numbers and positions in the input.

public void
lintWarning(JCDiagnostic.DiagnosticPosition pos, JCDiagnostic.LintWarning key)

Implements com.sun.tools.javac.parser.Lexer.lintWarning.

Report a warning that is subject to possible suppression by @SuppressWarnings.

public void
nextToken()

Implements com.sun.tools.javac.parser.Lexer.nextToken.

Consume the next token.

public Tokens.Token
prevToken()

Implements com.sun.tools.javac.parser.Lexer.prevToken.

Return the last character position of the previous token.

public void
setPrevToken(Tokens.Token prevToken)

Implements com.sun.tools.javac.parser.Lexer.setPrevToken.

Sets the previous token.

public Tokens.Token
split()

Implements com.sun.tools.javac.parser.Lexer.split.

Splits the current token in two and return the first (split) token.

public Tokens.Token
token()

Implements com.sun.tools.javac.parser.Lexer.token.

Return current token.

public Tokens.Token
token(int lookahead)

Implements com.sun.tools.javac.parser.Lexer.token.

Return token with given lookahead.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

docCommentsback to summary
private final Queue<Tokens.Comment> docComments

Queue of recently seen documentation comments. It is assumed the queue will typically be small.

prevTokenback to summary
private Tokens.Token prevToken

The previous token, set by nextToken().

savedTokensback to summary
private final List<Tokens.Token> savedTokens

Buffer of saved tokens (used during lookahead)

tokenback to summary
private Tokens.Token token

The token, set by nextToken().

tokenizerback to summary
private final JavaTokenizer tokenizer
tokensback to summary
protected Tokens tokens

Constructor Detail

Scannerback to summary
protected Scanner(ScannerFactory fac, CharBuffer buf)

Create a scanner from the input array. This method might modify the array. To avoid copying the input array, ensure that inputLength < input.length or input[input.length -1] is a white space character.

Parameters
fac:ScannerFactory

the factory which created this Scanner

buf:CharBuffer

the input, might be modified Must be positive and less than or equal to input.length.

Scannerback to summary
protected Scanner(ScannerFactory fac, char[] buf, int inputLength)
Scannerback to summary
protected Scanner(ScannerFactory fac, JavaTokenizer tokenizer)

Method Detail

ensureLookaheadback to summary
private void ensureLookahead(int lookahead)
errPosback to summary
public int errPos()

Implements com.sun.tools.javac.parser.Lexer.errPos.

Doc from com.sun.tools.javac.parser.Lexer.errPos.

Return the position where a lexical error occurred;

errPosback to summary
public void errPos(int pos)

Implements com.sun.tools.javac.parser.Lexer.errPos.

Doc from com.sun.tools.javac.parser.Lexer.errPos.

Set the position where a lexical error occurred;

getDocCommentsback to summary
public Queue<Tokens.Comment> getDocComments()

Implements com.sun.tools.javac.parser.Lexer.getDocComments.

Doc from com.sun.tools.javac.parser.Lexer.getDocComments.

Returns a queue for the documentation comments encountered in a compilation unit. Comments may be added to this queue by the implementation; clients may remove them from the queue as they are analyzed.

Note

all comments may also be associated with the following token.

Annotations
@Override
getLineMapback to summary
public Position.LineMap getLineMap()

Implements com.sun.tools.javac.parser.Lexer.getLineMap.

Doc from com.sun.tools.javac.parser.Lexer.getLineMap.

Build a map for translating between line numbers and positions in the input.

lintWarningback to summary
public void lintWarning(JCDiagnostic.DiagnosticPosition pos, JCDiagnostic.LintWarning key)

Implements com.sun.tools.javac.parser.Lexer.lintWarning.

Doc from com.sun.tools.javac.parser.Lexer.lintWarning.

Report a warning that is subject to possible suppression by @SuppressWarnings.

Annotations
@Override
nextTokenback to summary
public void nextToken()

Implements com.sun.tools.javac.parser.Lexer.nextToken.

Doc from com.sun.tools.javac.parser.Lexer.nextToken.

Consume the next token.

prevTokenback to summary
public Tokens.Token prevToken()

Implements com.sun.tools.javac.parser.Lexer.prevToken.

Doc from com.sun.tools.javac.parser.Lexer.prevToken.

Return the last character position of the previous token.

setPrevTokenback to summary
public void setPrevToken(Tokens.Token prevToken)

Implements com.sun.tools.javac.parser.Lexer.setPrevToken.

Doc from com.sun.tools.javac.parser.Lexer.setPrevToken.

Sets the previous token.

splitback to summary
public Tokens.Token split()

Implements com.sun.tools.javac.parser.Lexer.split.

Doc from com.sun.tools.javac.parser.Lexer.split.

Splits the current token in two and return the first (split) token. For instance '<<<' is split into two tokens '<' and '<<' respectively, and the latter is returned.

tokenback to summary
public Tokens.Token token()

Implements com.sun.tools.javac.parser.Lexer.token.

Doc from com.sun.tools.javac.parser.Lexer.token.

Return current token.

tokenback to summary
public Tokens.Token token(int lookahead)

Implements com.sun.tools.javac.parser.Lexer.token.

Doc from com.sun.tools.javac.parser.Lexer.token.

Return token with given lookahead.