Package redempt.redlex.data
Class TokenType
java.lang.Object
redempt.redlex.data.TokenType
- Direct Known Subclasses:
CharGroupToken,CharSetToken,ChoiceToken,EndOfFileToken,ListToken,NotToken,PlaceholderToken,RepeatingToken,StringChoiceToken,StringToken
Represents a type of token which can be used to create a Lexer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleancharacterMatches(String input, int pos, int offset) findForward(String str, int pos, LexContext ctx) getLexer()getName()abstract booleanlengthMatches(int length) abstract intabstract 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()void
-
Constructor Details
-
TokenType
Create a new TokenType with the given name- Parameters:
name- The name for this TokenType
-
-
Method Details
-
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
-
findForward
-
getMessage
-
replacePlaceholders
-
walk
-
characterMatches
-
lengthMatches
public abstract boolean lengthMatches(int length) -
minLength
public abstract int minLength() -
maxLength
public abstract int maxLength() -
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
-