Skip to content

Commit

Permalink
feat(parser): integrate jsep directly
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip committed Apr 20, 2024
1 parent a1f36f9 commit 83e3418
Show file tree
Hide file tree
Showing 11 changed files with 1,555 additions and 466 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ Nimma consists of 3 major components. These are:
- codegen (iterator/feedback + baseline),
- runtime (scope + sandbox + traverse).
Parser takes a JSON Path expression and generates an AST that's consumed by the codegen in the next step.
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.
Codegen is a two-step process:
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
"import": "./src/parser/index.mjs",
"require": "./cjs/parser/index.cjs"
},
"./parser/jsep": {
"import": "./src/parser/jsep.mjs",
"require": "./cjs/parser/jsep.cjs"
},
"./runtime": {
"import": "./src/runtime/index.mjs",
"require": "./cjs/runtime/index.cjs"
Expand All @@ -53,7 +49,7 @@
"url": "https://github.com/P0lip/nimma"
},
"scripts": {
"build": "rollup -c",
"build": "rollup -c && rm cjs/package.json",
"lint": "ls-lint && eslint --cache --cache-location .cache/ src && prettier --log-level error --ignore-path .gitignore --check --cache --cache-location .cache/.prettier src",
"test": "c8 mocha --config .mocharc ./src/**/__tests__/**/*.test.mjs && karma start karma.conf.cjs --log-level=error",
"prepublishOnly": "npm run lint && npm run test && npm run build",
Expand Down Expand Up @@ -91,7 +87,6 @@
"dependencies": {
"@jsep-plugin/regex": "^1.0.3",
"@jsep-plugin/ternary": "^1.1.3",
"astring": "^1.8.6",
"jsep": "^1.3.8"
"astring": "^1.8.6"
}
}
4 changes: 1 addition & 3 deletions src/codegen/baseline/generators.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import jsep from '../../parser/jsep.mjs';
import * as b from '../ast/builders.mjs';
import { isNegativeSliceExpression } from '../guards.mjs';
import internalScope from '../templates/internal-scope.mjs';
Expand Down Expand Up @@ -258,10 +257,9 @@ export function generateWildcardExpression(branch, iterator) {
export function generateFilterScriptExpression(
branch,
iterator,
{ value },
{ value: esTree },
tree,
) {
const esTree = jsep(value);
assertDefinedIdentifier(esTree);
const node = rewriteESTree(tree, esTree);

Expand Down
2 changes: 1 addition & 1 deletion src/codegen/tree/tree.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class ESTree {
b.identifier(name),
statefulFnParams,
b.blockStatement([
b.returnStatement(jsep(this.#availableShorthands[name])),
b.returnStatement(jsep.parse(this.#availableShorthands[name])),
]),
),
);
Expand Down
Loading

0 comments on commit 83e3418

Please sign in to comment.