From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus Newsgroups: gmane.emacs.devel Subject: Re: Implementing cuda-ts-mode Date: Thu, 25 Jul 2024 16:05:31 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20720"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jul 25 16:06:36 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sWz74-0005CK-MD for ged-emacs-devel@m.gmane-mx.org; Thu, 25 Jul 2024 16:06:34 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWz6Q-0001R8-5N; Thu, 25 Jul 2024 10:05:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sWz6M-0001Ds-HV for emacs-devel@gnu.org; Thu, 25 Jul 2024 10:05:51 -0400 Original-Received: from sonic317-26.consmr.mail.bf2.yahoo.com ([74.6.129.81]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWz6K-0004UY-8D for emacs-devel@gnu.org; Thu, 25 Jul 2024 10:05:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1721916342; bh=CfQWQ7uXKqLtH2QU4NALs1Prrcf2XifcoODK0zW8VBI=; h=Date:From:To:CC:Subject:In-Reply-To:References:From:Subject:Reply-To; b=IBrQw506tog7SUBt3jNQ7Yu20jd4wqbApkFJi0izdfCWI3cA+egqZD4+1x0DL+AJvsadaI5tYR4SFKbnmVh88hI4iZryxqJw8IFsJcjhXorzzneIqCP4Hhpbna9dgfH1qa0M7/72IHdQH2cA8qBNH3s9lruHpA6cb6JUe1Cw/SMl8Kdso0id92ifG2NFKVLMsQKiGmO46Ujv47EsyIof1coRwIlA9wdFrgJ1SuG3c7O97OcCs0liHaBLRBLyQumac7DtXWJNV0yOh4tjbNexDA8M/We+Z7hkezKtZG1qod7LfbNiduBlt9eV3/rnCSm+98bzw15YJhPzz7y48pT/mw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1721916342; bh=VRs01/luR4gDrx6i/3iiul7cLfoX173+/dvov7gRBVm=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=Yb5WRmgsj9S5y/XBa3tzQX1BQkt7eDOT8z/ICoOhAAsaK5dqG4uSSBFJ9+9uAPADfD3cbJ3a18RAe1auqhvRC5cMw1rLFm4jMDZFgMEBagHBn4UTeCqzsPuzX1vkDK8Hs77bXAjO0nSU8YdXghA0xeGbzB94N4RERhLbf1T5WjeuPlDSDWrReO80JKsPkTTGidkOzsBq/q4n1Ibj2euyULnY2xUt9sycno6WPy+HshwpOwVzdFvqZa0+IkAXbzWXqL/Pbn80o57EF++hEoXmr7i+hChuSNCo5dWa09k+KJ+RyZEHCf7qpGUWjBL9em2jbMaT6qk/s3a6sg2vYrzsMA== X-YMail-OSG: k.cST.QVM1m.F7OXgFU8Kfi3c3vfUDSX.gSi0mPrPcBoI5jQf7kmLpMsMmEo9R3 C7L6viiSJ41D8L3as1QoEwDLfttrZFnEuzekihrcWS20gBLswIZrFm4LbEb3Fgn_8YjPaKD99_R3 wonCwXqW3DGrQeSGsbzqOStTX.ylsJ4n2KjL2YKslaefKBxTuIWEBVSYVvs.2vlZ6d0iA9B7_4HT MSq_PZ9n87T5Q.zCzHiYPRjLS6903Sw8WuII_03Ovb1AgXyOVpQzwU.AEPuOJ.Vttdf3hd2uuRww Nd_XqVLgPXxMNZUuMxgIkcNIluJ78qCs0mTujfHkhLM4mOIiEKxPUf1AyMyoLKHGAgvyefjMROhx gHv3pB2lAvQvfQPt3lqk4_qLc2zedOYKhJXoEUrs1_Jz3JJW3RyUJ.WwZUHEPVkpN3GQmGItV5I6 QKPLj9S_BLwtpA.v4Ji_sGa.EoGxlULbFOGZA3geYzk8xKx7eFeEK1QH4Hop4LhGHmsEcAaqPsJf slS_Pxy3BedXFiWTIQdoZOElJGNw18Mjoa7pbnnrmPGDWoWQkC55MhakZ65W2YvAnMIG2ZOB1YB9 ZD7UPHX4ih6bvea0dHLty03VNbO5ZgvhIOTbprmH1jGX8Z0x6CRoRTncT5.da4NTsIUt7peMkTKW Lz3TXxl4hqdH_YwtHTs.DpBF_KQu4_Dd6sUw_QZCDEWEO0uwCyKO_XeGYlPIFMULKf9qEDFPzhg0 6VIg_eeigo2YffOada2_v1pDvS9CXqWr7w7kqfyDfRYwmhoQPZQkUYopz.9Hfu8Sv7dDNBf3piYZ f6Y3LyUzC1KMJw_fJglIjnjzlAYFoIK6VR9K1RY0iv X-Sonic-MF: X-Sonic-ID: 20e96bb9-c6ab-4e72-82ad-1ce0c09412ad Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.bf2.yahoo.com with HTTP; Thu, 25 Jul 2024 14:05:42 +0000 Original-Received: by hermes--production-ir2-57d49df6b5-sgkzc (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 40ee4c6cb24171ab384e7e28efa304f4; Thu, 25 Jul 2024 14:05:40 +0000 (UTC) In-Reply-To: X-Mailer: WebService/1.1.22501 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Received-SPF: pass client-ip=74.6.129.81; envelope-from=spacibba@aol.com; helo=sonic317-26.consmr.mail.bf2.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:322086 Archived-At: On July 25, 2024 9:42:10 AM GMT+02:00, Yuan Fu wrote= : > > >> On Jul 23, 2024, at 5:38=E2=80=AFAM, Ergus wrote: >>=20 >> Hi: >>=20 >> After a while and looking that the ts modules are getting mature I was >> planing to develop a `cuda-ts-mode'=2E >>=20 >> 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=2E >>=20 >> 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=2E The modes are threated as independent and there is a sor= t >> of "mode" variable that is dynamically checked everywhere=2E >>=20 >> So the simple question is: >>=20 >> 1=2E 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?) >>=20 >> Some advise on this? > >IIUC, tree-sitter-cuda is a separate grammar that is extended from tree-s= itter-cpp, right? Then inheriting c++-ts-mode won=E2=80=99t work since it= =E2=80=99ll setup everything using the cpp grammar=2E You=E2=80=99d need to= delete the cpp parser and add your cuda parser (doable), and change everyt= hing that refers to =E2=80=98cpp to =E2=80=98cuda (very hacky)=2E > >I guess we can add some map which tells Emacs to use the cuda grammar in = place of cpp=2E Kind of like treesit-load-name-override-list but more dynam= ic=2E > >Once we=E2=80=99re able to do that, you can define a new mode that derive= s from c++-ts-mode and expect all the setup in c++-ts-mode to work=2E > >Yuan Hi Yuan: Now I understand why c++-ts-mode does not inherit from c-ts-mode=2E This s= ort of inheritance is natural considering how tree sitter works=2E So I am = a bit surprised that nobody faced this before=2E I saw some derived modes c= hanges a while ago and I thought that it was related to this=2E The extra features that the Cuda grammar adds to c++ are actually not many= , but some are important to not break the indentation=2E=20 That's why, reimplementing the c++-ts-mode code substituting the entries s= eems as unnecessary and overkill to me=2E So I will wait for the new featur= e to be out before, then it will be more scalable and simple to do a Cuda-t= s-mode=2E Best, Ergus PD: Do you want me to open a bug report to keep track of this? --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E