unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Christian Johansson <christian@cvj.se>
To: Yuan Fu <casouri@gmail.com>
Cc: "Eli Zaretskii" <eliz@gnu.org>,
	"Daniel Martín" <mardani29@yahoo.es>,
	"Stefan Monnier" <monnier@iro.umontreal.ca>,
	"Emacs developers" <emacs-devel@gnu.org>
Subject: Re: New package emacs-parser-generator
Date: Wed, 1 Dec 2021 20:44:40 +0100	[thread overview]
Message-ID: <CCA4AD7D-35A4-4386-9C1E-45848D2FF4F0@cvj.se> (raw)
In-Reply-To: <ABADACCB-49B5-4A77-A2E9-B979E31348CE@gmail.com>

Ok thanks for the link, I will investigate and see if I can figure it out. 

Read a bit of the research and it seems to to use a state-independent lex-analyzer and do like multiple alternative / nondeterministic error-tolerant parses 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 <casouri@gmail.com>:
> 
> 
>> 
>>> 
>>> Tree-sitter parses incrementally, I modified primitive insert/delete functions in insdel.c to incrementally parse changed content. There is no need for threads as incremental parsing is extremely fast. We don’t make copies of buffer string, instead, we pass tree-sitter library a function that reads directly from the buffer.
>> 
>> Ok where can I read about this function? How does treesitter handle incremental parses which are state-dependent? For example PHPs lex-analyzer works differently in different states of the grammar, like do you signal to treesitter a point in the buffer so it can backtrack the parsers states in order to correctly perform a incremental parse on the new content?
> 
> I assume you mean the read function? It can be found here:
> 
> https://github.com/casouri/emacs/blob/106d050ad5d02f673f8a089e1f10c1eacfedd124/src/tree-sitter.c#L372
> 
> 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 backtracks behind the scenes. Presumably tree-sitter can figure out from where to backtrack from the change information we give it.
> 
> Yuan



      reply	other threads:[~2021-12-01 19:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-27 21:40 New package emacs-parser-generator Christian Johansson
2021-11-28  7:01 ` Eli Zaretskii
2021-11-28  7:22   ` Christian Johansson
2021-11-28 13:24     ` Stefan Monnier
2021-11-28 13:45       ` Christian Johansson
2021-11-28 23:46         ` Daniel Martín
2021-11-29 12:30           ` Eli Zaretskii
2021-11-29 13:09             ` Christian Johansson
2021-11-29 19:22               ` Yuan Fu
2021-12-01  7:52                 ` Christian Johansson
2021-12-01  8:39                   ` Yuan Fu
2021-12-01  8:51                     ` Christian Johansson
2021-12-01 13:45                       ` Stefan Monnier
2021-12-01 14:10                         ` Christian Johansson
2021-12-01 19:25                       ` Yuan Fu
2021-12-01 19:44                         ` Christian Johansson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CCA4AD7D-35A4-4386-9C1E-45848D2FF4F0@cvj.se \
    --to=christian@cvj.se \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=mardani29@yahoo.es \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).