Registry / serialization / lex-parser

lex-parser

JSON →
library0.1.4jsnpmunverified

A parser for lexical grammars used by jison and jison-lex. Currently at version 0.1.4, it parses lexical grammar definitions (similar to those used by Lex/Yacc) and returns a JSON representation. It is a low-level dependency for jison tools and not commonly used directly. The package appears to be stable but rarely updated, with the last release likely years ago. Unlike higher-level alternatives like jison itself, lex-parser focuses solely on parsing the grammar syntax.

npm install lex-parser
INSTALL
IMPORT
SIG · LEX-PARSER
L
lex-parser
serializationjavascriptv0.1.4
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.

default (parse function)
import lexParser from 'lex-parser'; const result = lexParser.parse('%%...');
const lexParser = require('lex-parser'); // Works for CJS but not ESM
Package exposes a single parse function as default export. In CommonJS environments, require is acceptable; for ESM, use import.
parse function (named)
import { parse } from 'lex-parser'; const result = parse('%%...');
import { lexParser } from 'lex-parser'; // Wrong symbol; named export is 'parse', not 'lexParser'.
The named export 'parse' is available. Avoid confusing with the package name.

Shows how to install, import, and use lexParser.parse() to parse a simple lexical grammar and output JSON.

import lexParser from 'lex-parser'; const grammar = ` NAME [a-zA-Z_][a-zA-Z0-9_-]* %% {NAME} return 'NAME'; `; const parsed = lexParser.parse(grammar); console.log(JSON.stringify(parsed, null, 2));
Debug
Known issues
gotchaPackage uses CommonJS module format by default; ESM may require additional configuration.
fix
Use dynamic import or configure bundler for CommonJS compatibility.
affects: >=0.0.1
deprecatedPackage is rarely updated; consider using jison-lex directly for grammar parsing inside jison workflows.
fix
Instead of using lex-parser directly, rely on jison or jison-lex which include it as a dependency.
affects: >=0.0.1
gotchaThe parse function expects a complete grammar string with '%%' separator between rules and code; missing it results in invalid output.
fix
Ensure grammar string includes '%%' to separate the rules section from optional trailing code.
affects: >=0.0.1
Errors
Common errors & fixes
lexParser.parse is not a function
Incorrect import: using import or require improperly. For example, importing as default but using .parse as if it were a method on an object.
fix
Use either: const result = lexParser.parse('%%...'); if lexParser is the default import (CommonJS), or const { parse } = require('lex-parser'); result = parse('%%...');
Cannot find module 'lex-parser'
Package not installed.
fix
Install via npm: npm install lex-parser
Upgrade
Version history
0.1.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
lex-parser — npm install lex-parser · libregistry