{"id":18789,"library":"simple-parser","title":"simple-parser","description":"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.","status":"active","version":"0.0.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install simple-parser","lang":"bash","label":"npm"},{"cmd":"yarn add simple-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add simple-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only; no CommonJS support.","wrong":"const Parser = require('simple-parser')","symbol":"Parser","correct":"import Parser from 'simple-parser'"},{"note":"Token is a named export, not default.","wrong":"import Token from 'simple-parser'","symbol":"Token","correct":"import { Token } from 'simple-parser'"},{"note":"TypeScript type export, not available at runtime.","symbol":"Rule","correct":"import { Rule } from 'simple-parser'"}],"quickstart":{"code":"import Parser from 'simple-parser';\n\nconst parser = new Parser();\nparser.define('DIGIT', /[0-9]/);\nparser.define('PLUS', /\\+/);\nparser.define('expr', ['DIGIT', 'PLUS', 'DIGIT']);\n\nconst result = parser.parse('3+5');\nconsole.log(result); // ['3', '+', '5']","lang":"typescript","description":"Creates a parser for simple arithmetic expressions using digit and plus rules, then parses a string."},"warnings":[{"fix":"Replace `parser.parseAll(input)` with `parser.parse(input)`.","message":"Method `parseAll` has been deprecated in favor of `parse`.","severity":"deprecated","affected_versions":"<=0.0.0"},{"fix":"Always use array syntax: `parser.define('ruleName', ['TOKEN1', 'TOKEN2'])`.","message":"Rules are defined with arrays, not strings; using strings silently fails.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use simple regex patterns without flags; pre-transform input if case-insensitivity needed.","message":"Parser does not support regex flags like 'g' or 'i' in token definitions.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use import Parser from 'simple-parser' (ESM).","cause":"Importing incorrectly (CommonJS usage).","error":"TypeError: Parser is not a constructor"},{"fix":"Remove Token from runtime imports; it's only for TypeScript types.","cause":"Attempting to use Token as a runtime value when it is a type-only export.","error":"ReferenceError: Token is not defined"},{"fix":"Change parser.define('rule', 'TOKEN') to parser.define('rule', ['TOKEN']).","cause":"Passing a string to define() instead of an array of token names.","error":"Error: Rule 'xxx' is not a string or array"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}