Civet icon indicating copy to clipboard operation
Civet copied to clipboard

Cannot create operator with same precedence as pipe

Open bbrk24 opened this issue 1 year ago • 4 comments
trafficstars

operator o right same(|) parses fine, but operator o right same(|>) doesn't parse. For some reason it lexes the latter as [(, |, >)] rather than [(, |>, )].

bbrk24 avatar Feb 21 '24 04:02 bbrk24

Civet does not consider |> a binary operator. It's not currently possible to put a custom operator at that level.

edemaine avatar Feb 21 '24 04:02 edemaine

I see. The error message is more informative if I type same(▷) instead.

bbrk24 avatar Feb 21 '24 04:02 bbrk24

The TC39 proposal says |> is on the same precedence level as =, but same(=) also doesn't work for much more obvious reasons. Though I am a little surprised same(++=) doesn't work, given that that's a runtime function call rather than actual assignment.

bbrk24 avatar Feb 21 '24 04:02 bbrk24

Now that we have precedence and associativity we can adjust the parser to have more things be binary operators but it may not be a small task.

STRd6 avatar Feb 21 '24 04:02 STRd6