|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.percederberg.grammatica.parser.Tokenizer
public class Tokenizer
A character stream tokenizer. This class groups the characters read from the stream together into tokens ("words"). The grouping is controlled by token patterns that contain either a fixed string to search for, or a regular expression. If the stream of characters don't match any of the token patterns, a parse exception is thrown.
| Field Summary | |
|---|---|
protected boolean |
ignoreCase
The ignore character case flag. |
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected boolean ignoreCase
| Constructor Detail |
|---|
public Tokenizer(java.io.Reader input)
input - the input stream to read
public Tokenizer(java.io.Reader input,
boolean ignoreCase)
input - the input stream to readignoreCase - the character case ignore flag| Method Detail |
|---|
public 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 id
public int getCurrentLine()
public int getCurrentColumn()
public void addPattern(TokenPattern pattern)
throws ParserCreationException
pattern - the pattern to add
ParserCreationException - 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 correctly
protected 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 character
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||