Reghex is an experimental, actively developed JavaScript parser generator that leverages the power of sticky regular expressions and runtime code generation to allow developers to quickly define and build parsers. Currently at version 3.0.2, it enables parser creation using a regex-like Domain Specific Language (DSL) within tagged template literals. Reghex offers flexibility by supporting both build-time pre-compilation via an optional Babel plugin (or `babel-plugin-macros` integration) and Just-In-Time (JIT) compilation at runtime, which incurs minimal overhead. Its core differentiator is the use of JavaScript's sticky regexes (`/y` flag) as the fundamental parsing primitive, allowing for efficient, continuous pattern matching by internally managing `lastIndex`. While still in its early stages with a potentially evolving API and a slower, feature-driven release cadence marked by major versions, it provides a unique approach to parser construction in JavaScript. Performance on older browsers like IE11 may be reduced due to its sticky regex polyfill.
npm install reghexVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a simple parser using `match` with a tagged template literal and then use `parse` to apply it to an input string.
Review existing parser grammars, especially those using interpolation predicates or the `+` operator, and adapt them to the new DSL behavior outlined in the v3.0.0 release notes.
Re-evaluate build processes and any custom tooling that interacted with Reghex's internal code generation, as the underlying architecture has been completely overhauled.
Exercise caution when deploying `reghex` in production environments. Pin dependency versions tightly and thoroughly test after any updates. Monitor GitHub for announcements of API changes.
If targeting environments like IE11, benchmark parser performance and consider alternative parsing strategies or selective loading if performance is critical for those users.
Review the regex patterns within your `match` definition. Ensure all quantifiers are applied to a valid character, group, or expression. For example, `(a)?*` is invalid.
Ensure you are using `import { match, parse } from 'reghex';` for ESM. If using CommonJS, verify your transpilation setup or check if a default export exists (which it doesn't for the main API).Switch to ES Module import syntax: `import { match, parse } from 'reghex';`.