Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top