3 ms·
The macro's input syntax could be improved by more directly matching the generated code ([C-EVOCATIVE][0]). Rather than pub node Expression = | BinOp ->
by couchand 3y ago
The macro's input syntax could be improved by more directly matching the generated code ([C-EVOCATIVE][0]).
Rather than
pub node Expression =
| BinOp -> Node<BinaryOperation>
| UnOp -> Node<UnaryOperation>
| Num -> Node<Number>
;
pub node BinaryOperation = {
lhs: Node<Expression>,
op: BinOp,
rhs: Node<Expression>,
}
write
pub enum Expression {
BinOp(Node<BinaryOperation>),
Node(Node<UnaryOperation>),
Num(Node<Number>),
}
pub struct BinaryOperation {
lhs: Node<Expression>,
op: BinOp,
rhs: Node<Expression>,
}
[0]: https://rust-lang.github.io/api-guidelines/macros.html#input-syntax-is-evocative-of-the-output-c-evocative https://rust-lang.github.io/api-guidelines/macros.html#input...