Skip to content

Commit 83e3418

Browse files
committed
feat(parser): integrate jsep directly
1 parent a1f36f9 commit 83e3418

File tree

11 files changed

+1555
-466
lines changed

11 files changed

+1555
-466
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ Nimma consists of 3 major components. These are:
294294
- codegen (iterator/feedback + baseline),
295295
- runtime (scope + sandbox + traverse).
296296

297-
Parser takes a JSON Path expression and generates an AST that's consumed by the codegen in the next step.
297+
Parser takes a JSON Path expression and generates an AST that's consumed by the codegen in the next step. Nimma has its own JSON Path expression parser that's different from all remaining ones, thus some there might be instances where Nimma will parse a given expression differently than JSONPath-plus or jsonpath.
298298

299299
Codegen is a two-step process:
300300

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-7
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
"import": "./src/parser/index.mjs",
3232
"require": "./cjs/parser/index.cjs"
3333
},
34-
"./parser/jsep": {
35-
"import": "./src/parser/jsep.mjs",
36-
"require": "./cjs/parser/jsep.cjs"
37-
},
3834
"./runtime": {
3935
"import": "./src/runtime/index.mjs",
4036
"require": "./cjs/runtime/index.cjs"
@@ -53,7 +49,7 @@
5349
"url": "https://github.com/P0lip/nimma"
5450
},
5551
"scripts": {
56-
"build": "rollup -c",
52+
"build": "rollup -c && rm cjs/package.json",
5753
"lint": "ls-lint && eslint --cache --cache-location .cache/ src && prettier --log-level error --ignore-path .gitignore --check --cache --cache-location .cache/.prettier src",
5854
"test": "c8 mocha --config .mocharc ./src/**/__tests__/**/*.test.mjs && karma start karma.conf.cjs --log-level=error",
5955
"prepublishOnly": "npm run lint && npm run test && npm run build",
@@ -91,7 +87,6 @@
9187
"dependencies": {
9288
"@jsep-plugin/regex": "^1.0.3",
9389
"@jsep-plugin/ternary": "^1.1.3",
94-
"astring": "^1.8.6",
95-
"jsep": "^1.3.8"
90+
"astring": "^1.8.6"
9691
}
9792
}

src/codegen/baseline/generators.mjs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import jsep from '../../parser/jsep.mjs';
21
import * as b from '../ast/builders.mjs';
32
import { isNegativeSliceExpression } from '../guards.mjs';
43
import internalScope from '../templates/internal-scope.mjs';
@@ -258,10 +257,9 @@ export function generateWildcardExpression(branch, iterator) {
258257
export function generateFilterScriptExpression(
259258
branch,
260259
iterator,
261-
{ value },
260+
{ value: esTree },
262261
tree,
263262
) {
264-
const esTree = jsep(value);
265263
assertDefinedIdentifier(esTree);
266264
const node = rewriteESTree(tree, esTree);
267265

src/codegen/tree/tree.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default class ESTree {
8080
b.identifier(name),
8181
statefulFnParams,
8282
b.blockStatement([
83-
b.returnStatement(jsep(this.#availableShorthands[name])),
83+
b.returnStatement(jsep.parse(this.#availableShorthands[name])),
8484
]),
8585
),
8686
);

0 commit comments

Comments
 (0)