Skip to content

Commit 9f6ac27

Browse files
committed
---
yaml --- r: 11402 b: refs/heads/master c: 77a0105 h: refs/heads/master v: v3
1 parent 12c809c commit 9f6ac27

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: a896eb326e00611434462191ca16efd38651e71c
2+
refs/heads/master: 77a01054fa5ee5e17faece9d68ecec9bf593778f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/comp/syntax/ext/qquote.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ iface qq_helper {
3030
fn mk_parse_fn(ext_ctxt,span) -> @ast::expr;
3131
fn get_fold_fn() -> str;
3232
}
33+
34+
impl of qq_helper for @ast::crate {
35+
fn span() -> span {self.span}
36+
fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_crate(*self, cx, v);}
37+
fn extract_mac() -> option<ast::mac_> {fail}
38+
fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
39+
mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_crate"])
40+
}
41+
fn get_fold_fn() -> str {"fold_crate"}
42+
}
3343
impl of qq_helper for @ast::expr {
3444
fn span() -> span {self.span}
3545
fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_expr(self, cx, v);}
@@ -145,6 +155,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span,
145155
let body = get_mac_body(ecx,_sp,body);
146156

147157
ret alt what {
158+
"crate" {finish(ecx, body, parse_crate)}
148159
"expr" {finish(ecx, body, parser::parse_expr)}
149160
"ty" {finish(ecx, body, parse_ty)}
150161
"item" {finish(ecx, body, parse_item)}
@@ -154,6 +165,10 @@ fn expand_ast(ecx: ext_ctxt, _sp: span,
154165
};
155166
}
156167

168+
fn parse_crate(p: parser) -> @ast::crate {
169+
parser::parse_crate_mod(p, [])
170+
}
171+
157172
fn parse_ty(p: parser) -> @ast::ty {
158173
parser::parse_ty(p, false)
159174
}
@@ -265,6 +280,9 @@ fn replace<T>(node: T, repls: [fragment], ff: fn (ast_fold, T) -> T)
265280
with *aft};
266281
ret ff(make_fold(f_pre), node);
267282
}
283+
fn fold_crate(f: ast_fold, &&n: @ast::crate) -> @ast::crate {
284+
@f.fold_crate(*n)
285+
}
268286
fn fold_expr(f: ast_fold, &&n: @ast::expr) -> @ast::expr {f.fold_expr(n)}
269287
fn fold_ty(f: ast_fold, &&n: @ast::ty) -> @ast::ty {f.fold_ty(n)}
270288
fn fold_item(f: ast_fold, &&n: @ast::item) -> @ast::item {f.fold_item(n)}

trunk/src/comp/syntax/print/pprust.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ fn print_crate(cm: codemap, span_diagnostic: diagnostic::span_handler,
7171
mutable cur_lit: 0u,
7272
mutable boxes: boxes,
7373
ann: ann};
74+
print_crate_(s, crate);
75+
}
76+
77+
fn print_crate_(s: ps, &&crate: @ast::crate) {
7478
print_mod(s, crate.node.module, crate.node.attrs);
7579
print_remaining_comments(s);
7680
eof(s.s);

trunk/src/test/run-pass/qquote.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ fn main() {
8888
let y = #ast{2};
8989
let test3 = #ast{$(x) + $(y)};
9090
check_pp(test3, pprust::print_expr, "1 + 2");
91+
92+
let crate = #ast(crate) { fn a() { } };
93+
check_pp(crate, pprust::print_crate_, "fn a() { }\n");
9194
}
9295

9396
fn check_pp<T>(expr: T, f: fn(pprust::ps, T), expect: str) {

0 commit comments

Comments
 (0)