emacs-devel
[Top][All Lists]
Advanced

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

Re: Tree-sitter api


From: Yuan Fu
Subject: Re: Tree-sitter api
Date: Sun, 22 Aug 2021 23:51:08 -0700

> 
> ada-mode takes the approach of embedding the indent rules directly in
> the grammar, and the functions that do that provide a few more options
> than yours. To see the definition of those functions, you'll have to
> install the wisi package, and look in wisi.info, section Grammar
> actions. (it would be nice if that info/html file was linked from the
> GNU ELPA package page; I'll start a new thread for that).

I had a cursory look at the manual for indent in wisi and have some questions. 
Why does wisi indent from “low-level productions”? (I think most indentation 
engine works line-by-line from the first line.) I don’t know much about how 
wisi works, but the indentation system seems to stem from circumstances quite 
different from that of tree-sitter. For example, wiki’s indent is devised 
alongside the grammar definition, while for tree-sitter, all the hard work of 
defining grammar is done for me and I’m merely a user of the grammar: that 
makes indenting with tree-sitter a much simpler job.

A problem I have with smie (and maybe wisi, but I didn’t look into wisi) is its 
seeming complexity. I’m merely a 22-year-old who drank too much coca-cola, and 
smie is too complicated for my soaked brain to comprehend. Having a traumatized 
experience trying to use smie[1], I want to make my indentation system as 
straightforward as possible. It doesn’t have to be complicated anyway, since it 
does so much less than wisi and smie. Right now I’d say it’s pretty simple, and 
most tasks (in indenting C) can be reasonably done, and I imagine difficult 
cases can be solved by writing custom matcher and anchor functions.

Stefan, can you have a look at tree-sitter-simple-indent? It’s like two 
messages up? It goes generally along the (pos . offset) idea but has some 
twists.

[1] Of course, I need to define the grammar when using smie while not when 
using tree-sitter, so it’s like comparing apple to pears, but I can’t resist 
finally telling a joke on the list.

Thanks,
Yuan


reply via email to

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