public class BaseTokenScanner extends Object
Modifier and Type | Field and Description |
---|---|
protected char |
m_chCurrent
The current working char.
|
protected int |
m_coffset
Offset of the current character.
|
protected boolean |
m_fIsEnd
The flag set when end of file is detected.
|
protected int |
m_iPos
The current position in the underlying Reader.
|
protected int |
m_iStartPos
The saved start position for a token.
|
protected int |
m_lineNumber
The current line number.
|
protected Reader |
m_reader
The underlying Reader holding the characters being tokenized.
|
protected String |
m_sNests
The characters used to begin nesting.
|
protected String |
m_sPunctuation
The characters used for punctuation.
|
protected String |
m_sUnnests
The characters used to end nesting.
|
protected StringBuffer |
m_tokenBuffer
The temporary buffer used to build the String representing a token.
|
Constructor and Description |
---|
BaseTokenScanner(Reader reader)
Construct a new BaseTokenScanner with the given Reader.
|
BaseTokenScanner(String s)
Construct a new BaseTokenScanner with the given String.
|
Modifier and Type | Method and Description |
---|---|
protected void |
advance()
Advance to the next character.
|
protected RuntimeException |
floatingPointFormatError()
A problem has been detected in a floating point number.
|
protected char |
getCurrentChar()
Answer the current char of the underlying Reader
|
boolean |
isEnd()
Test whether the receiver has reached the end of the underlying Reader
|
protected boolean |
isNest(char ch)
Test if the given char is a character that starts nesting/
|
protected boolean |
isPunctuation(char ch)
Test if the given char is a punctuation character.
|
protected LiteralBaseToken |
literalFloat()
A floating point literal has been detected so create.
|
BaseToken |
next()
Answer the next token from the underlying reader.
|
protected char |
nextChar()
Advance to the next character and return it.
|
protected void |
notePos()
Note the offset within the underlying Reader
|
void |
reset()
Reset the receiver so that tokenizing may begin again.
|
protected void |
resetTokenString()
Reset the buffer used for holding the current token
|
BaseToken |
scan()
Tokenize the entire expression at once.
|
protected BaseToken |
scanIdentifier()
Attemt to tokenize an Identifier.
|
protected BaseToken |
scanLiteral()
Attemt to tokenize a literal.
|
protected BaseToken |
scanNest(char ch)
Tokenize the characters between the beginning nest chararcer
and the character that ends the nest.
|
protected boolean |
scanOperator()
Attemt to tokenize an Operator.
|
void |
setNesting(String sNests,
String sUnnests)
Set the Strings used as nesting characters.
|
void |
setPunctuation(String s)
Set the String used to determine punctuation characters.
|
void |
skipWhiteSpace()
Skip over any whitespace characters.
|
protected void |
takeCurrentChar()
Add the current character to buffer that builds the current token.
|
protected void |
takeCurrentCharAndAdvance()
Add the current character to buffer that builds the current token and
advance.
|
protected String |
tokenString()
Convert the buffered characters into a String representing a token.
|
protected int m_iPos
protected int m_iStartPos
protected String m_sPunctuation
protected String m_sNests
protected String m_sUnnests
protected StringBuffer m_tokenBuffer
protected char m_chCurrent
protected Reader m_reader
protected boolean m_fIsEnd
protected int m_coffset
protected int m_lineNumber
public BaseTokenScanner(String s)
s
- the string to be tokenizedpublic BaseTokenScanner(Reader reader)
reader
- the Reader that is the source of chars to be tokenizedpublic BaseToken scan()
public void reset()
public BaseToken next()
public void skipWhiteSpace()
public boolean isEnd()
public void setPunctuation(String s)
s
- the String of characters to use as punctuationpublic void setNesting(String sNests, String sUnnests)
sNests
- the chars that start nestingsUnnests
- the chars that end nestingprotected boolean isPunctuation(char ch)
ch
- the char to testprotected boolean isNest(char ch)
ch
- the char to testprotected BaseToken scanNest(char ch)
ch
- the character that begins nestingBaseTokenScannerException
- if we reach the end of stream
before the matching end of nest character is reachedprotected BaseToken scanLiteral()
protected LiteralBaseToken literalFloat()
protected BaseToken scanIdentifier()
protected RuntimeException floatingPointFormatError()
protected boolean scanOperator()
protected char getCurrentChar()
protected void advance()
protected char nextChar()
protected void notePos()
protected String tokenString()
protected void resetTokenString()
protected void takeCurrentChar()
protected void takeCurrentCharAndAdvance()