-
-
Notifications
You must be signed in to change notification settings - Fork 13
Fix: Node bindings .length problem on parser.set_language(). #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…o version with the fix for lang error in node with latest cli
…oz of failing ci.
Hi @mashurr , Thanks a lot for taking the time to debug the issue and opening a PR. Just one thing. Do you think this fix will actually close #31? There is still a PR in node-tree-sitter repo attempting to implement compatibility with ABI 15, among other things: tree-sitter/node-tree-sitter#258. If you think this is a temporary fix until previous PR is merged I will reopen #31. |
the ABI 15 combatibility is already there from what I can gather from looking at api.h file linked via tree-sitter(v0.25.5) as submodule in node-tree-sitter v0.25.0 release (this is why my patch works). The only problem is it does not have prebuild nodes which I think the PR is trying to address. Even if submodule in node-tree-sitter for trbump up the v0.25.5 to v0.25.9 for the tree-sitter in the node-tree-sitter submodule, it will still not break the abi there only some deprecation warnings and variable name change for now based of the diff file of api.h. (attached below) So overall should be fine though bumping upto the correct fix with prebuilt libraries would be ideal for later. (would just be patch version update for the tree-sitter in package-lock.json hopefully) < typedef uint32_t (*TSDecodeFunction)(
---
> typedef uint32_t (*DecodeFunction)(
60,62d59
< // Deprecated alias to be removed in ABI 16
< typedef TSDecodeFunction DecodeFunction;
<
93c90
< TSDecodeFunction decode;
---
> DecodeFunction decode;
302c299,308
< * 2. Parsing was cancelled due to the progress callback returning true. This callback
---
> * 2. Parsing was cancelled due to a timeout that was set by an earlier call to
> * the [`ts_parser_set_timeout_micros`] function. You can resume parsing from
> * where the parser left out by calling [`ts_parser_parse`] again with the
> * same arguments. Or you can start parsing from scratch by first calling
> * [`ts_parser_reset`].
> * 3. Parsing was cancelled using a cancellation flag that was set by an
> * earlier call to [`ts_parser_set_cancellation_flag`]. You can resume parsing
> * from where the parser left out by calling [`ts_parser_parse`] again with
> * the same arguments.
> * 4. Parsing was cancelled due to the progress callback returning true. This callback
360c366
< * If the parser previously failed because of the progress callback, then
---
> * If the parser previously failed because of a timeout or a cancellation, then
366a373,383
>
> /**
> * @deprecated use [`ts_parser_parse_with_options`] and pass in a callback instead, this will be removed in 0.26.
> *
> * Set the maximum duration in microseconds that parsing should be allowed to
> * take before halting.
> *
> * If parsing takes longer than this, it will halt early, returning NULL.
> * See [`ts_parser_parse`] for more information.
> */
> void ts_parser_set_timeout_micros(TSParser *self, uint64_t timeout_micros);
368a386,410
> * @deprecated use [`ts_parser_parse_with_options`] and pass in a callback instead, this will be removed in 0.26.
> *
> * Get the duration in microseconds that parsing is allowed to take.
> */
> uint64_t ts_parser_timeout_micros(const TSParser *self);
>
> /**
> * @deprecated use [`ts_parser_parse_with_options`] and pass in a callback instead, this will be removed in 0.26.
> *
> * Set the parser's current cancellation flag pointer.
> *
> * If a non-null pointer is assigned, then the parser will periodically read
> * from this pointer during parsing. If it reads a non-zero value, it will
> * halt early, returning NULL. See [`ts_parser_parse`] for more information.
> */
> void ts_parser_set_cancellation_flag(TSParser *self, const size_t *flag);
>
> /**
> * @deprecated use [`ts_parser_parse_with_options`] and pass in a callback instead, this will be removed in 0.26.
> *
> * Get the parser's current cancellation flag pointer.
> */
> const size_t *ts_parser_cancellation_flag(const TSParser *self);
>
> /**
1050a1093,1112
>
> /**
> * @deprecated use [`ts_query_cursor_exec_with_options`] and pass in a callback instead, this will be removed in 0.26.
> *
> * Set the maximum duration in microseconds that query execution should be allowed to
> * take before halting.
> *
> * If query execution takes longer than this, it will halt early, returning NULL.
> * See [`ts_query_cursor_next_match`] or [`ts_query_cursor_next_capture`] for more information.
> */
> void ts_query_cursor_set_timeout_micros(TSQueryCursor *self, uint64_t timeout_micros);
>
> /**
> * @deprecated use [`ts_query_cursor_exec_with_options`] and pass in a callback instead, this will be removed in 0.26.
> *
> * Get the duration in microseconds that query execution is allowed to take.
> *
> * This is set via [`ts_query_cursor_set_timeout_micros`].
> */
> uint64_t ts_query_cursor_timeout_micros(const TSQueryCursor *self);
1202a1265,1266
> * @deprecated use [`ts_language_abi_version`] instead, this will be removed in 0.26.
> *
1208a1273,1281
> uint32_t ts_language_version(const TSLanguage *self);
>
> /**
> * Get the ABI version number for this language. This version number is used
> * to ensure that languages were generated by a compatible version of
> * Tree-sitter.
> *
> * See also [`ts_parser_set_language`].
> */
1346c1419
< * Get the number of languages instantiated in the given Wasm store.
---
> * Get the number of languages instantiated in the given wasm store. |
Thanks a lot for your research and explanation! |
fixes #31.
Solved the .length problem when doing setlanguage in tree-sitter as mentioned in the links in node projects.
The CI was breaking so regenerated the grammar to pass the ci with the latest tree-sitter-cli version. (This might require a better soln for future, changes in workflows perhaps, as the diff b/w version of parser.c was just the comment but the CI still failed.)