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 03:06:37 -0800 Message-ID: <787B1EB4-1925-4679-8747-449DCD685432@gmail.com> 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> 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="7051"; 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 Fri Dec 30 12:07:31 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 1pBDEY-0001dL-Bh for ged-emacs-devel@m.gmane-mx.org; Fri, 30 Dec 2022 12:07:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pBDDr-0001AK-8x; Fri, 30 Dec 2022 06:06:47 -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 1pBDDq-0001AC-Cq for emacs-devel@gnu.org; Fri, 30 Dec 2022 06:06:46 -0500 Original-Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pBDDo-00069l-4y; Fri, 30 Dec 2022 06:06:45 -0500 Original-Received: by mail-pl1-x62d.google.com with SMTP id jn22so21474048plb.13; Fri, 30 Dec 2022 03:06:41 -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=EYH6K9yKdhK3T0O6KqzdVBYWKV0wD38FRLfIe/FEwqg=; b=abGuZo9p8VOnQXukHVsyn+m2qI2mYNSKXLLtACxzNlGpCsmjkaICnV/YR2r2mM38p7 8SAB6WEdE4MnW0ykYs2ROmx6ExiLPEmyqQ0bgHUJcLbUzHRog3WK7Pr5hnuoHQXqY4Hn 0qVzvxWR6BP1KTDQUJfL7wBRZyWwVlOFvJvCwQ8XZMA4gUiuqHbOzyL4SyAWhWT+cW3b bHhzmMgowt76sY0q9sYhgnP5W1pORCn4r94yp4g6qmzdgjD7vfSL5BBN7omqIFOnGkhe VSBVtIeNsYtUrGiJRAeaxLsJFpmuD4tZ0bstpSwgJl/Vxgea8zkWWI6BbvfplsFIjvcu lpnA== 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=EYH6K9yKdhK3T0O6KqzdVBYWKV0wD38FRLfIe/FEwqg=; b=ICBGmU0PBB71JQhJxQh3EXZEYjSpN3rv9xfqpT8cIIFmo2dj8zB0UwkOXNyT/wD4CI UxVqWuoIp7vdK8tiF01JiyVd8bahK8ACLdLXLAnyJ08jFSDLAp70n0HAztMIsyz/3xG5 p6O6u1BzV5tYZfPiVII3ook0J5tLuPy95CdAyNKUEzfXImdG6bABEizI2ghSm06JgNmI ydQaoGAbch8Vf85RBJ8XoutBTN19aZr/e/hBrfIHu1roXlPyq+ys3bCmW3degY1pVM+3 80UMjmbFcidC0zaWtoxuYVrEoh230yDWnn2o9ZtXk138KU/996kn5cl3kKYFURdjdwe7 l/Ag== X-Gm-Message-State: AFqh2kraHXsDzYfJjLjy26ZWiQIkn+ur10GWHECjsoLt753+kM7IzkkL 7Ikm8L8iNOhsuNPeyRF2r3E= X-Google-Smtp-Source: AMrXdXs9JJ9pcUev9oGl4duwkOcJigt/O3dkHy496eowNNXpokodrPVD3QT8PYU3KjMlY6N+r2I/OQ== X-Received: by 2002:a17:902:f34a:b0:192:75b8:b461 with SMTP id q10-20020a170902f34a00b0019275b8b461mr15585126ple.37.1672398400280; Fri, 30 Dec 2022 03:06:40 -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 c5-20020a170902d90500b00189327b022bsm14506467plz.286.2022.12.30.03.06.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Dec 2022 03:06:39 -0800 (PST) In-Reply-To: <87wn6cyey5.fsf@posteo.net> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=casouri@gmail.com; helo=mail-pl1-x62d.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:302092 Archived-At: > 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. 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: (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"))) Yuan=