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: New tree-sitter mode: bison-ts-mode Date: Fri, 22 Sep 2023 01:45:43 -0700 Message-ID: <43D0D3E5-C61C-4051-957F-8BA258074882@gmail.com> References: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) 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="7383"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel To: =?utf-8?B?IkF1Z3VzdGluIENow6luZWF1IChCVHVpbiki?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 22 10:47:14 2023 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 1qjbog-0001iB-7y for ged-emacs-devel@m.gmane-mx.org; Fri, 22 Sep 2023 10:47:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjbnc-0001JI-4l; Fri, 22 Sep 2023 04:46:08 -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 1qjbna-0001Iv-CO for emacs-devel@gnu.org; Fri, 22 Sep 2023 04:46:06 -0400 Original-Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qjbnR-0002HA-3D for emacs-devel@gnu.org; Fri, 22 Sep 2023 04:46:06 -0400 Original-Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c364fb8a4cso17152075ad.1 for ; Fri, 22 Sep 2023 01:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695372355; x=1695977155; 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=aF1WECUXtBz37pil5w2i4sF/m2W/SyB9qRQXMxTIcmk=; b=R3AWOldgV88Sxy/4Rpx3WdC3Y0Mbch8kVciqZd1Bp8ylrAMDDtmb3SLbf36J2b9ogz nCDyGgrdesx5irR7u0AB+8xjM61dIyXcugA22kjD7dgywJRC67uDXyH9o2R+M/S6XO/e 3a9z8M0UTMjAmUlhh90B+bHYJpNf11bNC2IlKKEcMIRZgy9h4kcFZmS9QEH17rc5df9v 7WE7vMV9d/6UfX5f6Yri2aucV2YFWYYV9Ew6zb2uX5+LXWkgGa6cxmAN+nsF0eNNcDSJ YO1XS+m3mPuQ6dxU2S3C6XJUJoCT0AieZBbYocjIGMrzR0d0IDNZRdTDxkg/bknJP1Cb 6nfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695372355; x=1695977155; 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=aF1WECUXtBz37pil5w2i4sF/m2W/SyB9qRQXMxTIcmk=; b=q6E8DfWOy+WIr/uEtTIgiMmiOwwPVZMdlNZ5iHy0PJsAylB7iU6qXP3wLkm7JuhmUg zqsQuvUBsTZ9WVJ4+0w5QjdnoMJUf5f1wFTs48MZnQ6FVzuIh+tI6oX3BPxX+A91uocj CIKDSrnh202w1c3rXGPIE80Cf96IiV2hR+4QXnv/cHzCx3Otl0jLMX1tONn3L9PKDJ+m URWoHJG7TZC3iggwNu15cNODTl6RKwvvozqIgAOZwdwUXmvnsvLabIGwKowkKd/L4fL9 +NQNzi91RhTDEFfVNOJaIlyZd1Dr+tS+zf0Mmmi/8sdLgRLbXv/X+7jGK6GYUW33VzS+ q3rw== X-Gm-Message-State: AOJu0YyP1ayvhXGsJCyCnkZoc/DoSRikYQ59WjOhdqNx/oWmKYaZEUmF 4BsVz63Cmx53DTdZXU579GI78qi/Tm8= X-Google-Smtp-Source: AGHT+IH/8sn8obKdrJWRsZ54pXa0TUDRBTZDYLTPdUzE8lECv0TQ0STHpYLGHgrQCGtk5qx5Zofuug== X-Received: by 2002:a17:903:24e:b0:1bc:6799:3f6c with SMTP id j14-20020a170903024e00b001bc67993f6cmr9142488plh.35.1695372355276; Fri, 22 Sep 2023 01:45:55 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id jk12-20020a170903330c00b001bc930d4517sm2915431plb.42.2023.09.22.01.45.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2023 01:45:54 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3731.700.6) Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=casouri@gmail.com; helo=mail-pl1-x633.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:310943 Archived-At: > On Sep 21, 2023, at 1:15 PM, Augustin Ch=C3=A9neau (BTuin) = wrote: >=20 > Hello, > I'd like to propose a new tree-sitter mode for Emacs, bison-ts-mode. > This is a major mode for GNU Bison grammar files, and it supports the = embedded languages C, C++ and Java. Bison also supports D, but this = language is not yet supported in Emacs so this mode does not support it = either. >=20 > Since Bison is a superset of Yacc, it should work with Yacc without = modification. > The grammar is available here: = >=20 > This mode auto-detects the embedded language in the file if the = directive "%language" is set. >=20 >=20 > In addition of the mode, three patches are joined (should I open a bug = report for those?). >=20 >=20 > The first one is to add some missing rules in c-ts-mode. Currently = there is no rule if an identifier in a declaration is on a new line. > In these two cases, "variable_name" is not indented: >=20 > static myttype * > variable_name; >=20 > static myttype > variable_name; >=20 > The new behavior is the same as c-mode. >=20 >=20 >=20 > The second one fix an edge case with multiple languages indentation. = Here is a simple example: >=20 > // language_A > { > // language_B > } > // language_A >=20 >=20 > Here, brackets are managed by language_A, but everything inside is = managed by language_B. Meaning that if the pointer is at the beginning = of the third line (with the closing bracket), it will use language_B's = indent rules. But if the point is located on the bracket, it will use = language_A's rules. >=20 >=20 >=20 > The third patch simply extracts java-ts-mode's feature list in a = variable, to allow to reuse it. >=20 >=20 > Huge thanks to Yuan Fu for his help and his amazing work with = tree-sitter. Thanks! For now, I think we can just use the same feature names for different = languages (so no need for prefixes anymore). That way, enabling a = feature in the feature list would enable it for all languages. If a user = desires more fine-grained control, they can use = treesit-recompute-feature to enable/disable features for a particular = language. (I upgraded that function in 04fd8b173bd) Yuan=