Get the current token list (readonly).
Useful for passing to ParserBuilder.build as the tokenVocabulary argument.
Append tokens to the end of the builder's token list. TypeScript errors if a token name already exists.
One or more tokens to add.
Insert tokens after a specified reference token in the ordering.
The existing token to insert after.
One or more tokens to insert.
Insert tokens before a specified reference token in the ordering.
The existing token to insert before.
One or more tokens to insert.
Construct a Chevrotain Lexer from the current token ordering.
OptionallexerConfig: ILexerConfigOptional Chevrotain lexer configuration overrides.
Remove tokens from the builder by reference.
One or more tokens to remove. Throws if a token is not found.
Merge tokens from another LexerBuilder into this one. Duplicate tokens (by reference) are skipped. Different tokens with the same name cause an error unless an override is provided.
The other builder whose tokens to merge.
Tokens that take precedence when names conflict.
Move existing tokens so they appear after a specified reference token. The tokens must already exist in the builder.
The reference token to move after.
The tokens to reposition.
Move existing tokens so they appear before a specified reference token. The tokens must already exist in the builder.
The reference token to move before.
The tokens to reposition.
StaticcreateCreate a new LexerBuilder, optionally copying from an existing one.
Optionalstarter: UAn existing builder to copy tokens from. If omitted, starts empty.
Builder for constructing Chevrotain lexers with type-safe token management. Token ordering matters — the lexer matches the first token that fits, so more specific tokens (e.g., keywords) must be positioned before more general ones (e.g., identifiers).
Builders mutate internal state and return
this. Always start by copying an existing builder withLexerBuilder.create(existingBuilder).