@gram-data/tree-sitter-gram 0.3.11 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -89,6 +89,19 @@ Gram files support comments using `//` syntax:
89
89
  (hello)-->(world) // End-of-line comment
90
90
  ```
91
91
 
92
+ Documentation comments use `/** ... */` and parse as a `doc_comment` node. Editors inject the
93
+ [`gramdoc`](https://github.com/gram-data/tree-sitter-gramdoc) language into them (see `queries/injections.scm`):
94
+ ```gram
95
+ /**
96
+ * A human individual.
97
+ *
98
+ * @property name The full name of the person.
99
+ */
100
+ (Person {name: "STRING!"})
101
+ ```
102
+ A doc comment may appear anywhere a `//` comment may, including inside records and between pattern elements.
103
+ Plain `/* ... */` block comments are not supported, and `/**/` is not a doc comment.
104
+
92
105
  Learn more about `gram` at the [gram-data github org](https://github.com/gram-data).
93
106
 
94
107
  ## Editor Support
@@ -1,6 +1,6 @@
1
1
  id = "gram"
2
2
  name = "Gram Language Support"
3
- version = "0.3.11"
3
+ version = "0.4.0"
4
4
  schema_version = 1
5
5
  authors = ["Gram Data Contributors"]
6
6
  description = "Support for Gram notation - composable data patterns"
@@ -13,4 +13,4 @@ capabilities = [
13
13
  # path = "grammars/tree-sitter-gram"
14
14
  [grammars.gram]
15
15
  repository = "file:///Users/akollegger/Developer/gram-data/tree-sitter-gram"
16
- rev = "v0.3.11"
16
+ rev = "v0.4.0"
package/grammar.js CHANGED
@@ -4,6 +4,7 @@ module.exports = grammar({
4
4
  extras: ($) => [
5
5
  /\s/,
6
6
  $.comment,
7
+ $.doc_comment,
7
8
  ],
8
9
 
9
10
  rules: {
@@ -397,6 +398,10 @@ module.exports = grammar({
397
398
  ),
398
399
 
399
400
  comment: ($) => token(seq("//", /.*/)),
401
+
402
+ // Documentation comment: `/** ... */`. Content is injected as `gramdoc`
403
+ // (see queries/injections.scm). `/**/` is not a doc comment.
404
+ doc_comment: ($) => token(seq("/**", /[^*]*\*+([^/*][^*]*\*+)*/, "/")),
400
405
  },
401
406
  });
402
407
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gram-data/tree-sitter-gram",
3
- "version": "0.3.11",
3
+ "version": "0.4.0",
4
4
  "description": "subject-oriented notation for structured data",
5
5
  "homepage": "https://gram-data.github.io",
6
6
  "repository": {
@@ -53,7 +53,8 @@
53
53
  }
54
54
  },
55
55
  "devDependencies": {
56
- "eslint": "^9.37.0",
56
+ "eslint": "^10.3.0",
57
+ "node-gyp": "^13.1.0",
57
58
  "prebuildify": "^6.0.1",
58
59
  "tree-sitter": "^0.25.0",
59
60
  "tree-sitter-cli": "^0.26.5"
@@ -14,6 +14,7 @@
14
14
 
15
15
  ; Comment (FR-003)
16
16
  (comment) @comment
17
+ (doc_comment) @comment.documentation
17
18
 
18
19
  ; Tagged-string tag distinct from content (FR-002)
19
20
  (tagged_string tag: (symbol) @attribute)
@@ -27,3 +27,8 @@
27
27
  (tagged_string
28
28
  tag: (symbol) @injection.language
29
29
  content: (string_content) @injection.content)
30
+
31
+ ; Documentation comments: /** ... */ is gramdoc (https://github.com/gram-data/tree-sitter-gramdoc).
32
+ ; The whole comment text, including the delimiters, is the injected content.
33
+ ((doc_comment) @injection.content
34
+ (#set! injection.language "gramdoc"))
package/src/grammar.json CHANGED
@@ -1972,6 +1972,26 @@
1972
1972
  }
1973
1973
  ]
1974
1974
  }
1975
+ },
1976
+ "doc_comment": {
1977
+ "type": "TOKEN",
1978
+ "content": {
1979
+ "type": "SEQ",
1980
+ "members": [
1981
+ {
1982
+ "type": "STRING",
1983
+ "value": "/**"
1984
+ },
1985
+ {
1986
+ "type": "PATTERN",
1987
+ "value": "[^*]*\\*+([^/*][^*]*\\*+)*"
1988
+ },
1989
+ {
1990
+ "type": "STRING",
1991
+ "value": "/"
1992
+ }
1993
+ ]
1994
+ }
1975
1995
  }
1976
1996
  },
1977
1997
  "extras": [
@@ -1982,6 +2002,10 @@
1982
2002
  {
1983
2003
  "type": "SYMBOL",
1984
2004
  "name": "comment"
2005
+ },
2006
+ {
2007
+ "type": "SYMBOL",
2008
+ "name": "doc_comment"
1985
2009
  }
1986
2010
  ],
1987
2011
  "conflicts": [],
@@ -1218,6 +1218,11 @@
1218
1218
  "type": "decimal",
1219
1219
  "named": true
1220
1220
  },
1221
+ {
1222
+ "type": "doc_comment",
1223
+ "named": true,
1224
+ "extra": true
1225
+ },
1221
1226
  {
1222
1227
  "type": "false",
1223
1228
  "named": false