[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using incremental parsing in Emacs

From: yyoncho
Subject: Re: Using incremental parsing in Emacs
Date: Sun, 5 Jan 2020 23:12:56 +0200

tree-sitter seems to designed to handle that case OOTB

As per tree-sitter docs:

1. You start parsing via ts_parser_parse(in a separate thread).
2. Document is changed
3. Call ts_parser_set_cancellation_flag 
4. Call ts_tree_edit with the edits from 2
5. You call ts_parser_parse with the same params and tree-sitter is
smart enough to reuse the stuff that has already been parsed.

On Sun, Jan 5, 2020 at 10:28 PM Stefan Monnier <address@hidden> wrote:
> That's exactly the issue: if we need to make a copy just to run the
> parser asynchronously, then there's no advantage significant in having
> such asynchronous processing inside the Emacs process,

There can still be advantages depending on many other details.

Another option is to give them direct access to the buffer, but only
allow read-only access and impose some synchronization between the
threads, e.g.: prepare_before_change could signal the concurrent
threads and wait for them to acknowledge that they can't look at the
buffer positions after START and then re-allow access past START when we
finish the buffer modification or when we return to the command loop).

Similarly, when buffer relocation takes place, we'd first signal to
concurrent threads and wait for them to acknowledge that they've stopped
accessing the buffer's content, and later re-signal them to let them
know they can access it again.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]