Modifier and Type | Field and Description |
---|---|
static Token |
SKIP_TOKEN
Deprecated.
Use
TokenFactory.isSkipToken(Token) instead. |
Modifier and Type | Method and Description |
---|---|
Token<T> |
createCustomTextToken(T id,
CharSequence text,
int length,
PartType partType)
Deprecated.
This method is deprecated without replacement - see description
how a similar effect can be obtained.
|
Token<T> |
createPropertyToken(T id,
int length,
TokenPropertyProvider<T> propertyProvider)
Create complete token with properties.
|
Token<T> |
createPropertyToken(T id,
int length,
TokenPropertyProvider<T> propertyProvider,
PartType partType)
Create token with properties.
|
Token<T> |
createToken(T id)
Create token with token length corresponding
to the number of characters read from the lexer input.
|
Token<T> |
createToken(T id,
int length)
Create regular token instance with an explicit length.
|
Token<T> |
createToken(T id,
int length,
PartType partType)
Create regular token instance with an explicit length and part type.
|
Token<T> |
getFlyweightToken(T id,
String text)
Get flyweight token for the given arguments.
|
boolean |
isSkipToken(Token<T> token)
Check whether a token (produced by one of the token creation methods)
is a special flyweight token used in cases
when there is an active filtering of certain token ids (e.g.
|
@Deprecated public static final Token SKIP_TOKEN
TokenFactory.isSkipToken(Token)
instead.TokenFactory.isSkipToken(Token)
is a better typed alternative
to this field.public Token<T> createToken(T id)
TokenFactory.createToken(TokenId, int)
public Token<T> createToken(T id, int length)
id
- non-null token id recognized by the lexer.length
- >=0 length of the token to be created. The length must not
exceed the number of characters read from the lexer input.TokenFactory.SKIP_TOKEN
will be returned
if tokens for the given token id should be skipped
because of token id filter.public Token<T> createToken(T id, int length, PartType partType)
id
- non-null token id recognized by the lexer.length
- >=0 length of the token to be created. The length must not
exceed the number of characters read from the lexer input.partType
- whether this token is complete token or a part of a complete token.TokenFactory.SKIP_TOKEN
will be returned
if tokens for the given token id should be skipped
because of token id filter.public Token<T> getFlyweightToken(T id, String text)
id
- non-null token id.text
- non-null text that the flyweight token should carry.TokenFactory.SKIP_TOKEN
will be returned
if tokens for the given token id should be skipped
because of token id filter.public Token<T> createPropertyToken(T id, int length, TokenPropertyProvider<T> propertyProvider)
id
- non-null token id.length
- >=0 length of the token to be created. The length must not
exceed the number of characters read from the lexer input.propertyProvider
- token property provider or null if there are no extra properties.
See TokenPropertyProvider
for examples how this parameter may be used.TokenFactory.SKIP_TOKEN
will be returned
if tokens for the given token id should be skipped
because of token id filter.public Token<T> createPropertyToken(T id, int length, TokenPropertyProvider<T> propertyProvider, PartType partType)
id
- non-null token id.length
- >=0 length of the token to be created. The length must not
exceed the number of characters read from the lexer input.propertyProvider
- token property provider or null if there are no extra properties.
See TokenPropertyProvider
for examples how this parameter may be used.partType
- whether this token is complete or just a part of complete token.
Null may be passed which implies PartType.COMPLETE
.TokenFactory.SKIP_TOKEN
will be returned
if tokens for the given token id should be skipped
because of token id filter.@Deprecated public Token<T> createCustomTextToken(T id, CharSequence text, int length, PartType partType)
StripFirstAndLastCharTokenPropertyProvider implements TokenPropertyProvider { public TokenPropertyProvider INSTANCE = new StripFirstAndLastCharTokenPropertyProvider(); public Object getValue(Token token, Object key) { if (key == CharSequence.class) { return token.text().subSequence(1, token.length() - 1); } return null; } }
id
- non-null token id of the token being created.text
- non-null custom text assigned to the token.length
- recognized characters corresponding to the token being created.partType
- should always be null otherwise this method would throw
an exception.public boolean isSkipToken(Token<T> token)
token
- non-null token.