Package redempt.redlex.data
Class TokenType
java.lang.Object
redempt.redlex.data.TokenType
- Direct Known Subclasses:
CharGroupToken,CharSetToken,ChoiceToken,DebugToken,EndOfFileToken,ListToken,NotToken,PlaceholderToken,RepeatingToken,StringChoiceToken,StringToken,WrapperToken
Represents a type of token which can be used to create a Lexer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TokenfindForward(String str, int pos, LexContext ctx) intgetId()getLexer()getName()abstract intbooleannameMatches(String name) Check whether the name of this TokenType matches the given namevoidreplacePlaceholders(Map<String, TokenType> tokens) voidSets the Lexer this TokenType and its children belong tovoidSets the name of this TokenTypetoString()tryTokenize(String str, int pos, LexContext ctx) void
-
Constructor Details
-
TokenType
Create a new TokenType with the given name- Parameters:
name- The name for this TokenType
-
-
Method Details
-
getId
public int getId()- Returns:
- The numeric ID of this TokenType
-
setLexer
Sets the Lexer this TokenType and its children belong to- Parameters:
lexer- The Lexer
-
getLexer
- Returns:
- The Lexer this TokenType belongs to
-
nameMatches
Check whether the name of this TokenType matches the given name- Parameters:
name- The name to compare- Returns:
- Whether this TokenType's name matches the given name
-
getName
- Returns:
- The name of this TokenType
-
setName
Sets the name of this TokenType- Parameters:
name- The name to set
-
tryTokenize
-
getMessage
-
replacePlaceholders
-
walk
-
findForward
-
minLength
public abstract int minLength() -
calcFirstCharacters
-
getFirstCharacters
- Returns:
- A list of all the characters which may appear as the first character of this token. Includes null if this token may be zero-length.
-
toString
-