Registry / serialization / zeparser

zeparser

JSON →
library0.0.7jsnpmunverified

ZeParser is an early-stage JavaScript parser, last published as version 0.0.7 in June 2013. Developed by Peter van der Zee, it was designed to convert JavaScript input into a 'parse tree' (an array of arrays with tokens as leaves) or various token streams, including a 'white tree' (all tokens, including whitespace) and a 'black tree' (token stream without whitespace). The package also offered a `createParser` method to instantiate a parser with parsed input and access these tree structures directly. It featured simple and extended parsing modes, with the extended mode providing richer meta-information. While historically relevant for JavaScript parsing benchmarks, the project has been abandoned since its last release, meaning it does not support modern JavaScript syntax (ES2015+), lacks ongoing maintenance, and has no defined release cadence. An experimental v2 (`zeparser2`) was later introduced but also appears to be unmaintained.

npm install zeparser
INSTALL
IMPORT
SIG · ZEPARSER
Z
zeparser
serializationjavascriptv0.0.7
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ZeParser
const ZeParser = require('zeparser');
import { ZeParser } from 'zeparser';
This package is CommonJS-only, as it was published in 2013 (v0.0.7) before the widespread adoption of ES Modules in Node.js. Direct ESM imports are not supported.
parse
const ZeParser = require('zeparser'); const tree = ZeParser.parse('var a = 1;');
import { parse } from 'zeparser';
The primary parsing function `parse` is a static method on the `ZeParser` object. Attempting to destructure it as a named import will fail.
createParser
const ZeParser = require('zeparser'); const parserInstance = ZeParser.createParser('var a = 1;');
const { createParser } = require('zeparser');
`createParser` is also a static method of the main `ZeParser` object and should be accessed directly from the imported module. Destructuring requires specific CommonJS patterns not typically used for methods.

This quickstart demonstrates how to use `ZeParser.parse()` to get a basic parse tree and `ZeParser.createParser()` to access detailed token streams (including and excluding whitespace/comments). It highlights the CommonJS `require` syntax.

const ZeParser = require('zeparser'); const inputCode = ` function greet(name) { // A simple comment return 'Hello, ' + name + '!'; } var message = greet('World'); `; console.log('--- Parsing with ZeParser.parse() ---'); const parseTree = ZeParser.parse(inputCode); // The parse tree is an array of arrays representing the AST structure. // It includes tokens as leaf nodes. console.log('Parse Tree (excerpt):', JSON.stringify(parseTree, null, 2).substring(0, 500) + '...'); console.log('\n--- Using ZeParser.createParser() for detailed token streams ---'); const parserInstance = ZeParser.createParser(inputCode); // .wtree (white tree) includes all tokens, including whitespace and comments console.log('White Tree (first 5 tokens):', parserInstance.wtree.slice(0, 5)); // .btree (black tree) is the token stream without whitespace, line terminators, or comments console.log('Black Tree (first 5 tokens):', parserInstance.btree.slice(0, 5)); // Accessing a token's properties, e.g., the first token in the black tree if (parserInstance.btree.length > 0) { const firstToken = parserInstance.btree[0]; console.log('First token in black tree (type, value):', firstToken.type, firstToken.value); }
Debug
Known issues
breakingZeParser is an abandoned package, last published in 2013 (v0.0.7). It does not support modern JavaScript syntax (ES2015+), including `const`/`let`, arrow functions, classes, modules, or other contemporary language features. Attempting to parse modern JS will result in parsing errors or incorrect trees.
fix
Use a modern JavaScript parser like Acorn, Babel Parser (@babel/parser), or Esprima for any code written post-ES5.
affects: >=0.0.0
gotchaThe package is CommonJS-only and relies on `require()`. It does not provide ES Module exports (`import`). Using `import` statements directly will lead to module resolution errors in ESM-only environments.
fix
Always use `const ZeParser = require('zeparser');` for importing. If used in a modern ESM project, it might require a CommonJS wrapper or bundler configuration to work, but its primary limitation remains its inability to parse modern JS.
affects: >=0.0.0
gotchaThe documentation mentions 'simple' and 'extended' parsing modes, with the extended mode being default (`.ast` property true). The structure of the parse tree and token objects, particularly meta-information, might be less intuitive or well-documented compared to contemporary AST standards like ESTree.
fix
Thoroughly inspect the outputted `parseTree`, `.wtree`, and `.btree` structures for specific token properties and array nesting. Expect a custom AST format rather than a standardized one.
affects: >=0.0.0
Errors
Common errors & fixes
SyntaxError: Unexpected token 'const'
Attempting to parse JavaScript code containing `const`, `let`, arrow functions, classes, or other ES2015+ features.
fix
This parser is only compatible with ES5 (ECMAScript 5) and older syntax. It cannot parse modern JavaScript. Use a different, actively maintained parser.
TypeError: ZeParser.parse is not a function
Incorrectly importing the `ZeParser` module or attempting to call `parse` on a non-module object.
fix
Ensure you are using `const ZeParser = require('zeparser');` and then calling `ZeParser.parse(yourCode);`. This package is CommonJS, and its methods are accessed directly from the required module object.
ReferenceError: require is not defined (in browser environments)
Using `require('zeparser')` directly in a web browser without a CommonJS-compatible bundler.
fix
This package is intended for Node.js environments. For browser usage, you would need a tool like Webpack or Browserify to bundle it, but given its abandonment and lack of modern JS support, it's not recommended for new web projects.
Upgrade
Version history
0.0.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
34 hits · last 30 days
node
30
OpenAI (training)
1
Resources
zeparser — npm install zeparser · libregistry