ming_codes
ming_codes

Reputation: 2922

How to match colon in sweet.js?

macro m {
  rule {
    $a: $b
  } => {
    $a($b)
  }
}

m 1: 2

I think sweetjs is interpreting the colon as a marker for match class. If so, how do I escape that make make sweetjs match it as it is?

This seems to work just fine though

macro m {
  rule {
    :$b
  } => {
    $b
  }
}

m :1

Upvotes: 0

Views: 125

Answers (1)

timdisney
timdisney

Reputation: 5337

You can use $[:] to match a literal.

Upvotes: 1

Related Questions