From: Lynn Winebarger <owinebar@gmail.com>
To: Yuan Fu <casouri@gmail.com>
Cc: "Augustin Chéneau (BTuin)" <btuin@mailo.com>, emacs-devel@gnu.org
Subject: Re: Questions about tree-sitter
Date: Thu, 7 Sep 2023 20:11:06 -0400 [thread overview]
Message-ID: <CAM=F=bCEteJdREJ0f0e_DkMjpjM9sp6xhC4SQpq7GQVx7U-8VQ@mail.gmail.com> (raw)
In-Reply-To: <581816B0-2F41-42C9-B49A-70F7DD800212@gmail.com>
On Thu, Sep 7, 2023 at 7:42 PM Yuan Fu <casouri@gmail.com> wrote:
> > On Sep 6, 2023, at 9:11 AM, Lynn Winebarger <owinebar@gmail.com> wrote:
> >
> > On Wed, Aug 30, 2023 at 3:03 AM Yuan Fu <casouri@gmail.com> wrote:
> >>> Is it possible to reload a grammar after modifying it?
> >>
> >> No, and it’s probably not easy to implement either, since unloading the grammar would require Emacs to purge/invalid all the node/query/parsers using that grammar.
> >
> > [ ... ]
> > Therefore, given functionality to translate elisp data into the raw C
> > structures, we should be able to dynamically create language data
> > structures to pass to the tree-sitter library to create a library.
> > We would also need a table driven lexer framework in place of the
> > generated lexer in the C file to completely avoid going through a C
> > compiler.
> > The other novel features of tree-sitter parsers appear to be
> > implemented in the parser runtime, not in the table calculation.
> >
> > I've implemented LALR(1) parser generators two or three times in the
> > last couple of decades, this might be a fun project for me while I am
> > unambiguously able to contribute to GNU Emacs.
>
> That’ll be great. But note that the parser structure has scape hatches: certain things can be implemented by arbitrary C function. Also tree-sitter allows grammars to use custom scanners [1].
>
My primary interest is in using the tree-sitter parser framework with
the grammars and lexers constructed for Semantic in elisp. That's the
strongest use-case. That can be done by a single library implementing
a generic table-driven scanner function.
For other cases, it's a mixed bag. If only the grammar changes, and
all C code is fixed, then modifications to the grammar could be
reloaded. If this feature was really important to the user, they
could probably implement the C code to call Elisp functions that could
be updated dynamically, at least during development.
But you are correct that this will not solve the problem for arbitrary
tree-sitter language definitions with embedded C code. For use in
emacs, the user might implement any required functions in a dynamic
module that could be loaded and unloaded separately from the
tree-sitter language library. But that will not happen with the
parser.c produced by the tree-sitter cli tool.
Lynn
prev parent reply other threads:[~2023-09-08 0:11 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-29 21:26 Questions about tree-sitter Augustin Chéneau (BTuin)
2023-08-30 7:03 ` Yuan Fu
2023-08-30 11:28 ` Augustin Chéneau (BTuin)
2023-09-06 4:07 ` Yuan Fu
2023-09-08 11:53 ` Augustin Chéneau (BTuin)
2023-09-08 16:43 ` Yuan Fu
2023-09-09 16:39 ` Augustin Chéneau (BTuin)
2023-09-12 0:22 ` Yuan Fu
2023-09-13 12:43 ` Augustin Chéneau (BTuin)
2023-09-14 4:11 ` Yuan Fu
2023-09-18 17:04 ` Augustin Chéneau (BTuin)
2023-09-19 4:00 ` Yuan Fu
2023-09-01 2:39 ` Madhu
2023-09-01 6:53 ` Eli Zaretskii
2023-09-01 9:15 ` Madhu
2023-09-01 10:45 ` Dmitry Gutov
2023-09-01 10:58 ` Eli Zaretskii
2023-11-27 7:16 ` Madhu
2023-09-06 16:11 ` Lynn Winebarger
2023-09-07 23:42 ` Yuan Fu
2023-09-08 0:11 ` Lynn Winebarger [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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAM=F=bCEteJdREJ0f0e_DkMjpjM9sp6xhC4SQpq7GQVx7U-8VQ@mail.gmail.com' \
--to=owinebar@gmail.com \
--cc=btuin@mailo.com \
--cc=casouri@gmail.com \
--cc=emacs-devel@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.