Skip to content

Commit 7f29fbb

Browse files
committed
---
yaml --- r: 153389 b: refs/heads/try2 c: 2c4b6d6 h: refs/heads/master i: 153387: 4377479 v: v3
1 parent ccaffea commit 7f29fbb

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 6c8bb5a68a82afc0a94769b115988f4012e5991b
8+
refs/heads/try2: 2c4b6d6f7d6001bf9241f90f1465f4a98490a0d9
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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/try2/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)