Class AbstractTokenizer
java.lang.Object
org.infosmid.stream.dsl.AbstractTokenizer
- Direct Known Subclasses:
Tokenizer
The base class for tokenizers. Knows about tokenization in general but not specific to
a DSL variant. Provides state management and utility methods to real tokenizer
subclasses.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe string to be tokenized.protected int[]Positions of linebreaks in the parsed string.protected intLength of input data.protected intCurrent lexing position in the input data.Output stream of tokens.protected char[]The expressionString as a char array. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected booleanisAlphabetic(char ch) protected booleanisArgValueIdentifierTerminator(char ch, boolean quoteOpen) For the variant tokenizer (used following an '=' to parse an argument value) we only terminate that identifier if encountering a small set of characters.protected booleanisDigit(char ch) protected booleanisIdentifier(char ch) protected booleanisQuote(char ch) protected booleanisTwoCharToken(TokenKind kind) Check if this might be a two character token.protected booleanisWhitespace(char ch) protected voidTo prevent the need to quote all argument values, this identifier lexing function is used just after an '=' when we are about to digest an arg value.protected voidLex a string literal which uses double quotes as delimiters.protected voidprotected voidLex a string literal which uses single quotes as delimiters.protected voidpushCharToken(TokenKind kind) Push a token of just one character in length.protected voidpushPairToken(TokenKind kind) Push a token of two characters in length.voidraiseException(DSLMessage message, Object... inserts) protected booleansameQuotes(int pos1, int pos2) protected char[]subArray(int start, int end) toString()
-
Field Details
-
expressionString
The string to be tokenized. -
toProcess
protected char[] toProcessThe expressionString as a char array. -
max
protected int maxLength of input data. -
pos
protected int posCurrent lexing position in the input data. -
tokens
-
linebreaks
protected int[] linebreaksPositions of linebreaks in the parsed string.
-
-
Constructor Details
-
AbstractTokenizer
public AbstractTokenizer()
-
-
Method Details
-
getTokens
-
isTwoCharToken
-
pushCharToken
-
pushPairToken
-
isIdentifier
protected boolean isIdentifier(char ch) -
isQuote
protected boolean isQuote(char ch) -
isWhitespace
protected boolean isWhitespace(char ch) -
isDigit
protected boolean isDigit(char ch) -
isAlphabetic
protected boolean isAlphabetic(char ch) -
subArray
protected char[] subArray(int start, int end) -
lexIdentifier
protected void lexIdentifier() -
lexQuotedStringLiteral
protected void lexQuotedStringLiteral()Lex a string literal which uses single quotes as delimiters. To include a single quote within the literal, use a pair ''. -
lexDoubleQuotedStringLiteral
protected void lexDoubleQuotedStringLiteral()Lex a string literal which uses double quotes as delimiters. To include a single quote within the literal, use a pair "". -
isArgValueIdentifierTerminator
protected boolean isArgValueIdentifierTerminator(char ch, boolean quoteOpen) For the variant tokenizer (used following an '=' to parse an argument value) we only terminate that identifier if encountering a small set of characters. If the argument has included a ' to put something in quotes, we remember that and don't allow ' ' (space) and '\t' (tab) to terminate the value.- Parameters:
ch- char to be evaluatedquoteOpen- true if parsing an open quote- Returns:
- true if char is a type of terminator and quote is not open.
-
lexArgValueIdentifier
protected void lexArgValueIdentifier()To prevent the need to quote all argument values, this identifier lexing function is used just after an '=' when we are about to digest an arg value. It is much more relaxed about what it will include in the identifier. -
sameQuotes
protected boolean sameQuotes(int pos1, int pos2) -
toString
-
raiseException
-
addLinebreak
protected void addLinebreak()
-