From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_Paulo_Labegalini_de_Carvalho?= Newsgroups: gmane.emacs.devel Subject: Re: Implementation direction for shell-script-mode with tree-sitter Date: Thu, 27 Oct 2022 08:22:00 -0600 Message-ID: References: <87mt9j1k50.fsf@yahoo.com> <87tu3q6q8m.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000003e0e805ec04de1d" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29726"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, Yuan Fu , Theodor Thornhill , Eli Zaretskii To: Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Oct 27 16:26:10 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 1oo3pg-0007Sh-SL for ged-emacs-devel@m.gmane-mx.org; Thu, 27 Oct 2022 16:26:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oo3ly-0007BW-5f; Thu, 27 Oct 2022 10:22:18 -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 1oo3lw-0007Ai-Hd for emacs-devel@gnu.org; Thu, 27 Oct 2022 10:22:16 -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 1oo3lu-0000HS-UB; Thu, 27 Oct 2022 10:22:16 -0400 Original-Received: by mail-oi1-x234.google.com with SMTP id s125so1732509oib.6; Thu, 27 Oct 2022 07:22:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=lpognTnY5dEQTsGcScqQUGst4DS93paHHTBbbdAtGhA=; b=FhQ8hlCELXL7EUpkpoiZM9eZ3YbMb01921umUyBJZISIlvTwcUKUJecu/tKjPQ3jWT xxYJNCxAs1BDZCATXQ0SToO5MhdTS9iHKiMi2bhByQk3KExa4rEiMuUAhH0nioo68kIM pYlI+IQSvBWhirL8SfPEQ0FJ+6wYIWNEBHw5jQkpKbbHbp2R7gYSh5ZElFxRzF1lBL79 YJdb1AD+kurIGwYkpnavJK+krmbKKMoyJR5YqGf/Rfi9mP4DD2yxfsYOO5yjxQET7G9g syNN70kRAXvDSmG+nUo4jXCw6aDh87/Rydi9JAhFKnLhbgXYKczIhtzmDKyrGD0asZEC egGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lpognTnY5dEQTsGcScqQUGst4DS93paHHTBbbdAtGhA=; b=eX6GemY89m4uv985rNoDCvpXvHGson9x5w4sawF1pSDakVEzt69pcIiPLptkblUHLM rL8M87RUDKnEpF5ZzJd8dITkn7B9RXMV0zNDy0hzUMrr4vHgLtuE/zz9mDQPEEZmaLVb EjN/kUeKtMz6ijWgRWw3oxqBzb5cS3kTMHgDuJ7r16RMhD+wHQtWb5CAwsq82khGDKOY D74HspxfndxCdB3bBbCdHSlbvBWYDaDEjqeom/HY3V+UqBHbOccoHz0KV2K3sqCoo9P1 w4Wg5YbO4nndkzP/0ShU6p2NFFZBSx2b4FZyjMH5EYVUz3COkmPzzsVKkFAcDL/zeuWB 9xzQ== X-Gm-Message-State: ACrzQf3R9gwE5YtHRn7g9K9Rp/a3ktFhdPLPqppJyERgCKPnVqJDSH8j htAZ7n94mqt0QfQ1HheqWFGT7LnWe73YLvX+0U8= X-Google-Smtp-Source: AMsMyM4dubOa1xDQgTBx4Ey+Kfzpqg9VLoPDs3FIpq78JvjFZicFUOrSd6YI8Nc6YCEtPOiGh0pRQJR3KOlO+li3qB4= X-Received: by 2002:a05:6808:e88:b0:351:2725:ed84 with SMTP id k8-20020a0568080e8800b003512725ed84mr4847803oil.17.1666880532372; Thu, 27 Oct 2022 07:22:12 -0700 (PDT) In-Reply-To: <87tu3q6q8m.fsf@yahoo.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::234; envelope-from=jaopaulolc@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, HTML_MESSAGE=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: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:298619 Archived-At: --00000000000003e0e805ec04de1d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > > Some shells, such as csh, are very syntactically different from > bash. > That should not be a problem for tree-sitter as, once the csh tree-sitter library is loaded, the queries will only match the particular keywords and built-in commands of csh. However, I am able to test other shell variants as there is no tree-sitter grammar for them. The only one I have access to is for bash, but as I said I am trying to keep the implementation as generic as possible so, once those grammars are available the effort to use them should be low. > So won't you end up, in effect, reproducing the existing font-lock code? > That seems to be the case for the keyword fontification generated from the `sh-font-lock-var*' variables. The only way I found to avoid this is to explicitly specify the same regex queries for fontification used currently in sh-mode in the tree-sitter queries. This will create duplication of data but avoids the undesirable duplication of font-lock code. --=20 Jo=C3=A3o Paulo L. de Carvalho Ph.D Computer Science | IC-UNICAMP | Campinas , SP - Brazil Postdoctoral Research Fellow | University of Alberta | Edmonton, AB - Canad= a joao.carvalho@ic.unicamp.br joao.carvalho@ualberta.ca --00000000000003e0e805ec04de1d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Some shells, such as csh, are very syntactically differe= nt from
bash.

That should not be a problem for = tree-sitter as, once the csh tree-sitter library is loaded, the queries wil= l only match the particular keywords and built-in commands of csh.

However, I am able to test other shell variants as there i= s no tree-sitter grammar for them. The only one I have access to is for bas= h, but as I said I am trying to keep the implementation as generic as=C2=A0= possible so, once those grammars are available the effort to use them shoul= d be low.
=C2=A0
So won't you end up, in effect, reproducing the existing font-lock code= ?

That seems to be the case for the ke= yword fontification generated from the `sh-font-lock-var*' variables. T= he only way I found to avoid this is to explicitly specify the same regex q= ueries for fontification used currently in sh-mode in the tree-sitter queri= es. This will create duplication=C2=A0of data but avoids the undesirable du= plication of font-lock code.

--
Jo=C3= =A3o Paulo L. de Carvalho
Ph.D Computer Science | =C2=A0IC-UNICAMP | Cam= pinas , SP - Brazil
Postdoctoral Research Fellow | University of Alberta= | Edmonton, AB - Canada
--00000000000003e0e805ec04de1d--