all messages for Emacs-related lists mirrored at yhetil.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>,
	monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: New package emacs-parser-generator
Date: Wed, 1 Dec 2021 08:52:07 +0100	[thread overview]
Message-ID: <12F88CF0-4706-4C10-A76D-52CC0EEF8D0C@cvj.se> (raw)
In-Reply-To: <8ECC2C6B-9BB0-442F-98A5-39AB88E2AC12@gmail.com>

Alright, could you give some more details about when a buffer parse is triggered, is it via threads, is it sometimes incremental, does it work on a string copy of the buffer or on the buffer contents directly?

Does treesitter expose a (faster) regexp matcher that perhaps can be used by my library?

Regards
Christian

> 29 nov. 2021 kl. 20:22 skrev Yuan Fu <casouri@gmail.com>:
> 
> The tree-sitter integration doesn’t provide anything to define a grammar nor generating a parser. It merely uses pre-defined grammar (written by tree-sitter community) to parse buffers and produce an AST.
> 
> To write an tree-sitter grammar definition you need to write the grammar in JavaScript and pass it to tree-sitter’s parser generator. The generator spits out a grammar definition encoded in a C source file (in the form of a C struct). To use this grammar definition, we compile it to a library, load it at runtime, pass the struct to tree-sitter library, and tree-sitter can now parse according to this grammar definition.
> 
> The tree-sitter integration provides 1) Lisp wrappers for tree-sitter’s C API; 2) some convenient functions built on the C API; 3) integration with font-lock and indentation. I didn’t add any “common API”, I simply used existing frameworks in Emacs: for font-lock I used font-lock-fontify-region-function, for indent I used indent-line-function. If in the future a common API for parses is desirable, tree-sitter can easily comply.
> 
> IOW, this is what tree-sitter integration currently does:
> 
> font-lock                                indent
>      |                                     |
> font-lock-fontify-region-function        indent-line-function
>      |                                     |
>      |                                     |
> tree-sitter-font-lock-fontify-region     tree-sitter-indent-function
> 
> This is what could happen if we want a common API:
> 
> font-lock                                indent
>      |                                     |
> font-lock-fontify-region-function        indent-line-function
>      |                                     |
>      |                                     |
>     common  API  --------------------------+
>     /         \
>    /           \
>   /             \
> tree-sitter    other parser
> 
> Yuan



  reply	other threads:[~2021-12-01  7:52 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 [this message]
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

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=12F88CF0-4706-4C10-A76D-52CC0EEF8D0C@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 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.