[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [SPAM UNSURE] Tree-sitter api
From: |
Stephen Leake |
Subject: |
Re: [SPAM UNSURE] Tree-sitter api |
Date: |
Mon, 30 Aug 2021 17:48:35 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (windows-nt) |
Yuan Fu <casouri@gmail.com> writes:
> Thank you very much for spending time on this :-)
And thank you for the same; always helpful to have different points of view.
>> The indent of every new-line must be specified; low level productions
>> can contain new-lines.
>
> Ah, I see, what I did is to find the “largest” node that starts at
> BOL, and try to match that. IIUC, wisi starts from the “smallest”
> entity, and goes up (by getting its parent repeatedly) until there is
> a non-nil indent rule for it?
That's almost right. The indent rule for each production is applied
while walking the entire syntax tree in depth-first order.
>> To be fair, we'd have to look at the other types of rules, to see if
>> this pattern holds up.
>
> I tried and all rules can be translated into wisi’s style.
Ok.
> However, it ends up as verbose as the previous one. My idea is to
> write out match patterns (similar to that in wisi) and give names to
> the interesting ones (so we use names as opposed to position). Then,
> if any matched node happens to be the node at point, use that node’s
> corresponding indent rule to indent. And in the indent rule, we can
> refer to other matched nodes. For example, in the indent rule of
> list_rest, the anchor is list_first.
>
> Maybe there are better ways to implement this, but at its current
> stage I don’t think this is better than tree-sitter-simple-indent.
Ok.
> I think part of the reason why wisi’s indent rule can be succinct is
> that it is written along the grammar definition. It is hard to make
> tree-sitter’s indent rule as succinct while being easy to understand.
Right.
> IIUC, this tree-traversal method that you mentioned is like going
> bottom-up, and (in tree-sitter terms) match on each level, and
> accumulate indent delta for each matched indent rule, is that right?
Yes.
> Does wisi go all the way up to top-level?
Yes; the top-level rule says the indent of every line defaults to 0;
that covers any remaining 'nil' values.
I have not tried to make this part of ada-mode incremental yet (ie, only
visit changed nodes). I'm not sure that's possible.
--
-- Stephe
- Re: Tree-sitter api, (continued)
- Re: Tree-sitter api, Stefan Monnier, 2021/08/07
- Re: Tree-sitter api, Theodor Thornhill, 2021/08/07
- Re: Tree-sitter api, Stefan Monnier, 2021/08/07
- Re: Tree-sitter api, Yuan Fu, 2021/08/17
- Re: Tree-sitter api, Stephen Leake, 2021/08/18
- Re: Tree-sitter api, Yuan Fu, 2021/08/18
- Re: [SPAM UNSURE] Re: Tree-sitter api, Stephen Leake, 2021/08/19
- Re: Tree-sitter api, Yuan Fu, 2021/08/23
- Re: [SPAM UNSURE] Re: Tree-sitter api, Stephen Leake, 2021/08/24
- Re: [SPAM UNSURE] Tree-sitter api, Yuan Fu, 2021/08/27
- Re: [SPAM UNSURE] Tree-sitter api,
Stephen Leake <=
- Re: Tree-sitter api, Stefan Monnier, 2021/08/24
- Re: Tree-sitter api, Yuan Fu, 2021/08/21
- Re: Tree-sitter api, Yuan Fu, 2021/08/21
- Re: Tree-sitter api, Eli Zaretskii, 2021/08/22
- Re: Tree-sitter api, Eli Zaretskii, 2021/08/22
- Re: Tree-sitter api, Stefan Monnier, 2021/08/24
- Re: Tree-sitter api, Yuan Fu, 2021/08/27
- Re: Tree-sitter api, Yuan Fu, 2021/08/08
- Re: Tree-sitter api, Stefan Monnier, 2021/08/08
- Re: Tree-sitter api, Yuan Fu, 2021/08/08