If you are able to make TS crash reproducibly with any class code, please post it here so we can investigate further. This is very interesting!
Will do - I’m hoping it’s just bc I’m using old code.
Make sure you are running tree-sitter version 0.20.7. I suspect this release fixed the segfaults
Hi @dyalan.
Thanks for you long and detailed notes about setting the beast up on emacs. Thanks to this I’ve running tree-sitter on my archlinux.
Just to add something, as for now this line is not recognized as correct (at least for my box)
(add-to-list 'tree-sitter-major-mode-language-alist '(sclang-mode . supercollider))
Instead of this, I’ve added:
(after! tree-sitter
(add-to-list 'tree-sitter-major-mode-language-alist
'(sclang-mode . supercollider)))
(use-package! tree-sitter-langs
:after tree-sitter
:config
;; Ensure SuperCollider grammar is loaded
(tree-sitter-require 'supercollider))
Did you make some new functionality for sclang in emacs with tree-siiter? Would you give me some clue, what it is good for?
best
Hi all.
Happy to announce that tree-sitter-supercollider has gotten some serious love recently and is now even more robust. A lot of work by bsssssss, thanks!
tree-sitter-supercollider is now able to parse almost anything from SuperCollider syntax (that said, I keep discovering new esoteric syntax goodies (see issues)).
For those using sclang-mode in Emacs 29.1 and above, here is an experimetal (especially the indentation) sclang-ts-mode implementing tree-sitter grammar based syntax highlighting (fontification) and indentation.
Many thanks to Mads K and the contributors!
Any feedback is very welcome!
Hey yo,
I’ve been hacking the ts grammar and opened this:
Some changes:
- makes method chains bind before any binary operator via
_primary→_postfix - adds List Comprehensions
- flattens all binary operators into one left-to-right precedence rule (which matches sclang)
- fixes named arguments (
name: value) - differentiates
{ … }code blocks and( … )groups
Currently, the branch has 16 small commits, making it easy to review changes incrementally.
Sharing a few more suggestions, this time also for scanner.c, to enhance clarity and speed. The scanner now handles low-level details within Treesitter’s grammar.
For instance, I’ve replaced conditionals and regular expression checks with lookup tables for whitespace and operators, enabling sort speed to be constant. The updated scanner effectively manages nested /* ... */ comments, maintaining comment depth and allowing graceful recovery from unclosed comments.
Additionally, a state machine is implemented to identify operators such as ++ and ->, as well as pattern-matching operators of 1 to 3 characters, rather than relying on string comparisons. It is faster and more convenient, since it can infer even new operators. The scanner utilizes a compact state representation (only two bytes) to track comment depth and array depth, enabling even smoother incremental parsing.
The code ended up being around 200 lines shorter. Glad to receive feedback, this is still experimental.
When cloning the repo I’m asked for a password:
git clone https://github.com/supercollider/tree-sitter-supercollider.git
Klone nach 'tree-sitter-supercollider' …
Username for 'https://github.com':
Cloning other repos works fine without any password.
You need to use ssh, I think ![]()