|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.millscript.millscript.syntax.TokenizerImpl
public class TokenizerImpl
This class performs the basic tokenisation of the MillScript language. A single instance of this class would be used to tokenise one file/source.
| Field Summary | |
|---|---|
protected Configuration |
config
The current configuration. |
protected org.millscript.commons.util.map.EHashMap<java.lang.Integer,java.lang.CharSequence> |
interpolationMap
Used to store interpolation values, mapping the position in the interpolated string to the value to be interpolated. |
| Method Summary | |
|---|---|
boolean |
checkWhere(char ch)
Check if the tokenzier is using the specified strategy for reading names and strings. |
void |
dropToken()
Drops the current token, ready to read the next one. |
java.lang.String |
getAttributeName()
Returns the current token, checking it is a valid XML element attribute name. |
java.lang.String |
getErrorString()
Returns the current token for use as an error message. |
int |
getInt()
Returns the current token as an int. |
int |
getLineNumber()
Returns the line number of the current token. |
java.lang.String |
getName()
Returns the current token as a name, or interned string. |
java.lang.String |
getOrigin()
Returns the origin of this tokenizers character source. |
char |
getQuoteChar()
Returns the first character of the current token, which will be the quote character for a string token. |
java.lang.String |
getString()
Returns the current token as a string. |
java.lang.String |
getStringNoQuotes()
Returns the current token as a string, without the surrounding quotes. |
java.lang.String |
getStringNoQuotes(int a,
int b)
Returns the current token as a string, with the specified number of characters removed from the start and end. |
java.lang.String |
getTagName()
Returns the current token, checking it is a valid XML element name. |
java.util.regex.Pattern |
makePattern()
Returns a new tradition regular expression Pattern, made
from the contents of the current buffer. |
void |
markReader()
Marks the current position in the reader, so we can jump back to the marked position if required. |
void |
mustRead(java.lang.String sym)
Tests if the next token is the same as the specified string. |
TokenType |
nextToken()
Returns the type of the next token. |
boolean |
peekRead(java.lang.String sym)
Peeks a look at the next token and compares it to the specified value. |
TokenType |
peekToken()
Peeks a look at the type of the next token to be returned by nextToken. |
void |
resetReader()
Resets the reader to the previously marked position. |
void |
setContext(java.lang.String s,
int n)
|
void |
setLineNumber(int n)
|
void |
setOrigin(java.lang.String o)
|
void |
setWhere(char ch)
Sets the tokenizers current strategy for reading names and strings. |
boolean |
tryRead(java.lang.String sym)
Tests if the next token is the same as the specified string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Configuration config
protected org.millscript.commons.util.map.EHashMap<java.lang.Integer,java.lang.CharSequence> interpolationMap
| Method Detail |
|---|
public java.lang.String getOrigin()
Tokenizer
getOrigin in interface org.millscript.commons.alert.AlertOrigingetOrigin in interface TokenizerTokenizer.getOrigin()public int getLineNumber()
Tokenizer
getLineNumber in interface org.millscript.commons.alert.AlertOrigingetLineNumber in interface TokenizerTokenizer.getLineNumber()public void setWhere(char ch)
Tokenizer
setWhere in interface Tokenizerch - the new strategyTokenizer.setWhere(char)public boolean checkWhere(char ch)
Tokenizer
checkWhere in interface Tokenizerch - the test strategy
true if the test and current strategy are the same,
otherwise falseTokenizer.checkWhere(char)public java.util.regex.Pattern makePattern()
TokenizerPattern, made
from the contents of the current buffer. It looks for the last
/ in the string to see if there are any flags specified.
makePattern in interface TokenizerPattern for the current bufferTokenizer.makePattern()public TokenType nextToken()
Tokenizer
nextToken in interface TokenizerTokenType of the next tokenTokenizer.nextToken()public TokenType peekToken()
TokenizernextToken.
peekToken in interface TokenizerTokenType of the next token to be returned by a
call to Tokenizer.nextToken()Tokenizer.peekToken()public void dropToken()
Tokenizer
dropToken in interface TokenizerTokenizer.dropToken()public boolean tryRead(java.lang.String sym)
Tokenizer
tryRead in interface Tokenizersym - the token we want to try and read
true if the next token is the same as the one
specified, false otherwiseTokenizer.tryRead(java.lang.String)public void markReader()
Tokenizer
markReader in interface TokenizerTokenizer.markReader()public void resetReader()
Tokenizer
resetReader in interface TokenizerTokenizer.resetReader()public boolean peekRead(java.lang.String sym)
Tokenizer
peekRead in interface Tokenizersym - the token we want to try and read
true if the next token is the same as the one
specified, false otherwiseTokenizer.peekRead(java.lang.String)public void mustRead(java.lang.String sym)
Tokenizer
mustRead in interface Tokenizersym - the token we want to try and readTokenizer.mustRead(java.lang.String)public java.lang.String getString()
Tokenizer
getString in interface TokenizerTokenizer.getString()public java.lang.String getErrorString()
Tokenizer
getErrorString in interface TokenizerTokenizer.getErrorString()public java.lang.String getAttributeName()
Tokenizer
getAttributeName in interface TokenizerTokenizer.getAttributeName()public java.lang.String getTagName()
Tokenizer
getTagName in interface TokenizerTokenizer.getTagName()public java.lang.String getStringNoQuotes()
Tokenizer
getStringNoQuotes in interface TokenizerTokenizer.getStringNoQuotes()
public java.lang.String getStringNoQuotes(int a,
int b)
Tokenizer
getStringNoQuotes in interface Tokenizera - the number of character to remove from the start of the current
tokenb - the number of character to remove from the end of the current
token
Tokenizer.getStringNoQuotes(int, int)public char getQuoteChar()
Tokenizer
getQuoteChar in interface TokenizerTokenizer.getQuoteChar()public java.lang.String getName()
Tokenizer
getName in interface TokenizerTokenizer.getName()public int getInt()
Tokenizer
getInt in interface TokenizerTokenizer.getInt()
public void setContext(java.lang.String s,
int n)
setContext in interface org.millscript.commons.alert.AlertOriginAlertOrigin.setContext(java.lang.String, int)public void setLineNumber(int n)
setLineNumber in interface org.millscript.commons.alert.AlertOriginAlertOrigin.setLineNumber(int)public void setOrigin(java.lang.String o)
setOrigin in interface org.millscript.commons.alert.AlertOriginAlertOrigin.setOrigin(java.lang.String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||