Skip to content

Commit 272c834

Browse files
committed
---
yaml --- r: 124238 b: refs/heads/try c: 2c4b6d6 h: refs/heads/master v: v3
1 parent df3632f commit 272c834

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 6c35d513cea468b30759b4f78becf28f11a123c0
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: afbcbbc77ffc6b10053bc543daf7d2e05d68cc01
5-
refs/heads/try: 6c8bb5a68a82afc0a94769b115988f4012e5991b
5+
refs/heads/try: 2c4b6d6f7d6001bf9241f90f1465f4a98490a0d9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libsyntax/ext/base.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ pub type IdentMacroExpanderFn =
104104
/// just into the compiler's internal macro table, for `make_def`).
105105
pub trait MacResult {
106106
/// Define a new macro.
107+
// this should go away; the idea that a macro might expand into
108+
// either a macro definition or an expression, depending on what
109+
// the context wants, is kind of silly.
107110
fn make_def(&self) -> Option<MacroDef> {
108111
None
109112
}
@@ -115,6 +118,12 @@ pub trait MacResult {
115118
fn make_items(&self) -> Option<SmallVector<Gc<ast::Item>>> {
116119
None
117120
}
121+
122+
/// Create zero or more methods.
123+
fn make_methods(&self) -> Option<SmallVector<Gc<ast::Method>>> {
124+
None
125+
}
126+
118127
/// Create a pattern.
119128
fn make_pat(&self) -> Option<Gc<ast::Pat>> {
120129
None
@@ -222,6 +231,7 @@ impl DummyResult {
222231
span: sp,
223232
}
224233
}
234+
225235
}
226236

227237
impl MacResult for DummyResult {
@@ -232,6 +242,14 @@ impl MacResult for DummyResult {
232242
Some(DummyResult::raw_pat(self.span))
233243
}
234244
fn make_items(&self) -> Option<SmallVector<Gc<ast::Item>>> {
245+
// this code needs a comment... why not always just return the Some() ?
246+
if self.expr_only {
247+
None
248+
} else {
249+
Some(SmallVector::zero())
250+
}
251+
}
252+
fn make_methods(&self) -> Option<SmallVector<Gc<ast::Method>>> {
235253
if self.expr_only {
236254
None
237255
} else {

branches/try/src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct ParserAnyMacro<'a> {
3838
impl<'a> ParserAnyMacro<'a> {
3939
/// Make sure we don't have any tokens left to parse, so we don't
4040
/// silently drop anything. `allow_semi` is so that "optional"
41-
/// semilons at the end of normal expressions aren't complained
41+
/// semicolons at the end of normal expressions aren't complained
4242
/// about e.g. the semicolon in `macro_rules! kapow( () => {
4343
/// fail!(); } )` doesn't get picked up by .parse_expr(), but it's
4444
/// allowed to be there.
@@ -73,6 +73,9 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
7373
let mut ret = SmallVector::zero();
7474
loop {
7575
let mut parser = self.parser.borrow_mut();
76+
// so... do outer attributes attached to the macro invocation
77+
// just disappear? This question applies to make_methods, as
78+
// well.
7679
match parser.parse_item_with_outer_attributes() {
7780
Some(item) => ret.push(item),
7881
None => break
@@ -81,6 +84,20 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
8184
self.ensure_complete_parse(false);
8285
Some(ret)
8386
}
87+
88+
fn make_methods(&self) -> Option<SmallVector<Gc<ast::Method>>> {
89+
let mut ret = SmallVector::zero();
90+
loop {
91+
let mut parser = self.parser.borrow_mut();
92+
match parser.token {
93+
EOF => break,
94+
_ => ret.push(parser.parse_method(None))
95+
}
96+
}
97+
self.ensure_complete_parse(false);
98+
Some(ret)
99+
}
100+
84101
fn make_stmt(&self) -> Option<Gc<ast::Stmt>> {
85102
let attrs = self.parser.borrow_mut().parse_outer_attributes();
86103
let ret = self.parser.borrow_mut().parse_stmt(attrs);

0 commit comments

Comments
 (0)