Custom (honu-style) operator support. Still need to do a little bit of cleaning/testing before I merge. Here's the syntax I'm going with at the moment:
unaryop neg 14 {$op} => #{ -$op }
binaryop plus 12 left { $lhs, $rhs } => #{ $lhs + $rhs }
The definition syntax is actually just a macro that desugars down to a primitive form:
binaryop (plus) 12 left {
macro {
rule { ($left:expr) ($right:expr) } => {
$left + $right
}
}
}
One interesting question came up while I was working on this. How should we order precedence? The precedence table on mdn is ordered from highest (0) to lowest (18), which seems a bit backwards since bigger numbers have lower precedence. I've flipped this for sweet.js so 0 binds least tightly and 18 binds most tightly. Is this the right choice or will people be confused because of the mdn page?