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: Sun, 24 Sep 2023 14:10:12 -0700 Message-ID: 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="28732"; 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 Sun Sep 24 23:11:16 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 1qkWNo-0007MT-Ou for ged-emacs-devel@m.gmane-mx.org; Sun, 24 Sep 2023 23:11:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qkWN4-0004C7-KV; Sun, 24 Sep 2023 17:10:30 -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 1qkWN3-0004Au-82 for emacs-devel@gnu.org; Sun, 24 Sep 2023 17:10:29 -0400 Original-Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qkWN1-0002SZ-E2 for emacs-devel@gnu.org; Sun, 24 Sep 2023 17:10:29 -0400 Original-Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3aca1543608so3529712b6e.0 for ; Sun, 24 Sep 2023 14:10:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695589825; x=1696194625; 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=L92Sy40nxQqD2I1A3gfGtBR9nBuAx+Q5ktqOBgGcKaI=; b=JK7d3d8wJWMHk7NmaZPAzu0imIRBtAnJGiQBC72q4CL6bqlP6racq0yup099/jktNE Mc8xyuNBCabjg/E5mZJkACirgmic+aSwY/ddvjxViIwP55fx8IjdTQhE9yEiaIqUZrd3 THzZpvUcFhHCicTfac7fGOWLpMB6rwIlbDIQMAXDR1nMtMlETfNHC/WPLXG/5mnUEduq 8i2wl3synW9CbDakzv3Ouq4xS7EY0qyRh33hLPG+1LRwa18H/+ZYfzjc3d3Z5ZU7Rtka ZoWW9qnf9Qdw07//629rmhNFL+G8+oB9mGKrGPBEwXYALZMTxZI6f4aTdJyCRyVfImWF qgmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695589825; x=1696194625; 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=L92Sy40nxQqD2I1A3gfGtBR9nBuAx+Q5ktqOBgGcKaI=; b=Fw38SwhFsbyRYxNR4a6Z4mZi+lKsa83vfwp49kRorXQBCHfkQwYPKYB/tqLqQDNJJt 6lKk6oy4Ha0yh8n9ShcsqwdMmEriCcAYw+uukv9oOxeS78ubTI84PVTp3I3RWkzW69vQ N6FI3SXxsRt6zPa8tOKGIEKX0Wsv7YQqZ9m0d1RFaa7N1gJQjTgRVAJzQkk5JJVHdMRh ax35ZMMWq92OCREgTTOfnaOZ4eSf3fUtUr8K9FEpaAiyT0yEktd6qAv0AJxQfCwmJSTN Y0OUsKFfPAJaOl7l2jVuakRJ2OeyvxbP1t7UoN4xU8JRU50D0TJ6wqdHtuTsncZyBrjH W+Ug== X-Gm-Message-State: AOJu0Yyh1W5J3EkTedEGrP9hqnVE9YdIZoA43z0SIc6eIoSP+7en47bW 2uu6trmPcmCf8HTxmnbxOZU= X-Google-Smtp-Source: AGHT+IETLvYc3kOKeGOXGhSLcycrn5k8VYSxm+uPVilEWCT8BShR30Il5FlQ5s11e/Im0GPjm8asmA== X-Received: by 2002:a05:6808:14d4:b0:3ae:237a:1338 with SMTP id f20-20020a05680814d400b003ae237a1338mr7531314oiw.1.1695589825329; Sun, 24 Sep 2023 14:10:25 -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 4-20020a17090a098400b00274a9f8e82asm9112499pjo.51.2023.09.24.14.10.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Sep 2023 14:10:24 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3731.700.6) Received-SPF: pass client-ip=2607:f8b0:4864:20::234; envelope-from=casouri@gmail.com; helo=mail-oi1-x234.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:311030 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. Actually, a second thought. IIUC the reason for this change is that = without these rules, no indentation is done for variable names in code = like static myttype * variable_name; static myttype variable_name; This is fine in normal C code, since no indentation is the same as zero indentation, which is what we want. But for C embedded in Bison, no indentation is not the same as zero indentation. We want it indent to the top-level indentation of the embedded C. E.g., { static myttype variable_name; } rather than { static myttype variable_name; } Right? In that case, we should really add a fallback indent rule for the = embedded c in bison, such that it indents to the top-level of the = embedded c. This is more robust than trying to cover all cases in the c = rules. Does that make sense? Basically, add something like (catch-all bison-ts-mode--bison-parent ,bison-ts-mode-indent-offset) To the end of C=E2=80=99s indent rules. Yuan=