Package snap.parse
Class Tokenizer
java.lang.Object
snap.parse.Tokenizer
- Direct Known Subclasses:
XMLParser.XMLTokenizer
A class to extract tokens from a char sequence.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal char
charAt
(int anIndex) CharSequence method.createTokenForProps
(String aName, String aPattern, int aStart, int anEnd) Creates a new token for given properties.final char
eatChar()
Returns the char at the current index plus offset.void
eatChars
(int charCount) Advances charIndex by given char count.void
Eats the chars till line end.void
Turns on Java style comments.void
Turns on special tokens.final int
Returns the current parse char location.getInput()
Returns the current tokenizer input.Returns the last token.Returns the next token.protected ParseToken
Returns the next token.Regex[]
Returns the array of regexes.Returns the current token doc.Returns the current token line.final boolean
hasChar()
Returns whether another char is available.final boolean
hasChars
(int aVal) Returns whether another given number of chars is available.final int
length()
CharSequence method.final char
nextChar()
Returns the next parse char.final char
nextCharAt
(int anOffset) Returns the char at the current index plus offset.boolean
nextCharEquals
(char aChar) Returns whether next char is equal to given char.boolean
nextCharsStartWith
(CharSequence startChars) Returns whether next chars start with given string.void
setCharIndex
(int aValue) Sets the current parse char location.void
setInput
(CharSequence anInput) Sets the current tokenizer input.void
setLastToken
(ParseToken aToken) Sets the last token.void
setRegexes
(Regex[] theRegexes) Sets the array of regexes.void
setRegexesForGrammar
(Grammar aGrammar) Sets the regexes for given grammar.protected ParseToken
tokenizerFailed
(String nextChars) Called when next chars don't conform to any known token pattern.
-
Field Details
-
_charIndex
protected int _charIndex -
_tokenLine
-
SKIP
- See Also:
-
SINGLE_LINE_COMMENT
- See Also:
-
MULTI_LINE_COMMENT
- See Also:
-
TEXT_BLOCK
- See Also:
-
TEXT_BLOCK_MORE
- See Also:
-
TEXT_BLOCK_PATTERN
- See Also:
-
-
Constructor Details
-
Tokenizer
public Tokenizer()Constructor.
-
-
Method Details
-
getRegexes
Returns the array of regexes. -
setRegexes
Sets the array of regexes. -
setRegexesForGrammar
Sets the regexes for given grammar. -
getInput
Returns the current tokenizer input. -
setInput
Sets the current tokenizer input. -
length
public final int length()CharSequence method. -
charAt
public final char charAt(int anIndex) CharSequence method. -
hasChar
public final boolean hasChar()Returns whether another char is available. -
hasChars
public final boolean hasChars(int aVal) Returns whether another given number of chars is available. -
nextChar
public final char nextChar()Returns the next parse char. -
nextCharAt
public final char nextCharAt(int anOffset) Returns the char at the current index plus offset. -
nextCharEquals
public boolean nextCharEquals(char aChar) Returns whether next char is equal to given char. -
nextCharsStartWith
Returns whether next chars start with given string. -
eatChar
public final char eatChar()Returns the char at the current index plus offset. -
eatChars
public void eatChars(int charCount) Advances charIndex by given char count. -
eatCharsTillLineEnd
public void eatCharsTillLineEnd()Eats the chars till line end. -
getCharIndex
public final int getCharIndex()Returns the current parse char location. -
setCharIndex
public void setCharIndex(int aValue) Sets the current parse char location. -
getLastToken
Returns the last token. -
setLastToken
Sets the last token. -
getNextToken
Returns the next token. -
getNextTokenImpl
Returns the next token. -
getTokenLine
Returns the current token line. -
getTokenDoc
Returns the current token doc. -
createTokenForProps
Creates a new token for given properties. -
tokenizerFailed
Called when next chars don't conform to any known token pattern. Default implementation just throws ParseExcpetion. -
enableCodeComments
public void enableCodeComments()Turns on Java style comments. -
enableSpecialTokens
public void enableSpecialTokens()Turns on special tokens.
-