The `oniguruma-parser` library provides a robust TypeScript solution for working with Oniguruma regular expressions, offering functionalities such as parsing, validation, AST traversal, transformation, and optimization. The current stable version is 0.12.2, with minor releases frequently introducing new features like optimizer improvements (v0.12.1), support for new flags (v0.12.0), and quality-of-life enhancements for AST manipulation (v0.10.0). Its primary distinction lies in its deep understanding and accurate representation of the Oniguruma regex engine's specific syntax and semantics, which differs from standard ECMAScript regexes. It is widely utilized and battle-tested in critical projects like `Oniguruma-To-ES` and `tm-grammars`, which process tens of thousands of real-world Oniguruma regexes for tools such as VS Code and Shiki, ensuring high fidelity and reliability for TextMate grammars, Ruby, and PHP environments.
npm install oniguruma-parserVerified import paths — ran on the pinned version, not inferred.
Parses an Oniguruma regular expression pattern into its Abstract Syntax Tree (AST) representation, demonstrating basic usage with flags and compile-time rules.
Refactor AST traversal and manipulation logic to use the `body` property for node content and adjust for the removal of the `Pattern` node. Review the updated AST structure by logging parsed regexes.
Update any code accessing `CapturingGroup` properties to use `isSubroutined` instead of `hasSubroutine`.
Consult the updated AST types for `kind` property values and adjust any code that relies on specific `kind` values for pattern matching or conditional logic.
Review all calls to `createQuantifier` and ensure arguments are in the correct order (`kind` before `element`), `kind` is explicitly provided, and `min`/`max` values are set accurately without relying on implicit possessive conversion.
Adjust `Traverser` visitor logic, especially if relying on the order of `exit` calls for `'*'` and specific node types. Ensure that general cleanup or finalization logic in `'*'` `exit` accounts for this change.
Prefer using ESM imports if possible, or closely monitor the `oniguruma-parser-cjs` project for updates and compatibility with the official `oniguruma-parser` releases.
Update your AST traversal and manipulation code to use the `body` property for accessing child nodes or content, as well as accounting for the removal of the `Pattern` node type.
Replace all instances of `capturingGroup.hasSubroutine` with `capturingGroup.isSubroutined` in your code.
Review the `createQuantifier` function signature. Ensure that the `kind` argument (e.g., `'greedy'`, `'lazy'`, `'possessive'`) is explicitly provided as the second argument, followed by the `element` and then `min`/`max` values.
No dependency data recorded yet.