about summary refs log tree commit diff
path: root/src/comp/syntax/ext
diff options
context:
space:
mode:
authorKevin Atkinson <kevina@cs.utah.edu>2012-02-01 00:20:31 -0700
committerKevin Atkinson <kevina@cs.utah.edu>2012-02-03 20:41:48 -0700
commitda74a7f9ca774cd8addcb00a361bb230facc3b31 (patch)
tree56a6c60c5d6825a02e59c8934deba409334f70e0 /src/comp/syntax/ext
parent5ea04c65c151708272b92d00c8448156239affb2 (diff)
downloadrust-da74a7f9ca774cd8addcb00a361bb230facc3b31.tar.gz
rust-da74a7f9ca774cd8addcb00a361bb230facc3b31.zip
Make macro arg optional in syntax, again untested.
Diffstat (limited to 'src/comp/syntax/ext')
-rw-r--r--src/comp/syntax/ext/base.rs7
-rw-r--r--src/comp/syntax/ext/concat_idents.rs1
-rw-r--r--src/comp/syntax/ext/env.rs1
-rw-r--r--src/comp/syntax/ext/fmt.rs1
-rw-r--r--src/comp/syntax/ext/ident_to_str.rs1
-rw-r--r--src/comp/syntax/ext/log_syntax.rs1
-rw-r--r--src/comp/syntax/ext/simplext.rs4
7 files changed, 15 insertions, 1 deletions
diff --git a/src/comp/syntax/ext/base.rs b/src/comp/syntax/ext/base.rs
index 824931a759b..415c6cb5d9b 100644
--- a/src/comp/syntax/ext/base.rs
+++ b/src/comp/syntax/ext/base.rs
@@ -118,6 +118,13 @@ fn make_new_lit(cx: ext_ctxt, sp: codemap::span, lit: ast::lit_) ->
     ret @{id: cx.next_id(), node: ast::expr_lit(sp_lit), span: sp};
 }
 
+fn get_mac_arg(cx: ext_ctxt, sp: span, arg: ast::mac_arg) -> @ast::expr {
+    alt (arg) {
+      some(expr) {expr}
+      none {cx.span_fatal(sp, "missing macro args")}
+    }
+}
+
 fn get_mac_body(cx: ext_ctxt, sp: span, args: ast::mac_body)
     -> ast::mac_body_
 {
diff --git a/src/comp/syntax/ext/concat_idents.rs b/src/comp/syntax/ext/concat_idents.rs
index b451e449b30..538c40a9d66 100644
--- a/src/comp/syntax/ext/concat_idents.rs
+++ b/src/comp/syntax/ext/concat_idents.rs
@@ -4,6 +4,7 @@ import syntax::ast;
 
 fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
                      _body: ast::mac_body) -> @ast::expr {
+    let arg = get_mac_arg(cx,sp,arg);
     let args: [@ast::expr] =
         alt arg.node {
           ast::expr_vec(elts, _) { elts }
diff --git a/src/comp/syntax/ext/env.rs b/src/comp/syntax/ext/env.rs
index 8cf299c5e67..b9b42028c0f 100644
--- a/src/comp/syntax/ext/env.rs
+++ b/src/comp/syntax/ext/env.rs
@@ -11,6 +11,7 @@ export expand_syntax_ext;
 
 fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
                      _body: ast::mac_body) -> @ast::expr {
+    let arg = get_mac_arg(cx,sp,arg);
     let args: [@ast::expr] =
         alt arg.node {
           ast::expr_vec(elts, _) { elts }
diff --git a/src/comp/syntax/ext/fmt.rs b/src/comp/syntax/ext/fmt.rs
index b2425079ed8..b7834175d2f 100644
--- a/src/comp/syntax/ext/fmt.rs
+++ b/src/comp/syntax/ext/fmt.rs
@@ -15,6 +15,7 @@ export expand_syntax_ext;
 
 fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
                      _body: ast::mac_body) -> @ast::expr {
+    let arg = get_mac_arg(cx,sp,arg);
     let args: [@ast::expr] =
         alt arg.node {
           ast::expr_vec(elts, _) { elts }
diff --git a/src/comp/syntax/ext/ident_to_str.rs b/src/comp/syntax/ext/ident_to_str.rs
index a5a2dedcbf9..9245e5aa6d4 100644
--- a/src/comp/syntax/ext/ident_to_str.rs
+++ b/src/comp/syntax/ext/ident_to_str.rs
@@ -4,6 +4,7 @@ import syntax::ast;
 
 fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
                      _body: ast::mac_body) -> @ast::expr {
+    let arg = get_mac_arg(cx,sp,arg);
     let args: [@ast::expr] =
         alt arg.node {
           ast::expr_vec(elts, _) { elts }
diff --git a/src/comp/syntax/ext/log_syntax.rs b/src/comp/syntax/ext/log_syntax.rs
index 4047a1b95d3..911cf9ff2eb 100644
--- a/src/comp/syntax/ext/log_syntax.rs
+++ b/src/comp/syntax/ext/log_syntax.rs
@@ -4,6 +4,7 @@ import std::io::writer_util;
 
 fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
                      _body: ast::mac_body) -> @ast::expr {
+    let arg = get_mac_arg(cx,sp,arg);
     cx.print_backtrace();
     std::io::stdout().write_line(print::pprust::expr_to_str(arg));
 
diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs
index b8722122b69..d8496203e3d 100644
--- a/src/comp/syntax/ext/simplext.rs
+++ b/src/comp/syntax/ext/simplext.rs
@@ -671,6 +671,7 @@ fn p_t_s_r_actual_vector(cx: ext_ctxt, elts: [@expr], _repeat_after: bool,
 
 fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
                      _body: ast::mac_body) -> base::macro_def {
+    let arg = get_mac_arg(cx,sp,arg);
     let args: [@ast::expr] =
         alt arg.node {
           ast::expr_vec(elts, _) { elts }
@@ -716,7 +717,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
                     }
                     clauses +=
                         [@{params: pattern_to_selectors
-                               (cx, invoc_arg),
+                               (cx, get_mac_arg(cx,mac.span,invoc_arg)),
                            body: elts[1u]}];
 
                     // FIXME: check duplicates (or just simplify
@@ -757,6 +758,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
 
     fn generic_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
                          _body: ast::mac_body, clauses: [@clause]) -> @expr {
+        let arg = get_mac_arg(cx,sp,arg);
         for c: @clause in clauses {
             alt use_selectors_to_bind(c.params, arg) {
               some(bindings) { ret transcribe(cx, bindings, c.body); }