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 api Date: Sun, 22 Aug 2021 23:51:08 -0700 Message-ID: <8B9072FF-02F5-48CC-844A-1E0C2FC42CE9@gmail.com> References: <83r1f7hydn.fsf@gnu.org> <95F37923-5BF9-4D81-B361-267CF119FBCA@gmail.com> <735AF34C-FD18-4A6A-A99D-E5D8EB4DE4F3@gmail.com> <86im02bobr.fsf@stephe-leake.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35791"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Theodor Thornhill , Stefan Monnier , =?utf-8?Q?Cl=C3=A9ment_Pit-Claudel?= , emacs-devel To: Stephen Leake Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Aug 23 08:53:00 2021 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 1mI3pL-00094i-SI for ged-emacs-devel@m.gmane-mx.org; Mon, 23 Aug 2021 08:52:59 +0200 Original-Received: from localhost ([::1]:34896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mI3pJ-0002Bi-JY for ged-emacs-devel@m.gmane-mx.org; Mon, 23 Aug 2021 02:52:57 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mI3ng-0001UK-Gt for emacs-devel@gnu.org; Mon, 23 Aug 2021 02:51:16 -0400 Original-Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:36392) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mI3nd-0001MO-Et; Mon, 23 Aug 2021 02:51:16 -0400 Original-Received: by mail-pg1-x536.google.com with SMTP id t1so15790964pgv.3; Sun, 22 Aug 2021 23:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=xhe/H/EBKhAKJaSUoErwT6QFopcj7uPWVUg/TdFGC/o=; b=qIW1kiv1IReXtxjwCH3zJNUHNaoc3ubLCW/+PAEbryCLSlVUWboJWbQbEBzx7bGyCp +ZZEp4l6LVC+bQcAcyUVNsJR0eISMyC+xOJxYMR9LBAMYBMAiXDb7kfgA6WWLoNrknk4 mTHL5XKpciiaej/N9CYGL8+Je59ZXqGIMPCwW5bmcYb2KbhG2z4vi5FKvAx2QcwIENUT Nyd0p+kF85ROmkPSa7yEdDX7kYlRncwyGLz6uS8dbDLDv4uPxkCdH8RnSSZBOneFJv/y Sy9obEZYSTSyziHT3kUaJoQN21BUoLNVoHVun/SZT/dkV1zgbLx++Bv0KWp3h0UJUxrY 2bVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=xhe/H/EBKhAKJaSUoErwT6QFopcj7uPWVUg/TdFGC/o=; b=giGO7624LYJM2BbUVrBVKxZY4d9gWV0SZUhF6enSppD2+waSTpaGiw4AXqH9jPMoM0 rJS6l4tMqb0TjSvfAKbkz6F99dHoLzxbdK635OEppV94j2hRGxKZU8PAbo79GWak8+lz XycWc50rvnziCOcFCEL7f0RlOGzofaerRqOZvR20HCxDi/eUKVSw1Sn/jJ7cTUIwR4sM KEZxACryniNrAccwTymmDC+SavxNO4L9ryl5/aZ/QNJXNkhy8nocuEg01CYfrkB0k0VE Dol91w1c3FsNw0+KQrzSMgVFoZUaGzqRnKm4D457PrWpNLUIbSGQU07H5AD0fgLNYP+5 /Q/A== X-Gm-Message-State: AOAM532nMMsCLpojjzhF6dZDKJa7BGCL4EkJsQm1igx3/z0VHfCeentZ 8bJZ/lxsTuK5CrQ+4oUyCM4= X-Google-Smtp-Source: ABdhPJxjRKFWVfEJNLIF+VgtnUE891sILsP0KLHEFY+58X2MjqPw8R15S0q2rfXHn5PJyEi5OLqS5g== X-Received: by 2002:a62:bd09:0:b0:3e2:99c1:9b4f with SMTP id a9-20020a62bd09000000b003e299c19b4fmr30686347pff.54.1629701470856; Sun, 22 Aug 2021 23:51:10 -0700 (PDT) Original-Received: from [10.11.16.203] (wsip-70-166-26-37.sd.sd.cox.net. [70.166.26.37]) by smtp.gmail.com with ESMTPSA id v25sm14345552pfm.202.2021.08.22.23.51.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Aug 2021 23:51:10 -0700 (PDT) In-Reply-To: <86im02bobr.fsf@stephe-leake.org> X-Mailer: Apple Mail (2.3654.60.0.2.21) Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=casouri@gmail.com; helo=mail-pg1-x536.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.23 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:272863 Archived-At: >=20 > ada-mode takes the approach of embedding the indent rules directly in > the grammar, and the functions that do that provide a few more options > than yours. To see the definition of those functions, you'll have to > install the wisi package, and look in wisi.info, section Grammar > actions. (it would be nice if that info/html file was linked from the > GNU ELPA package page; I'll start a new thread for that). I had a cursory look at the manual for indent in wisi and have some = questions. Why does wisi indent from =E2=80=9Clow-level productions=E2=80=9D= ? (I think most indentation engine works line-by-line from the first = line.) I don=E2=80=99t know much about how wisi works, but the = indentation system seems to stem from circumstances quite different from = that of tree-sitter. For example, wiki=E2=80=99s indent is devised = alongside the grammar definition, while for tree-sitter, all the hard = work of defining grammar is done for me and I=E2=80=99m merely a user of = the grammar: that makes indenting with tree-sitter a much simpler job. A problem I have with smie (and maybe wisi, but I didn=E2=80=99t look = into wisi) is its seeming complexity. I=E2=80=99m merely a 22-year-old = who drank too much coca-cola, and smie is too complicated for my soaked = brain to comprehend. Having a traumatized experience trying to use = smie[1], I want to make my indentation system as straightforward as = possible. It doesn=E2=80=99t have to be complicated anyway, since it = does so much less than wisi and smie. Right now I=E2=80=99d say it=E2=80=99= s pretty simple, and most tasks (in indenting C) can be reasonably done, = and I imagine difficult cases can be solved by writing custom matcher = and anchor functions. Stefan, can you have a look at tree-sitter-simple-indent? It=E2=80=99s = like two messages up? It goes generally along the (pos . offset) idea = but has some twists. [1] Of course, I need to define the grammar when using smie while not = when using tree-sitter, so it=E2=80=99s like comparing apple to pears, = but I can=E2=80=99t resist finally telling a joke on the list. Thanks, Yuan=