diff options
| author | Kevin Atkinson <kevina@cs.utah.edu> | 2012-01-25 16:38:09 -0700 |
|---|---|---|
| committer | Kevin Atkinson <kevina@cs.utah.edu> | 2012-02-03 20:23:49 -0700 |
| commit | 5ef53382aeac2de7e6dcc43c156312d2e68c15e4 (patch) | |
| tree | 0687cc4a0a4bdd20b5118541dd149a2a7a9ec8c0 /src/comp/syntax/ext | |
| parent | 75edd9ff69625292b1c4d5f05502d1fd28b39f55 (diff) | |
Add support for parsing quasi-quotes, doesn't do anything useful yet.
Diffstat (limited to 'src/comp/syntax/ext')
| -rw-r--r-- | src/comp/syntax/ext/expand.rs | 10 | ||||
| -rw-r--r-- | src/comp/syntax/ext/simplext.rs | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/comp/syntax/ext/expand.rs b/src/comp/syntax/ext/expand.rs index d5482a1e62f..afcb184652c 100644 --- a/src/comp/syntax/ext/expand.rs +++ b/src/comp/syntax/ext/expand.rs @@ -5,7 +5,7 @@ import option::{none, some}; import std::map::hashmap; import vec; -import syntax::ast::{crate, expr_, expr_mac, mac_invoc}; +import syntax::ast::{crate, expr_, expr_mac, mac_invoc, mac_qq}; import syntax::fold::*; import syntax::ext::base::*; import syntax::parse::parser::parse_expr_from_source_str; @@ -45,6 +45,7 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, } } } + mac_qq(sp, exp) { (expand_qquote(cx, sp, exp), s) } _ { cx.span_bug(mac.span, "naked syntactic bit") } } } @@ -52,6 +53,13 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, }; } +fn expand_qquote(cx: ext_ctxt, sp: span, e: @ast::expr) -> ast::expr_ { + import syntax::ext::build::*; + let str = codemap::span_to_snippet(sp, cx.session().parse_sess.cm); + let expr = make_new_str(cx, e.span, str); + ret expr.node; +} + // FIXME: this is a terrible kludge to inject some macros into the default // compilation environment. When the macro-definition system is substantially // more mature, these should move from here, into a compiled part of libcore diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs index cc133e704e7..3ee7a422d2e 100644 --- a/src/comp/syntax/ext/simplext.rs +++ b/src/comp/syntax/ext/simplext.rs @@ -587,6 +587,9 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) { none { no_des(cx, blk.span, "under `#{}`"); } } } + ast::mac_qq(_,_) { no_des(cx, mac.span, "quasiquotes"); } + ast::mac_aq(_,_) { no_des(cx, mac.span, "antiquotes"); } + ast::mac_var(_) { no_des(cx, mac.span, "antiquote variables"); } } } |
