@creationix/rex 0.3.1 → 0.6.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 +24 -0
- package/package.json +9 -6
- package/rex-cli.js +1334 -1190
- package/rex-cli.ts +268 -27
- package/rex-repl.js +1048 -1135
- package/rex-repl.ts +392 -103
- package/rex.js +290 -954
- package/rex.ohm +48 -21
- package/rex.ohm-bundle.cjs +1 -1
- package/rex.ohm-bundle.d.ts +27 -8
- package/rex.ohm-bundle.js +1 -1
- package/rex.ts +388 -218
- package/rexc-interpreter.ts +386 -88
- package/rx-cli.js +2836 -0
- package/rx-cli.ts +298 -0
package/README.md
CHANGED
|
@@ -47,6 +47,30 @@ npx -y @creationix/rex -- --expr "when x do y end"
|
|
|
47
47
|
|
|
48
48
|
`npx` works with Node.js alone (v22.18+). `bunx` works with Bun alone.
|
|
49
49
|
|
|
50
|
+
## Data Tool (`rx`)
|
|
51
|
+
|
|
52
|
+
`rx` inspects, converts, and filters REXC and JSON data.
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
rx data.rexc # pretty-print as tree
|
|
56
|
+
rx data.rexc --to json # convert rexc → JSON
|
|
57
|
+
rx data.json --to rexc # convert JSON → rexc
|
|
58
|
+
cat data.rexc | rx # read from stdin (auto-detect)
|
|
59
|
+
rx -s .routes[0].op data.rexc # select a sub-value
|
|
60
|
+
rx data.rexc --to json -o out.json # write to file
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Format is auto-detected from file extension (`.json`, `.rexc`) or by content sniffing on stdin. Override with `--from json|rexc`.
|
|
64
|
+
|
|
65
|
+
Output defaults to tree view on a TTY, JSON when piped. Override with `--to json|rexc|tree` (shortcuts: `-j`, `-r`, `-t`).
|
|
66
|
+
|
|
67
|
+
Run without installing:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
bun run rx data.rexc # from repo root
|
|
71
|
+
bun run packages/rex-lang/rx-cli.ts data.rexc # from anywhere
|
|
72
|
+
```
|
|
73
|
+
|
|
50
74
|
## Programmatic API
|
|
51
75
|
|
|
52
76
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@creationix/rex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Compiler and parser for the Rex language",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rex",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
],
|
|
12
12
|
"type": "module",
|
|
13
13
|
"bin": {
|
|
14
|
-
"rex": "
|
|
14
|
+
"rex": "rex-cli.js",
|
|
15
|
+
"rx": "rx-cli.js"
|
|
15
16
|
},
|
|
16
17
|
"main": "rex.js",
|
|
17
18
|
"types": "./rex.ts",
|
|
@@ -31,12 +32,14 @@
|
|
|
31
32
|
"rex.ohm-bundle.d.ts",
|
|
32
33
|
"rexc-interpreter.ts",
|
|
33
34
|
"rex-repl.ts",
|
|
34
|
-
"rex-repl.js"
|
|
35
|
+
"rex-repl.js",
|
|
36
|
+
"rx-cli.ts",
|
|
37
|
+
"rx-cli.js"
|
|
35
38
|
],
|
|
36
39
|
"scripts": {
|
|
37
40
|
"test": "bun test",
|
|
38
41
|
"build:grammar": "ohm generateBundles --withTypes rex.ohm && node -e \"require('node:fs').copyFileSync('rex.ohm-bundle.js','rex.ohm-bundle.cjs')\"",
|
|
39
|
-
"build:js": "bun build rex.ts --outfile rex.js --format esm --target node && bun build rex-repl.ts --outfile rex-repl.js --format esm --target node && bun build rex-cli.ts --outfile rex-cli.js --format esm --target node && node -e \"const fs=require('fs')
|
|
42
|
+
"build:js": "bun build rex.ts --outfile rex.js --format esm --target node && bun build rex-repl.ts --outfile rex-repl.js --format esm --target node && bun build rex-cli.ts --outfile rex-cli.js --format esm --target node && bun build rx-cli.ts --outfile rx-cli.js --format esm --target node && node -e \"const fs=require('fs');for(const f of['rex-cli.js','rx-cli.js'])fs.writeFileSync(f,'#!/usr/bin/env node\\n'+fs.readFileSync(f,'utf8'))\"",
|
|
40
43
|
"compile": "bun run rex-cli.ts",
|
|
41
44
|
"verify:docs": "bun run verify-doc-examples.ts",
|
|
42
45
|
"pack:dry-run": "npm pack --dry-run",
|
|
@@ -48,7 +51,7 @@
|
|
|
48
51
|
},
|
|
49
52
|
"repository": {
|
|
50
53
|
"type": "git",
|
|
51
|
-
"url": "https://github.com/creationix/rex",
|
|
54
|
+
"url": "git+https://github.com/creationix/rex.git",
|
|
52
55
|
"directory": "packages/rex-lang"
|
|
53
56
|
},
|
|
54
57
|
"license": "MIT",
|
|
@@ -59,4 +62,4 @@
|
|
|
59
62
|
"@ohm-js/cli": "^2.0.1",
|
|
60
63
|
"@types/bun": "latest"
|
|
61
64
|
}
|
|
62
|
-
}
|
|
65
|
+
}
|