tree-sitter-ucode 0.6.0 → 0.6.1

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
@@ -2,17 +2,24 @@
2
2
 
3
3
  Tree-sitter grammar for [ucode](https://github.com/jow-/ucode), the ECMAScript-like scripting language used in OpenWrt.
4
4
 
5
- Two grammars are provided:
5
+ Three grammars are provided:
6
6
 
7
- | Grammar | Scope | File types |
8
- |---------|-------|------------|
9
- | `ucode` | `source.uc` | `.uc`, `.ucode`, `.ut` |
10
- | `ucode_markup` | `source.ucode.markup` | `.uc`, `.ucode`, `.ut`, `.uc.tmpl` (template files — detected by content) |
7
+ | Grammar | Scope | File types | Purpose |
8
+ |---------|-------|------------|---------|
9
+ | `ucode` | `source.uc` | `.uc`, `.ucode`, `.ut` | Plain ucode source files |
10
+ | `ucode_markup` | `source.ucode.markup` | `.uc`, `.ucode`, `.ut` (template files — detected by content) | Ucode template files mixing raw text and code tags |
11
+ | `ucdocs` | — | injected | JSDoc-style `/** */` doc comment blocks |
12
+
13
+ `ucode` and `ucode_markup` share file extensions. Template files are distinguished from plain
14
+ code files by content: any file containing a tag opener (`{%`, `{{`, or `{#`) at the start
15
+ of a line (with optional leading whitespace) is automatically parsed by `ucode_markup`. Plain
16
+ code files fall back to `ucode`. See [File-type detection](#file-type-detection) below.
11
17
 
12
- Both grammars share the same file extensions. Template files are distinguished from plain
13
- code files by content: any file whose first tag opener (`{%`, `{{`, or `{#`) appears at
14
- the start of a line is automatically parsed by `ucode_markup`. Plain code files fall back
15
- to `ucode`. See [File-type detection](#file-type-detection) below.
18
+ `ucdocs` is not a standalone file grammar it is automatically injected by the `ucode` and
19
+ `ucode_markup` grammars into every `/** */` doc comment block. Tools that load grammars
20
+ directly from `tree-sitter.json` (including the tree-sitter CLI) handle this automatically.
21
+ Editor plugins may require registering the `ucdocs` grammar separately see the editor
22
+ sections below.
16
23
 
17
24
  ## Ucode vs JavaScript
18
25
 
@@ -29,6 +36,34 @@ Ucode is an ECMAScript subset with OpenWrt-specific extensions. Key differences:
29
36
  | Regex flags | `g`, `i`, `s` only | Full set |
30
37
  | Module system | Static `import`/`export` only; no `from` on re-exports | Full ES modules |
31
38
 
39
+ ## Doc comment grammar (ucdocs)
40
+
41
+ `/** */` blocks are parsed by the `ucdocs` grammar and injected into the host parse tree.
42
+ The grammar understands the following tags:
43
+
44
+ | Tag | Syntax |
45
+ |-----|--------|
46
+ | `@param` | `@param {Type} name description` |
47
+ | `@returns` / `@return` | `@returns {Type} description` |
48
+ | `@throws` / `@throw` | `@throws {Type} description` |
49
+ | `@type` | `@type {Type}` |
50
+ | `@typedef` | `@typedef {Type} TypeName` |
51
+ | `@template` | `@template T, U` |
52
+ | `@function` | `@function module:path#member` |
53
+ | `@module` | `@module name` |
54
+ | `@deprecated` | `@deprecated description` |
55
+ | `@since` | `@since version` |
56
+ | `@see` | `@see reference` |
57
+ | `@example` | `@example code` |
58
+ | `@default` | `@default value` |
59
+
60
+ Type expressions support: primitives (`int`, `float`, `string`, `boolean`, `null`, `void`,
61
+ `function`), `*`/`any`, `list<T>`, `dict<T>`, record types (`{field: T}`), named types
62
+ (`TypeName`, `TypeName<T, U>`), cross-module refs (`module:path.To.Type`), named function
63
+ types `(name: T) => U`, anonymous function types `function(T): U`, union `T | U`, nullable
64
+ `?T`, and array postfix `T[]`. Inline `{@link ...}` tags and optional params `[name=default]`
65
+ are also supported.
66
+
32
67
  ## Requirements
33
68
 
34
69
  - [tree-sitter CLI](https://github.com/tree-sitter/tree-sitter) ≥ 0.24
@@ -38,10 +73,10 @@ Ucode is an ECMAScript subset with OpenWrt-specific extensions. Key differences:
38
73
 
39
74
  ```sh
40
75
  npm install
41
- npm run build # generate + compile Node.js bindings
76
+ npm run build # generate + compile Node.js bindings (ucode and ucode_markup only)
42
77
  ```
43
78
 
44
- To regenerate parsers after editing a grammar file:
79
+ To regenerate parsers after editing a grammar file (run from the repo root):
45
80
 
46
81
  ```sh
47
82
  # ucode grammar
@@ -49,27 +84,33 @@ npx tree-sitter generate
49
84
 
50
85
  # ucode_markup grammar (generated from grammar.js — do not edit markup/grammar.js directly)
51
86
  node scripts/generate-markup-grammar.js
52
- cd markup && npx tree-sitter generate
87
+ npx tree-sitter generate markup/grammar.js --output markup/src
88
+
89
+ # ucdocs grammar (not included in npm run build — must be regenerated manually)
90
+ npx tree-sitter generate ucdocs/grammar.js --output ucdocs/src
53
91
  ```
54
92
 
55
93
  ## Test
56
94
 
57
95
  ```sh
58
- npm test # runs tree-sitter test for ucode and ucode_markup
96
+ npm test # builds and tests all three grammars (ucode, ucode_markup, ucdocs)
59
97
  ```
60
98
 
61
- To filter by corpus file name:
99
+ To filter by corpus file name (run from the repo root):
62
100
 
63
101
  ```sh
64
102
  npx tree-sitter test --file-name control_flow
65
- cd markup && npx tree-sitter test --file-name markup
103
+ (cd markup && npx tree-sitter test --file-name markup)
104
+ (cd ucdocs && npx tree-sitter test --file-name tags)
105
+ (cd ucdocs && npx tree-sitter test --file-name types)
66
106
  ```
67
107
 
68
108
  ## File-type detection
69
109
 
70
- Both grammars claim the same file extensions. Tools that respect `content-regex` in
110
+ Both `ucode` and `ucode_markup` claim the same file extensions. Tools that respect `content-regex` in
71
111
  `tree-sitter.json` (including the tree-sitter CLI ≥ 0.24) automatically route
72
- template files to `ucode_markup` when a tag opener appears at the start of a line.
112
+ template files to `ucode_markup` when a tag opener (`{%`, `{{`, or `{#`) appears at
113
+ the start of a line (with optional leading whitespace).
73
114
  Editors that manage their own filetype dispatch (Neovim, Helix) need an explicit
74
115
  rule — see the editor sections below.
75
116
 
@@ -102,11 +143,15 @@ grammar = "ucode_markup"
102
143
 
103
144
  [[grammar]]
104
145
  name = "ucode"
105
- source = { git = "https://github.com/m00qek/tree-sitter-ucode", rev = "v0.5.0" }
146
+ source = { git = "https://github.com/m00qek/tree-sitter-ucode", rev = "v0.6.0" }
106
147
 
107
148
  [[grammar]]
108
149
  name = "ucode_markup"
109
- source = { git = "https://github.com/m00qek/tree-sitter-ucode", rev = "v0.5.0", subpath = "markup" }
150
+ source = { git = "https://github.com/m00qek/tree-sitter-ucode", rev = "v0.6.0", subpath = "markup" }
151
+
152
+ [[grammar]]
153
+ name = "ucdocs"
154
+ source = { git = "https://github.com/m00qek/tree-sitter-ucode", rev = "v0.6.0", subpath = "ucdocs" }
110
155
  ```
111
156
 
112
157
  Helix does not support content-based filetype detection for shared extensions. For
@@ -134501,8 +134501,8 @@ TS_PUBLIC const TSLanguage *tree_sitter_ucode_markup(void) {
134501
134501
  .max_reserved_word_set_size = 28,
134502
134502
  .metadata = {
134503
134503
  .major_version = 0,
134504
- .minor_version = 5,
134505
- .patch_version = 0,
134504
+ .minor_version = 6,
134505
+ .patch_version = 1,
134506
134506
  },
134507
134507
  };
134508
134508
  return &language;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tree-sitter-ucode",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Ucode grammar for tree-sitter",
5
5
  "repository": {
6
6
  "type": "git",
package/src/parser.c CHANGED
@@ -113826,8 +113826,8 @@ TS_PUBLIC const TSLanguage *tree_sitter_ucode(void) {
113826
113826
  .max_reserved_word_set_size = 28,
113827
113827
  .metadata = {
113828
113828
  .major_version = 0,
113829
- .minor_version = 5,
113830
- .patch_version = 0,
113829
+ .minor_version = 6,
113830
+ .patch_version = 1,
113831
113831
  },
113832
113832
  };
113833
113833
  return &language;
Binary file
Binary file
package/tree-sitter.json CHANGED
@@ -78,7 +78,7 @@
78
78
  }
79
79
  ],
80
80
  "metadata": {
81
- "version": "0.5.0",
81
+ "version": "0.6.1",
82
82
  "license": "MIT",
83
83
  "description": "Ucode grammar for tree-sitter",
84
84
  "links": {
package/ucdocs/grammar.js CHANGED
@@ -41,7 +41,7 @@ module.exports = grammar({
41
41
  ),
42
42
 
43
43
  _begin: _ => token(seq('/', /\*+/)),
44
- _end: _ => token(seq(/\**/, '/')),
44
+ _end: _ => token(seq(/\*+/, '/')),
45
45
 
46
46
  // Used after a type_expression/rest_type_expression has already claimed `{` at
47
47
  // this position (param_tag, returns_tag, throws_tag) — excludes _brace_text so
@@ -119,7 +119,7 @@
119
119
  "members": [
120
120
  {
121
121
  "type": "PATTERN",
122
- "value": "\\**"
122
+ "value": "\\*+"
123
123
  },
124
124
  {
125
125
  "type": "STRING",