Skip to content

Commit

Permalink
Use ANTLR grammar for PartiQL diagnostics (#383)
Browse files Browse the repository at this point in the history
* Use ANTLR grammar for PartiQL diagnostics
  • Loading branch information
akoreman authored Jul 22, 2024
1 parent c22c2bc commit 59e654a
Show file tree
Hide file tree
Showing 15 changed files with 22,051 additions and 29 deletions.
18 changes: 18 additions & 0 deletions package-lock.json

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

8 changes: 7 additions & 1 deletion server/aws-lsp-partiql/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# automatically generated files from wasm-pack
/src/partiql-parser-wasm/**/*.*
# automatically generated files from tree-sitter
/src/tree-sitter-wasm/**/*.*
/src/tree-sitter-wasm/**/*.*
# automatically generated files from antlr
/src/antlr-generated
# antlr grammar files
/src/antlr-grammar
6 changes: 5 additions & 1 deletion server/aws-lsp-partiql/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# automatically generated files from wasm-pack
/src/partiql-parser-wasm/**/*.*
# automatically generated files from tree-sitter
/src/tree-sitter-wasm/**/*.*
/src/tree-sitter-wasm/**/*.*
# automatically generated files from antlr
/src/antlr-generated
# antlr grammar files
/src/antlr-grammar
5 changes: 5 additions & 0 deletions server/aws-lsp-partiql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ To update the binary used by the server, run `npm run update-parser-binary`. Thi

To update the binary used in package `web-tree-sitter`, run `npm run update-treesitter-wasm`. This update is forced to make everytime upgrading the version of `web-tree-sitter`. This will compile the `tree-sitter.wasm` file inside the package into a base64 string in a TypeScript file to the `src/tree-sitter-parser` folder as `tree-sitter-inline.ts`.

### Updating the ANTLR lexer and parser

The ANTLR lexer and parser grammars are defined in `src/antlr-grammar`, the files in `src/antlr-generated` are automatically generated from the grammar files. To
update these files, run `npm run update-antlr`. The current grammar files can be found at https://github.com/partiql/partiql-lang-kotlin/tree/main/partiql-parser/src/main/antlr.

### Tests

Tests for this package are run using [Jest](https://jestjs.io/), to run the tests in this package run `-npm run test`.
Expand Down
7 changes: 5 additions & 2 deletions server/aws-lsp-partiql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
"copy-empty-binary": "tsx build-scripts/create-empty-wasm-file.mts",
"update-parser-binary": "tsx build-scripts/compile-inline-partiql-wasm.mts",
"compile-treesitter-parser-wasm": "tsx build-scripts/compile-inline-tree-sitter-parser-wasm.mts",
"update-treesitter-wasm": "tsx build-scripts/compile-inline-tree-sitter-wasm.mts"
"update-treesitter-wasm": "tsx build-scripts/compile-inline-tree-sitter-wasm.mts",
"update-antlr": "antlr4ng -Dlanguage=TypeScript -no-visitor -no-listener -Xexact-output-dir -o src/antlr-generated src/antlr-grammar/PartiQLTokens.g4 src/antlr-grammar/PartiQLParser.g4"
},
"files": [
"out"
],
"dependencies": {
"antlr4ng": "^3.0.4",
"@aws/language-server-runtimes": "^0.2.10",
"web-tree-sitter": "0.22.6"
},
Expand All @@ -33,7 +35,8 @@
"@types/jest": "29.5.12",
"ts-jest": "^29.1.2",
"tsx": "^4.7.2",
"zx": "^8.1.0"
"zx": "^8.1.0",
"antlr4ng-cli": "^2.0.0"
},
"prettier": {
"printWidth": 120,
Expand Down
Loading

0 comments on commit 59e654a

Please sign in to comment.