[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CC Mode -> Tree sitter challenge
From: |
Theodor Thornhill |
Subject: |
Re: CC Mode -> Tree sitter challenge |
Date: |
Sun, 06 Nov 2022 07:04:47 +0100 |
On 6 November 2022 02:13:14 CET, Yuan Fu <casouri@gmail.com> wrote:
>
>
>> On Nov 5, 2022, at 9:38 AM, Theodor Thornhill <theo@thornhill.no> wrote:
>>
>>
>> Hi again, Eli!
>>
>>>>
>>>> Interesting. My guess is that there are still some improvement possible in
>>>> the indent-region code, considering that part of treesit.el is quite new.
>>>>
>>>> What do you think, Yuan? Any thoughts?
>>>>
>>>> Anyways, I'll keep working on this and see how far I get next coming
>>>> weeks. At least in performance it seems I have a good thing going here :-)
>>>>
>>>
>>> Thinking of it, some of the indentation questions isn't compiled. I'll run
>>> it again later when they are compiled as well :-)
>>>
>>
>> Yes, that was the issue. Now the scores are as follows:
>
>The indentation code has a list of rules, and it runs each rule top-to-bottom
>until one rules matches, then it uses that rule to determine how much to
>indent. The ordering of each rule could be tweaked so that most frequent case
>comes forward. We can also arrange these rules not linearly but in a tree, so
>if one rules matches/doesn’t match, some other rules can be skipped.
I think the system as it is now it fine, at least for the time being. But I
hold no strong opinions there :)
>
>What exactly did you compile? I tried byte-compiling indentation rules before
>but didn’t see a significant speed-up.
>
>Yuan
See https://git.sr.ht/~theo/tree-sitter-modes/tree/master/item/c-ts-mode.el#L92
Sometimes when exploring indentation i use rules like this. Usually I try to
find other ways after, but I just assumed they weren't perf problems.
Apparently they are!
And by the way, i created an anchor like this:
https://git.sr.ht/~theo/tree-sitter-modes/tree/master/item/c-ts-mode.el#L57
This is nice when you need to just move a token to col 0, such as
preproc-directives. Maybe that should be a standard one? It could use the
buffer-root-node, but this was so simple and fast that I just did it like that.
What do you think?
Theo
- Re: CC Mode -> Tree sitter challenge, (continued)
- Re: CC Mode -> Tree sitter challenge, Theodor Thornhill, 2022/11/05
- Re: CC Mode -> Tree sitter challenge, Eli Zaretskii, 2022/11/05
- Re: CC Mode -> Tree sitter challenge, Theodor Thornhill, 2022/11/05
- Re: CC Mode -> Tree sitter challenge, Theodor Thornhill, 2022/11/05
- Re: CC Mode -> Tree sitter challenge, Eli Zaretskii, 2022/11/05
- Re: CC Mode -> Tree sitter challenge, Theodor Thornhill, 2022/11/05
- Re: CC Mode -> Tree sitter challenge, Theodor Thornhill, 2022/11/05
- Re: CC Mode -> Tree sitter challenge, Theodor Thornhill, 2022/11/05
- Re: CC Mode -> Tree sitter challenge, Eli Zaretskii, 2022/11/05
- Re: CC Mode -> Tree sitter challenge, Yuan Fu, 2022/11/05
- Re: CC Mode -> Tree sitter challenge,
Theodor Thornhill <=
- Re: CC Mode -> Tree sitter challenge, Yuan Fu, 2022/11/06
- Re: CC Mode -> Tree sitter challenge, Theodor Thornhill, 2022/11/07
Re: CC Mode -> Tree sitter challenge, Stefan Monnier, 2022/11/05