In L-System notation a pattern would look something like this:
A(a)<A(x)>B(b, c) if a+b+c < 10 => B(a+b, a+c)A(x+a+b+c)
I'm trying to write rust macros to expand these. So I have something like this:
macro_rules! test {
($lc:pat < $a:pat > $rc:pat) => { ... };
}
But it won't let me. It says:
error: `$a:pat` is followed by `>`, which is not allowed for `pat` fragments
--> src/main.rs:7:23
|
7 | ($lc:pat < $a:pat > $rc:pat) => { log_syntax!($lc); log_syntax!($a); log_syntax!($rc); };
| ^ not allowed after `pat` fragments
|
= note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in`
Why aren't these allowed after the pat type? What can I match against to get this?
I can't use tt because apparently parenthesis aren't allowed for that.