Reputation: 128
I want to use parenthesis in macros body to group expressions. For example:
macro m {
rule { ($x, $y) } => {
$x >>> ($y * 5)
}
}
Sweet.js remove all parenthesis:
m(6, 7) => 6 >>> 7 * 5
I expect next output:
m(6, 7) => 6 >>> (7 * 5)
How can I escape parenthesis inside macros body?
Upvotes: 1
Views: 141
Reputation: 5337
Sweet.js (technically escodegen which sweet.js uses for codegen) only removes redundant parens (ie precedence rules mean that 6 >>> 7 * 5 === 6 >>> (7 * 5)
so the parens aren't needed) so you shouldn't need to do anything to escape parens in macros.
Upvotes: 3