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: Tree-sitter introduction documentation Date: Fri, 30 Dec 2022 15:33:19 -0800 Message-ID: References: <83edszjslp.fsf@gnu.org> <87tu1vxs3a.fsf@ledu-giraud.fr> <831qozjob7.fsf@gnu.org> <87cz8jxoat.fsf@ledu-giraud.fr> <83wn6ri7pn.fsf@gnu.org> <5e0a3185-de82-b339-0fa2-956779e63d6f@cornell.edu> <868rj6vfep.fsf@gmail.com> <4895891b-e5ea-9c37-f51b-df2e479ee758@yandex.ru> <83y1qt11xq.fsf@gnu.org> <9eb013da-d0fc-8e17-c6e3-1e8f913aebfa@yandex.ru> <83pmc50xxc.fsf@gnu.org> <71cfe4e8-3bb8-b0a6-9be5-8c0a6d92cfab@yandex.ru> <83h6xg29z3.fsf@gnu.org> <87wn6cyey5.fsf@posteo.net> <787B1EB4-1925-4679-8747-449DCD685432@gmail.com> <87v8lt9lqy.fsf@posteo.net> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18491"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , Eli Zaretskii , Dmitry Gutov , theophilusx@gmail.com, emacs-devel@gnu.org To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Dec 31 00:34:12 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 1pBOtA-0004XR-24 for ged-emacs-devel@m.gmane-mx.org; Sat, 31 Dec 2022 00:34:12 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pBOsT-0003VL-2q; Fri, 30 Dec 2022 18:33:29 -0500 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 1pBOsR-0003Uy-0p for emacs-devel@gnu.org; Fri, 30 Dec 2022 18:33:27 -0500 Original-Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pBOsP-0003aN-9t; Fri, 30 Dec 2022 18:33:26 -0500 Original-Received: by mail-pj1-x1035.google.com with SMTP id o2so18242979pjh.4; Fri, 30 Dec 2022 15:33:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=16JSvTqxGa/dAcO5cW3tqgS45urVwHMGS74STbODqG4=; b=fE8+a4WW6vQhXr/u50f5vUCUJv4u5YqAzErkoAHUhPM1uL1PsAIllZCt4GOLDUhZ39 J6CIRL6ansXt6Ck7qsRa9TeWb3KzrDXhxlUJsvQIML4YJXMjv7Sr37yLuHQXmXbw0xOh yvuAsgfcEU8I1wN575IHkiyBc+7antJldj6SWIDLbJC1NU60Sepep2mGvLtawF8UNlGL PIo5QqtiTkT4kKLORcv+o9BV/yD/1Mk+l8O2NQU4UBis4ICw3eiMIPWIMKeiNzpDIi2a MutmxFM/k9eLL5m4Fg0yEHT30MOsigReSWmxdR5Y2KmEXFC0Q+bKAdamUwZlFkBCOzJf glww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=16JSvTqxGa/dAcO5cW3tqgS45urVwHMGS74STbODqG4=; b=DaJFJguc8xV8qt2E1nod6de/gf2NEptO0svCevyLJvWtUACPkzHuUKt2TCjUyUSC8b 8OY1fspbE0y2CDHggEyf2fK0aXQTF6aWrWz3d5upvWRnW7Bhs6nQCehTOdCMlshPIwcZ LJK0lB9JoPUpRHoHJdDM5c//wSR09x0qmJm/FQqQczxL3U5JEU8JgdGhbHXBoQHpzMp5 1xHGPcWxvOxpqzZAOHjHen4kTSHatcFv1x+e2/iQ4RFafeD2xgpvvTsFdaA3U1LOk3R+ Yqhm2p0FLUEyO2pvAuRWNtC8V84STIovGkXzdzrJrcT6FoXHon24Dio1hcN2tgj9gSQM 2rXw== X-Gm-Message-State: AFqh2kpHqcaR9TuRxr3yaiR7E3Zf/6fdZ8HDCU6TKFQIGr7F/Xfxe9y8 v1u5bioqCbjtBpklzQo4WnY= X-Google-Smtp-Source: AMrXdXuSyoNDaSMShP0MBLxDzOtmm6wOoWg1C5AV9CHw1e1MhveC4wtt/g84yBCMsERA8WrZ3/l9bg== X-Received: by 2002:a17:902:d052:b0:192:5950:656c with SMTP id l18-20020a170902d05200b001925950656cmr27001179pll.37.1672443203298; Fri, 30 Dec 2022 15:33:23 -0800 (PST) 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 u2-20020a1709026e0200b00168dadc7354sm13972791plk.78.2022.12.30.15.33.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Dec 2022 15:33:22 -0800 (PST) In-Reply-To: <87v8lt9lqy.fsf@posteo.net> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=casouri@gmail.com; helo=mail-pj1-x1035.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:302138 Archived-At: > On Dec 30, 2022, at 3:25 AM, Philip Kaludercic = wrote: >=20 > Yuan Fu writes: >=20 >>> On Dec 27, 2022, at 8:44 AM, Philip Kaludercic = wrote: >>>=20 >>> Stefan Monnier writes: >>>=20 >>>>> It doesn't need any project, it is literally two command lines. >>>>> Here's an example: >>>>>=20 >>>>> gcc -O2 -I. -c -o parser.o parser.c >>>>> gcc -shared parser.o scanner.o -ltree-sitter -o = libtree-sitter-c-sharp.dll >>>>=20 >>>> AFAIK `parser.c` is a file generated from the actual grammar's = source, >>>> itself written in Javascript. >>>>=20 >>>> So the above instructions are akin to downloading a precompiled = binary >>>> and installing it. While it is the most convenient path for the >>>> end-users, it's important w.r.t Freedom to make sure that grammars = can >>>> also be regenerated from source by the end users. >>>=20 >>> I have asked the question before, but freedom or not, the above is a >>> nuisance to run for every language. If the process is as automatic = as >>> the above example demonstrates, shouldn't Emacs have a command to = take a >>> grammar and compile+install it? I guess this could be more = complicated >>> if the grammar is generated using a custom tool-chain for each = language >>> (or is it always Javascript?), but nothing impossible. >>=20 >> Though the magic of programming, such command now exists: = treesit-install-language-grammar. It needs recipes to work, though. The = recipe would involve https://github.com, which I guess is probably too = heretical to include in Emacs source, so I left the recipes empty. I = tested the install command with these recipes: >>=20 >> (setq treesit-language-source-alist >> '((python = "https://github.com/tree-sitter/tree-sitter-python.git") >> (typescript = "https://github.com/tree-sitter/tree-sitter-typescript.git" >> "typescript/src" "typescript"))) >>=20 >> Yuan >=20 > If acceptable, it looks good. I could imagine that it should be OK if > we point to GitHub, since we are just using it as a Git host. Here = are > a few suggestions Thanks, I made some changes according to your diff. Yuan=