apg-lite is a lightweight JavaScript parser for ABNF (Augmented Backus-Naur Form) grammars, supporting a simplified subset of SABNF operators. It functions strictly as a parser, requiring grammar objects to be pre-generated using `apg-js` (version 4.3.0 or higher) with its `--lite` option. Currently at version 1.0.5, it parses only JavaScript strings, a key distinction from `apg-js` which handles arbitrary arrays of positive integers. The library retains only User-Defined Terminals (UDT), positive look-ahead (AND), and negative look-ahead (NOT) operators from the SABNF superset. It offers simplified AST manipulation, parse tree tracing for debugging, and statistics collection for profiling, all encapsulated within a single ECMAScript Module (ESM) compatible JavaScript file. The package is actively maintained, with a release cadence driven by bug fixes and minor enhancements, as demonstrated by recent updates to its robust, dependency-free URI parser.
npm install apg-liteVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use the self-contained UriParser to parse various URI strings, logging success or failure with the resulting AST.
Use `apg-js` (version 4.3.0 or higher) with its `--lite` option to generate the grammar object files, then import those generated objects into your `apg-lite` application.
Ensure all input for `apg-lite` parsers is a JavaScript string. If you require parsing integer arrays, consider using the full `apg-js` library instead.
Simplify your ABNF/SABNF grammars to rely solely on the supported UDT, AND, and NOT operators for use with `apg-lite`. For full SABNF feature support, use `apg-js`.
Update to `apg-lite` version 1.0.5 or higher to ensure correct and RFC-compliant URI parsing behavior, especially if using the `UriParser`.
For Node.js, ensure your project or file is configured for ESM (e.g., `"type": "module"` in `package.json` or using `.mjs` file extensions) and use `import` statements. For browsers, use `<script src="..."></script>` for `web-parser.js`.
Either change your Node.js project to use ESM by adding `"type": "module"` to `package.json`, or rename the file to have a `.mjs` extension. Alternatively, if bundling for a browser, ensure your bundler supports ESM.
Verify the correct ESM import path (e.g., `import { Parser } from 'apg-lite/lib/parser'`) and ensure your environment supports ESM. If `Parser` is a factory function, use `Parser()` instead of `new Parser()`.No dependency data recorded yet.