Package org.openzen.zenscript.lexer
Class CompiledDFA<T>
java.lang.Object
org.openzen.zenscript.lexer.CompiledDFA<T>
- Type Parameters:
T- final type
Represents a compiled DFA. A compiled DFA has a compact representation and
is immediately usable for efficient processing.
A compiled DFA can be converted to a compact integer array. This array can then be hardcoded in an application.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCompiledDFA(Map<Integer, Integer>[] transitions, T[] finals) Constructs a compiled DFA from the specified transition graph and finals arrays. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends TokenType & Comparable<T>>
CompiledDFA<T> createLexerDFA(T[] tokenTypes, Class<T> tokenClass) Determines the token type for the given token.booleanChecks if this value evaluates to a valid token.toString()
-
Field Details
-
transitions
-
finals
-
-
Constructor Details
-
CompiledDFA
Constructs a compiled DFA from the specified transition graph and finals arrays.The transition array specifies all transitions for each state. The finals array specifies the final class index of each state, or NOFINAL if the state is not a final. There can multiple final classes, which can, for example, be used to distinguish token types.
- Parameters:
transitions- transitions graphfinals- finals
-
-
Method Details
-
createLexerDFA
public static <T extends TokenType & Comparable<T>> CompiledDFA<T> createLexerDFA(T[] tokenTypes, Class<T> tokenClass) -
eval
Determines the token type for the given token. Returns null if the given token is not a valid token.- Parameters:
value- token value- Returns:
- token type
-
matches
Checks if this value evaluates to a valid token.- Parameters:
value- value to check- Returns:
- true if matching, false otherwise
-
toString
-