public class Tokenizer
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
ignoreCase
The ignore character case flag.
|
Constructor and Description |
---|
Tokenizer(java.io.Reader input)
Creates a new case-sensitive tokenizer for the specified input
stream.
|
Tokenizer(java.io.Reader input,
boolean ignoreCase)
Creates a new tokenizer for the specified input stream.
|
Modifier and Type | Method and Description |
---|---|
void |
addPattern(TokenPattern pattern)
Adds a new token pattern to the tokenizer.
|
int |
getCurrentColumn()
Returns the current column number.
|
int |
getCurrentLine()
Returns the current line number.
|
java.lang.String |
getPatternDescription(int id)
Returns a description of the token pattern with the specified
id.
|
boolean |
getUseTokenList()
Checks if the token list feature is used.
|
protected Token |
newToken(TokenPattern pattern,
java.lang.String image,
int line,
int column)
Factory method for creating a new token.
|
Token |
next()
Finds the next token on the stream.
|
void |
reset(java.io.Reader input)
Resets this tokenizer for usage with another input stream.
|
void |
setUseTokenList(boolean useTokenList)
Sets the token list feature flag.
|
java.lang.String |
toString()
Returns a string representation of this object.
|
public Tokenizer(java.io.Reader input)
input
- the input stream to readpublic Tokenizer(java.io.Reader input, boolean ignoreCase)
input
- the input stream to readignoreCase
- the character case ignore flagpublic boolean getUseTokenList()
setUseTokenList(boolean)
,
Token.getPreviousToken()
,
Token.getNextToken()
public void setUseTokenList(boolean useTokenList)
useTokenList
- the token list feature flaggetUseTokenList()
,
Token.getPreviousToken()
,
Token.getNextToken()
public java.lang.String getPatternDescription(int id)
id
- the token pattern idpublic int getCurrentLine()
public int getCurrentColumn()
public void addPattern(TokenPattern pattern) throws ParserCreationException
pattern
- the pattern to addParserCreationException
- if the pattern couldn't be
added to the tokenizerpublic void reset(java.io.Reader input)
input
- the new input stream to readParser.reset(Reader)
public Token next() throws ParseException
ParseException
- if the input stream couldn't be read or
parsed correctlyprotected Token newToken(TokenPattern pattern, java.lang.String image, int line, int column)
pattern
- the token patternimage
- the token image (i.e. characters)line
- the line number of the first charactercolumn
- the column number of the first characterpublic java.lang.String toString()
toString
in class java.lang.Object