From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: Call for volunteers: add tree-sitter support to major modes Date: Thu, 20 Oct 2022 08:19:28 +0800 Message-ID: <87czan8hyn.fsf@yahoo.com> References: <83czb1jrm3.fsf@gnu.org> <878rlo7on0.fsf@thornhill.no> <83k04y1gd2.fsf@gnu.org> <87wn8xbyr2.fsf@yahoo.com> <713135A0-FF74-43F5-969E-CECDF3C02DE6@gmail.com> <87sfjlbpw9.fsf@yahoo.com> <21B0931E-728E-4F17-8BC0-D8218BE65489@gnu.org> <87h701beqv.fsf@yahoo.com> <835ygh18w5.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27551"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org, casouri@gmail.com, acm@muc.de, theo@thornhill.no To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Oct 20 02:22:03 2022 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 1olJJy-0006zm-GA for ged-emacs-devel@m.gmane-mx.org; Thu, 20 Oct 2022 02:22:02 +0200 Original-Received: from localhost ([::1]:41956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olJJx-000121-7S for ged-emacs-devel@m.gmane-mx.org; Wed, 19 Oct 2022 20:22:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olJHm-00008c-EM for emacs-devel@gnu.org; Wed, 19 Oct 2022 20:19:46 -0400 Original-Received: from sonic310-25.consmr.mail.ne1.yahoo.com ([66.163.186.206]:41509) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olJHi-00024h-OV for emacs-devel@gnu.org; Wed, 19 Oct 2022 20:19:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1666225177; bh=qMQdExTxEaR6VuOgiGtssxOtLa4TfL/cawiEGulqwAQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=j99Gr5hsyN/Xgi7z1jI/MkGPvLqSIhJeZvVMXhLQ2r+py6iNHfi1oa+QykJuwdBRZRRxxZ1lYl2FhwFpqYduEZ4YbnUU9RHKoRLmUdlUw6GkKM8snYQ6qdv4kX5cQ6nAOXJCDQOkxsSHCQF3qXRDgbPTHfSjL7i+p+6xw+uz0xpVkqiubfXo3NYnMqnpa0XPT8hf50UOjItyN5MeZG55XYvZR9TvU2MQeTRENHR3mBgRI3jYHBzXlWH0HfjsuQIUvqYObphHAr+xzpTTVXq7iAbzAjElsTEX55+ImWm2V6vA9xLHgHpSfLLW6nZWSoKxkS7cKOf5BAvZl8KS36/PBw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1666225177; bh=uWBhaAH28zGlx8tlAdyCnuYwFSZgQS68nERow0mfMDO=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=O5YsGJqv8btWpAYgMRnGKHC6hZo6s5PhMUSOtR+W3TusCEZxrhtlbJvxUzNfB+F0zgyEO0HgWpYk2cVDRKqK5OQBben7mXlbJMn4OtkQ4+z9vqoUt5/DSwWCw4U+7ITRkN8pLmTmSzImW81nbrZspKPOrRJ+1sEokP4euuOJ9DNDlQ2x3rvSm6W3jHqWF83CtiubTh0ZtTPDBmC0mcAiR65zpWIPYHe5DjyCW2uu7SUGpAvbZ785WIV1vZl/bkqRTh04bwBZN7xtDB9jz8QfUT/79LFBCCfbaehxAcW9yyTiZb5hGLzrKSHg+w7e4q2YawNnudxddF+6/1LZGZrxYg== X-YMail-OSG: U4d9g50VM1nhLob3iK2Ar_X6rxJsexc8gQ._B8SE6QeKVV4aQXyvaKSTGx9RbZT b_9pqPnCsp7ypsK_inhigbWdUvu7g.hTFDWzYBx6gXa20AyhEiGsokgPIs.OFqQvPt30VQdcONZp qUalwJLVwfY_62b8nWY6OZQxnrvyMKpS5tDisnC5Q6hXatHUsK4JY6CTWQiMkiHjH_y9zJa.B27o 6pKOEWJnmowfWd6UYSwublLPhUkRx7RKFyhxIANTE9lfwuO61LNU2E2QEZBE931aghoiko0AVZaA CavEde8O4YC7hnjhELtADydctQzMdsP7h0UOcX.XSN7c_8owJqrPyYhYEc7f5o5FlAzcnTpyvw7n eJezvAfR7fTL1cWPDCAf1AhLWVbzQS5_tkwXaZIX.LRuT4lYuiuIRMzCNcv2ZWOTfboXk2hX5xvQ UrFX3susnXpsueimSs80gglwJhFgzgT_1XYlvfeSYLKMBqT9ZoqItBEca3PpKgzVG.ZGXVc8HIFz WHVd.qNUzsTYHRRMJMShoHS.AGRNg_gFpQ9eMM7AUcBxmCsTa_6EQ4LCtdM8dfFtizMMWKV7VWmQ kdKVQ2TktI4nPK1AZqyVMK8n0k.UZg7KMw73oCfr2OFfEuUROc_BG0DcpMF_ND13M5ODWFLquRFF 7IPp_yZ20zZbjtxX0Dg73ynCXjTohE8fQWC8QFvdb0ZV2lBELMeI9CBfAG_PE26O4kPQV5SVlq.W NESO6c18Eu1MI_U7mItdUKjYqjzbvKRX5vq0dCYZUPRwJvHPL5zkDlfPWHjtfNHza1fExs2qFbpO UcDJLlkqr268ZqecOXfV_Dt9JF.vZnDpAop9u.J1tj X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ne1.yahoo.com with HTTP; Thu, 20 Oct 2022 00:19:37 +0000 Original-Received: by hermes--production-sg3-74fb94585-7d79w (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 0d8fd3d7c9a779435f213204e079d4c8; Thu, 20 Oct 2022 00:19:33 +0000 (UTC) In-Reply-To: <835ygh18w5.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 18 Oct 2022 17:52:42 +0300") X-Mailer: WebService/1.1.20754 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.186.206; envelope-from=luangruo@yahoo.com; helo=sonic310-25.consmr.mail.ne1.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=unavailable 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" Xref: news.gmane.io gmane.emacs.devel:298129 Archived-At: Eli Zaretskii writes: > This part definitely isn't valid: > > extern maybe_tls (int) errno; > > $ gcc -c buggy_c.c > buggy_c.c: In function 'maybe_tls': > buggy_c.c:1:26: error: expected declaration specifiers before 'errno' > 1 | extern maybe_tls (int) errno; > | ^~~~~ > buggy_c.c:1:21: error: parameter name omitted > 1 | extern maybe_tls (int) errno; > | ^~~ > buggy_c.c:2: error: expected '{' at end of input Well, what if tree-sitter is given the following macro definition? # if !defined (LinkTargetKO) && !defined (__cc_lint__) # define maybe_tls(type) _task_local_/**/type # else # define maybe_tls(type) type # endif > And this: > > BEGIN_A_KIND_OF_SECTION ({ > ENTRY (dx, dy, shx, shy) > float dx, dy, shx, shy; > > if (!bar (other_function (dx, dy, shx, shy), > etc, etc, etc)) > die ("bar", sys_errlist[errno]); > }, register float, section_name); > > can only be valid C if BEGIN_A_KIND_OF_SECTION does something very > creative, like expands to nothing at all. So, for a fair discussion, > please show the macros used here, and let's see what does tree-sitter > do when it's shown the macros. This particular macro is a little too long for me to trim down into a form I'm actually allowed to send here. But what happens when tree-sitter is shown the other macro, maybe_tls? > Why is that "much worse" than what CC Mode does? Just yesterday I had > a perfectly valid C code where CC Mode was unable to fontify several > function calls correctly. I attach it below. You can see it > yourself: go to line 2000 in treesit.c of the feature/tree-stter > branch. Unlike many CC Mode bugs, this one isn't transient: killing > the buffer and revisiting the file reproduces the same problem. (This > problem seems to be solved in Emacs 29, btw. But I see its like > almost every day in other situations.) > > I'm quite sure CC Mode "succeeds" with your example of invalid C code > simply by sheer luck. And what's more important to me is that it > fails in much simpler, straightforward cases, where I wouldn't expect > any trouble at all. Trust me, I have my own bad experiences with CC Mode fontification. See the slew of bugs I found and reported with Emacs 29's CC Mode just this week: bug#58537, bug#58534, bug#58539. My problem is the blanket dismissal of what CC Mode actually gets right that seems to be alarmingly prevalent around here ("... in Emacs 30, let's get rid of CC Mode!") > The code you posted didn't include the definition of P_, so how do you > expect a parser to guess what it is? Include it in the code, and > let's see then what happens. # ifdef (__cc_check_protos__) # define _P(protos...) /**/protos # else # define _P(protos...) # endif > This is valid C? It is in this compiler (and C preprocessor), which has not seen major updates since 1994, and is yet still used by suits. > And after all that said, I'll trade CC Mode's fontifications for much > more performant C mode any day, even if the faster mode sometimes > errs. The CC Mode's performance is abysmally slow. > Here's the picture I promised: I agree that's bad, but so is the tree-sitter fontification of K&R areas. According to this ticket, tree-sitter currently doesn't support them at all: https://github.com/tree-sitter/tree-sitter-c/issues/75. At least there is work in that area, but it has not seen activity since Sept 2021.