From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrei Kuznetsov Newsgroups: gmane.emacs.devel Subject: Re: [SPAM UNSURE] Re: [SPAM UNSURE] Maybe we're taking a wrong approach towards tree-sitter Date: Fri, 30 Jul 2021 08:54:21 +0800 Message-ID: <87bl6kmxj6.fsf@163.com> References: <8735rzyzbz.fsf@163.com> <86v94v3xh9.fsf@stephe-leake.org> <87o8amy88o.fsf@163.com> <20210728123612.pr2ddrf6vmynknxn@Ergus> <877dhawpr7.fsf@163.com> <86o8akog7f.fsf@stephe-leake.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22846"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Ergus , emacs-devel@gnu.org To: Stephen Leake Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jul 30 02:55:27 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 1m9GoB-0005ig-7s for ged-emacs-devel@m.gmane-mx.org; Fri, 30 Jul 2021 02:55:27 +0200 Original-Received: from localhost ([::1]:45540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m9Go8-0002ym-Kl for ged-emacs-devel@m.gmane-mx.org; Thu, 29 Jul 2021 20:55:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9GnP-0002GX-9G for emacs-devel@gnu.org; Thu, 29 Jul 2021 20:54:39 -0400 Original-Received: from m12-14.163.com ([220.181.12.14]:60184) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m9GnL-0006it-9K for emacs-devel@gnu.org; Thu, 29 Jul 2021 20:54:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=Kv4dj kCD3iyBm4QZirsIdUEgqjzCQnPB9KYndP4BHDQ=; b=d8JmBhpQxJ9L2EpDzlwdE 7/hIvB9sNN+ovTbdqCjadTWgE10MZCsuMS92JaAz3cUvgiH+ilq/CDKLXu6VqyF+ cXOo0MCXnf04pLp3NmehW8W3KwDyNjJNr8Pt6cO5P5+gjPo58SzypkugU1NgaUEP ZqsOagT7i0ljRTQYTUrg98= Original-Received: from po-lus-librem-15 (unknown [61.172.31.87]) by smtp10 (Coremail) with SMTP id DsCowADX8Mq9TQNh0eK6DQ--.65006S2; Fri, 30 Jul 2021 08:54:21 +0800 (CST) In-Reply-To: <86o8akog7f.fsf@stephe-leake.org> (Stephen Leake's message of "Thu, 29 Jul 2021 16:25:40 -0700") X-CM-TRANSID: DsCowADX8Mq9TQNh0eK6DQ--.65006S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7uw4DCF18Ar4rtrW3uF13XFb_yoW8ur1DpF 4Yg3yktrnYqry0kws7Ary8X3WfArZ5G39xWFnxWw4akw4DJ34I9ry7Kr4aka4Uurs5Wa1Y qa9Yka47GFn0yFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UAkusUUUUU= X-Originating-IP: [61.172.31.87] X-CM-SenderInfo: rurskkarusmjiyx6il2tof0z/1tbiPh3fpFxBnpFAaAAAsi Received-SPF: pass client-ip=220.181.12.14; envelope-from=r12451428287@163.com; helo=m12-14.163.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FROM_LOCAL_DIGITS=0.001, FROM_LOCAL_HEX=0.006, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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:271817 Archived-At: Stephen Leake writes: > The "generator" and the "runtime" are two separate programs, with > separate functions, used at different times. > > The generator takes the javascript language grammar file and translates > it (thru lots of hairy computations) into code that builds a parse table > and other data structures. The tree-sitter generator outputs that code > in C; it might be possible to adapt it to output in elisp (the wisitoken > generator used to output elisp, but i gave that up when I implemented > error recover in Ada; elisp is way to slow for that). > > The "runtime" uses the parse table to parse text at runtime, in response > to user actions on the buffer. To be useful in an interactive editing > context, it must have robust error recovery. What is your error recovery > algorithm? Currently extremely naive. After an error occurs, it skips productions until it can parses without errors, and just continues from there. I plan to improve it somewhat in the near future. > Are you talking about the generator or runtime here? The runtime. The parser generator does not seem to be astonishingly fast, but I don't think most people will have any cause to run it very often. > That's the runtime. Actual time for xdisp.c, preferably compared with a > tree-sitter parse run on the same machine, would be helpful. I'm currently pre-occupied and unable to work on this, but I will return with these measurements as soon as reasonably possible. > How long does the generator take? I did not measure that, but as most people would be loading compiled parsers, and not running the generator, I don't think it would matter too much. FWIW macroexpansion of the macro `defgrammar' blocks Emacs for a second or 2. > This seems to imply that the runtime supports incremental parse, so it > does not reparse the whole buffer each time; is that true? Indeed. I've not yet figured out a particularly good way of recording changes though -- as of present it relies on its own versions of self-insert-command, kill-region, et cetera.