about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-06-01 09:37:39 -0700
committerbors <bors@rust-lang.org>2013-06-01 09:37:39 -0700
commit44af5064d0ac3d45223f1555b299f10fd4902f5c (patch)
tree33a4db59bd936a73594ca144e809b6074d6ccef3 /src/libsyntax/parse
parentb8391ccea0b2e2718a4d4ef999e9f03583c7ddea (diff)
parent5fb254695b4db9af3d8e33577fae28ae9f7006c5 (diff)
downloadrust-44af5064d0ac3d45223f1555b299f10fd4902f5c.tar.gz
rust-44af5064d0ac3d45223f1555b299f10fd4902f5c.zip
auto merge of #6871 : pcwalton/rust/de-pub-impl, r=pcwalton
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/common.rs96
-rw-r--r--src/libsyntax/parse/obsolete.rs27
-rw-r--r--src/libsyntax/parse/parser.rs219
-rw-r--r--src/libsyntax/parse/token.rs19
4 files changed, 177 insertions, 184 deletions
diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs
index bdbe91e4112..8a930cf9afd 100644
--- a/src/libsyntax/parse/common.rs
+++ b/src/libsyntax/parse/common.rs
@@ -52,18 +52,18 @@ pub fn token_to_str(reader: @reader, token: &token::Token) -> ~str {
     token::to_str(reader.interner(), token)
 }
 
-pub impl Parser {
+impl Parser {
     // convert a token to a string using self's reader
-    fn token_to_str(&self, token: &token::Token) -> ~str {
+    pub fn token_to_str(&self, token: &token::Token) -> ~str {
         token::to_str(self.reader.interner(), token)
     }
 
     // convert the current token to a string using self's reader
-    fn this_token_to_str(&self) -> ~str {
+    pub fn this_token_to_str(&self) -> ~str {
         self.token_to_str(self.token)
     }
 
-    fn unexpected_last(&self, t: &token::Token) -> ! {
+    pub fn unexpected_last(&self, t: &token::Token) -> ! {
         self.span_fatal(
             *self.last_span,
             fmt!(
@@ -73,7 +73,7 @@ pub impl Parser {
         );
     }
 
-    fn unexpected(&self) -> ! {
+    pub fn unexpected(&self) -> ! {
         self.fatal(
             fmt!(
                 "unexpected token: `%s`",
@@ -84,7 +84,7 @@ pub impl Parser {
 
     // expect and consume the token t. Signal an error if
     // the next token is not t.
-    fn expect(&self, t: &token::Token) {
+    pub fn expect(&self, t: &token::Token) {
         if *self.token == *t {
             self.bump();
         } else {
@@ -98,7 +98,7 @@ pub impl Parser {
         }
     }
 
-    fn parse_ident(&self) -> ast::ident {
+    pub fn parse_ident(&self) -> ast::ident {
         self.check_strict_keywords();
         self.check_reserved_keywords();
         match *self.token {
@@ -120,7 +120,7 @@ pub impl Parser {
         }
     }
 
-    fn parse_path_list_ident(&self) -> ast::path_list_ident {
+    pub fn parse_path_list_ident(&self) -> ast::path_list_ident {
         let lo = self.span.lo;
         let ident = self.parse_ident();
         let hi = self.last_span.hi;
@@ -130,17 +130,17 @@ pub impl Parser {
 
     // consume token 'tok' if it exists. Returns true if the given
     // token was present, false otherwise.
-    fn eat(&self, tok: &token::Token) -> bool {
+    pub fn eat(&self, tok: &token::Token) -> bool {
         return if *self.token == *tok { self.bump(); true } else { false };
     }
 
-    fn is_keyword(&self, kw: keywords::Keyword) -> bool {
+    pub fn is_keyword(&self, kw: keywords::Keyword) -> bool {
         token::is_keyword(kw, self.token)
     }
 
     // if the next token is the given keyword, eat it and return
     // true. Otherwise, return false.
-    fn eat_keyword(&self, kw: keywords::Keyword) -> bool {
+    pub fn eat_keyword(&self, kw: keywords::Keyword) -> bool {
         let is_kw = match *self.token {
             token::IDENT(sid, false) => kw.to_ident().repr == sid.repr,
             _ => false
@@ -152,7 +152,7 @@ pub impl Parser {
     // if the given word is not a keyword, signal an error.
     // if the next token is not the given word, signal an error.
     // otherwise, eat it.
-    fn expect_keyword(&self, kw: keywords::Keyword) {
+    pub fn expect_keyword(&self, kw: keywords::Keyword) {
         if !self.eat_keyword(kw) {
             self.fatal(
                 fmt!(
@@ -165,7 +165,7 @@ pub impl Parser {
     }
 
     // signal an error if the given string is a strict keyword
-    fn check_strict_keywords(&self) {
+    pub fn check_strict_keywords(&self) {
         if token::is_strict_keyword(self.token) {
             self.span_err(*self.last_span,
                           fmt!("found `%s` in ident position", self.this_token_to_str()));
@@ -173,7 +173,7 @@ pub impl Parser {
     }
 
     // signal an error if the current token is a reserved keyword
-    fn check_reserved_keywords(&self) {
+    pub fn check_reserved_keywords(&self) {
         if token::is_reserved_keyword(self.token) {
             self.fatal(fmt!("`%s` is a reserved keyword", self.this_token_to_str()));
         }
@@ -182,7 +182,7 @@ pub impl Parser {
     // expect and consume a GT. if a >> is seen, replace it
     // with a single > and continue. If a GT is not seen,
     // signal an error.
-    fn expect_gt(&self) {
+    pub fn expect_gt(&self) {
         if *self.token == token::GT {
             self.bump();
         } else if *self.token == token::BINOP(token::SHR) {
@@ -203,11 +203,10 @@ pub impl Parser {
 
     // parse a sequence bracketed by '<' and '>', stopping
     // before the '>'.
-    fn parse_seq_to_before_gt<T: Copy>(
-        &self,
-        sep: Option<token::Token>,
-        f: &fn(&Parser) -> T
-    ) -> OptVec<T> {
+    pub fn parse_seq_to_before_gt<T: Copy>(&self,
+                                           sep: Option<token::Token>,
+                                           f: &fn(&Parser) -> T)
+                                           -> OptVec<T> {
         let mut first = true;
         let mut v = opt_vec::Empty;
         while *self.token != token::GT
@@ -224,11 +223,10 @@ pub impl Parser {
         return v;
     }
 
-    fn parse_seq_to_gt<T: Copy>(
-        &self,
-        sep: Option<token::Token>,
-        f: &fn(&Parser) -> T
-    ) -> OptVec<T> {
+    pub fn parse_seq_to_gt<T: Copy>(&self,
+                                    sep: Option<token::Token>,
+                                    f: &fn(&Parser) -> T)
+                                    -> OptVec<T> {
         let v = self.parse_seq_to_before_gt(sep, f);
         self.expect_gt();
         return v;
@@ -237,12 +235,11 @@ pub impl Parser {
     // parse a sequence, including the closing delimiter. The function
     // f must consume tokens until reaching the next separator or
     // closing bracket.
-    fn parse_seq_to_end<T: Copy>(
-        &self,
-        ket: &token::Token,
-        sep: SeqSep,
-        f: &fn(&Parser) -> T
-    ) -> ~[T] {
+    pub fn parse_seq_to_end<T: Copy>(&self,
+                                     ket: &token::Token,
+                                     sep: SeqSep,
+                                     f: &fn(&Parser) -> T)
+                                     -> ~[T] {
         let val = self.parse_seq_to_before_end(ket, sep, f);
         self.bump();
         val
@@ -251,12 +248,11 @@ pub impl Parser {
     // parse a sequence, not including the closing delimiter. The function
     // f must consume tokens until reaching the next separator or
     // closing bracket.
-    fn parse_seq_to_before_end<T: Copy>(
-        &self,
-        ket: &token::Token,
-        sep: SeqSep,
-        f: &fn(&Parser) -> T
-    ) -> ~[T] {
+    pub fn parse_seq_to_before_end<T: Copy>(&self,
+                                            ket: &token::Token,
+                                            sep: SeqSep,
+                                            f: &fn(&Parser) -> T)
+                                            -> ~[T] {
         let mut first: bool = true;
         let mut v: ~[T] = ~[];
         while *self.token != *ket {
@@ -276,13 +272,12 @@ pub impl Parser {
     // parse a sequence, including the closing delimiter. The function
     // f must consume tokens until reaching the next separator or
     // closing bracket.
-    fn parse_unspanned_seq<T: Copy>(
-        &self,
-        bra: &token::Token,
-        ket: &token::Token,
-        sep: SeqSep,
-        f: &fn(&Parser) -> T
-    ) -> ~[T] {
+    pub fn parse_unspanned_seq<T: Copy>(&self,
+                                        bra: &token::Token,
+                                        ket: &token::Token,
+                                        sep: SeqSep,
+                                        f: &fn(&Parser) -> T)
+                                        -> ~[T] {
         self.expect(bra);
         let result = self.parse_seq_to_before_end(ket, sep, f);
         self.bump();
@@ -291,13 +286,12 @@ pub impl Parser {
 
     // NB: Do not use this function unless you actually plan to place the
     // spanned list in the AST.
-    fn parse_seq<T: Copy>(
-        &self,
-        bra: &token::Token,
-        ket: &token::Token,
-        sep: SeqSep,
-        f: &fn(&Parser) -> T
-    ) -> spanned<~[T]> {
+    pub fn parse_seq<T: Copy>(&self,
+                              bra: &token::Token,
+                              ket: &token::Token,
+                              sep: SeqSep,
+                              f: &fn(&Parser) -> T)
+                              -> spanned<~[T]> {
         let lo = self.span.lo;
         self.expect(bra);
         let result = self.parse_seq_to_before_end(ket, sep, f);
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index 085d24d7e68..f11219f6c9e 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -73,9 +73,9 @@ impl to_bytes::IterBytes for ObsoleteSyntax {
     }
 }
 
-pub impl Parser {
+impl Parser {
     /// Reports an obsolete syntax non-fatal error.
-    fn obsolete(&self, sp: span, kind: ObsoleteSyntax) {
+    pub fn obsolete(&self, sp: span, kind: ObsoleteSyntax) {
         let (kind_str, desc) = match kind {
             ObsoleteLowerCaseKindBounds => (
                 "lower-case kind bounds",
@@ -232,13 +232,16 @@ pub impl Parser {
 
     // Reports an obsolete syntax non-fatal error, and returns
     // a placeholder expression
-    fn obsolete_expr(&self, sp: span, kind: ObsoleteSyntax) -> @expr {
+    pub fn obsolete_expr(&self, sp: span, kind: ObsoleteSyntax) -> @expr {
         self.obsolete(sp, kind);
         self.mk_expr(sp.lo, sp.hi, expr_lit(@respan(sp, lit_nil)))
     }
 
-    priv fn report(&self, sp: span, kind: ObsoleteSyntax, kind_str: &str,
-                   desc: &str) {
+    fn report(&self,
+              sp: span,
+              kind: ObsoleteSyntax,
+              kind_str: &str,
+              desc: &str) {
         self.span_err(sp, fmt!("obsolete syntax: %s", kind_str));
 
         if !self.obsolete_set.contains(&kind) {
@@ -247,7 +250,8 @@ pub impl Parser {
         }
     }
 
-    fn token_is_obsolete_ident(&self, ident: &str, token: &Token) -> bool {
+    pub fn token_is_obsolete_ident(&self, ident: &str, token: &Token)
+                                   -> bool {
         match *token {
             token::IDENT(sid, _) => {
                 str::eq_slice(*self.id_to_str(sid), ident)
@@ -256,11 +260,11 @@ pub impl Parser {
         }
     }
 
-    fn is_obsolete_ident(&self, ident: &str) -> bool {
+    pub fn is_obsolete_ident(&self, ident: &str) -> bool {
         self.token_is_obsolete_ident(ident, self.token)
     }
 
-    fn eat_obsolete_ident(&self, ident: &str) -> bool {
+    pub fn eat_obsolete_ident(&self, ident: &str) -> bool {
         if self.is_obsolete_ident(ident) {
             self.bump();
             true
@@ -269,7 +273,7 @@ pub impl Parser {
         }
     }
 
-    fn try_parse_obsolete_struct_ctor(&self) -> bool {
+    pub fn try_parse_obsolete_struct_ctor(&self) -> bool {
         if self.eat_obsolete_ident("new") {
             self.obsolete(*self.last_span, ObsoleteStructCtor);
             self.parse_fn_decl();
@@ -280,7 +284,7 @@ pub impl Parser {
         }
     }
 
-    fn try_parse_obsolete_with(&self) -> bool {
+    pub fn try_parse_obsolete_with(&self) -> bool {
         if *self.token == token::COMMA
             && self.token_is_obsolete_ident("with",
                                             &self.look_ahead(1u)) {
@@ -295,7 +299,8 @@ pub impl Parser {
         }
     }
 
-    fn try_parse_obsolete_priv_section(&self, attrs: &[attribute]) -> bool {
+    pub fn try_parse_obsolete_priv_section(&self, attrs: &[attribute])
+                                           -> bool {
         if self.is_keyword(keywords::Priv) && self.look_ahead(1) == token::LBRACE {
             self.obsolete(copy *self.span, ObsoletePrivSection);
             self.eat_keyword(keywords::Priv);
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index c47092ef61c..00ad12ce402 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -272,9 +272,9 @@ impl Drop for Parser {
     fn finalize(&self) {}
 }
 
-pub impl Parser {
+impl Parser {
     // advance the parser by one token
-    fn bump(&self) {
+    pub fn bump(&self) {
         *self.last_span = copy *self.span;
         let next = if *self.buffer_start == *self.buffer_end {
             self.reader.next_token()
@@ -288,17 +288,20 @@ pub impl Parser {
         *self.tokens_consumed += 1u;
     }
     // EFFECT: replace the current token and span with the given one
-    fn replace_token(&self, next: token::Token, lo: BytePos, hi: BytePos) {
+    pub fn replace_token(&self,
+                         next: token::Token,
+                         lo: BytePos,
+                         hi: BytePos) {
         *self.token = next;
         *self.span = mk_sp(lo, hi);
     }
-    fn buffer_length(&self) -> int {
+    pub fn buffer_length(&self) -> int {
         if *self.buffer_start <= *self.buffer_end {
             return *self.buffer_end - *self.buffer_start;
         }
         return (4 - *self.buffer_start) + *self.buffer_end;
     }
-    fn look_ahead(&self, distance: uint) -> token::Token {
+    pub fn look_ahead(&self, distance: uint) -> token::Token {
         let dist = distance as int;
         while self.buffer_length() < dist {
             self.buffer[*self.buffer_end] = self.reader.next_token();
@@ -306,49 +309,49 @@ pub impl Parser {
         }
         return copy self.buffer[(*self.buffer_start + dist - 1) & 3].tok;
     }
-    fn fatal(&self, m: &str) -> ! {
+    pub fn fatal(&self, m: &str) -> ! {
         self.sess.span_diagnostic.span_fatal(*copy self.span, m)
     }
-    fn span_fatal(&self, sp: span, m: &str) -> ! {
+    pub fn span_fatal(&self, sp: span, m: &str) -> ! {
         self.sess.span_diagnostic.span_fatal(sp, m)
     }
-    fn span_note(&self, sp: span, m: &str) {
+    pub fn span_note(&self, sp: span, m: &str) {
         self.sess.span_diagnostic.span_note(sp, m)
     }
-    fn bug(&self, m: &str) -> ! {
+    pub fn bug(&self, m: &str) -> ! {
         self.sess.span_diagnostic.span_bug(*copy self.span, m)
     }
-    fn warn(&self, m: &str) {
+    pub fn warn(&self, m: &str) {
         self.sess.span_diagnostic.span_warn(*copy self.span, m)
     }
-    fn span_err(&self, sp: span, m: &str) {
+    pub fn span_err(&self, sp: span, m: &str) {
         self.sess.span_diagnostic.span_err(sp, m)
     }
-    fn abort_if_errors(&self) {
+    pub fn abort_if_errors(&self) {
         self.sess.span_diagnostic.handler().abort_if_errors();
     }
-    fn get_id(&self) -> node_id { next_node_id(self.sess) }
+    pub fn get_id(&self) -> node_id { next_node_id(self.sess) }
 
-    fn id_to_str(&self, id: ident) -> @~str {
+    pub fn id_to_str(&self, id: ident) -> @~str {
         self.sess.interner.get(id)
     }
 
     // is this one of the keywords that signals a closure type?
-    fn token_is_closure_keyword(&self, tok: &token::Token) -> bool {
+    pub fn token_is_closure_keyword(&self, tok: &token::Token) -> bool {
         token::is_keyword(keywords::Pure, tok) ||
             token::is_keyword(keywords::Unsafe, tok) ||
             token::is_keyword(keywords::Once, tok) ||
             token::is_keyword(keywords::Fn, tok)
     }
 
-    fn token_is_lifetime(&self, tok: &token::Token) -> bool {
+    pub fn token_is_lifetime(&self, tok: &token::Token) -> bool {
         match *tok {
             token::LIFETIME(*) => true,
             _ => false,
         }
     }
 
-    fn get_lifetime(&self, tok: &token::Token) -> ast::ident {
+    pub fn get_lifetime(&self, tok: &token::Token) -> ast::ident {
         match *tok {
             token::LIFETIME(ref ident) => copy *ident,
             _ => self.bug("not a lifetime"),
@@ -356,8 +359,7 @@ pub impl Parser {
     }
 
     // parse a ty_bare_fun type:
-    fn parse_ty_bare_fn(&self) -> ty_
-    {
+    pub fn parse_ty_bare_fn(&self) -> ty_ {
         /*
 
         extern "ABI" [pure|unsafe] fn <'lt> (S) -> T
@@ -386,10 +388,10 @@ pub impl Parser {
     }
 
     // parse a ty_closure type
-    fn parse_ty_closure(&self,
-                        sigil: ast::Sigil,
-                        region: Option<@ast::Lifetime>)
-                        -> ty_ {
+    pub fn parse_ty_closure(&self,
+                            sigil: ast::Sigil,
+                            region: Option<@ast::Lifetime>)
+                            -> ty_ {
         /*
 
         (&|~|@) ['r] [pure|unsafe] [once] fn [:Bounds] <'lt> (S) -> T
@@ -440,7 +442,7 @@ pub impl Parser {
     }
 
     // looks like this should be called parse_unsafety
-    fn parse_unsafety(&self) -> purity {
+    pub fn parse_unsafety(&self) -> purity {
         if self.eat_keyword(keywords::Pure) {
             self.obsolete(*self.last_span, ObsoletePurity);
             return impure_fn;
@@ -452,7 +454,7 @@ pub impl Parser {
     }
 
     // parse a function type (following the 'fn')
-    fn parse_ty_fn_decl(&self) -> (fn_decl, OptVec<ast::Lifetime>) {
+    pub fn parse_ty_fn_decl(&self) -> (fn_decl, OptVec<ast::Lifetime>) {
         /*
 
         (fn) <'lt> (S) -> T
@@ -487,7 +489,7 @@ pub impl Parser {
     }
 
     // parse the methods in a trait declaration
-    fn parse_trait_methods(&self) -> ~[trait_method] {
+    pub fn parse_trait_methods(&self) -> ~[trait_method] {
         do self.parse_unspanned_seq(
             &token::LBRACE,
             &token::RBRACE,
@@ -563,9 +565,8 @@ pub impl Parser {
         }
     }
 
-
     // parse a possibly mutable type
-    fn parse_mt(&self) -> mt {
+    pub fn parse_mt(&self) -> mt {
         let mutbl = self.parse_mutability();
         let t = self.parse_ty(false);
         mt { ty: t, mutbl: mutbl }
@@ -573,7 +574,7 @@ pub impl Parser {
 
     // parse [mut/const/imm] ID : TY
     // now used only by obsolete record syntax parser...
-    fn parse_ty_field(&self) -> ty_field {
+    pub fn parse_ty_field(&self) -> ty_field {
         let lo = self.span.lo;
         let mutbl = self.parse_mutability();
         let id = self.parse_ident();
@@ -590,7 +591,7 @@ pub impl Parser {
     }
 
     // parse optional return type [ -> TY ] in function decl
-    fn parse_ret_ty(&self) -> (ret_style, @Ty) {
+    pub fn parse_ret_ty(&self) -> (ret_style, @Ty) {
         return if self.eat(&token::RARROW) {
             let lo = self.span.lo;
             if self.eat(&token::NOT) {
@@ -621,7 +622,7 @@ pub impl Parser {
     // parse a type.
     // Useless second parameter for compatibility with quasiquote macros.
     // Bleh!
-    fn parse_ty(&self, _: bool) -> @Ty {
+    pub fn parse_ty(&self, _: bool) -> @Ty {
         maybe_whole!(self, nt_ty);
 
         let lo = self.span.lo;
@@ -722,11 +723,9 @@ pub impl Parser {
     }
 
     // parse the type following a @ or a ~
-    fn parse_box_or_uniq_pointee(
-        &self,
-        sigil: ast::Sigil,
-        ctor: &fn(v: mt) -> ty_) -> ty_
-    {
+    pub fn parse_box_or_uniq_pointee(&self,
+                                     sigil: ast::Sigil,
+                                     ctor: &fn(v: mt) -> ty_) -> ty_ {
         // @'foo fn() or @foo/fn() or @fn() are parsed directly as fn types:
         match *self.token {
             token::LIFETIME(*) => {
@@ -765,7 +764,7 @@ pub impl Parser {
         ctor(mt)
     }
 
-    fn parse_borrowed_pointee(&self) -> ty_ {
+    pub fn parse_borrowed_pointee(&self) -> ty_ {
         // look for `&'lt` or `&'foo ` and interpret `foo` as the region name:
         let opt_lifetime = self.parse_opt_lifetime();
 
@@ -778,7 +777,7 @@ pub impl Parser {
     }
 
     // parse an optional, obsolete argument mode.
-    fn parse_arg_mode(&self) {
+    pub fn parse_arg_mode(&self) {
         if self.eat(&token::BINOP(token::MINUS)) {
             self.obsolete(*self.span, ObsoleteMode);
         } else if self.eat(&token::ANDAND) {
@@ -794,7 +793,7 @@ pub impl Parser {
         }
     }
 
-    fn is_named_argument(&self) -> bool {
+    pub fn is_named_argument(&self) -> bool {
         let offset = if *self.token == token::BINOP(token::AND) {
             1
         } else if *self.token == token::BINOP(token::MINUS) {
@@ -819,7 +818,7 @@ pub impl Parser {
 
     // This version of parse arg doesn't necessarily require
     // identifier names.
-    fn parse_arg_general(&self, require_name: bool) -> arg {
+    pub fn parse_arg_general(&self, require_name: bool) -> arg {
         let mut is_mutbl = false;
         let pat = if require_name || self.is_named_argument() {
             self.parse_arg_mode();
@@ -844,12 +843,12 @@ pub impl Parser {
     }
 
     // parse a single function argument
-    fn parse_arg(&self) -> arg_or_capture_item {
+    pub fn parse_arg(&self) -> arg_or_capture_item {
         either::Left(self.parse_arg_general(true))
     }
 
     // parse an argument in a lambda header e.g. |arg, arg|
-    fn parse_fn_block_arg(&self) -> arg_or_capture_item {
+    pub fn parse_fn_block_arg(&self) -> arg_or_capture_item {
         self.parse_arg_mode();
         let is_mutbl = self.eat_keyword(keywords::Mut);
         let pat = self.parse_pat();
@@ -870,7 +869,7 @@ pub impl Parser {
         })
     }
 
-    fn maybe_parse_fixed_vstore(&self) -> Option<@ast::expr> {
+    pub fn maybe_parse_fixed_vstore(&self) -> Option<@ast::expr> {
         if self.eat(&token::BINOP(token::STAR)) {
             self.obsolete(*self.last_span, ObsoleteFixedLengthVectorType);
             Some(self.parse_expr())
@@ -885,7 +884,7 @@ pub impl Parser {
     }
 
     // matches token_lit = LIT_INT | ...
-    fn lit_from_token(&self, tok: &token::Token) -> lit_ {
+    pub fn lit_from_token(&self, tok: &token::Token) -> lit_ {
         match *tok {
             token::LIT_INT(i, it) => lit_int(i, it),
             token::LIT_UINT(u, ut) => lit_uint(u, ut),
@@ -900,7 +899,7 @@ pub impl Parser {
     }
 
     // matches lit = true | false | token_lit
-    fn parse_lit(&self) -> lit {
+    pub fn parse_lit(&self) -> lit {
         let lo = self.span.lo;
         let lit = if self.eat_keyword(keywords::True) {
             lit_bool(true)
@@ -916,7 +915,7 @@ pub impl Parser {
     }
 
     // matches '-' lit | lit
-    fn parse_literal_maybe_minus(&self) -> @expr {
+    pub fn parse_literal_maybe_minus(&self) -> @expr {
         let minus_lo = self.span.lo;
         let minus_present = self.eat(&token::BINOP(token::MINUS));
 
@@ -935,7 +934,7 @@ pub impl Parser {
 
     // parse a path into a vector of idents, whether the path starts
     // with ::, and a span.
-    fn parse_path(&self) -> (~[ast::ident],bool,span) {
+    pub fn parse_path(&self) -> (~[ast::ident],bool,span) {
         let lo = self.span.lo;
         let is_global = self.eat(&token::MOD_SEP);
         let (ids,span{lo:_,hi,expn_info}) = self.parse_path_non_global();
@@ -943,7 +942,7 @@ pub impl Parser {
     }
 
     // parse a path beginning with an identifier into a vector of idents and a span
-    fn parse_path_non_global(&self) -> (~[ast::ident],span) {
+    pub fn parse_path_non_global(&self) -> (~[ast::ident],span) {
         let lo = self.span.lo;
         let mut ids = ~[];
         // must be at least one to begin:
@@ -966,8 +965,7 @@ pub impl Parser {
     }
 
     // parse a path that doesn't have type parameters attached
-    fn parse_path_without_tps(&self)
-        -> @ast::Path {
+    pub fn parse_path_without_tps(&self) -> @ast::Path {
         maybe_whole!(self, nt_path);
         let (ids,is_global,sp) = self.parse_path();
         @ast::Path { span: sp,
@@ -980,7 +978,7 @@ pub impl Parser {
     // parse a path optionally with type parameters. If 'colons'
     // is true, then type parameters must be preceded by colons,
     // as in a::t::<t1,t2>
-    fn parse_path_with_tps(&self, colons: bool) -> @ast::Path {
+    pub fn parse_path_with_tps(&self, colons: bool) -> @ast::Path {
         debug!("parse_path_with_tps(colons=%b)", colons);
 
         maybe_whole!(self, nt_path);
@@ -1042,7 +1040,7 @@ pub impl Parser {
     }
 
     /// parses 0 or 1 lifetime
-    fn parse_opt_lifetime(&self) -> Option<@ast::Lifetime> {
+    pub fn parse_opt_lifetime(&self) -> Option<@ast::Lifetime> {
         match *self.token {
             token::LIFETIME(*) => {
                 Some(@self.parse_lifetime())
@@ -1064,7 +1062,7 @@ pub impl Parser {
         }
     }
 
-    fn token_is_lifetime(&self, tok: &token::Token) -> bool {
+    pub fn token_is_lifetime(&self, tok: &token::Token) -> bool {
         match *tok {
             token::LIFETIME(_) => true,
             _ => false
@@ -1073,7 +1071,7 @@ pub impl Parser {
 
     /// Parses a single lifetime
     // matches lifetime = ( LIFETIME ) | ( IDENT / )
-    fn parse_lifetime(&self) -> ast::Lifetime {
+    pub fn parse_lifetime(&self) -> ast::Lifetime {
         match *self.token {
             token::LIFETIME(i) => {
                 let span = copy self.span;
@@ -1107,7 +1105,7 @@ pub impl Parser {
     // matches lifetimes = ( lifetime ) | ( lifetime , lifetimes )
     // actually, it matches the empty one too, but putting that in there
     // messes up the grammar....
-    fn parse_lifetimes(&self) -> OptVec<ast::Lifetime> {
+    pub fn parse_lifetimes(&self) -> OptVec<ast::Lifetime> {
         /*!
          *
          * Parses zero or more comma separated lifetimes.
@@ -1139,13 +1137,13 @@ pub impl Parser {
         }
     }
 
-    fn token_is_mutability(&self, tok: &token::Token) -> bool {
+    pub fn token_is_mutability(&self, tok: &token::Token) -> bool {
         token::is_keyword(keywords::Mut, tok) ||
         token::is_keyword(keywords::Const, tok)
     }
 
     // parse mutability declaration (mut/const/imm)
-    fn parse_mutability(&self) -> mutability {
+    pub fn parse_mutability(&self) -> mutability {
         if self.eat_keyword(keywords::Mut) {
             m_mutbl
         } else if self.eat_keyword(keywords::Const) {
@@ -1156,7 +1154,7 @@ pub impl Parser {
     }
 
     // parse ident COLON expr
-    fn parse_field(&self) -> field {
+    pub fn parse_field(&self) -> field {
         let lo = self.span.lo;
         let i = self.parse_ident();
         self.expect(&token::COLON);
@@ -1167,7 +1165,7 @@ pub impl Parser {
         })
     }
 
-    fn mk_expr(&self, lo: BytePos, hi: BytePos, node: expr_) -> @expr {
+    pub fn mk_expr(&self, lo: BytePos, hi: BytePos, node: expr_) -> @expr {
         @expr {
             id: self.get_id(),
             callee_id: self.get_id(),
@@ -1176,7 +1174,7 @@ pub impl Parser {
         }
     }
 
-    fn mk_mac_expr(&self, lo: BytePos, hi: BytePos, m: mac_) -> @expr {
+    pub fn mk_mac_expr(&self, lo: BytePos, hi: BytePos, m: mac_) -> @expr {
         @expr {
             id: self.get_id(),
             callee_id: self.get_id(),
@@ -1185,7 +1183,7 @@ pub impl Parser {
         }
     }
 
-    fn mk_lit_u32(&self, i: u32) -> @expr {
+    pub fn mk_lit_u32(&self, i: u32) -> @expr {
         let span = self.span;
         let lv_lit = @codemap::spanned {
             node: lit_uint(i as u64, ty_u32),
@@ -1203,7 +1201,7 @@ pub impl Parser {
     // at the bottom (top?) of the precedence hierarchy,
     // parse things like parenthesized exprs,
     // macros, return, etc.
-    fn parse_bottom_expr(&self) -> @expr {
+    pub fn parse_bottom_expr(&self) -> @expr {
         maybe_whole_expr!(self);
 
         let lo = self.span.lo;
@@ -1414,23 +1412,20 @@ pub impl Parser {
     }
 
     // parse a block or unsafe block
-    fn parse_block_expr(
-        &self,
-        lo: BytePos,
-        blk_mode: blk_check_mode
-    ) -> @expr {
+    pub fn parse_block_expr(&self, lo: BytePos, blk_mode: blk_check_mode)
+                            -> @expr {
         self.expect(&token::LBRACE);
         let blk = self.parse_block_tail(lo, blk_mode);
         return self.mk_expr(blk.span.lo, blk.span.hi, expr_block(blk));
     }
 
     // parse a.b or a(13) or a[4] or just a
-    fn parse_dot_or_call_expr(&self) -> @expr {
+    pub fn parse_dot_or_call_expr(&self) -> @expr {
         let b = self.parse_bottom_expr();
         self.parse_dot_or_call_expr_with(b)
     }
 
-    fn parse_dot_or_call_expr_with(&self, e0: @expr) -> @expr {
+    pub fn parse_dot_or_call_expr_with(&self, e0: @expr) -> @expr {
         let mut e = e0;
         let lo = e.span.lo;
         let mut hi;
@@ -1504,7 +1499,7 @@ pub impl Parser {
 
     // parse an optional separator followed by a kleene-style
     // repetition token (+ or *).
-    fn parse_sep_and_zerok(&self) -> (Option<token::Token>, bool) {
+    pub fn parse_sep_and_zerok(&self) -> (Option<token::Token>, bool) {
         if *self.token == token::BINOP(token::STAR)
             || *self.token == token::BINOP(token::PLUS) {
             let zerok = *self.token == token::BINOP(token::STAR);
@@ -1525,7 +1520,7 @@ pub impl Parser {
     }
 
     // parse a single token tree from the input.
-    fn parse_token_tree(&self) -> token_tree {
+    pub fn parse_token_tree(&self) -> token_tree {
         maybe_whole!(deref self, nt_tt);
 
         // this is the fall-through for the 'match' below.
@@ -1612,7 +1607,7 @@ pub impl Parser {
 
     // parse a stream of tokens into a list of token_trees,
     // up to EOF.
-    fn parse_all_token_trees(&self) -> ~[token_tree] {
+    pub fn parse_all_token_trees(&self) -> ~[token_tree] {
         let mut tts = ~[];
         while *self.token != token::EOF {
             tts.push(self.parse_token_tree());
@@ -1620,7 +1615,7 @@ pub impl Parser {
         tts
     }
 
-    fn parse_matchers(&self) -> ~[matcher] {
+    pub fn parse_matchers(&self) -> ~[matcher] {
         // unification of matchers and token_trees would vastly improve
         // the interpolation of matchers
         maybe_whole!(self, nt_matchers);
@@ -1642,12 +1637,11 @@ pub impl Parser {
     // This goofy function is necessary to correctly match parens in matchers.
     // Otherwise, `$( ( )` would be a valid matcher, and `$( () )` would be
     // invalid. It's similar to common::parse_seq.
-    fn parse_matcher_subseq(
-        &self,
-        name_idx: @mut uint,
-        bra: token::Token,
-        ket: token::Token
-    ) -> ~[matcher] {
+    pub fn parse_matcher_subseq(&self,
+                                name_idx: @mut uint,
+                                bra: token::Token,
+                                ket: token::Token)
+                                -> ~[matcher] {
         let mut ret_val = ~[];
         let mut lparens = 0u;
 
@@ -1664,7 +1658,7 @@ pub impl Parser {
         return ret_val;
     }
 
-    fn parse_matcher(&self, name_idx: @mut uint) -> matcher {
+    pub fn parse_matcher(&self, name_idx: @mut uint) -> matcher {
         let lo = self.span.lo;
 
         let m = if *self.token == token::DOLLAR {
@@ -1699,7 +1693,7 @@ pub impl Parser {
     }
 
     // parse a prefix-operator expr
-    fn parse_prefix_expr(&self) -> @expr {
+    pub fn parse_prefix_expr(&self) -> @expr {
         let lo = self.span.lo;
         let hi;
 
@@ -1791,13 +1785,12 @@ pub impl Parser {
     }
 
     // parse an expression of binops
-    fn parse_binops(&self) -> @expr {
+    pub fn parse_binops(&self) -> @expr {
         self.parse_more_binops(self.parse_prefix_expr(), 0)
     }
 
     // parse an expression of binops of at least min_prec precedence
-    fn parse_more_binops(&self, lhs: @expr, min_prec: uint) ->
-        @expr {
+    pub fn parse_more_binops(&self, lhs: @expr, min_prec: uint) -> @expr {
         if self.expr_is_complete(lhs) { return lhs; }
         let peeked = copy *self.token;
         if peeked == token::BINOP(token::OR) &&
@@ -1841,7 +1834,7 @@ pub impl Parser {
     // parse an assignment expression....
     // actually, this seems to be the main entry point for
     // parsing an arbitrary expression.
-    fn parse_assign_expr(&self) -> @expr {
+    pub fn parse_assign_expr(&self) -> @expr {
         let lo = self.span.lo;
         let lhs = self.parse_binops();
         match *self.token {
@@ -1892,7 +1885,7 @@ pub impl Parser {
     }
 
     // parse an 'if' expression ('if' token already eaten)
-    fn parse_if_expr(&self) -> @expr {
+    pub fn parse_if_expr(&self) -> @expr {
         let lo = self.last_span.lo;
         let cond = self.parse_expr();
         let thn = self.parse_block();
@@ -1907,7 +1900,7 @@ pub impl Parser {
     }
 
     // `|args| { ... }` or `{ ...}` like in `do` expressions
-    fn parse_lambda_block_expr(&self) -> @expr {
+    pub fn parse_lambda_block_expr(&self) -> @expr {
         self.parse_lambda_expr_(
             || {
                 match *self.token {
@@ -1935,7 +1928,7 @@ pub impl Parser {
     }
 
     // `|args| expr`
-    fn parse_lambda_expr(&self) -> @expr {
+    pub fn parse_lambda_expr(&self) -> @expr {
         self.parse_lambda_expr_(|| self.parse_fn_block_decl(),
                                 || self.parse_expr())
     }
@@ -1943,11 +1936,10 @@ pub impl Parser {
     // parse something of the form |args| expr
     // this is used both in parsing a lambda expr
     // and in parsing a block expr as e.g. in for...
-    fn parse_lambda_expr_(
-        &self,
-        parse_decl: &fn() -> fn_decl,
-        parse_body: &fn() -> @expr
-    ) -> @expr {
+    pub fn parse_lambda_expr_(&self,
+                              parse_decl: &fn() -> fn_decl,
+                              parse_body: &fn() -> @expr)
+                              -> @expr {
         let lo = self.last_span.lo;
         let decl = parse_decl();
         let body = parse_body();
@@ -1964,7 +1956,7 @@ pub impl Parser {
                             expr_fn_block(decl, fakeblock));
     }
 
-    fn parse_else_expr(&self) -> @expr {
+    pub fn parse_else_expr(&self) -> @expr {
         if self.eat_keyword(keywords::If) {
             return self.parse_if_expr();
         } else {
@@ -1976,9 +1968,11 @@ pub impl Parser {
     // parse a 'for' or 'do'.
     // the 'for' and 'do' expressions parse as calls, but look like
     // function calls followed by a closure expression.
-    fn parse_sugary_call_expr(&self, keyword: ~str,
-                              sugar: CallSugar,
-                              ctor: &fn(v: @expr) -> expr_) -> @expr {
+    pub fn parse_sugary_call_expr(&self,
+                                  keyword: ~str,
+                                  sugar: CallSugar,
+                                  ctor: &fn(v: @expr) -> expr_)
+                                  -> @expr {
         let lo = self.last_span;
         // Parse the callee `foo` in
         //    for foo || {
@@ -2035,7 +2029,7 @@ pub impl Parser {
         }
     }
 
-    fn parse_while_expr(&self) -> @expr {
+    pub fn parse_while_expr(&self) -> @expr {
         let lo = self.last_span.lo;
         let cond = self.parse_expr();
         let body = self.parse_block();
@@ -2043,7 +2037,7 @@ pub impl Parser {
         return self.mk_expr(lo, hi, expr_while(cond, body));
     }
 
-    fn parse_loop_expr(&self, opt_ident: Option<ast::ident>) -> @expr {
+    pub fn parse_loop_expr(&self, opt_ident: Option<ast::ident>) -> @expr {
         // loop headers look like 'loop {' or 'loop unsafe {'
         let is_loop_header =
             *self.token == token::LBRACE
@@ -2126,7 +2120,7 @@ pub impl Parser {
     }
 
     // parse an expression
-    fn parse_expr(&self) -> @expr {
+    pub fn parse_expr(&self) -> @expr {
         return self.parse_expr_res(UNRESTRICTED);
     }
 
@@ -2257,7 +2251,7 @@ pub impl Parser {
     }
 
     // parse a pattern.
-    fn parse_pat(&self) -> @pat {
+    pub fn parse_pat(&self) -> @pat {
         maybe_whole!(self, nt_pat);
 
         let lo = self.span.lo;
@@ -2580,7 +2574,7 @@ pub impl Parser {
 
     // parse a statement. may include decl.
     // precondition: any attributes are parsed already
-    fn parse_stmt(&self, item_attrs: ~[attribute]) -> @stmt {
+    pub fn parse_stmt(&self, item_attrs: ~[attribute]) -> @stmt {
         maybe_whole!(self, nt_stmt);
 
         fn check_expected_item(p: &Parser, current_attrs: &[attribute]) {
@@ -2674,7 +2668,7 @@ pub impl Parser {
     }
 
     // parse a block. No inner attrs are allowed.
-    fn parse_block(&self) -> blk {
+    pub fn parse_block(&self) -> blk {
         maybe_whole!(self, nt_block);
 
         let lo = self.span.lo;
@@ -2924,7 +2918,7 @@ pub impl Parser {
     // matches generics = ( ) | ( < > ) | ( < typaramseq ( , )? > ) | ( < lifetimes ( , )? > )
     //                  | ( < lifetimes , typaramseq ( , )? > )
     // where   typaramseq = ( typaram ) | ( typaram , typaramseq )
-    fn parse_generics(&self) -> ast::Generics {
+    pub fn parse_generics(&self) -> ast::Generics {
         if self.eat(&token::LT) {
             let lifetimes = self.parse_lifetimes();
             let ty_params = self.parse_seq_to_gt(
@@ -2958,9 +2952,7 @@ pub impl Parser {
     }
 
     // parse the argument list and result type of a function declaration
-    fn parse_fn_decl(&self)
-        -> fn_decl
-    {
+    pub fn parse_fn_decl(&self) -> fn_decl {
         let args_or_capture_items: ~[arg_or_capture_item] =
             self.parse_unspanned_seq(
                 &token::LPAREN,
@@ -3398,9 +3390,10 @@ pub impl Parser {
     }
 
     // parse a structure field declaration
-    fn parse_single_struct_field(&self,
-                                 vis: visibility,
-                                 attrs: ~[attribute]) -> @struct_field {
+    pub fn parse_single_struct_field(&self,
+                                     vis: visibility,
+                                     attrs: ~[attribute])
+                                     -> @struct_field {
         if self.eat_obsolete_ident("let") {
             self.obsolete(*self.last_span, ObsoleteLet);
         }
@@ -4214,7 +4207,7 @@ pub impl Parser {
         return iovi_none;
     }
 
-    fn parse_item(&self, attrs: ~[attribute]) -> Option<@ast::item> {
+    pub fn parse_item(&self, attrs: ~[attribute]) -> Option<@ast::item> {
         match self.parse_item_or_view_item(attrs, true) {
             iovi_none =>
                 None,
@@ -4493,7 +4486,7 @@ pub impl Parser {
 
     // Parses a source module as a crate. This is the main
     // entry point for the parser.
-    fn parse_crate_mod(&self) -> @crate {
+    pub fn parse_crate_mod(&self) -> @crate {
         let lo = self.span.lo;
         // parse the crate's inner attrs, maybe (oops) one
         // of the attrs of an item:
@@ -4507,7 +4500,7 @@ pub impl Parser {
                                config: copy self.cfg })
     }
 
-    fn parse_str(&self) -> @~str {
+    pub fn parse_str(&self) -> @~str {
         match *self.token {
             token::LIT_STR(s) => {
                 self.bump();
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index f50b9f8936a..b716384c6cc 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -393,21 +393,22 @@ pub struct ident_interner {
     priv interner: StrInterner,
 }
 
-pub impl ident_interner {
-    fn intern(&self, val: &str) -> ast::ident {
+impl ident_interner {
+    pub fn intern(&self, val: &str) -> ast::ident {
         ast::ident { repr: self.interner.intern(val), ctxt: 0 }
     }
-    fn gensym(&self, val: &str) -> ast::ident {
+    pub fn gensym(&self, val: &str) -> ast::ident {
         ast::ident { repr: self.interner.gensym(val), ctxt: 0 }
     }
-    fn get(&self, idx: ast::ident) -> @~str {
+    pub fn get(&self, idx: ast::ident) -> @~str {
         self.interner.get(idx.repr)
     }
-    fn len(&self) -> uint {
+    pub fn len(&self) -> uint {
         self.interner.len()
     }
-    fn find_equiv<Q:Hash + IterBytes + Equiv<@~str>>(&self, val: &Q)
-                                                     -> Option<ast::ident> {
+    pub fn find_equiv<Q:Hash +
+                        IterBytes +
+                        Equiv<@~str>>(&self, val: &Q) -> Option<ast::ident> {
         match self.interner.find_equiv(val) {
             Some(v) => Some(ast::ident { repr: v, ctxt: 0 }),
             None => None,
@@ -586,8 +587,8 @@ pub mod keywords {
         Be,
     }
 
-    pub impl Keyword {
-        fn to_ident(&self) -> ident {
+    impl Keyword {
+        pub fn to_ident(&self) -> ident {
             match *self {
                 As => ident { repr: 35, ctxt: 0 },
                    Break => ident { repr: 36, ctxt: 0 },