From unknown Fri Aug 15 15:28:35 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#72691 <72691@debbugs.gnu.org> To: bug#72691 <72691@debbugs.gnu.org> Subject: Status: Recursive descent in treesiter parse tree Reply-To: bug#72691 <72691@debbugs.gnu.org> Date: Fri, 15 Aug 2025 22:28:35 +0000 retitle 72691 Recursive descent in treesiter parse tree reassign 72691 emacs submitter 72691 Pranshu Sharma severity 72691 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 18 03:35:14 2024 Received: (at submit) by debbugs.gnu.org; 18 Aug 2024 07:35:15 +0000 Received: from localhost ([127.0.0.1]:55352 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfaRW-0005Ff-FL for submit@debbugs.gnu.org; Sun, 18 Aug 2024 03:35:14 -0400 Received: from lists.gnu.org ([209.51.188.17]:33496) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfXzQ-0000VM-UF for submit@debbugs.gnu.org; Sun, 18 Aug 2024 00:58:05 -0400 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 1sfXym-0007le-Ru for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2024 00:57:24 -0400 Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sfXyl-00020N-7p for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2024 00:57:24 -0400 Received: by mail-qv1-xf2f.google.com with SMTP id 6a1803df08f44-6bf6606363fso19285956d6.3 for ; Sat, 17 Aug 2024 21:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723957042; x=1724561842; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=Y+avsQXNuHzCcHrDwbnmpzAkj3nnprKUuzKSOIuGx+A=; b=f0bHHyf5t0ZQwTjXiTYGUKtuYKBu0VhVpL3g8j2Q8gy8415fjQZ8B8eLxPhm6KIQCl 46TPP1emsrXaQVWPQgn45pzKwuYwIziFeYJYPTp6aiHNpmzo6PiOOPsYq/GML5vpMe7l zBTSe5gN5PpEAXRIdgD3JIGwVttGrrxEUfZaCkl2jSN9cA6G5EnPE8J0xnQFUyx2bL1N R2uwxhVZVuiNkVd1t5OPtG2SbDqfTleUwuFCDCCDWOdsqYry//H0YFeoWUe5HevW3KrB TnP5vqD/0oKM4fqhOaLkf0/l/XcUKT7EvHPL9JDtIsSlSNY6LxcMiCNjvyOPK5AdkltJ Iwlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723957042; x=1724561842; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Y+avsQXNuHzCcHrDwbnmpzAkj3nnprKUuzKSOIuGx+A=; b=e83PUd8e6aU3ANHlEx5lL37mLW90D8h/t0iefXZBgWuujR+6zWcwuGdciS1wNKlZ7/ rL9sLaudOaVQTeAABNaTHQgE1l22GxdqcjNoPvyDhcTkKaxr+PG5uehh+6L48kaz6XhN 9eFO73ldT/12/nSqx57ojSx+JVyV3+4fNftUP05Nm+gipsSUWWKQApD2hZC2bUqm4Aja vS8deAeGiTwFXl00DJyBNTJ0sloUS9ulr7zw3xveOKxPCF2eH/oHFhGyOzbcep9dIxvd ZU6kYIgoAx5qVW6s4DwivPnDiSGn+O/Z/78ZAFcoidqR+1Zj/o8C5La6zRyF8Ll0+wXA q+Bg== X-Gm-Message-State: AOJu0YzmxNePziKXD4KMWLBAivZq+0Vytbt0MbZ3D3OlLNqyevdsj9w2 8CHKls4peIaN7HCbCV1VqAXM6SqBIp/67uWIXeUb2EuXaUrky0wWUfvQRchNEDxHYTJ08Zmb19x asL346LnxTyirCgVi2ice/66aL5LBmr6S X-Google-Smtp-Source: AGHT+IE9F0vpqGnIeBN7Wyk+thC+iiv3DiAJi+v0RaoEeGuULT9jyPdQXcd6UYgAJT4H/OByj1PZBUUaVmIc+hnrVQ4= X-Received: by 2002:a05:6214:3d0c:b0:6bd:8264:be8b with SMTP id 6a1803df08f44-6bf7ce6ac4dmr61457736d6.37.1723957041722; Sat, 17 Aug 2024 21:57:21 -0700 (PDT) MIME-Version: 1.0 From: Pranshu Sharma Date: Sun, 18 Aug 2024 14:57:10 +1000 Message-ID: Subject: Recursive descent in treesiter parse tree To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary="0000000000001479ff061fee079e" Received-SPF: pass client-ip=2607:f8b0:4864:20::f2f; envelope-from=pranshusharma198@gmail.com; helo=mail-qv1-xf2f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sun, 18 Aug 2024 03:35:13 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) --0000000000001479ff061fee079e Content-Type: text/plain; charset="UTF-8" Hello all, I am trying to write a major mode in which all instances of a node in another matched node. For this, recursion is needed, and for that it is necessary to store a match in a variable: Say I want to highlight all instances of (x) that are inside y in the following parse tree, where bolded means I want to match: (x) in (q (y (*x*) (l (*x*) (l (*x*) (p))) (x)) "(y) @test @test . (_) @font-lock-variable-name-face" "(y) @test (@test . (_) @font-lock-variable-name-face)" "(y) @test (test . (_) @font-lock-variable-name-face)" All of the above fail, which leads me to think that @test stores the text instead of the tree. In this case, how would I recursively match all instances of --0000000000001479ff061fee079e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello all,

I am trying to write a major= mode in which all instances of a node in another=C2=A0matched node. For th= is, recursion is needed, and for that it is necessary=C2=A0to store a match= in a variable:
Say I want to highlight all instances of (x) that= are inside y in the following parse tree, where bolded means I want to mat= ch:
(x) in (q (y (x) (l (x) (l (x) (p))) (x)= )

"(y) @test
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 @test . (_) @font-lock-variable-name-face"
"(y) @te= st
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (@test . (_) @font-lock-variable-name-fac= e)"
"(y) @test
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (test= . (_) @font-lock-variable-name-face)"

All of= the above fail, which leads me to think that=C2=A0@test stores the text in= stead of the tree. In this case, how would I recursively match all instance= s of=C2=A0
--0000000000001479ff061fee079e-- From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 18 05:25:16 2024 Received: (at 72691) by debbugs.gnu.org; 18 Aug 2024 09:25:16 +0000 Received: from localhost ([127.0.0.1]:55430 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfcA0-0008Fc-D2 for submit@debbugs.gnu.org; Sun, 18 Aug 2024 05:25:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45962) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfc9y-0008FO-TX for 72691@debbugs.gnu.org; Sun, 18 Aug 2024 05:25:15 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sfc9F-0008P7-Gb; Sun, 18 Aug 2024 05:24:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=VrmP5Req9mwLaeeKDEdhkfB1ER3WTWPJzx2o5eB5vLQ=; b=ZnsZXlvJiQja te1XDWRp8YFvEUPMFwOlbaleVoq0KPQq9tvXYLad/0xCLXCv16BdhkJOuCgQfjzUz86WZNDW+Dob0 on8Pby4IoGfXWfN+AORRQaKhHL98LydFqBeG3yNRpKUWX972wyJBrMb1sJJ+i/o1SJ4mpGQ5pYJTs kN1BtxCLvenPTNVb5qltaUQAKDWbTxSw6av9Q+sm5vDxGshy5WnWppK8lkq578SOZ/nKvuNm+5ZP4 K4GM5pV4IRPS4V/CyIDL4uWvPAfrm95zWfhK6MEb/88dWokgZELxbOG+T6+yE9Q0WwgG3lCazeALR JrPSPOFQfo9i+do23cwckg==; Date: Sun, 18 Aug 2024 12:24:26 +0300 Message-Id: <86y14uyyid.fsf@gnu.org> From: Eli Zaretskii To: Pranshu Sharma , Yuan Fu In-Reply-To: (message from Pranshu Sharma on Sun, 18 Aug 2024 14:57:10 +1000) Subject: Re: bug#72691: Recursive descent in treesiter parse tree References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 72691 Cc: 72691@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Pranshu Sharma > Date: Sun, 18 Aug 2024 14:57:10 +1000 > > I am trying to write a major mode in which all instances of a node in another matched node. For this, recursion > is needed, and for that it is necessary to store a match in a variable: > Say I want to highlight all instances of (x) that are inside y in the following parse tree, where bolded means I > want to match: > (x) in (q (y (x) (l (x) (l (x) (p))) (x)) > > "(y) @test > @test . (_) @font-lock-variable-name-face" > "(y) @test > (@test . (_) @font-lock-variable-name-face)" > "(y) @test > (test . (_) @font-lock-variable-name-face)" > > All of the above fail, which leads me to think that @test stores the text instead of the tree. In this case, how > would I recursively match all instances of Adding Yuan. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 18 11:33:57 2024 Received: (at 72691) by debbugs.gnu.org; 18 Aug 2024 15:33:57 +0000 Received: from localhost ([127.0.0.1]:56503 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfhum-0001iE-Iq for submit@debbugs.gnu.org; Sun, 18 Aug 2024 11:33:57 -0400 Received: from mail-oo1-f45.google.com ([209.85.161.45]:54720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfhNm-0000bU-OE for 72691@debbugs.gnu.org; Sun, 18 Aug 2024 10:59:51 -0400 Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-5d59e491fefso1817946eaf.1 for <72691@debbugs.gnu.org>; Sun, 18 Aug 2024 07:59:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723993084; x=1724597884; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=iNgg5CyFg7JF+vCdILvo68+eNL6eWTI4PBaAEl2O5YU=; b=iRX0HaEtQadTWXV2Uo7iaVDNCTSqsOHjRJ6CMfLAq0SSM6rt8Xm3bbaJLRxok+1AaG Bpt0oFiNTSDI+oZB5zwPfiHLv7wBOIub5cjWJngZNg/LN9b+F0OsKSUheeMc4+4tPkbq aiUgMKvPukN8+I1meRTi+79Alcwjy5l+qf4Z4KJ3wQ8XbiM+JtGZPOfhPspmjs1IQTYC E8MahZ05Pfz2G1vYuaj7G6Mks5IfX0jmdPzhHarqVgQP9WeGIunsPt8paBe4sF9GmvNW /Oprzc2zxRaB+h+0sdbS5hnoyvHvd7qjJBQbjANcpIIv6imCumRKIJLZ7XECVnc7Oi7y vKbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723993084; x=1724597884; 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=iNgg5CyFg7JF+vCdILvo68+eNL6eWTI4PBaAEl2O5YU=; b=IbDD39asnSRk6+daTMwy8FXfuioQho1Q9OpTLdlTevfQjbnyXDuj95Mk9peTkbyO/n ot9wYRUtWsSX0o1CbScF+uVurhOZTF96BwmaaWIs7r4NxaP60wrpaoo10VuIz/2eHHu7 Ou/1NdCwArF80oSUKIdmBhhDuTG+iuG535hb3Rspj0xn2yWxflmz5MtIpxjSVfdnq+pV nDAhyEZYGN2FvVMqudtbuCJWgcH+kSDFtMVpyLnD3pMIlzrsATbwBL/3GeEdArWHSLWU v1lOgvfFmQiursFata1/W+HDnS+0Yp7iEp4SuZqUpfK3MtwVToUCeKEmIhixmy4TWWYu zWkw== X-Forwarded-Encrypted: i=1; AJvYcCVNFG4ZpNDdY1/0mtf3Yn0OVZKj5sOMHW7LTBqLrphOTLsKilzDbtqJYGmYxYtc4P6EYavQh6ws3pWJ/egIyyeTJ6S2Fyw= X-Gm-Message-State: AOJu0YwFhZRKxxnX1nv1iksXFTvW121ofMFZAucoMf7/77+CUmOWVQaR MM45rgHfYTZPj8PRDxv+8Yf2JAlS3gF9H2oT3FgdNsmF0NxzncsngiVDBoXOW4zJMBMtLxyWHAd 3xMSnsInnXaT8CyMExt7RE1GIDOo= X-Google-Smtp-Source: AGHT+IHTtdoUb6WiKzNSVjYX5jw7MdYpFDf/pZ+KKZvesvjRtlgWGxlTDLVLPFDYvhG6MubKa1dPGTqjhzFyJ9Oa6bs= X-Received: by 2002:a05:6358:431f:b0:1a2:598a:452e with SMTP id e5c5f4694b2df-1b393103546mr608161955d.1.1723993084295; Sun, 18 Aug 2024 07:58:04 -0700 (PDT) MIME-Version: 1.0 References: <86y14uyyid.fsf@gnu.org> In-Reply-To: <86y14uyyid.fsf@gnu.org> From: Pranshu Sharma Date: Mon, 19 Aug 2024 00:57:54 +1000 Message-ID: Subject: Re: bug#72691: Recursive descent in treesiter parse tree To: Eli Zaretskii Content-Type: multipart/alternative; boundary="00000000000062841b061ff66ba9" X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 72691 X-Mailman-Approved-At: Sun, 18 Aug 2024 11:33:53 -0400 Cc: Yuan Fu , 72691@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --00000000000062841b061ff66ba9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Ok, I found the solution: you have to capture witha function and traverse the whole tree recursively On Sun, 18 Aug 2024, 7:24=E2=80=AFpm Eli Zaretskii, wrote: > > From: Pranshu Sharma > > Date: Sun, 18 Aug 2024 14:57:10 +1000 > > > > I am trying to write a major mode in which all instances of a node in > another matched node. For this, recursion > > is needed, and for that it is necessary to store a match in a variable: > > Say I want to highlight all instances of (x) that are inside y in the > following parse tree, where bolded means I > > want to match: > > (x) in (q (y (x) (l (x) (l (x) (p))) (x)) > > > > "(y) @test > > @test . (_) @font-lock-variable-name-face" > > "(y) @test > > (@test . (_) @font-lock-variable-name-face)" > > "(y) @test > > (test . (_) @font-lock-variable-name-face)" > > > > All of the above fail, which leads me to think that @test stores the > text instead of the tree. In this case, how > > would I recursively match all instances of > > Adding Yuan. > --00000000000062841b061ff66ba9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Ok, I found the solution: you have to capture=C2=A0 witha fu= nction and traverse the whole tree recursively


On Sun= , 18 Aug 2024, 7:24=E2=80=AFpm Eli Zaretskii, <eliz@gnu.org> wrote:
= > From: Pranshu Sharma <pranshusharma198@gmail.com> > Date: Sun, 18 Aug 2024 14:57:10 +1000
>
> I am trying to write a major mode in which all instances of a node in = another matched node. For this, recursion
> is needed, and for that it is necessary to store a match in a variable= :
> Say I want to highlight all instances of (x) that are inside y in the = following parse tree, where bolded means I
> want to match:
> (x) in (q (y (x) (l (x) (l (x) (p))) (x))
>
> "(y) @test
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0@test . (_) @font-lock-variable-name-= face"
> "(y) @test
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(@test . (_) @font-lock-variable-name= -face)"
> "(y) @test
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(test . (_) @font-lock-variable-name-= face)"
>
> All of the above fail, which leads me to think that @test stores the t= ext instead of the tree. In this case, how
> would I recursively match all instances of

Adding Yuan.
--00000000000062841b061ff66ba9-- From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 19 23:40:19 2024 Received: (at 72691) by debbugs.gnu.org; 20 Aug 2024 03:40:19 +0000 Received: from localhost ([127.0.0.1]:59523 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sgFjH-0002hV-Gm for submit@debbugs.gnu.org; Mon, 19 Aug 2024 23:40:19 -0400 Received: from mail-pl1-f169.google.com ([209.85.214.169]:48296) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sgFjF-0002hG-9f for 72691@debbugs.gnu.org; Mon, 19 Aug 2024 23:40:17 -0400 Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-201df0b2df4so38601735ad.0 for <72691@debbugs.gnu.org>; Mon, 19 Aug 2024 20:39:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724125109; x=1724729909; darn=debbugs.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=wYaqKuroLEDoHEq8FQi11XXCI1wWnmcQ7SOWlOgnzjQ=; b=RssJ99rv/TXtpztEzofEan1yTH+LfUVH5NO0OchoJol3EVi3pfYyruIFTHXLVKs1q+ azmXDGPJm+9B7ZGrwO53dNW5vbhUKQjZ8Nfql0mg2zJpTHuJmd5z3UEF1asNOOLojON1 PXPglCAUO/aMslIUqnEP7+nLAJSzgvTO8/344bwuE9pjr+sX2bSShoP0QXP8YwKTq8Ro 0a86Yp6BrduZE2yVv37lm2rz2EFwhPbhBLAgEcuLLWVXSbCVHlf0VWl13PtjnD0Bn8E2 Ug9uwigEAZ8/7MWe6FZaYd+LCrST6yKrf181wIs0v5FLh2sviaSrdzfofTvyG2W9TD7T zcGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724125109; x=1724729909; 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=wYaqKuroLEDoHEq8FQi11XXCI1wWnmcQ7SOWlOgnzjQ=; b=PpXdoutYLEwyGMz+byk4Jpi7/s+POe3/Em+e/omFMizWcfV/ZySF2bzQRge5gFNEuY IieyeF0fNe7Oc40jS059pfm7wHxosGyJi9WqOryGTcL2LLozmUJ4ZuUseo3bYknpexut Ub8rbod4EGyHRUvlbiXgi1vSVpqowDMsRMc4xWvC9aqxdkClgiaNgeBIzFsYjJIGXpWn G699lsr6IC/3sv42SxFRrQ8tEn69fL4tEdJHI+MN3xaoKSYmW83ehwpMmSF28B0aFv/N 2+aDylhIFk0tbqacRy0TOH5+VZPUqigKgx4KofbBEfSK3xi98kOjcW3t0bLmA5okdUj0 y6lA== X-Forwarded-Encrypted: i=1; AJvYcCUi1xnBa/tWJYpQzK6/e4P6toe57WsMRpalvd2eiZJvhBbHCvrIEX8Aq0QtQVPmI5G82p2Daajd0+W4q2SXPDwa/ZE1GB8= X-Gm-Message-State: AOJu0YzLMYEMYDm0OKdt3PPRKywvev3Jie/6p97WTmKjWbEDE2N6Qgbf WnT3Z5RXbdiZ0l0zj0zJ07raM0iRfcHWTympKIdASryZNkIDJe0z X-Google-Smtp-Source: AGHT+IGPxunu3xSavV6ETsm0Cbi5gH02E6UVzGVHwJ0iLYycuHl4JEOUM8b4ChvSabgBoquQDaxmkw== X-Received: by 2002:a17:902:e74b:b0:202:35a8:42 with SMTP id d9443c01a7336-20235a8015bmr89181295ad.49.1724125108680; Mon, 19 Aug 2024 20:38:28 -0700 (PDT) Received: from smtpclient.apple ([2601:646:8f81:6120:edc4:5dff:2f35:3b4a]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201f039ef06sm69219465ad.249.2024.08.19.20.38.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Aug 2024 20:38:28 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: bug#72691: Recursive descent in treesiter parse tree From: Yuan Fu In-Reply-To: Date: Mon, 19 Aug 2024 20:38:16 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: References: <86y14uyyid.fsf@gnu.org> To: Pranshu Sharma X-Mailer: Apple Mail (2.3774.600.62) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 72691 Cc: Eli Zaretskii , 72691@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Aug 18, 2024, at 7:57=E2=80=AFAM, Pranshu Sharma = wrote: >=20 > Ok, I found the solution: you have to capture witha function and = traverse the whole tree recursively As you=E2=80=99ve found out, tree-sitter=E2=80=99s query system = doesn=E2=80=99t support the feature you want (it=E2=80=99ll be quite = expensive to implement, I think). Even if you=E2=80=99ve found a = solution, if you want, maybe you can describe your actual use-case and I = can check if your solution is the most optimal. Yuan >=20 > On Sun, 18 Aug 2024, 7:24=E2=80=AFpm Eli Zaretskii, = wrote: > > From: Pranshu Sharma > > Date: Sun, 18 Aug 2024 14:57:10 +1000 > >=20 > > I am trying to write a major mode in which all instances of a node = in another matched node. For this, recursion > > is needed, and for that it is necessary to store a match in a = variable: > > Say I want to highlight all instances of (x) that are inside y in = the following parse tree, where bolded means I > > want to match: > > (x) in (q (y (x) (l (x) (l (x) (p))) (x)) > >=20 > > "(y) @test > > @test . (_) @font-lock-variable-name-face" > > "(y) @test > > (@test . (_) @font-lock-variable-name-face)" > > "(y) @test > > (test . (_) @font-lock-variable-name-face)" > >=20 > > All of the above fail, which leads me to think that @test stores the = text instead of the tree. In this case, how > > would I recursively match all instances of=20 >=20 > Adding Yuan. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 31 04:13:30 2024 Received: (at 72691-done) by debbugs.gnu.org; 31 Aug 2024 08:13:31 +0000 Received: from localhost ([127.0.0.1]:53889 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1skJEg-0006aX-HI for submit@debbugs.gnu.org; Sat, 31 Aug 2024 04:13:30 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38100) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1skJEe-0006aE-Qu for 72691-done@debbugs.gnu.org; Sat, 31 Aug 2024 04:13:29 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1skJDd-0007cH-NC; Sat, 31 Aug 2024 04:12:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=B61rMLfj4xG1py2uzbaHMkkdLgEiGG09pMGTKKnT7SM=; b=esvty3Gj7rxnIC7BoXmA B6Tt7io4S9YyEija2p7Hpn6gY4Bs4mjcWfkPujy62LGG9TtSSgIXOfDBevHWVzkiyiyNMsZ74g3oT VfRnmRhA9yzIgVwlX2Y6JNyJJiTUDNpv8rugJ+GpClCXubLu+iVyYRMXctakDDQNmsqhHo7PqSHet 4KDaUBCq46W56KJeSR7ktFbvo0rTYBwZfZVUpCFSYrT6QfGhdddJty+vzW311W6RNrh4PLvhhroTv eJRB+b5hcFMdAtr69hDUd6d8i9/wZzjz8Pqf6qePgousUyaZonLk7LHAauqY1UZY/cRRDl145Y4aD C3nGgodY/83mRg==; Date: Sat, 31 Aug 2024 11:12:23 +0300 Message-Id: <86h6b1cdqw.fsf@gnu.org> From: Eli Zaretskii To: Yuan Fu In-Reply-To: (message from Yuan Fu on Mon, 19 Aug 2024 20:38:16 -0700) Subject: Re: bug#72691: Recursive descent in treesiter parse tree References: <86y14uyyid.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 72691-done Cc: pranshusharma198@gmail.com, 72691-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Yuan Fu > Date: Mon, 19 Aug 2024 20:38:16 -0700 > Cc: Eli Zaretskii , > 72691@debbugs.gnu.org > > > > > On Aug 18, 2024, at 7:57 AM, Pranshu Sharma wrote: > > > > Ok, I found the solution: you have to capture witha function and traverse the whole tree recursively > > As you’ve found out, tree-sitter’s query system doesn’t support the feature you want (it’ll be quite expensive to implement, I think). Even if you’ve found a solution, if you want, maybe you can describe your actual use-case and I can check if your solution is the most optimal. No further comments, so I'm now closing this bug. From unknown Fri Aug 15 15:28:35 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 28 Sep 2024 11:24:10 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator