@Kha Note that I had to write the weird pattern ``` match_syntax stx with | `(notation:$prec $items* => $rhs) => expandNotationAux stx prec items rhs | `(notation $noprec* $items* => $rhs) => expandNotationAux stx none items rhs | _ => Macro.throwUnsupported ``` with the weird `$noprec*` to match the case where the optional precedence is not provided. I realized this is not a bug, but I guess most users will be puzzled by this behavior. If we had a kind for `notationItem`, I would be able to write ``` `(notation $items:notationItems* => $rhs) ```
27 lines
354 B
Text
27 lines
354 B
Text
new_frontend
|
|
|
|
notation:50 a `**` b:50 => b * a * b
|
|
notation "~" a => a+a
|
|
|
|
namespace Foo
|
|
notation "~~" a => a+a
|
|
end Foo
|
|
|
|
syntax:60 term "+++" term:59 : term
|
|
|
|
syntax "<|" term "|>" : term
|
|
|
|
macro_rules
|
|
| `($a +++ $b) => `($a + $b + $b)
|
|
|
|
macro_rules
|
|
| `(<| $x |>) => `($x +++ 1 ** 2)
|
|
|
|
|
|
#check <| 2 |>
|
|
|
|
#check <| ~2 |>
|
|
|
|
#check <| ~~2 |>
|
|
|
|
#check <| <| 3 |> |>
|