public abstract class BaseRawTokenizer<T extends TokenBase> extends Object
Modifier and Type | Field and Description |
---|---|
protected StringBuilder |
aggregateContents
Contents of aggregate
|
protected int |
aggregateStart
Start offset of aggregate
|
protected int |
aggregateStartColumn
Column number of aggregate
|
protected int |
aggregateStartLine
Line number of aggregate
|
Constructor and Description |
---|
BaseRawTokenizer() |
Modifier and Type | Method and Description |
---|---|
protected void |
addBadCharacterProblem(String badChar) |
T |
buildAggregateToken(int type)
Build a token from the current aggregated text and the given type
|
T |
buildToken(int type)
Builds a token with the specified type and text, using the current
getOffset(), getLine(), and getColumn().
|
protected T |
buildToken(int type,
int start,
int end,
int line,
int column,
CharSequence text) |
T |
buildToken(int type,
String text)
Build a token of the specified type, using the current yytext(),
getOffset(), getLine(), and getColumn().
|
protected void |
continueAggregate()
Add the current yytext() to the current aggregate
|
protected void |
continueAggregate(char c) |
protected void |
continueAggregate(char[] chars) |
protected void |
continueAggregate(String text) |
protected void |
continueAggregate(antlr.Token token) |
protected T |
fetchToken(int type,
int start,
int end,
int line,
int column,
CharSequence text)
Builds a token, or reuses a token, based on the underlying token pool
|
protected abstract void |
fillBuffer(StringBuilder builder) |
protected abstract int |
getColumn()
Gets the current column number of the tokenizer.
|
protected String |
getContext(int line)
Get the current context as a string (to help with debugging)
|
protected ISourceLocation |
getCurrentSourceLocation(int tokenLength)
Create a
ISourceLocation object based on the current lexer state. |
String |
getLastTokenText() |
int |
getLastTokenType() |
protected abstract int |
getLine()
Gets the current line number of the tokenizer.
|
protected abstract int |
getOffset()
Gets the current offset of the tokenizer into the file buffer.
|
List<ICompilerProblem> |
getProblems() |
String |
getSourcePath()
Gets the source path for the file being tokenized.
|
protected boolean |
hasAggregateContents() |
boolean |
hasProblems() |
protected abstract T[] |
initTokenPool() |
protected abstract T |
newToken(int type,
int start,
int end,
int line,
int column,
CharSequence text) |
void |
reset() |
protected void |
setLastToken(T token) |
void |
setReuseLastToken()
signals that we should reuse the last token in the token pool without
filling our buffer
|
void |
setSourcePath(String sourcePath)
Sets the source path for the file being tokenized.
|
protected void |
startAggregate()
Initialize a new aggregate with the current yytext() and position
|
protected void |
startAggregate(antlr.Token token) |
protected abstract String |
yytext()
Gets the text of the current token.
|
protected int aggregateStart
protected int aggregateStartLine
protected int aggregateStartColumn
protected StringBuilder aggregateContents
protected abstract T[] initTokenPool()
protected abstract String yytext()
public String getSourcePath()
public void setSourcePath(String sourcePath)
protected abstract int getOffset()
protected abstract int getLine()
protected abstract int getColumn()
protected void addBadCharacterProblem(String badChar)
protected final ISourceLocation getCurrentSourceLocation(int tokenLength)
ISourceLocation
object based on the current lexer state.tokenLength
- Length of the problematic input.public boolean hasProblems()
public List<ICompilerProblem> getProblems()
protected T buildToken(int type, int start, int end, int line, int column, CharSequence text)
public void reset()
public final int getLastTokenType()
public final String getLastTokenText()
protected void setLastToken(T token)
protected final void startAggregate()
protected final void startAggregate(antlr.Token token)
protected void continueAggregate()
protected final void continueAggregate(antlr.Token token)
protected final void continueAggregate(String text)
protected final void continueAggregate(char c)
protected final void continueAggregate(char[] chars)
protected abstract void fillBuffer(StringBuilder builder)
protected final boolean hasAggregateContents()
public final void setReuseLastToken()
protected final T fetchToken(int type, int start, int end, int line, int column, CharSequence text)
type
- the type of token to buildstart
- the token startend
- the token endline
- the token linecolumn
- the token columntext
- the token textprotected abstract T newToken(int type, int start, int end, int line, int column, CharSequence text)
public T buildAggregateToken(int type)
type
- token type (based on the appropriate XxxTokenTypes interface)public final T buildToken(int type)
type
- token type (based on the appropriate XxxTokenTypes interface)public T buildToken(int type, String text)
type
- token type (based on the appropriate XxxTokenTypes interface)protected String getContext(int line)
line
- current line numberCopyright © 2016 The Apache Software Foundation. All rights reserved.