From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Implementing cuda-ts-mode Date: Thu, 25 Jul 2024 00:42:10 -0700 Message-ID: References: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) 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="2438"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Ergus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jul 25 09:43:11 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 1sWt82-0000Y3-Vw for ged-emacs-devel@m.gmane-mx.org; Thu, 25 Jul 2024 09:43:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWt7L-00083r-6D; Thu, 25 Jul 2024 03:42:27 -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 1sWt7K-00083g-3X for emacs-devel@gnu.org; Thu, 25 Jul 2024 03:42:26 -0400 Original-Received: from mail-oo1-xc31.google.com ([2607:f8b0:4864:20::c31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWt7I-0001bv-Gr for emacs-devel@gnu.org; Thu, 25 Jul 2024 03:42:25 -0400 Original-Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-5cce7626c87so340665eaf.2 for ; Thu, 25 Jul 2024 00:42:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721893342; x=1722498142; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=yQtxXxDuUCC1/DtdvxumZqwPPrS31sRS1UcVXKEBbrA=; b=jNJMZEPo1Z6M4U+79UqzNznedjjgLNq+Z9aQf8dXB3i0tTqfWoYh09KBOaiNk91wJl IFcpQPhVViknV6bS/UGqC0HK7WwfrkGtaTfhEJq8dB7xQzUqRP0iXd+jQVaan0axyYy8 8pjvvi6jH0gs6fEcrnmVhZ5F+cydJPlWwhFDYi/Y8WZ7AkKUybLoP9YbUSbUvDXH8/Ls zNWaO0eoc0VXuh651jKiaEoNA/lumt4A61TJgg/ZutME+e/AVlqpwic/mrvcN/0YgW7g fbj9j6PBDC4SbIqH24KB+9VbMj0N2eLA8OobGXnj03DbfBlXGQL8BprLkQT5HHjPcRsA uMyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721893342; x=1722498142; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yQtxXxDuUCC1/DtdvxumZqwPPrS31sRS1UcVXKEBbrA=; b=h7MjsKVLEZ/ORv5zTQqbAXqkL05FMfuE2xOHROhxDII1jQX9V4TJZMjgXC+wq0PAsZ NK01UU+x2dACDlOEEi/RDdiW6ExQ9x0dNF+v44gvgVcumPXeNpUBcOGRjiVZoJvhE2IV 4zadROFd+1AR4+ddO784KfcBc6hozz9T5HwlYHyVZpmmqVRpc0FGw5TxR4hnxy20srWt lY0JihfnErWOsF2a52943TSsatZ6FpJIfVhnPSMPuJYCTac4s3fXYYo2CqRBYB17+QJg 8csMeM4Zgb+oee2qYBs27yzL39FxaF5YwJuaGxSpVJMzPUJakC9heaZXcskLlupWUG36 ohiQ== X-Gm-Message-State: AOJu0Yx9ug/QYQqMmH6sCA6n9FoCQok0QWlDpCXBfOLlqcQkU7S84a4v /8zHsENvt5ggO6bOFLgefJSUZNQ0H0TeFYOev6X4v6OnTvMa3wPe X-Google-Smtp-Source: AGHT+IHXv/e3COesYVn3XiZm7jlyyFj2AekQTMe7uu9FJYQ1s+G456oe0qyAzMiINQDbj2WQL9HRHQ== X-Received: by 2002:a05:6358:5f03:b0:1aa:ac10:bfc7 with SMTP id e5c5f4694b2df-1acfb98bdcemr104193555d.30.1721893341771; Thu, 25 Jul 2024 00:42:21 -0700 (PDT) Original-Received: from smtpclient.apple ([2601:646:8f81:6120:f9a7:9274:d0c2:c842]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f9ec3d0esm681298a12.70.2024.07.25.00.42.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2024 00:42:21 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3774.600.62) Received-SPF: pass client-ip=2607:f8b0:4864:20::c31; envelope-from=casouri@gmail.com; helo=mail-oo1-xc31.google.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, 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:322072 Archived-At: > 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'. >=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. >=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. The modes are threated as independent and there is a sort > of "mode" variable that is dynamically checked everywhere. >=20 > So the simple question is: >=20 > 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?) >=20 > 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=E2=80=99t work = since it=E2=80=99ll setup everything using the cpp grammar. You=E2=80=99d = need to delete the cpp parser and add your cuda parser (doable), and = change everything that refers to =E2=80=98cpp to =E2=80=98cuda (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=E2=80=99re 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=