> Originally I *did* want to operate on AST, because I couldn't get macro > system to parse more than the first statement when I was writing my rules > like this: > ( $head:stmt ; $($rest:*stmt*);+ ) => ( $head ; stmt_list!( > $($rest);+ ) ); > Apparently interpolated statements cannot be re-parsed again? > Correct.
> > Is tt specifier documented somewhere? I am guessing it stands for "token > tree", but what is a token tree? How is it different from AST? > A token tree is "almost unparsed": it consists of a sequence of tokens surrounded by `()`, `[]`, or `{}`, or a single token. It's the AST node that the macro parser knows how to parse into actually useful AST nodes. It isn't documented, sadly. > > >> macro_rules! stmt_list( >> ( while $cond:expr { $($body:tt)+ } ) => >> ( while $cond { stmt_list!( $($body)+ ) } ); >> ( $head:stmt ; $($rest:tt)+ ) => >> ( $head ; stmt_list!( $($rest)+ ) ); >> ( $head:stmt ) => >> ( $head ); >> ) >> > That doesn't seem to work :-( > Could you try wrapping `{}` inside the parens on the 2nd RHS, and adding a semicolon after all three invocations of `stmt_list!`? For future debugging back-and-forth, please contact me in #rust (I'm `pauls`), since that'll be easier than email? Paul
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev