Skip to content

Commit

Permalink
fix list type
Browse files Browse the repository at this point in the history
  • Loading branch information
salamaashoush committed Aug 6, 2024
1 parent 991b8e4 commit bf63ffe
Show file tree
Hide file tree
Showing 9 changed files with 4,131 additions and 3,697 deletions.
34 changes: 24 additions & 10 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function withParens(rules) {
module.exports = grammar({
name: "pact",
extras: ($) => [$.comment, WHITESPACE],
conflicts: ($) => [[$._literal, $.doc], [$._from, $.s_expression], [$.list]],
conflicts: ($) => [[$.list]],
// supertypes: ($) => [$.s_expression],
word: ($) => $.atom,
rules: {
Expand Down Expand Up @@ -109,6 +109,27 @@ module.exports = grammar({
atom: ($) => ATOM,
reference: ($) => prec(20, seq($.atom, repeat(seq(".", $.atom)))),
// _delimiter: ($) => choice(".", ",", ":", "::"),
// object{type_parameter}, table{type_parameter}
_parametrized_object: ($) =>
prec(
40,
seq(
optional(choice("object", "table")),
"{",
field("type_parameter", alias($.reference, $.type_parameter)),
"}"
)
),
// [object{type_parameter}]
_parametrized_list: ($) =>
prec(
40,
seq(
"[",
field("type_parameter", alias($.type_identifier, $.type_parameter)),
"]"
)
),
type_identifier: ($) =>
prec.left(
20,
Expand All @@ -122,15 +143,8 @@ module.exports = grammar({
"value",
"keyset",
"guard",
prec(
40,
seq(
optional(choice("object", "table")),
"{",
field("type_parameter", alias($.reference, $.type_parameter)),
"}"
)
),
$._parametrized_object,
$._parametrized_list,
"object",
"table"
)
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "tree-sitter-pact",
"version": "0.0.2",
"version": "0.0.3",
"description": "Pact grammar for tree-sitter",
"main": "./bindings/node",
"main": "bindings/node",
"types": "bindings/node",
"scripts": {
"generate": "tree-sitter generate",
Expand Down Expand Up @@ -32,7 +32,7 @@
"author": "Salama Ashoush <[email protected]>",
"license": "MIT",
"dependencies": {
"node-addon-api": "^8.0.0",
"node-addon-api": "^8.1.0",
"node-gyp-build": "^4.8.1"
},
"peerDependencies": {
Expand All @@ -44,10 +44,10 @@
}
},
"devDependencies": {
"node-gyp": "^10.1.0",
"node-gyp": "^10.2.0",
"prebuildify": "^6.0.1",
"tree-sitter": "^0.21.1",
"tree-sitter-cli": "^0.22.6",
"prebuildify": "^6.0.1"
"tree-sitter-cli": "^0.22.6"
},
"tree-sitter": [
{
Expand All @@ -73,5 +73,6 @@
],
"injection-regex": "^(pact|repl)$"
}
]
],
"packageManager": "[email protected]"
}
Loading

0 comments on commit bf63ffe

Please sign in to comment.