wenkokke / tree-sitter-talon

Tree Sitter parser for Talon files.
MIT License
8 stars 5 forks source link

support no space between spoken form and parens? #21

Closed pokey closed 1 year ago

pokey commented 1 year ago

Talon supports hello(world): bar to map a spoken form equivalent to hello world: bar. Do we want to support this?

wenkokke commented 1 year ago

No, because that would clash with the special syntax key(...): and such, and would make parsing a mess.

pokey commented 1 year ago

I don't think it actually clashes with that syntax, and it appears you have special cases for all the functions anyway, so I'm not sure I see a problem

Fwiw, note that on the converse, key (a): foo is treated by Talon as equivalent to key a: foo (ie it matches someone saying the literal phrase "key a"). Not arguing we want to support that either, but we are introducing inconsistencies with the Talon parser

wenkokke commented 1 year ago

Inconsistencies are unfortunately difficult to avoid because the Talon syntax is ambiguous.

wenkokke commented 1 year ago

In my experience, using higher precedence for key(..) as a key binding over a command makes the error correcting behavior of the tree sitter parser act up.

Therefore this is probably best solved with lookahead in the lexer.

pokey commented 1 year ago

Ok so just to make sure we're on the same page, how do you want to parse the following:

hello(world): bar
key (a): bar

And does today's parsing of this program match your desired parsing? If the answer to that last question is "yes", then we can close this issue, but just wanted to make it all explicit

To be clear, Talon parses it as equivalent to the following:

hello world: bar
key a: bar

If we do parse them the same way Talon does, I'd argue the autoformatter should transform them to the second form above, but that's obv out of scope for this repo

wenkokke commented 1 year ago

I agree with these parsings. The cases I'm unsure about are:

key(not-a-valid-key-name): bar

Do you know what Talon parses these as?

AndreasArvidsson commented 1 year ago

Pretty sure the parser doesn't care about valid key names. The content inside the parentheses is just a string. That would probably generate a unknown key error when Talon tries to utilize the key value.

wenkokke commented 1 year ago

Closing in favour of meta issue #33