Class Lexer
java.lang.Object
org.episteme.natural.computing.compiler.Lexer
A simple lexer (tokenizer) for DSL processing.
Converts input text into a stream of tokens based on configurable patterns.
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classException thrown when lexer encounters invalid input.static classRepresents a single token.static classRepresents a token type with its pattern. -
Constructor Summary
ConstructorsConstructorDescriptionLexer()Creates a lexer with default token types.Lexer(List<Lexer.TokenType> tokenTypes) Creates a lexer with custom token types. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTokenType(Lexer.TokenType type) Adds a custom token type (higher priority than defaults).Tokenizes the input string.
-
Constructor Details
-
Lexer
public Lexer()Creates a lexer with default token types. -
Lexer
Creates a lexer with custom token types.
-
-
Method Details
-
addTokenType
Adds a custom token type (higher priority than defaults). -
tokenize
Tokenizes the input string.- Parameters:
input- Source code to tokenize- Returns:
- List of tokens
- Throws:
Lexer.LexerException- if unrecognized characters are found
-