Package io.karatelabs.parser
Class BaseLexer
java.lang.Object
io.karatelabs.parser.BaseLexer
- Direct Known Subclasses:
JsLexer
Abstract base class for lexers. Provides common utilities for character
handling, position tracking, and tokenization.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected charadvance()protected booleanisAtEnd()protected static booleanisDigit(char c) protected static booleanisHexDigit(char c) protected static booleanisIdentifierPart(char c) protected static booleanisIdentifierStart(char c) protected booleanmatch(char expected) abstract Tokenprotected charpeek()protected charpeek(int offset) protected abstract TokenTypeTokenizes the source into a list of tokens.
-
Field Details
-
resource
-
buffer
-
source
-
length
protected final int length -
pos
protected int pos -
line
protected int line -
col
protected int col -
tokenStart
protected int tokenStart -
tokenLine
protected int tokenLine -
tokenCol
protected int tokenCol
-
-
Constructor Details
-
BaseLexer
-
-
Method Details
-
nextToken
-
scanToken
-
tokenize
Tokenizes the source into a list of tokens. Tokens are stored in the lexer's buffer with prev/next navigation. Comments are collected for primary tokens. -
isAtEnd
protected boolean isAtEnd() -
peek
protected char peek() -
peek
protected char peek(int offset) -
advance
protected char advance() -
match
protected boolean match(char expected) -
isDigit
protected static boolean isDigit(char c) -
isHexDigit
protected static boolean isHexDigit(char c) -
isIdentifierStart
protected static boolean isIdentifierStart(char c) -
isIdentifierPart
protected static boolean isIdentifierPart(char c)
-