Update invocation syntax for macro_rules!

This commit is contained in:
Paul Stansifer 2012-08-22 17:47:11 -07:00
parent 345363866c
commit 38891b91bf
13 changed files with 36 additions and 36 deletions

View File

@ -16,9 +16,9 @@ import io::WriterUtil;
import pipes::{port, chan, SharedChan};
macro_rules! move_out {
macro_rules! move_out (
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } }
}
)
enum request {
get_count,

View File

@ -12,9 +12,9 @@ import io::WriterUtil;
import pipes::{port, PortSet, chan};
macro_rules! move_out {
macro_rules! move_out (
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } }
}
)
enum request {
get_count,

View File

@ -32,11 +32,11 @@ proto! pingpong_unbounded {
}
// This stuff should go in libcore::pipes
macro_rules! move_it {
macro_rules! move_it (
{ $x:expr } => { let t <- *ptr::addr_of($x); t }
}
)
macro_rules! follow {
macro_rules! follow (
{
$($message:path($($x: ident),+) -> $next:ident $e:expr)+
} => (
@ -62,7 +62,7 @@ macro_rules! follow {
_ => { fail }
}
)
}
)
fn switch<T: send, Tb: send, U>(+endp: pipes::recv_packet_buffered<T, Tb>,
f: fn(+option<T>) -> U) -> U {

View File

@ -34,9 +34,9 @@ import comm::port;
import comm::recv;
import comm::send;
macro_rules! move_out {
macro_rules! move_out (
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } }
}
)
trait word_reader {
fn read_word() -> option<~str>;

View File

@ -15,13 +15,13 @@ left.
*/
macro_rules! html {
macro_rules! html (
{ $($body:tt)* } => (
parse_node!( []; []; $($body)* )
)
}
)
macro_rules! parse_node {
macro_rules! parse_node (
{
[:$head:ident ($(:$head_nodes:expr),*)
$(:$tags:ident ($(:$tag_nodes:expr),*))*];
@ -72,7 +72,7 @@ macro_rules! parse_node {
);
{ []; [:$e:expr]; } => ( $e );
}
)
fn main() {
let page = html! (

View File

@ -9,12 +9,12 @@ fn main() {
assert (mylambda!(y, y * 2)(8) == 16);
macro_rules! mylambda_tt{
macro_rules! mylambda_tt(
{$x:ident, $body:expr} => {
fn f($x: int) -> int { return $body; };
f
}
}
)
assert(mylambda_tt!(y, y * 2)(8) == 16)
}

View File

@ -5,8 +5,8 @@ fn main() {
assert (trivial!() == 16);
macro_rules! trivial_tt{
macro_rules! trivial_tt(
{} => {1*2*4*2*1}
}
)
assert(trivial_tt!() == 16);
}

View File

@ -2,9 +2,9 @@
fn main() {
#macro[[#apply[f, [x, ...]], f(x, ...)]];
macro_rules! apply_tt{
macro_rules! apply_tt(
{$f:expr, ($($x:expr),*)} => {$f($($x),*)}
}
)
fn add(a: int, b: int) -> int { return a + b; }

View File

@ -1,5 +1,5 @@
macro_rules! overly_complicated {
macro_rules! overly_complicated (
{$fnname:ident, $arg:ident, $ty:ty, $body:block, $val:expr, $pat:pat, $res:path} =>
{
fn $fnname($arg: $ty) -> option<$ty> $body
@ -11,7 +11,7 @@ macro_rules! overly_complicated {
}
}
}
)
fn main() {
assert overly_complicated!(f, x, option<uint>, { return some(x); },
some(8u), some(y), y) == 8u

View File

@ -4,8 +4,8 @@ fn main() {
#macro[[#m1[a], a * 4]];
assert (m1!(2) == 8);
macro_rules! m1tt {
macro_rules! m1tt (
{$a:expr} => {$a*4}
};
);
assert(m1tt!(2) == 8);
}

View File

@ -32,9 +32,9 @@ proto! bank {
}
}
macro_rules! move_it {
macro_rules! move_it (
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } }
}
)
fn switch<T: send, U>(+endp: pipes::recv_packet<T>,
f: fn(+option<T>) -> U) -> U {
@ -43,7 +43,7 @@ fn switch<T: send, U>(+endp: pipes::recv_packet<T>,
fn move_it<T>(-x: T) -> T { x }
macro_rules! follow {
macro_rules! follow (
{
$($message:path$(($($x: ident),+))||* -> $next:ident $e:expr)+
} => (
@ -54,7 +54,7 @@ macro_rules! follow {
_ => { fail }
}
);
}
)
fn client_follow(+bank: bank::client::login) {
import bank::*;

View File

@ -8,7 +8,7 @@
import double_buffer::client::*;
import double_buffer::give_buffer;
macro_rules! select_if {
macro_rules! select_if (
{
$index:expr,
$count:expr,
@ -48,9 +48,9 @@ macro_rules! select_if {
} => {
fail
}
}
)
macro_rules! select {
macro_rules! select (
{
$( $port:path => {
$($message:path$(($($x: ident),+))dont_type_this*
@ -62,7 +62,7 @@ macro_rules! select {
$($message$(($($x),+))dont_type_this* -> $next $e),+
], )+)
}
}
)
// Types and protocols
struct Buffer {

View File

@ -3,7 +3,7 @@
{
// select!
macro_rules! select_if {
macro_rules! select_if (
{
$index:expr,
@ -44,9 +44,9 @@ macro_rules! select_if {
)
}
};
}
)
macro_rules! select {
macro_rules! select (
{
$( $port:path => {
$($message:path$(($($x: ident),+))dont_type_this*
@ -58,6 +58,6 @@ macro_rules! select {
$(type_this $message$(($(x $x),+))dont_type_this* -> $next => { $e }),+
])+)
}
}
)
}