Class Tokenizer
- java.lang.Object
-
- com.inductiveautomation.snap.parse.Tokenizer
-
- Direct Known Subclasses:
JavaTokenizer
public class Tokenizer extends java.lang.ObjectA class to extract tokens from a char sequence.
-
-
Field Summary
Fields Modifier and Type Field Description protected int_charIndexprotected int_lineIndexprotected int_lineStart
-
Constructor Summary
Constructors Constructor Description Tokenizer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPattern(java.lang.String aName, java.lang.String aPattern, boolean isLiteral)Adds a pattern.voidaddPatterns(ParseRule aRule)Adds patterns to this tokenizer for given rule.charcharAt(int anIndex)CharSequence method.protected TokencreateToken(java.lang.String aName, java.lang.String aPattern, int aStart, int anEnd, Token aSpclTkn)Creates a new token.chargetChar()Returns the current parse char.intgetCharIndex()Returns the current parse char location.intgetColumnIndex()Returns the current column index in the current line.intgetColumnNumber()Returns the current column number.java.lang.CharSequencegetInput()Returns the current tokenizer input.java.lang.CharSequencegetInput(int aStart, int anEnd)Returns the input subsequence for the given range of characters in input.intgetLineIndex()Returns the current line index.intgetLineNumber()Returns the current line number.intgetLineStart()Returns the current line start index.Regex[]getMatchers(char aChar)Returns list of matchers for a char.TokengetNextSpecialToken()Processes and returns next special token.TokengetNextToken()Returns the next token.protected Regex[]getRegexes()Returns the array of regexes (creating it if missing).protected voidgoobleWhiteSpace()Gobble input characters until next non-whitespace or input end.intlength()CharSequence method.voidsetInput(java.lang.CharSequence anInput)Sets the current tokenizer input.
-
-
-
Method Detail
-
getInput
public java.lang.CharSequence getInput()
Returns the current tokenizer input.
-
setInput
public void setInput(java.lang.CharSequence anInput)
Sets the current tokenizer input.
-
getInput
public java.lang.CharSequence getInput(int aStart, int anEnd)Returns the input subsequence for the given range of characters in input.
-
addPattern
public void addPattern(java.lang.String aName, java.lang.String aPattern, boolean isLiteral)Adds a pattern.
-
addPatterns
public void addPatterns(ParseRule aRule)
Adds patterns to this tokenizer for given rule.
-
getRegexes
protected Regex[] getRegexes()
Returns the array of regexes (creating it if missing).
-
charAt
public char charAt(int anIndex)
CharSequence method.
-
length
public int length()
CharSequence method.
-
getChar
public char getChar()
Returns the current parse char.
-
getCharIndex
public int getCharIndex()
Returns the current parse char location.
-
getLineIndex
public int getLineIndex()
Returns the current line index.
-
getLineStart
public int getLineStart()
Returns the current line start index.
-
getColumnIndex
public int getColumnIndex()
Returns the current column index in the current line.
-
getLineNumber
public int getLineNumber()
Returns the current line number.
-
getColumnNumber
public int getColumnNumber()
Returns the current column number.
-
getNextToken
public Token getNextToken()
Returns the next token.
-
getMatchers
public Regex[] getMatchers(char aChar)
Returns list of matchers for a char.
-
createToken
protected Token createToken(java.lang.String aName, java.lang.String aPattern, int aStart, int anEnd, Token aSpclTkn)
Creates a new token.
-
getNextSpecialToken
public Token getNextSpecialToken()
Processes and returns next special token.
-
goobleWhiteSpace
protected void goobleWhiteSpace()
Gobble input characters until next non-whitespace or input end.
-
-