[Top][All Lists]

[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: Mon, 07 Nov 2022 09:05:13 +0100

Hi Yuan.

>>> 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 :)
> Yeah if there is no performance issue, it’s better to keep things simple.
>>> 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!
> I see, we can precompile these queries automatically for the user. 

I think that's a good idea

>> 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?
> I’ll add it, thanks!

My pleasure :)

Come to think of it.  Maybe also some "this should always be fixed at
column N"?


reply via email to

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