tree-sitter-objectscript 1.7.4 → 1.7.5

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
@@ -67,27 +67,6 @@ temporary `studio-highlights.scm` copy step those staged crates need today.
67
67
 
68
68
  For Node bindings specifically, `.nvmrc` pins the expected Node version.
69
69
 
70
- ## Editor Integration
71
-
72
- - Zed: [ObjectScript extension](https://zed.dev/extensions/objectscript)
73
- - Neovim (`nvim-treesitter`):
74
- - Install grammars with `:TSInstall objectscript_udl`, `:TSInstall objectscript`, and `:TSInstall objectscript_routine`
75
- - Optional filetype mapping for `.cls` and routine extensions:
76
-
77
- ```lua
78
- vim.filetype.add({
79
- extension = {
80
- cls = "objectscript_udl",
81
- mac = "objectscript_routine",
82
- inc = "objectscript_routine",
83
- int = "objectscript_routine",
84
- rtn = "objectscript_routine",
85
- },
86
- })
87
- ```
88
-
89
- - Emacs: [emacs-objectscript-ts-mode](https://github.com/intersystems/emacs-objectscript-ts-mode)
90
-
91
70
  ## Quick Development
92
71
 
93
72
  Install the [tree-sitter CLI](https://tree-sitter.github.io/tree-sitter/creating-parsers/1-getting-started.html), then run commands from a grammar directory (`objectscript`, `udl`, `core`, `expr`, or `objectscript_routine`):
@@ -140,9 +119,85 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, workflow, query sync, and bind
140
119
  - [InterSystems ObjectScript documentation](https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_intro)
141
120
  - [Tree-sitter documentation](https://tree-sitter.github.io/tree-sitter/)
142
121
 
143
- ## License
144
-
145
- MIT. See [LICENSE](LICENSE).
122
+ ## Editor Integration
123
+ - [Zed](zed.dev)
124
+ On Zed, you can use `tree-sitter-objectscript` by downloading the [InterSystems ObjectScript extension](https://zed.dev/extensions/objectscript)
125
+ - [Neovim](https://neovim.io/)
126
+ We currently have a [PR](https://github.com/nvim-treesitter/nvim-treesitter/pull/8587) open with `nvim-treesitter`, and if that gets merged in, the setup process will be automated. However, this repo is currently archived, so for now do the following to setup the grammars in neovim:
127
+ #### Step 1: Create `~/.config/nvim/lua/plugins/objectscript-treesitter.lua`
128
+ Add the following content to that file:
129
+ **IMPORTANT: Make sure to replace the revision section with the commit that you want.**
130
+ ```lua
131
+
132
+ return {
133
+ -- configure nvim-treesitter
134
+ {
135
+ "nvim-treesitter/nvim-treesitter",
136
+ init = function()
137
+ vim.filetype.add({
138
+ extension = {
139
+ cls = "objectscript_udl",
140
+ mac = "objectscript_routine",
141
+ inc = "objectscript_routine",
142
+ int = "objectscript_routine",
143
+ rtn = "objectscript_routine"
144
+ },
145
+ })
146
+
147
+ vim.api.nvim_create_autocmd("FileType", {
148
+ pattern = { "objectscript_udl", "objectscript_routine" },
149
+ callback = function(args)
150
+ vim.treesitter.start(args.buf)
151
+ end,
152
+ })
153
+
154
+ vim.api.nvim_create_autocmd('User', { pattern = 'TSUpdate',
155
+ callback = function()
156
+ local parsers = require("nvim-treesitter.parsers")
157
+
158
+ parsers.objectscript_udl = {
159
+ install_info = {
160
+ url = "https://github.com/intersystems/tree-sitter-objectscript",
161
+ revision = "f1c568c622a0a43191563fd4c5e649a61eef11cc",
162
+ location = "udl",
163
+ queries = "udl/queries",
164
+ }
165
+ }
166
+
167
+ parsers.objectscript_routine = {
168
+ install_info = {
169
+ url = "https://github.com/intersystems/tree-sitter-objectscript",
170
+ revision = "f1c568c622a0a43191563fd4c5e649a61eef11cc",
171
+ location = "objectscript_routine",
172
+ queries = "objectscript_routine/queries",
173
+ }
174
+ }
175
+ end})
176
+ end,
177
+
178
+ opts = function(_, opts)
179
+ opts.ensure_installed = opts.ensure_installed or {}
180
+ for _, lang in ipairs({ "objectscript_udl", "objectscript_routine" }) do
181
+ if not vim.tbl_contains(opts.ensure_installed, lang) then
182
+ table.insert(opts.ensure_installed, lang)
183
+ end
184
+ end
185
+ end,
186
+ },
187
+ }
188
+ ```
189
+ #### Step 2: Remove cached data from nvim if necessary (if previously installed)
190
+
191
+ ```zsh
192
+ rm -rf ~/.local/share/nvim/site/parser \
193
+ ~/.local/share/nvim/site/parser-info \
194
+ ~/.local/share/nvim/site/queries
195
+ ```
196
+
197
+ #### Step 3: Open Neovim and Install `objectscript_udl` and `objectscript_routine`
198
+ ```vim
199
+ :TSInstall objectscript_udl objectscript_routine
200
+ ```
146
201
 
147
202
  [ci]: https://img.shields.io/github/actions/workflow/status/intersystems/tree-sitter-objectscript/ci.yml?logo=github&label=CI
148
203
  [npm]: https://img.shields.io/npm/v/tree-sitter-objectscript?logo=npm
package/common/scanner.h CHANGED
@@ -9,6 +9,7 @@ enum ObjectScript_Core_Scanner_TokenType {
9
9
  _ARGUMENTLESS_LOOP,
10
10
  _WHITESPACE,
11
11
  TAG,
12
+ ROUTINE,
12
13
  ANGLED_BRACKET_FENCED_TEXT,
13
14
  PAREN_FENCED_TEXT,
14
15
  EMBEDDED_SQL_MARKER,
@@ -44,6 +45,7 @@ static const char* token_names[] = {
44
45
  "_ARGUMENTLESS_LOOP",
45
46
  "_WHITESPACE",
46
47
  "TAG",
48
+ "ROUTINE",
47
49
  "ANGLED_BRACKET_FENCED_TEXT",
48
50
  "PAREN_FENCED_TEXT",
49
51
  "EMBEDDED_SQL_MARKER",
@@ -145,6 +147,8 @@ struct ObjectScript_Core_Scanner {
145
147
  // When true, column-1 identifiers are treated as statements unless they
146
148
  // are clearly labels/tags.
147
149
  bool column1_statement_mode;
150
+ // When true, a column-1 tag named ROUTINE is emitted as ROUTINE instead of TAG.
151
+ bool routine_token_mode;
148
152
  bool special_pound_if_mode;
149
153
  uint32_t special_pound_if_mode_if_depth;
150
154
  int32_t html_marker_buffer[MARKER_BUFFER_MAX_LEN];
@@ -1133,6 +1137,14 @@ else if (valid_symbols[_ASSERT_NO_SPACE_BETWEEN_RULES]) {
1133
1137
  advance(lexer);
1134
1138
  } while (is_label_char(lexer->lookahead));
1135
1139
 
1140
+ if (scanner->routine_token_mode &&
1141
+ valid_symbols[ROUTINE] &&
1142
+ ascii_upper_eq(ident, len, "ROUTINE")) {
1143
+ lexer->result_symbol = ROUTINE;
1144
+ scanner->terminated_newline = false;
1145
+ return true;
1146
+ }
1147
+
1136
1148
  if (!scanner->column1_statement_mode) {
1137
1149
  lexer->result_symbol = TAG;
1138
1150
  scanner->terminated_newline = false;
@@ -1346,6 +1358,7 @@ static void ObjectScript_Core_Scanner_init(struct ObjectScript_Core_Scanner *sca
1346
1358
  scanner->html_marker_buffer_len = 0;
1347
1359
  scanner->terminated_newline = false;
1348
1360
  scanner->column1_statement_mode = false;
1361
+ scanner->routine_token_mode = false;
1349
1362
  scanner->special_pound_if_mode = false;
1350
1363
  scanner->special_pound_if_mode_if_depth = 0;
1351
1364
  }
package/core/grammar.js CHANGED
@@ -136,6 +136,7 @@ module.exports = grammar(objectscript_expr, {
136
136
  $._argumentless_loop,
137
137
  $._whitespace,
138
138
  $.tag,
139
+ $.routine,
139
140
  $.angled_bracket_fenced_text,
140
141
  $.paren_fenced_text,
141
142
  $.embedded_sql_marker,