A lightweight, minimalistic parser for simple grammars, currently at version 0.0.0. It aims to provide a straightforward API for tokenizing and parsing input strings with user-defined rules. Unlike more complex parser generators (e.g., ANTLR, PEG.js), simple-parser focuses on simplicity and zero dependencies, making it suitable for small projects or educational use. The release cadence is not yet established as it is in early development. Key differentiators include a tiny footprint and an intuitive rule definition syntax.
npm install simple-parserVerified import paths — ran on the pinned version, not inferred.
Creates a parser for simple arithmetic expressions using digit and plus rules, then parses a string.
Replace `parser.parseAll(input)` with `parser.parse(input)`.
Always use array syntax: `parser.define('ruleName', ['TOKEN1', 'TOKEN2'])`.Use simple regex patterns without flags; pre-transform input if case-insensitivity needed.
Use import Parser from 'simple-parser' (ESM).
Remove Token from runtime imports; it's only for TypeScript types.
Change parser.define('rule', 'TOKEN') to parser.define('rule', ['TOKEN']).No dependency data recorded yet.