parseman 0.47.0 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -21
- package/dist/analysis/diagnostics.js +2955 -357
- package/dist/analysis/diagnostics.js.map +3 -3
- package/dist/cli/index.js +2946 -348
- package/dist/cli/index.js.map +3 -3
- package/dist/combinators/expect.d.ts +1 -0
- package/dist/combinators/expect.d.ts.map +1 -1
- package/dist/combinators/expected.d.ts +8 -0
- package/dist/combinators/expected.d.ts.map +1 -0
- package/dist/combinators/first-set.d.ts +8 -0
- package/dist/combinators/first-set.d.ts.map +1 -1
- package/dist/combinators/grammar.d.ts.map +1 -1
- package/dist/combinators/keywords.d.ts +4 -0
- package/dist/combinators/keywords.d.ts.map +1 -1
- package/dist/combinators/literal.d.ts.map +1 -1
- package/dist/combinators/not.d.ts.map +1 -1
- package/dist/combinators/peek.d.ts.map +1 -1
- package/dist/combinators/regex.d.ts.map +1 -1
- package/dist/combinators/repeat.d.ts.map +1 -1
- package/dist/combinators/sequence.d.ts.map +1 -1
- package/dist/combinators/trivia-skip.d.ts +19 -1
- package/dist/combinators/trivia-skip.d.ts.map +1 -1
- package/dist/compiler/direct-projection.d.ts +12 -0
- package/dist/compiler/direct-projection.d.ts.map +1 -0
- package/dist/compiler/token-alphabet.d.ts +845 -5
- package/dist/compiler/token-alphabet.d.ts.map +1 -1
- package/dist/compiler/token-capability.d.ts +3 -0
- package/dist/compiler/token-capability.d.ts.map +1 -0
- package/dist/compiler/token-capability.js +3192 -0
- package/dist/compiler/token-capability.js.map +6 -0
- package/dist/cst/trivia-charscan.d.ts +3 -0
- package/dist/cst/trivia-charscan.d.ts.map +1 -1
- package/dist/cst/trivia-css-scanner.d.ts +5 -0
- package/dist/cst/trivia-css-scanner.d.ts.map +1 -0
- package/dist/cst/trivia-kinds.d.ts.map +1 -1
- package/dist/index.js +2959 -348
- package/dist/index.js.map +3 -3
- package/dist/language-service/index.js +7 -1
- package/dist/language-service/index.js.map +1 -1
- package/dist/plugin/index.js +2969 -358
- package/dist/plugin/index.js.map +3 -3
- package/dist/spec/index.js +366 -49
- package/dist/spec/index.js.map +2 -2
- package/dist/table/assemble.d.ts.map +1 -1
- package/dist/table/child-slots.d.ts.map +1 -1
- package/dist/table/compile-rule-map.d.ts +3 -1
- package/dist/table/compile-rule-map.d.ts.map +1 -1
- package/dist/table/emit-assembly.d.ts +13 -14
- package/dist/table/emit-assembly.d.ts.map +1 -1
- package/dist/table/emit.d.ts.map +1 -1
- package/dist/table/encode.d.ts.map +1 -1
- package/dist/table/exec-baseline.d.ts.map +1 -1
- package/dist/table/exec.d.ts.map +1 -1
- package/dist/table/index.js +4839 -2232
- package/dist/table/index.js.map +3 -3
- package/dist/table/lex-body.d.ts +9 -0
- package/dist/table/lex-body.d.ts.map +1 -0
- package/dist/table/lex-program.d.ts +25 -0
- package/dist/table/lex-program.d.ts.map +1 -0
- package/dist/table/ops.d.ts +47 -4
- package/dist/table/ops.d.ts.map +1 -1
- package/dist/table/program.d.ts +53 -2
- package/dist/table/program.d.ts.map +1 -1
- package/dist/table/scalar-terminal.d.ts +13 -0
- package/dist/table/scalar-terminal.d.ts.map +1 -0
- package/dist/table/site-labels.d.ts.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +12 -11
- package/src/combinators/expect.ts +1 -0
- package/src/combinators/expected.ts +17 -0
- package/src/combinators/first-set.ts +82 -3
- package/src/combinators/grammar.ts +8 -3
- package/src/combinators/keywords.ts +22 -6
- package/src/combinators/literal.ts +2 -1
- package/src/combinators/not.ts +5 -1
- package/src/combinators/peek.ts +5 -1
- package/src/combinators/regex.ts +5 -3
- package/src/combinators/repeat.ts +4 -10
- package/src/combinators/sequence.ts +35 -16
- package/src/combinators/trivia-skip.ts +75 -11
- package/src/compiler/direct-projection.ts +43 -0
- package/src/compiler/token-alphabet.ts +4316 -12
- package/src/compiler/token-capability.ts +6 -0
- package/src/cst/trivia-charscan.ts +34 -0
- package/src/cst/trivia-css-scanner.ts +142 -0
- package/src/cst/trivia-kinds.ts +3 -1
- package/src/plugin/index.ts +4 -4
- package/src/table/assemble.ts +1224 -222
- package/src/table/child-slots.ts +4 -3
- package/src/table/compile-rule-map.ts +21 -3
- package/src/table/emit-assembly.ts +363 -109
- package/src/table/emit.ts +26 -1
- package/src/table/encode.ts +246 -54
- package/src/table/exec-baseline.ts +3 -7
- package/src/table/exec.ts +140 -18
- package/src/table/lex-body.ts +30 -0
- package/src/table/lex-program.ts +422 -0
- package/src/table/ops.ts +50 -4
- package/src/table/program.ts +67 -2
- package/src/table/scalar-terminal.ts +51 -0
- package/src/table/site-labels.ts +13 -3
- package/src/table/stamp.ts +3 -3
- package/src/types.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/analysis/diagnostics.cjs +0 -13736
- package/dist/analysis/diagnostics.cjs.map +0 -6
- package/dist/cli/index.cjs +0 -14837
- package/dist/cli/index.cjs.map +0 -6
- package/dist/index.cjs +0 -16303
- package/dist/index.cjs.map +0 -6
- package/dist/language-service/index.cjs +0 -1302
- package/dist/language-service/index.cjs.map +0 -6
- package/dist/oracle/index.cjs +0 -254
- package/dist/oracle/index.cjs.map +0 -6
- package/dist/plugin/index.cjs +0 -16009
- package/dist/plugin/index.cjs.map +0 -6
- package/dist/run/index.cjs +0 -577
- package/dist/run/index.cjs.map +0 -6
- package/dist/spec/index.cjs +0 -6188
- package/dist/spec/index.cjs.map +0 -6
- package/dist/table/index.cjs +0 -11375
- package/dist/table/index.cjs.map +0 -6
package/README.md
CHANGED
|
@@ -10,27 +10,28 @@ Parser combinators are pleasant to write and usually slow. Parser generators are
|
|
|
10
10
|
usually mean grammar files, generated code, and extra tooling. Parséman is a combinator
|
|
11
11
|
library with an optional compiler, and it gives you both.
|
|
12
12
|
|
|
13
|
-
**Parsing to JS values, the
|
|
14
|
-
suite** — ahead of every other library measured, at every grammar and every
|
|
15
|
-
that suite.
|
|
13
|
+
**Parsing to JS values, the runtime-compiled artifact is the fastest general-purpose JS
|
|
14
|
+
parser in the suite** — ahead of every other library measured, at every grammar and every
|
|
15
|
+
input size in that suite.
|
|
16
16
|
Every parser in the suite builds real output: objects, row arrays, AST nodes. On a 7.7 kB
|
|
17
|
-
GraphQL document Parséman takes **
|
|
18
|
-
edges it out
|
|
17
|
+
GraphQL document Parséman takes **188 µs**; Peggy takes 323 µs. Only a purpose-built native
|
|
18
|
+
edges it out: `JSON.parse` on JSON.
|
|
19
19
|
|
|
20
20
|

|
|
21
21
|
|
|
22
|
-
Two more results. The compiled CST path beats Lezer on the JSON CST fixture — **
|
|
23
|
-
|
|
22
|
+
Two more results. The compiled CST path beats Lezer on the JSON CST fixture — **242 µs** vs
|
|
23
|
+
570 µs at 11.9 kB — while producing a richer tree carrying spans and trivia. And `parseDoc`
|
|
24
24
|
stores parent-relative spans, so an in-place edit costs a fraction of a full reparse rather
|
|
25
25
|
than a multiple of it. Results move with grammar shape, input size and runtime — which is
|
|
26
26
|
why [the suite](#benchmarks) ships with the library rather than only its conclusions.
|
|
27
27
|
|
|
28
28
|
You get there by writing normal code. Add the bundler plugin, mark one import, and the
|
|
29
|
-
combinators you already wrote compile to
|
|
30
|
-
sets and left-factors
|
|
29
|
+
combinators you already wrote compile to an optimized `TableProgram` artifact — the compiler
|
|
30
|
+
computes first sets, links direct bodies for proven shapes, and left-factors choices for you.
|
|
31
31
|
|
|
32
32
|
Grammars work the same in plain JavaScript: the macro compiles a `.js` grammar to the same
|
|
33
|
-
output as a `.ts` one
|
|
33
|
+
output as a `.ts` one. The package ships one ESM implementation, loadable through either
|
|
34
|
+
`import` or `require()` on the supported Node versions. Write in TypeScript and result
|
|
34
35
|
types are inferred across the whole combinator chain — types you didn't have to write out.
|
|
35
36
|
|
|
36
37
|
Reach for it when you want CST/AST nodes with spans and trivia, error recovery and
|
|
@@ -54,7 +55,7 @@ npm install parseman
|
|
|
54
55
|
```
|
|
55
56
|
|
|
56
57
|
Pre-1.0: minor versions may carry breaking changes — check the [changelog](./CHANGELOG.md)
|
|
57
|
-
before upgrading. Requires Node `^20.19.0 || >=22.
|
|
58
|
+
before upgrading. Requires Node `^20.19.0 || >=22.13.0`.
|
|
58
59
|
|
|
59
60
|
## Quick start
|
|
60
61
|
|
|
@@ -84,9 +85,9 @@ The same combinator code runs three ways, with identical results:
|
|
|
84
85
|
- **Interpreter** — zero setup, works anywhere (tests, REPLs, dynamic grammars).
|
|
85
86
|
- **Macro build** — a [bundler plugin](https://matthew-dean.github.io/parseman/guide/macro-mode)
|
|
86
87
|
evaluates your grammar at build time and inlines the result. The combinator import you
|
|
87
|
-
mark `with { type: 'macro' }` disappears entirely; what ships is
|
|
88
|
-
|
|
89
|
-
app keeps
|
|
88
|
+
mark `with { type: 'macro' }` disappears entirely; what ships is a compact table artifact
|
|
89
|
+
using the shared `parseman/table` runtime. Executing it still goes through `run()`/`parse()`,
|
|
90
|
+
so an app keeps Parseman as an ordinary dependency — see
|
|
90
91
|
[the three modes](https://matthew-dean.github.io/parseman/guide/modes).)
|
|
91
92
|
- **`compile()`** — the same optimizer, on demand at runtime.
|
|
92
93
|
|
|
@@ -158,13 +159,13 @@ Benchmarked against [Peggy](https://peggyjs.org/),
|
|
|
158
159
|
[Lezer](https://lezer.codemirror.net/) on JSON, CSV and GraphQL, at three input sizes each.
|
|
159
160
|
Each chart's legend names the libraries measured for that grammar.
|
|
160
161
|
|
|
161
|
-
Largest fixture of each,
|
|
162
|
-
GraphQL **
|
|
163
|
-
**
|
|
164
|
-
chart,
|
|
162
|
+
Largest fixture of each, runtime compile against the fastest other library on that chart:
|
|
163
|
+
GraphQL **188 µs** vs Peggy's 323 µs, JSON **223 µs** vs Chevrotain's 238 µs, CSV
|
|
164
|
+
**114 µs** vs Peggy's 422 µs. Native `JSON.parse` does JSON large in 50.3 µs. On the CST
|
|
165
|
+
chart, runtime compile runs 242 µs against Lezer's 570 µs parse-only.
|
|
165
166
|
|
|
166
|
-
Those are the committed charts, regenerated
|
|
167
|
-
the
|
|
167
|
+
Those are the committed 0.48.0 charts, regenerated on 2026-08-14 on an M4 Pro with
|
|
168
|
+
Node 25.9.0. They include the restored small rows for JSON, CSV, GraphQL, and CST.
|
|
168
169
|
|
|
169
170
|

|
|
170
171
|
|
|
@@ -188,13 +189,18 @@ nodes, so the numbers come from a spec-shaped language rather than a toy.
|
|
|
188
189
|
pnpm install
|
|
189
190
|
pnpm test # interpreter + compiled parity, ordered-choice semantics
|
|
190
191
|
pnpm typecheck
|
|
191
|
-
pnpm build # ESM +
|
|
192
|
+
pnpm build # ESM + .d.ts → dist/
|
|
192
193
|
pnpm docs:dev # this documentation site, locally
|
|
193
194
|
```
|
|
194
195
|
|
|
195
196
|
Benchmark and chart tasks (`pnpm bench`, `bench:svg`, `bench:parseman`, …) are described in
|
|
196
197
|
the [benchmarks guide](https://matthew-dean.github.io/parseman/guide/benchmarks#reproducing-the-numbers).
|
|
197
198
|
|
|
199
|
+
The frozen 0.48 runtime architecture and release specification is
|
|
200
|
+
[`docs/design/parseman-0.48.md`](./docs/design/parseman-0.48.md). Detailed measurements
|
|
201
|
+
and rejected experiments remain in the linked evidence registers rather than being
|
|
202
|
+
treated as current design.
|
|
203
|
+
|
|
198
204
|
## License
|
|
199
205
|
|
|
200
206
|
MIT © [Matthew Dean](https://github.com/matthew-dean)
|