============================================ Macro invocation - no arguments ============================================ a!(); b![]; c!{}; --- (source_file (macro_invocation (identifier) (token_tree)) (macro_invocation (identifier) (token_tree)) (macro_invocation (identifier) (token_tree))) ============================================ Macro invocation - arbitrary tokens ============================================ a!(* a *); a!(& a &); a!(- a -); a!(b + c + +); ---- (source_file (macro_invocation (identifier) (token_tree (identifier))) (macro_invocation (identifier) (token_tree (identifier))) (macro_invocation (identifier) (token_tree (identifier))) (macro_invocation (identifier) (token_tree (identifier) (identifier)))) ============================================ Macro definition ============================================ macro_rules! say_hello { () => ( println!("Hello!"); ) } macro_rules! four { () => {1 + 3}; } macro_rules! foo { (x => $e:expr) => (println!("mode X: {}", $e)); (y => $e:expr) => (println!("mode Y: {}", $e)) } macro_rules! o_O { ( $($x:expr; [ $( $y:expr ),* ]);* ) => { $($($x + $e),*),* } } macro_rules! zero_or_one { ($($e:expr),?) => { $($e),? }; } ---- (source_file (macro_definition name: (identifier) (macro_rule left: (token_tree_pattern) right: (token_tree (identifier) (token_tree (string_literal))))) (macro_definition name: (identifier) (macro_rule left: (token_tree_pattern) right: (token_tree (integer_literal) (integer_literal)))) (macro_definition name: (identifier) (macro_rule left: (token_tree_pattern (identifier) (token_binding_pattern name: (metavariable) type: (fragment_specifier))) right: (token_tree (identifier) (token_tree (string_literal) (metavariable)))) (macro_rule left: (token_tree_pattern (identifier) (token_binding_pattern name: (metavariable) type: (fragment_specifier))) right: (token_tree (identifier) (token_tree (string_literal) (metavariable))))) (macro_definition name: (identifier) (macro_rule left: (token_tree_pattern (token_repetition_pattern (token_binding_pattern name: (metavariable) type: (fragment_specifier)) (token_tree_pattern (token_repetition_pattern (token_binding_pattern name: (metavariable) type: (fragment_specifier)))))) right: (token_tree (token_repetition (token_repetition (metavariable) (metavariable)))))) (macro_definition name: (identifier) (macro_rule left: (token_tree_pattern (token_repetition_pattern (token_binding_pattern name: (metavariable) type: (fragment_specifier)))) right: (token_tree (token_repetition (metavariable))))))