[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Questions about tree-sitter
From: |
BTuin |
Subject: |
Questions about tree-sitter |
Date: |
Tue, 29 Aug 2023 23:26:52 +0200 |
User-agent: |
Mozilla Thunderbird |
Hello,
I have a few questions about tree-sitter.
I'm currently developing a grammar for GNU Bison alongside a tree-sitter
major mode, it's a work in progress. The grammar is here:
<https://gitlab.com/btuin2/tree-sitter-bison>, still incomplete but so
far able to parse simple files, and the major mode prototype is
attached to this message.
So, the questions:
1. Is there a way to reload a grammar?
Emacs is pretty nice as a playground for testing grammars, but once a
grammar is loaded, it won't be loaded again until Emacs restarts (as far
as I know).
Is it possible to reload a grammar after modifying it?
2. How to mix multiple languages?
It would be very useful for Bison since its mixed with C or other languages.
According to the documentation I need to use the function
`treesit-range-rules` to set the variable `treesit-range-settings`, but
it seems to have no effect. The language in the selected nodes doesn't
change (as attested by `(treesit-language-at (point))`).
I did it that way (extracted from the attachment):
(setq-local treesit-range-settings
(treesit-range-rules
:embed 'c
:host 'bison
'((undelimited_code_block) @capture)))
Am I missing something?
3. Is it possible to trigger a hook when a node is modified?
Since Bison supports multiple languages (C, C++, Java and D), I'd like
to watch the declaration "%language LANGUAGE" to change the embedded
language when needed.
Is there a way to do that?
Thanks!
bison-ts-mode.el
Description: Text document
- Questions about tree-sitter,
BTuin <=