{"id":12703,"library":"zeparser","title":"ZeParser JavaScript Parser","description":"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.","status":"abandoned","version":"0.0.7","language":"javascript","source_language":"en","source_url":"git://github.com/qfox/ZeParser","tags":["javascript"],"install":[{"cmd":"npm install zeparser","lang":"bash","label":"npm"},{"cmd":"yarn add zeparser","lang":"bash","label":"yarn"},{"cmd":"pnpm add zeparser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import { ZeParser } from 'zeparser';","symbol":"ZeParser","correct":"const ZeParser = require('zeparser');"},{"note":"The primary parsing function `parse` is a static method on the `ZeParser` object. Attempting to destructure it as a named import will fail.","wrong":"import { parse } from 'zeparser';","symbol":"parse","correct":"const ZeParser = require('zeparser');\nconst tree = ZeParser.parse('var a = 1;');"},{"note":"`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.","wrong":"const { createParser } = require('zeparser');","symbol":"createParser","correct":"const ZeParser = require('zeparser');\nconst parserInstance = ZeParser.createParser('var a = 1;');"}],"quickstart":{"code":"const ZeParser = require('zeparser');\n\nconst inputCode = `\n  function greet(name) {\n    // A simple comment\n    return 'Hello, ' + name + '!';\n  }\n  var message = greet('World');\n`;\n\nconsole.log('--- Parsing with ZeParser.parse() ---');\nconst parseTree = ZeParser.parse(inputCode);\n// The parse tree is an array of arrays representing the AST structure.\n// It includes tokens as leaf nodes.\nconsole.log('Parse Tree (excerpt):', JSON.stringify(parseTree, null, 2).substring(0, 500) + '...');\n\nconsole.log('\\n--- Using ZeParser.createParser() for detailed token streams ---');\nconst parserInstance = ZeParser.createParser(inputCode);\n\n// .wtree (white tree) includes all tokens, including whitespace and comments\nconsole.log('White Tree (first 5 tokens):', parserInstance.wtree.slice(0, 5));\n\n// .btree (black tree) is the token stream without whitespace, line terminators, or comments\nconsole.log('Black Tree (first 5 tokens):', parserInstance.btree.slice(0, 5));\n\n// Accessing a token's properties, e.g., the first token in the black tree\nif (parserInstance.btree.length > 0) {\n  const firstToken = parserInstance.btree[0];\n  console.log('First token in black tree (type, value):', firstToken.type, firstToken.value);\n}","lang":"javascript","description":"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."},"warnings":[{"fix":"Use a modern JavaScript parser like Acorn, Babel Parser (@babel/parser), or Esprima for any code written post-ES5.","message":"ZeParser 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.","severity":"breaking","affected_versions":">=0.0.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=0.0.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"This parser is only compatible with ES5 (ECMAScript 5) and older syntax. It cannot parse modern JavaScript. Use a different, actively maintained parser.","cause":"Attempting to parse JavaScript code containing `const`, `let`, arrow functions, classes, or other ES2015+ features.","error":"SyntaxError: Unexpected token 'const'"},{"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.","cause":"Incorrectly importing the `ZeParser` module or attempting to call `parse` on a non-module object.","error":"TypeError: ZeParser.parse is not a function"},{"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.","cause":"Using `require('zeparser')` directly in a web browser without a CommonJS-compatible bundler.","error":"ReferenceError: require is not defined (in browser environments)"}],"ecosystem":"npm"}