Skip to content

Commit

Permalink
🚸 improve type_annotation and schema grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
salamaashoush committed Sep 20, 2024
1 parent aaa85ab commit 746d8f5
Show file tree
Hide file tree
Showing 11 changed files with 3,778 additions and 3,865 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,21 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-14]
node-version: [22]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Set up tree-sitter
uses: tree-sitter/setup-action/cli@v1
- name: Run tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
- name: Install dependencies
run: pnpm install
- name: Run ESLint
run: npm run lint
run: pnpm lint
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Then run `:TSInstall pact` in neovim.
also you need to link the queries folder to your nvim config folder

``` bash
mkdir -p ~/.config/nvim/after/queries/pact
ln ./queries/highlights.scm ~/.config/nvim/after/queries/pact/highlights.scm
ln ./queries/locals.scm ~/.config/nvim/after/queries/pact/locals.scm
ln ./queries/textobjects.scm ~/.config/nvim/after/queries/pact/textobjects.scm
Expand Down
21 changes: 11 additions & 10 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,18 @@ module.exports = grammar({
"table"
)
),
type_annotation: ($) => seq(":", field("type", $.type_identifier)),
type_annotation: ($) => seq(":", $.type_identifier),
parameter_list: ($) => withParens(optional(repeat($.parameter))),
parameter: ($) =>
seq(
field("name", alias($.atom, $.parameter_identifier)),
optional($.type_annotation)
field("type", optional($.type_annotation))
),
schema_property: ($) =>
schema_field_list: ($) => repeat1($.schema_field),
schema_field: ($) =>
seq(
field("name", alias($.atom, $.schema_property_identifier)),
optional($.type_annotation)
field("name", alias($.atom, $.schema_field_identifier)),
field("type", optional($.type_annotation))
),
pair: ($) =>
seq(field("key", $._property_name), ":", field("value", $._from)),
Expand Down Expand Up @@ -252,7 +253,7 @@ module.exports = grammar({
"defun",
seq(
field("name", $._def_name),
optional(seq(":", field("return_type", $.type_identifier)))
field("return_type", optional($.type_annotation))
),
field("parameters", $.parameter_list),
optional($._doc_or_meta),
Expand All @@ -269,7 +270,7 @@ module.exports = grammar({
"defcap",
seq(
field("name", $._def_name),
optional(seq(":", field("return_type", $.type_identifier)))
field("return_type", optional($.type_annotation))
),
field("parameters", $.parameter_list),
optional($._doc_or_meta),
Expand Down Expand Up @@ -299,7 +300,7 @@ module.exports = grammar({
"defpact",
seq(
field("name", $._def_name),
optional(seq(":", field("return_type", $.type_identifier)))
field("return_type", optional($.type_annotation))
),
field("parameters", $.parameter_list),
optional($._doc_or_meta),
Expand All @@ -316,7 +317,7 @@ module.exports = grammar({
"defschema",
field("name", $._def_name),
optional($._doc_or_meta),
field("body", repeat($.schema_property)),
field("fields", $.schema_field_list),
PARENS_RIGHT
)
),
Expand All @@ -341,7 +342,7 @@ module.exports = grammar({
let_variable: ($) =>
seq(
field("name", alias($.atom, $.let_variable_identifier)),
optional($.type_annotation)
field("type", optional($.type_annotation))
),
let_bind_pair: ($) =>
seq(PARENS_LEFT, $.let_variable, field("value", $._from), PARENS_RIGHT),
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tree-sitter-pact",
"version": "0.0.4",
"version": "0.0.5",
"description": "Pact grammar for tree-sitter",
"main": "bindings/node",
"types": "bindings/node",
Expand All @@ -10,7 +10,7 @@
"start": "tree-sitter playground",
"lint": "eslint grammar.js",
"test": "tree-sitter test && node --test bindings/node/*_test.js",
"build": "node-gyp-build && tree-sitter build --wasm",
"build": "tree-sitter build && tree-sitter build --wasm",
"prepublish": "pnpm run build",
"parse:test": "tree-sitter parse test.pact",
"parse:coin": "tree-sitter parse coin.pact"
Expand All @@ -35,8 +35,8 @@
"node-gyp-build": "^4.8.2"
},
"devDependencies": {
"@eslint/js": "^9.10.0",
"eslint": "^9.10.0",
"@eslint/js": "^9.11.0",
"eslint": "^9.11.0",
"globals": "^15.9.0",
"node-gyp": "^10.2.0",
"prebuildify": "^6.0.1",
Expand Down Expand Up @@ -76,5 +76,5 @@
"injection-regex": "^(pact|repl)$"
}
],
"packageManager": "pnpm@9.10.0"
"packageManager": "pnpm@9.11.0"
}
36 changes: 18 additions & 18 deletions pnpm-lock.yaml

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

Loading

0 comments on commit 746d8f5

Please sign in to comment.