* Implementing cuda-ts-mode
[not found] <v2a2js5ssoz7d3hquenaieubgmj263tz3ejbogordd5t3ys4v2.ref@efpjojlxrlv4>
@ 2024-07-23 12:38 ` Ergus
2024-07-25 7:42 ` Yuan Fu
0 siblings, 1 reply; 7+ messages in thread
From: Ergus @ 2024-07-23 12:38 UTC (permalink / raw)
To: emacs-devel
Hi:
After a while and looking that the ts modules are getting mature I was
planing to develop a `cuda-ts-mode'.
However after reading the documentation it is not totally clear to me
how to proceed in this specific case because cuda is a sort of
"extension" over C++, so I expect that the cuda-ts-mode somehow
"inherits" from c++-ts-mode.
My initial idea was to replicate how I was expecting that c++-ts-mode
should inherit from c-ts-mode, but it looks like this doesn't happen in
a clear way. The modes are threated as independent and there is a sort
of "mode" variable that is dynamically checked everywhere.
So the simple question is:
1. The approach of trying to inherit from c++-ts-mode is correct? (I mean,
is c++-ts-mode intended to be used like a "base" to inherit from?)
Some advise on this?
Thanks in advance,
Ergus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Implementing cuda-ts-mode
2024-07-23 12:38 ` Implementing cuda-ts-mode Ergus
@ 2024-07-25 7:42 ` Yuan Fu
2024-07-25 14:05 ` Ergus
2024-07-29 5:10 ` Björn Bidar
0 siblings, 2 replies; 7+ messages in thread
From: Yuan Fu @ 2024-07-25 7:42 UTC (permalink / raw)
To: Ergus; +Cc: emacs-devel
> On Jul 23, 2024, at 5:38 AM, Ergus <spacibba@aol.com> wrote:
>
> Hi:
>
> After a while and looking that the ts modules are getting mature I was
> planing to develop a `cuda-ts-mode'.
>
> However after reading the documentation it is not totally clear to me
> how to proceed in this specific case because cuda is a sort of
> "extension" over C++, so I expect that the cuda-ts-mode somehow
> "inherits" from c++-ts-mode.
>
> My initial idea was to replicate how I was expecting that c++-ts-mode
> should inherit from c-ts-mode, but it looks like this doesn't happen in
> a clear way. The modes are threated as independent and there is a sort
> of "mode" variable that is dynamically checked everywhere.
>
> So the simple question is:
>
> 1. The approach of trying to inherit from c++-ts-mode is correct? (I mean,
> is c++-ts-mode intended to be used like a "base" to inherit from?)
>
> Some advise on this?
IIUC, tree-sitter-cuda is a separate grammar that is extended from tree-sitter-cpp, right? Then inheriting c++-ts-mode won’t work since it’ll setup everything using the cpp grammar. You’d need to delete the cpp parser and add your cuda parser (doable), and change everything that refers to ‘cpp to ‘cuda (very hacky).
I guess we can add some map which tells Emacs to use the cuda grammar in place of cpp. Kind of like treesit-load-name-override-list but more dynamic.
Once we’re able to do that, you can define a new mode that derives from c++-ts-mode and expect all the setup in c++-ts-mode to work.
Yuan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Implementing cuda-ts-mode
2024-07-25 7:42 ` Yuan Fu
@ 2024-07-25 14:05 ` Ergus
2024-07-27 23:22 ` Yuan Fu
2024-07-29 5:10 ` Björn Bidar
1 sibling, 1 reply; 7+ messages in thread
From: Ergus @ 2024-07-25 14:05 UTC (permalink / raw)
To: Yuan Fu; +Cc: emacs-devel
On July 25, 2024 9:42:10 AM GMT+02:00, Yuan Fu <casouri@gmail.com> wrote:
>
>
>> On Jul 23, 2024, at 5:38 AM, Ergus <spacibba@aol.com> wrote:
>>
>> Hi:
>>
>> After a while and looking that the ts modules are getting mature I was
>> planing to develop a `cuda-ts-mode'.
>>
>> However after reading the documentation it is not totally clear to me
>> how to proceed in this specific case because cuda is a sort of
>> "extension" over C++, so I expect that the cuda-ts-mode somehow
>> "inherits" from c++-ts-mode.
>>
>> My initial idea was to replicate how I was expecting that c++-ts-mode
>> should inherit from c-ts-mode, but it looks like this doesn't happen in
>> a clear way. The modes are threated as independent and there is a sort
>> of "mode" variable that is dynamically checked everywhere.
>>
>> So the simple question is:
>>
>> 1. The approach of trying to inherit from c++-ts-mode is correct? (I mean,
>> is c++-ts-mode intended to be used like a "base" to inherit from?)
>>
>> Some advise on this?
>
>IIUC, tree-sitter-cuda is a separate grammar that is extended from tree-sitter-cpp, right? Then inheriting c++-ts-mode won’t work since it’ll setup everything using the cpp grammar. You’d need to delete the cpp parser and add your cuda parser (doable), and change everything that refers to ‘cpp to ‘cuda (very hacky).
>
>I guess we can add some map which tells Emacs to use the cuda grammar in place of cpp. Kind of like treesit-load-name-override-list but more dynamic.
>
>Once we’re able to do that, you can define a new mode that derives from c++-ts-mode and expect all the setup in c++-ts-mode to work.
>
>Yuan
Hi Yuan:
Now I understand why c++-ts-mode does not inherit from c-ts-mode. This sort of inheritance is natural considering how tree sitter works. So I am a bit surprised that nobody faced this before. I saw some derived modes changes a while ago and I thought that it was related to this.
The extra features that the Cuda grammar adds to c++ are actually not many, but some are important to not break the indentation.
<https://github.com/tree-sitter-grammars/tree-sitter-cuda/blob/master/grammar.js>
That's why, reimplementing the c++-ts-mode code substituting the entries seems as unnecessary and overkill to me. So I will wait for the new feature to be out before, then it will be more scalable and simple to do a Cuda-ts-mode.
Best,
Ergus
PD: Do you want me to open a bug report to keep track of this?
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Implementing cuda-ts-mode
2024-07-25 14:05 ` Ergus
@ 2024-07-27 23:22 ` Yuan Fu
2024-07-31 0:15 ` Yuan Fu
0 siblings, 1 reply; 7+ messages in thread
From: Yuan Fu @ 2024-07-27 23:22 UTC (permalink / raw)
To: Ergus; +Cc: emacs-devel
> On Jul 25, 2024, at 7:05 AM, Ergus <spacibba@aol.com> wrote:
>
>
>
> On July 25, 2024 9:42:10 AM GMT+02:00, Yuan Fu <casouri@gmail.com> wrote:
>>
>>
>>> On Jul 23, 2024, at 5:38 AM, Ergus <spacibba@aol.com> wrote:
>>>
>>> Hi:
>>>
>>> After a while and looking that the ts modules are getting mature I was
>>> planing to develop a `cuda-ts-mode'.
>>>
>>> However after reading the documentation it is not totally clear to me
>>> how to proceed in this specific case because cuda is a sort of
>>> "extension" over C++, so I expect that the cuda-ts-mode somehow
>>> "inherits" from c++-ts-mode.
>>>
>>> My initial idea was to replicate how I was expecting that c++-ts-mode
>>> should inherit from c-ts-mode, but it looks like this doesn't happen in
>>> a clear way. The modes are threated as independent and there is a sort
>>> of "mode" variable that is dynamically checked everywhere.
>>>
>>> So the simple question is:
>>>
>>> 1. The approach of trying to inherit from c++-ts-mode is correct? (I mean,
>>> is c++-ts-mode intended to be used like a "base" to inherit from?)
>>>
>>> Some advise on this?
>>
>> IIUC, tree-sitter-cuda is a separate grammar that is extended from tree-sitter-cpp, right? Then inheriting c++-ts-mode won’t work since it’ll setup everything using the cpp grammar. You’d need to delete the cpp parser and add your cuda parser (doable), and change everything that refers to ‘cpp to ‘cuda (very hacky).
>>
>> I guess we can add some map which tells Emacs to use the cuda grammar in place of cpp. Kind of like treesit-load-name-override-list but more dynamic.
>>
>> Once we’re able to do that, you can define a new mode that derives from c++-ts-mode and expect all the setup in c++-ts-mode to work.
>>
>> Yuan
>
> Hi Yuan:
>
> Now I understand why c++-ts-mode does not inherit from c-ts-mode. This sort of inheritance is natural considering how tree sitter works. So I am a bit surprised that nobody faced this before. I saw some derived modes changes a while ago and I thought that it was related to this.
>
> The extra features that the Cuda grammar adds to c++ are actually not many, but some are important to not break the indentation.
>
> <https://github.com/tree-sitter-grammars/tree-sitter-cuda/blob/master/grammar.js>
>
> That's why, reimplementing the c++-ts-mode code substituting the entries seems as unnecessary and overkill to me. So I will wait for the new feature to be out before, then it will be more scalable and simple to do a Cuda-ts-mode.
>
> Best,
> Ergus
>
> PD: Do you want me to open a bug report to keep track of this?
Yeah, that’ll be great. Thanks! I’ve implemented the feature; once you create a bug report I’ll push to master for you and others to try it out.
Yuan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Implementing cuda-ts-mode
2024-07-25 7:42 ` Yuan Fu
2024-07-25 14:05 ` Ergus
@ 2024-07-29 5:10 ` Björn Bidar
1 sibling, 0 replies; 7+ messages in thread
From: Björn Bidar @ 2024-07-29 5:10 UTC (permalink / raw)
To: Yuan Fu; +Cc: Ergus, emacs-devel
Yuan Fu <casouri@gmail.com> writes:
> I guess we can add some map which tells Emacs to use the cuda grammar in place of cpp. Kind of like treesit-load-name-override-list but more dynamic.
That would make sense. There are other such as examples where something
like this could be very useful such as for Typescript or QML grammar, both
inherit grammar from JavaScript grammar
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Implementing cuda-ts-mode
2024-07-27 23:22 ` Yuan Fu
@ 2024-07-31 0:15 ` Yuan Fu
2024-07-31 21:06 ` Ergus
0 siblings, 1 reply; 7+ messages in thread
From: Yuan Fu @ 2024-07-31 0:15 UTC (permalink / raw)
To: Ergus; +Cc: emacs-devel
> On Jul 27, 2024, at 4:22 PM, Yuan Fu <casouri@gmail.com> wrote:
>
>
>
>> On Jul 25, 2024, at 7:05 AM, Ergus <spacibba@aol.com> wrote:
>>
>>
>>
>> On July 25, 2024 9:42:10 AM GMT+02:00, Yuan Fu <casouri@gmail.com> wrote:
>>>
>>>
>>>> On Jul 23, 2024, at 5:38 AM, Ergus <spacibba@aol.com> wrote:
>>>>
>>>> Hi:
>>>>
>>>> After a while and looking that the ts modules are getting mature I was
>>>> planing to develop a `cuda-ts-mode'.
>>>>
>>>> However after reading the documentation it is not totally clear to me
>>>> how to proceed in this specific case because cuda is a sort of
>>>> "extension" over C++, so I expect that the cuda-ts-mode somehow
>>>> "inherits" from c++-ts-mode.
>>>>
>>>> My initial idea was to replicate how I was expecting that c++-ts-mode
>>>> should inherit from c-ts-mode, but it looks like this doesn't happen in
>>>> a clear way. The modes are threated as independent and there is a sort
>>>> of "mode" variable that is dynamically checked everywhere.
>>>>
>>>> So the simple question is:
>>>>
>>>> 1. The approach of trying to inherit from c++-ts-mode is correct? (I mean,
>>>> is c++-ts-mode intended to be used like a "base" to inherit from?)
>>>>
>>>> Some advise on this?
>>>
>>> IIUC, tree-sitter-cuda is a separate grammar that is extended from tree-sitter-cpp, right? Then inheriting c++-ts-mode won’t work since it’ll setup everything using the cpp grammar. You’d need to delete the cpp parser and add your cuda parser (doable), and change everything that refers to ‘cpp to ‘cuda (very hacky).
>>>
>>> I guess we can add some map which tells Emacs to use the cuda grammar in place of cpp. Kind of like treesit-load-name-override-list but more dynamic.
>>>
>>> Once we’re able to do that, you can define a new mode that derives from c++-ts-mode and expect all the setup in c++-ts-mode to work.
>>>
>>> Yuan
>>
>> Hi Yuan:
>>
>> Now I understand why c++-ts-mode does not inherit from c-ts-mode. This sort of inheritance is natural considering how tree sitter works. So I am a bit surprised that nobody faced this before. I saw some derived modes changes a while ago and I thought that it was related to this.
>>
>> The extra features that the Cuda grammar adds to c++ are actually not many, but some are important to not break the indentation.
>>
>> <https://github.com/tree-sitter-grammars/tree-sitter-cuda/blob/master/grammar.js>
>>
>> That's why, reimplementing the c++-ts-mode code substituting the entries seems as unnecessary and overkill to me. So I will wait for the new feature to be out before, then it will be more scalable and simple to do a Cuda-ts-mode.
>>
>> Best,
>> Ergus
>>
>> PD: Do you want me to open a bug report to keep track of this?
>
> Yeah, that’ll be great. Thanks! I’ve implemented the feature; once you create a bug report I’ll push to master for you and others to try it out.
I have some other stuff that I want to push. So I went ahead and created bug#72388 and pushed the new feature to master. Now there’s a treesit-language-remap-alist.
See if that works for you, and we can continue discussion in the bug report :-)
Yuan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Implementing cuda-ts-mode
2024-07-31 0:15 ` Yuan Fu
@ 2024-07-31 21:06 ` Ergus
0 siblings, 0 replies; 7+ messages in thread
From: Ergus @ 2024-07-31 21:06 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 3783 bytes --]
Hi Yuan:
Very thanks for taking care of this so quickly.
I actually tried to open the bug as you suggested a few days ago (and add a new message to 72263) but now just found that both messages failed to deliver.
Next week I will give it a first try to the cuda-ts-mode. Let's continue in the bug report then.
Thanks again,
Ergus
On July 31, 2024 2:15:00 AM GMT+02:00, Yuan Fu <casouri@gmail.com> wrote:
>
>
>> On Jul 27, 2024, at 4:22 PM, Yuan Fu <casouri@gmail.com> wrote:
>>
>>
>>
>>> On Jul 25, 2024, at 7:05 AM, Ergus <spacibba@aol.com> wrote:
>>>
>>>
>>>
>>> On July 25, 2024 9:42:10 AM GMT+02:00, Yuan Fu <casouri@gmail.com> wrote:
>>>>
>>>>
>>>>> On Jul 23, 2024, at 5:38 AM, Ergus <spacibba@aol.com> wrote:
>>>>>
>>>>> Hi:
>>>>>
>>>>> After a while and looking that the ts modules are getting mature I was
>>>>> planing to develop a `cuda-ts-mode'.
>>>>>
>>>>> However after reading the documentation it is not totally clear to me
>>>>> how to proceed in this specific case because cuda is a sort of
>>>>> "extension" over C++, so I expect that the cuda-ts-mode somehow
>>>>> "inherits" from c++-ts-mode.
>>>>>
>>>>> My initial idea was to replicate how I was expecting that c++-ts-mode
>>>>> should inherit from c-ts-mode, but it looks like this doesn't happen in
>>>>> a clear way. The modes are threated as independent and there is a sort
>>>>> of "mode" variable that is dynamically checked everywhere.
>>>>>
>>>>> So the simple question is:
>>>>>
>>>>> 1. The approach of trying to inherit from c++-ts-mode is correct? (I mean,
>>>>> is c++-ts-mode intended to be used like a "base" to inherit from?)
>>>>>
>>>>> Some advise on this?
>>>>
>>>> IIUC, tree-sitter-cuda is a separate grammar that is extended from tree-sitter-cpp, right? Then inheriting c++-ts-mode won’t work since it’ll setup everything using the cpp grammar. You’d need to delete the cpp parser and add your cuda parser (doable), and change everything that refers to ‘cpp to ‘cuda (very hacky).
>>>>
>>>> I guess we can add some map which tells Emacs to use the cuda grammar in place of cpp. Kind of like treesit-load-name-override-list but more dynamic.
>>>>
>>>> Once we’re able to do that, you can define a new mode that derives from c++-ts-mode and expect all the setup in c++-ts-mode to work.
>>>>
>>>> Yuan
>>>
>>> Hi Yuan:
>>>
>>> Now I understand why c++-ts-mode does not inherit from c-ts-mode. This sort of inheritance is natural considering how tree sitter works. So I am a bit surprised that nobody faced this before. I saw some derived modes changes a while ago and I thought that it was related to this.
>>>
>>> The extra features that the Cuda grammar adds to c++ are actually not many, but some are important to not break the indentation.
>>>
>>> <https://github.com/tree-sitter-grammars/tree-sitter-cuda/blob/master/grammar.js>
>>>
>>> That's why, reimplementing the c++-ts-mode code substituting the entries seems as unnecessary and overkill to me. So I will wait for the new feature to be out before, then it will be more scalable and simple to do a Cuda-ts-mode.
>>>
>>> Best,
>>> Ergus
>>>
>>> PD: Do you want me to open a bug report to keep track of this?
>>
>> Yeah, that’ll be great. Thanks! I’ve implemented the feature; once you create a bug report I’ll push to master for you and others to try it out.
>
>I have some other stuff that I want to push. So I went ahead and created bug#72388 and pushed the new feature to master. Now there’s a treesit-language-remap-alist.
>
>See if that works for you, and we can continue discussion in the bug report :-)
>
>Yuan
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
[-- Attachment #2: Type: text/html, Size: 4839 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-07-31 21:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <v2a2js5ssoz7d3hquenaieubgmj263tz3ejbogordd5t3ys4v2.ref@efpjojlxrlv4>
2024-07-23 12:38 ` Implementing cuda-ts-mode Ergus
2024-07-25 7:42 ` Yuan Fu
2024-07-25 14:05 ` Ergus
2024-07-27 23:22 ` Yuan Fu
2024-07-31 0:15 ` Yuan Fu
2024-07-31 21:06 ` Ergus
2024-07-29 5:10 ` Björn Bidar
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.