From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christian Johansson Newsgroups: gmane.emacs.devel Subject: Re: New package emacs-parser-generator Date: Wed, 1 Dec 2021 20:44:40 +0100 Message-ID: References: Mime-Version: 1.0 (1.0) 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="16600"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , =?utf-8?Q?Daniel_Mart=C3=ADn?= , Stefan Monnier , Emacs developers To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 01 20:48:49 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 1msVaz-00045g-4c for ged-emacs-devel@m.gmane-mx.org; Wed, 01 Dec 2021 20:48:49 +0100 Original-Received: from localhost ([::1]:51586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1msVax-0003o2-CV for ged-emacs-devel@m.gmane-mx.org; Wed, 01 Dec 2021 14:48:47 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:42338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1msVX6-0008Pq-PL for emacs-devel@gnu.org; Wed, 01 Dec 2021 14:44:48 -0500 Original-Received: from mailrelay2-3.pub.mailoutpod1-cph3.one.com ([46.30.212.11]:29469) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1msVX3-0004Bl-08 for emacs-devel@gnu.org; Wed, 01 Dec 2021 14:44:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cvj.se; s=rsa1; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version:from: content-transfer-encoding:content-type:from; bh=Bqjac9TLVKcpBpM3cWIvFXOBgtfIUcBRyL0pDCFzRr0=; b=i+CyFhsNqDawWqSmNIm3Wd1UKq+wfqon3wCIT/AGyfWbV8SqD2wIl/TgdEDPi6cYlWiKD0I6g+iWI RDR088jCBCatLKIWp1QxQ98FI7EcfvzvPpYHijeSMlcHZ2bWOCnP5thp4ERf6GS7wOqdlss++MMtFA dZPtHnu7ryPRYbcUrs2AzbjvWyyls/m50HjK9DLHipDXEf+Z7BgiXD4pnK7lC3PIBixumBCbeYGdhz g9ppTe/cEUbL3/dmgxhxk+beoiQXO0H6waGKlqo9Tlb2yZut5kgvYDpqgKM4BUqrZ2mlv989jkVe2W O5x3r1WKckM+NwbLKftmvRij2YCO9ag== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=cvj.se; s=ed1; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version:from: content-transfer-encoding:content-type:from; bh=Bqjac9TLVKcpBpM3cWIvFXOBgtfIUcBRyL0pDCFzRr0=; b=13rCvfXTt+uiupFnJpt/kljCvE5JQ3aYmKp+nU7lWJ/oYeP8Z3z8HBsWEnsErYfKUczvrv/hEA0cq An+ixd+Cw== X-HalOne-Cookie: 0286bd9faefd28bfda65c85b4607ab7fa6108c7a X-HalOne-ID: 1fc0a938-52df-11ec-bd63-d0431ea8a290 Original-Received: from smtpclient.apple (c188-150-212-230.bredband.tele2.se [188.150.212.230]) by mailrelay2.pub.mailoutpod1-cph3.one.com (Halon) with ESMTPSA id 1fc0a938-52df-11ec-bd63-d0431ea8a290; Wed, 01 Dec 2021 19:44:41 +0000 (UTC) In-Reply-To: X-Mailer: iPhone Mail (19A404) Received-SPF: none client-ip=46.30.212.11; envelope-from=christian@cvj.se; helo=mailrelay2-3.pub.mailoutpod1-cph3.one.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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=unavailable 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" Xref: news.gmane.io gmane.emacs.devel:280688 Archived-At: Ok thanks for the link, I will investigate and see if I can figure it out.=20= Read a bit of the research and it seems to to use a state-independent lex-an= alyzer and do like multiple alternative / nondeterministic error-tolerant pa= rses to make a probalistic best parse which is then merged into the previous= AST or something like that.. Regards Christian > 1 dec. 2021 kl. 20:25 skrev Yuan Fu : >=20 > =EF=BB=BF >>=20 >>>=20 >>> Tree-sitter parses incrementally, I modified primitive insert/delete fun= ctions in insdel.c to incrementally parse changed content. There is no need f= or threads as incremental parsing is extremely fast. We don=E2=80=99t make c= opies of buffer string, instead, we pass tree-sitter library a function that= reads directly from the buffer. >>=20 >> Ok where can I read about this function? How does treesitter handle incre= mental parses which are state-dependent? For example PHPs lex-analyzer works= differently in different states of the grammar, like do you signal to trees= itter a point in the buffer so it can backtrack the parsers states in order t= o correctly perform a incremental parse on the new content? >=20 > I assume you mean the read function? It can be found here: >=20 > https://github.com/casouri/emacs/blob/106d050ad5d02f673f8a089e1f10c1eacfed= d124/src/tree-sitter.c#L372 >=20 > Tree-sitter only requires to be informed of every change to the buffer, it= will read the buffer for itself and update the AST. I have no idea if it ba= cktracks behind the scenes. Presumably tree-sitter can figure out from where= to backtrack from the change information we give it. >=20 > Yuan