Skip to content

Commit

Permalink
v0breaking: dropped chevrotain for custom parser
Browse files Browse the repository at this point in the history
Rewrote parser from scratch. It has no dependencies now if you do not count my utility library.

It's also much much faster (~50x). Most queries now only take a couple of milliseconds where before they took 50+.

The majority of the external API should be the same, but some chevrotain only stuff is no longer exposed.

It also drops support for generating chevrotain's railroat diagrams.
  • Loading branch information
AlansCodeLog committed May 27, 2024
1 parent 10b30d7 commit 3346d73
Show file tree
Hide file tree
Showing 64 changed files with 5,413 additions and 5,284 deletions.
41 changes: 0 additions & 41 deletions .eslintrc.cjs

This file was deleted.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ pnpm install @witchcraft/expressit
# Usage

```ts
import { Parser, ErrorToken } from "@witchcraft/expressit"
// while you can import from "@witchcraft/expressit", if using something like vite, it's recommended you do not use barrel imports.
import { Parser } from "@witchcraft/expressit/Parser.js"
import { ErrorToken } from "@witchcraft/expressit/classes/ErrorToken.js"

const parser = new Parser({/* opts */})
const context = {
Expand Down
9 changes: 4 additions & 5 deletions demo/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/* eslint-disable no-eval */
/* eslint-disable no-restricted-imports */
import "./style.css"

import { crop } from "@alanscodelog/utils"
import { crop } from "@alanscodelog/utils/crop"
import { Parser } from "@witchcraft/expressit"
import { parseParserOptions } from "@witchcraft/expressit/helpers/parser/index.js"
import { prettyAst } from "@witchcraft/expressit/utils"

import { Parser } from "@witchcraft/expressit"


const body = document.body

Expand Down Expand Up @@ -106,7 +105,7 @@ function onInput(e) {
values: "<span>",
info: "<span>",
error: "<span>",
hint: "<span>"
hint: "<span>",
})
els.resultSimple.innerHTML = parsedString

Expand Down
3 changes: 0 additions & 3 deletions docs-src/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ src
┃ ┣ classes - the actual ast node classes
┃ ┣ handlers.ts - used inside grammar/ParserBase.ts to handle the creation of tokens / ast node classes
┣ examples - contains fully implemented parser examples
┣ grammar
┃ ┣ createTokens.ts - contains the main lexer logic
┃ ┗ ParserBase.ts - contains the main chevrotain parser logic
┣ helpers
┃ ┣ general - ...various internal helper functions not related to parsing + default functions for the default parser options
┃ ┣ parser - ...various internal helper functions used before/during parsing
Expand Down
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from "@alanscodelog/eslint-config"
export default config

53 changes: 19 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@
"types": "./dist/ast/*",
"import": "./dist/ast/*"
},
"./grammar": {
"types": "./dist/grammar/index.d.ts",
"import": "./dist/grammar/index.js"
},
"./grammar/*": {
"types": "./dist/grammar/*",
"import": "./dist/grammar/*"
},
"./helpers": {
"types": "./dist/helpers/index.d.ts",
"import": "./dist/helpers/index.js"
Expand Down Expand Up @@ -58,8 +50,8 @@
"import": "./dist/examples/*"
},
"./*": {
"types": "./dist/*",
"import": "./dist/*"
"types": "./dist/types/*",
"import": "./dist/types/*"
}
},
"scripts": {
Expand All @@ -74,10 +66,10 @@
"lint:commits": "commitlint --from $(git rev-list --max-parents=0 HEAD) --to HEAD --verbose",
"lint:imports": "madge --circular --extensions ts ./src",
"lint": "npm run lint:types && npm run lint:eslint",
"coverage": "vitest --coverage",
"coverage:dev": "vitest --watch --coverage",
"test": "npm run lint:types && vitest run",
"test:watch": "vitest --watch",
"coverage": "vitest --exclude '.direnv/**/*' --coverage",
"coverage:dev": "vitest --exclude '.direnv/**/*' --watch --coverage",
"test": "npm run lint:types && vitest run --exclude '.direnv/**/*'",
"test:watch": "vitest --watch --exclude '.direnv/**/*'",
"test:inspect-errors": "cross-env INSPECT_ERRORS=true npm run test",
"doc": "typedoc --options typedoc.config.cjs",
"doc:watch": "onchange -i \"src/**/*.ts\" \"typedoc.config.cjs\" -- npm run doc",
Expand All @@ -88,45 +80,38 @@
"demo:build": "cd demo && npm run build",
"actions:debug": "act -r -v -j build",
"gen:exports": "indexit update -o '${path}.js' -i **/*.d.ts",
"prepare": "husky install && npm run build"
"prepare": "husky && npm run build"
},
"dependencies": {
"@alanscodelog/utils": "4.0.0-beta.15",
"chevrotain": "^11.0.3"
"@alanscodelog/utils": "4.0.0-beta.15"
},
"devDependencies": {
"@alanscodelog/commitlint-config": "^2.0.0",
"@alanscodelog/eslint-config": "^4.0.3",
"@alanscodelog/semantic-release-config": "^3.0.0",
"@alanscodelog/tsconfigs": "^3.2.0",
"@alanscodelog/tsconfigs": "^4.0.1",
"@knodes/typedoc-plugin-pages": "^0.23.4",
"@types/node": "^20.4.1",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"@vitest/coverage-c8": "^0.33.0",
"commitlint": "^17.6.6",
"@vitest/coverage-v8": "^1.6.0",
"commitlint": "^19.3.0",
"concurrently": "^8.2.0",
"cross-env": "^7.0.3",
"eslint": "^8.44.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsdoc": "^46.4.3",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint": "^9.0.0",
"fast-glob": "^3.3.1",
"http-server": "^14.1.1",
"husky": "^8.0.3",
"husky": "^9.0.11",
"indexit": "2.1.0-beta.3",
"madge": "^6.1.0",
"madge": "^7.0.0",
"onchange": "^7.1.0",
"semantic-release": "^22.0.5",
"semantic-release": "^23.1.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.7",
"typedoc": "~0.23.1",
"typescript": "~5.0.0",
"vite": "^4.4.2",
"vite-plugin-externalize-deps": "^0.7.0",
"typescript": "~5.4.5",
"vite": "^5.2.11",
"vite-plugin-externalize-deps": "^0.8.0",
"vite-tsconfig-paths": "^4.2.0",
"vitest": "^0.34.6"
"vitest": "^1.6.0"
},
"author": "Alan <alanscodelog@gmail.com>",
"repository": "https://github.com/witchcraftjs/expressit",
Expand Down
Loading

0 comments on commit 3346d73

Please sign in to comment.