usagi-coffee / tree-sitter-abl

OpenEdge ABL grammar for tree-sitter
MIT License
5 stars 1 forks source link

These keywords are being captured with all the spaces in front. Is this a correct behavior? #42

Closed PauliusKu closed 1 month ago

PauliusKu commented 1 month ago

We made some workarounds for this issue already, but it would be nice to make it work correctly from your side.

METHOD: image

END (CLASS): image

DEFINE (PROPERTY): image

comments: image

jkbz64 commented 1 month ago

I guess what you don't like is that is says method definition starts at 0 (1) line, this is due to whitespace handling decision done in the parser - specificially this line extras: ($) => [$.comment, $.include, /[\s\f\uFEFF\u2060\u200B]|\\\r?\n/],, it says that each of the element (third is whitespace regex) can appear everywhere in the syntax BEFORE the element, so in this case when it tries to match kw("METHOD") it also matches whitespace BEFORE it (whitespace does not appear in the syntax tree due to it not having a name like comment/include), not having whitespace rule in the extras would require manual whitespace handling which would be extremely complicated in progress case as it does not care about whitespace at all. I could maybe pull off some workaround for your case in CLASS'es but no idea how would I go about doing a global fix (except for removing whitespace from extras, which.... will break the entire parser and require code redesign for the entire parser)

image

PauliusKu commented 1 month ago

Thanks for the explanation. Okay, I think we can manage this issue on our side then. I am closing this ticket.