Chevrotain Allstar is a specialized plugin for the Chevrotain parser library, designed to enhance its lookahead capabilities. It implements the ALL(*) lookahead algorithm, a technique initially introduced for ANTLR4. Unlike Chevrotain's default LL(*k*) behavior, which has a bounded lookahead, ALL(*) offers unbounded lookahead, allowing the parser to resolve ambiguities in more complex grammars by examining an arbitrary number of upcoming tokens. The current stable version is 0.4.1. This library is specifically tailored for users who require more powerful lookahead than Chevrotain's built-in strategies provide, typically when dealing with highly ambiguous or context-sensitive grammar rules. Its release cadence is generally tied to the development of the Langium project and Chevrotain itself, making updates less frequent than a core library.
npm install chevrotain-allstarVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `LLStarLookaheadStrategy` into a Chevrotain parser, showing a simple grammar with a choice that can utilize the unbounded lookahead. It defines tokens, a parser class, and then parses a sample input.
Profile your parser's performance with and without ALL(*) and consider if your grammar can be refactored to reduce ambiguity or if a bounded lookahead is sufficient. Only use ALL(*) for specific rules that genuinely require it.
Always check the `chevrotain-allstar` release notes and `peerDependencies` when upgrading your core Chevrotain library. Ensure both packages are compatible versions.
Thoroughly test your grammar and inputs after integrating ALL(*). Be aware of the theoretical underpinnings of ALL(*) and how it interacts with your grammar's specific ambiguities.
Install chevrotain: `npm install chevrotain` or `yarn add chevrotain`.
Ensure that `chevrotain-allstar` and `chevrotain` are compatible versions as specified in `chevrotain-allstar`'s peer dependencies. Update both packages if necessary.
Ensure your parser class extends `EmbeddedActionsParser` (or `CstParser`) from `chevrotain` and that `LLStarLookaheadStrategy` is correctly instantiated and passed in the constructor options, as shown in the quickstart.