Canopy is a parser compiler for parsing expression grammars (PEG) targeting JavaScript, Java, Python, and Ruby. Version 0.4.1 is the latest stable release; the project appears to be in maintenance mode with no recent activity. It generates standalone parsers with no runtime dependencies, making it lightweight. Unlike PEG.js or Nearley, Canopy offers multi-language code generation from a single grammar file.
npm install canopyNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a simple PEG grammar, compile it with Canopy CLI, and use the generated parser in JavaScript.
Ensure your code is compatible with strict mode. Avoid using reserved words as node labels.
Regenerate parsers after upgrading Canopy to avoid silent failures.
Rewrite left-recursive rules using iteration or right recursion. Canopy does not support left recursion.
Use version 0.4 or later, or manually convert to ESM.
Run canopy grammar.peg --lang javascript --output parser.js to generate the parser.
Check grammar for non-ASCII characters or misplaced operators. Refer to PEG specification.
Use a bundler like Webpack or include a shim for process.env if needed. Alternatively, avoid using environment variable features.
No dependency data recorded yet.