Chevrotain
Home
Features
Tutorial
Guide
FAQ
Changes
APIs
Playground
Benchmark
Discussions
GitHub
Home
Features
Tutorial
Guide
FAQ
Changes
APIs
Playground
Benchmark
Discussions
GitHub
  • Features

    • Blazing Fast
    • LL(K) Grammars
    • Separation of Grammar and Semantics
    • Easy Debugging
    • Fault Tolerance
    • Multiple Start Rules
    • Customizable Error Messages
    • Parameterized Rules
    • Gates
    • Syntactic Content Assist
    • Grammar Inheritance
    • Backtracking
    • Syntax Diagrams
    • RegExp Based Lexers
    • Position Tracking
    • Token Alternative Matches
    • Token Skipping
    • Token Categories
    • Token Grouping
    • Custom Token Patterns
    • Lexer Modes

Position Tracking

// TODO: we should document the location tracking for both Lexer and Parser in this section...

Chevrotain lexers will track the full token position information by default. This means: token_skipping

  • start and end offsets.
  • start and end lines.
  • start and end columns.

The level of position information tracking can be reduced by using the positionTracking lexer config option. For example:

import { Lexer } from "chevrotain";
const allTokens = [];
// createTokens...
const myLexer = new Lexer(allTokens, { positionTracking: "onlyOffset" });
Edit this page on GitHub
Last Updated: 1/24/26, 5:39 PM
Contributors: Shahar Soel, Soel, bd82, Clément Dessoude, i060847, I060847, Gaurav
Prev
RegExp Based Lexers
Next
Token Alternative Matches