mozilla/sweet.js — pull request #162 by natefaubion (2013-12-14 04:43:37+00:00)
Title: Infix progress

This is an ongoing PR to track the progress of infix macros. Please chime in at any point. I've broken it down into goals that I'll periodically update so you can see how far along it is:

- [x] Refactor the `macro` macro to translate infix `rule`s into infix `case`s.
- [ ] Refactor `syntaxCase` to understand the `infix` form and matching semantics.
- [ ] Add "reverse" support to the pattern matcher (return a shallow-reversed pattern tree)
- [ ] Plumb together `enforest` and `expandTermTree` to keep track of previous syntax/terms.
- [ ] Plumb the previous syntax/terms into the macro transformers.

***

For the time being, I'm using the following form for infix macros because it's the easiest to parse (anything before the bar is lookbehind, anything after is business as usual):

```js
macro foo {
rule infix { $lhs | $rhs } => { ... }
case infix { $lhs | $name $rhs } => { ... }
}
```

Another proposed forms for infix `case`s:

```js
macro foo {
rule infix { $lhs | $rhs } => { ... }
case infix { $lhs |$name| $rhs } => { ... }
}
```

And @disnet liked the haskelly:

```js
macro foo {
rule infix { $lhs | $rhs } => { ... }
case infix { $lhs `$name` $rhs } => { ... }
}
```