Permalink
Browse files

Update invocation syntax for `macro_rules!`

  • Loading branch information...
paulstansifer committed Aug 23, 2012
1 parent 3453638 commit 38891b91bfe5d3fd10e841dbc6f67965bed141ea
@@ -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,
@@ -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,
@@ -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 {
@@ -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>;
@@ -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! (
@@ -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)
}
@@ -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);
}
@@ -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; }
@@ -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
@@ -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);
}
@@ -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::*;
@@ -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 {
@@ -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 }),+
])+)
}
-}
+)
}

0 comments on commit 38891b9

Please sign in to comment.