about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/attr.rs2
-rw-r--r--src/libsyntax/parse/mod.rs78
-rw-r--r--src/libsyntax/parse/obsolete.rs2
-rw-r--r--src/libsyntax/parse/parser.rs10
4 files changed, 46 insertions, 46 deletions
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs
index 0a74c7ca821..399648ef1d8 100644
--- a/src/libsyntax/parse/attr.rs
+++ b/src/libsyntax/parse/attr.rs
@@ -28,7 +28,7 @@ pub trait ParserAttr {
     fn parse_optional_meta(&mut self) -> Vec<@ast::MetaItem> ;
 }
 
-impl ParserAttr for Parser {
+impl<'a> ParserAttr for Parser<'a> {
     // Parse attributes that appear before an item
     fn parse_outer_attributes(&mut self) -> Vec<ast::Attribute> {
         let mut attrs: Vec<ast::Attribute> = Vec::new();
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index cb49ad0905c..19291f72101 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -46,9 +46,9 @@ pub struct ParseSess {
     included_mod_stack: RefCell<Vec<Path> >,
 }
 
-pub fn new_parse_sess() -> @ParseSess {
+pub fn new_parse_sess() -> ParseSess {
     let cm = @CodeMap::new();
-    @ParseSess {
+    ParseSess {
         cm: cm,
         span_diagnostic: mk_span_handler(default_handler(), cm),
         included_mod_stack: RefCell::new(Vec::new()),
@@ -57,8 +57,8 @@ pub fn new_parse_sess() -> @ParseSess {
 
 pub fn new_parse_sess_special_handler(sh: @SpanHandler,
                                       cm: @codemap::CodeMap)
-                                      -> @ParseSess {
-    @ParseSess {
+                                      -> ParseSess {
+    ParseSess {
         cm: cm,
         span_diagnostic: sh,
         included_mod_stack: RefCell::new(Vec::new()),
@@ -73,7 +73,7 @@ pub fn new_parse_sess_special_handler(sh: @SpanHandler,
 pub fn parse_crate_from_file(
     input: &Path,
     cfg: ast::CrateConfig,
-    sess: @ParseSess
+    sess: &ParseSess
 ) -> ast::Crate {
     new_parser_from_file(sess, cfg, input).parse_crate_mod()
     // why is there no p.abort_if_errors here?
@@ -82,17 +82,17 @@ pub fn parse_crate_from_file(
 pub fn parse_crate_attrs_from_file(
     input: &Path,
     cfg: ast::CrateConfig,
-    sess: @ParseSess
+    sess: &ParseSess
 ) -> Vec<ast::Attribute> {
     let mut parser = new_parser_from_file(sess, cfg, input);
     let (inner, _) = parser.parse_inner_attrs_and_next();
-    return inner;
+    inner
 }
 
 pub fn parse_crate_from_source_str(name: ~str,
                                    source: ~str,
                                    cfg: ast::CrateConfig,
-                                   sess: @ParseSess)
+                                   sess: &ParseSess)
                                    -> ast::Crate {
     let mut p = new_parser_from_source_str(sess,
                                            cfg,
@@ -104,20 +104,20 @@ pub fn parse_crate_from_source_str(name: ~str,
 pub fn parse_crate_attrs_from_source_str(name: ~str,
                                          source: ~str,
                                          cfg: ast::CrateConfig,
-                                         sess: @ParseSess)
+                                         sess: &ParseSess)
                                          -> Vec<ast::Attribute> {
     let mut p = new_parser_from_source_str(sess,
                                            cfg,
                                            name,
                                            source);
     let (inner, _) = maybe_aborted(p.parse_inner_attrs_and_next(),p);
-    return inner;
+    inner
 }
 
 pub fn parse_expr_from_source_str(name: ~str,
                                   source: ~str,
                                   cfg: ast::CrateConfig,
-                                  sess: @ParseSess)
+                                  sess: &ParseSess)
                                   -> @ast::Expr {
     let mut p = new_parser_from_source_str(sess, cfg, name, source);
     maybe_aborted(p.parse_expr(), p)
@@ -126,7 +126,7 @@ pub fn parse_expr_from_source_str(name: ~str,
 pub fn parse_item_from_source_str(name: ~str,
                                   source: ~str,
                                   cfg: ast::CrateConfig,
-                                  sess: @ParseSess)
+                                  sess: &ParseSess)
                                   -> Option<@ast::Item> {
     let mut p = new_parser_from_source_str(sess, cfg, name, source);
     let attrs = p.parse_outer_attributes();
@@ -136,7 +136,7 @@ pub fn parse_item_from_source_str(name: ~str,
 pub fn parse_meta_from_source_str(name: ~str,
                                   source: ~str,
                                   cfg: ast::CrateConfig,
-                                  sess: @ParseSess)
+                                  sess: &ParseSess)
                                   -> @ast::MetaItem {
     let mut p = new_parser_from_source_str(sess, cfg, name, source);
     maybe_aborted(p.parse_meta_item(),p)
@@ -146,7 +146,7 @@ pub fn parse_stmt_from_source_str(name: ~str,
                                   source: ~str,
                                   cfg: ast::CrateConfig,
                                   attrs: Vec<ast::Attribute> ,
-                                  sess: @ParseSess)
+                                  sess: &ParseSess)
                                   -> @ast::Stmt {
     let mut p = new_parser_from_source_str(
         sess,
@@ -160,7 +160,7 @@ pub fn parse_stmt_from_source_str(name: ~str,
 pub fn parse_tts_from_source_str(name: ~str,
                                  source: ~str,
                                  cfg: ast::CrateConfig,
-                                 sess: @ParseSess)
+                                 sess: &ParseSess)
                                  -> Vec<ast::TokenTree> {
     let mut p = new_parser_from_source_str(
         sess,
@@ -174,48 +174,48 @@ pub fn parse_tts_from_source_str(name: ~str,
 }
 
 // Create a new parser from a source string
-pub fn new_parser_from_source_str(sess: @ParseSess,
-                                  cfg: ast::CrateConfig,
-                                  name: ~str,
-                                  source: ~str)
-                                  -> Parser {
+pub fn new_parser_from_source_str<'a>(sess: &'a ParseSess,
+                                     cfg: ast::CrateConfig,
+                                     name: ~str,
+                                     source: ~str)
+                                     -> Parser<'a> {
     filemap_to_parser(sess,string_to_filemap(sess,source,name),cfg)
 }
 
 /// Create a new parser, handling errors as appropriate
 /// if the file doesn't exist
-pub fn new_parser_from_file(
-    sess: @ParseSess,
+pub fn new_parser_from_file<'a>(
+    sess: &'a ParseSess,
     cfg: ast::CrateConfig,
     path: &Path
-) -> Parser {
+) -> Parser<'a> {
     filemap_to_parser(sess,file_to_filemap(sess,path,None),cfg)
 }
 
 /// Given a session, a crate config, a path, and a span, add
 /// the file at the given path to the codemap, and return a parser.
 /// On an error, use the given span as the source of the problem.
-pub fn new_sub_parser_from_file(
-    sess: @ParseSess,
+pub fn new_sub_parser_from_file<'a>(
+    sess: &'a ParseSess,
     cfg: ast::CrateConfig,
     path: &Path,
     sp: Span
-) -> Parser {
+) -> Parser<'a> {
     filemap_to_parser(sess,file_to_filemap(sess,path,Some(sp)),cfg)
 }
 
 /// Given a filemap and config, return a parser
-pub fn filemap_to_parser(sess: @ParseSess,
-                         filemap: @FileMap,
-                         cfg: ast::CrateConfig) -> Parser {
+pub fn filemap_to_parser<'a>(sess: &'a ParseSess,
+                             filemap: @FileMap,
+                             cfg: ast::CrateConfig) -> Parser<'a> {
     tts_to_parser(sess,filemap_to_tts(sess,filemap),cfg)
 }
 
 // must preserve old name for now, because quote! from the *existing*
 // compiler expands into it
-pub fn new_parser_from_tts(sess: @ParseSess,
-                     cfg: ast::CrateConfig,
-                     tts: Vec<ast::TokenTree> ) -> Parser {
+pub fn new_parser_from_tts<'a>(sess: &'a ParseSess,
+                               cfg: ast::CrateConfig,
+                               tts: Vec<ast::TokenTree>) -> Parser<'a> {
     tts_to_parser(sess,tts,cfg)
 }
 
@@ -224,7 +224,7 @@ pub fn new_parser_from_tts(sess: @ParseSess,
 
 /// Given a session and a path and an optional span (for error reporting),
 /// add the path to the session's codemap and return the new filemap.
-pub fn file_to_filemap(sess: @ParseSess, path: &Path, spanopt: Option<Span>)
+pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
     -> @FileMap {
     let err = |msg: &str| {
         match spanopt {
@@ -250,13 +250,13 @@ pub fn file_to_filemap(sess: @ParseSess, path: &Path, spanopt: Option<Span>)
 
 // given a session and a string, add the string to
 // the session's codemap and return the new filemap
-pub fn string_to_filemap(sess: @ParseSess, source: ~str, path: ~str)
+pub fn string_to_filemap(sess: &ParseSess, source: ~str, path: ~str)
                          -> @FileMap {
     sess.cm.new_filemap(path, source)
 }
 
 // given a filemap, produce a sequence of token-trees
-pub fn filemap_to_tts(sess: @ParseSess, filemap: @FileMap)
+pub fn filemap_to_tts(sess: &ParseSess, filemap: @FileMap)
     -> Vec<ast::TokenTree> {
     // it appears to me that the cfg doesn't matter here... indeed,
     // parsing tt's probably shouldn't require a parser at all.
@@ -267,9 +267,9 @@ pub fn filemap_to_tts(sess: @ParseSess, filemap: @FileMap)
 }
 
 // given tts and cfg, produce a parser
-pub fn tts_to_parser(sess: @ParseSess,
-                     tts: Vec<ast::TokenTree> ,
-                     cfg: ast::CrateConfig) -> Parser {
+pub fn tts_to_parser<'a>(sess: &'a ParseSess,
+                         tts: Vec<ast::TokenTree>,
+                         cfg: ast::CrateConfig) -> Parser<'a> {
     let trdr = lexer::new_tt_reader(sess.span_diagnostic, None, tts);
     Parser(sess, cfg, ~trdr)
 }
@@ -594,7 +594,7 @@ mod test {
     }
 
     #[test] fn parse_ident_pat () {
-        let mut parser = string_to_parser(~"b");
+        let mut parser = string_to_parser(&new_parse_sess(), ~"b");
         assert!(parser.parse_pat() ==
                    @ast::Pat{id: ast::DUMMY_NODE_ID,
                              node: ast::PatIdent(
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index 393282dd063..1d7bf2ef6da 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -59,7 +59,7 @@ pub trait ParserObsoleteMethods {
     fn eat_obsolete_ident(&mut self, ident: &str) -> bool;
 }
 
-impl ParserObsoleteMethods for Parser {
+impl<'a> ParserObsoleteMethods for Parser<'a> {
     /// Reports an obsolete syntax non-fatal error.
     fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
         let (kind_str, desc) = match kind {
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index f52effb8c81..d183eb44cc2 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -284,8 +284,8 @@ struct ParsedItemsAndViewItems {
 
 /* ident is handled by common.rs */
 
-pub fn Parser(sess: @ParseSess, cfg: ast::CrateConfig, rdr: ~Reader:)
-              -> Parser {
+pub fn Parser<'a>(sess: &'a ParseSess, cfg: ast::CrateConfig, rdr: ~Reader:)
+              -> Parser<'a> {
     let tok0 = rdr.next_token();
     let span = tok0.sp;
     let placeholder = TokenAndSpan {
@@ -320,8 +320,8 @@ pub fn Parser(sess: @ParseSess, cfg: ast::CrateConfig, rdr: ~Reader:)
     }
 }
 
-pub struct Parser {
-    sess: @ParseSess,
+pub struct Parser<'a> {
+    sess: &'a ParseSess,
     cfg: CrateConfig,
     // the current token:
     token: token::Token,
@@ -354,7 +354,7 @@ fn is_plain_ident_or_underscore(t: &token::Token) -> bool {
     is_plain_ident(t) || *t == token::UNDERSCORE
 }
 
-impl Parser {
+impl<'a> Parser<'a> {
     // convert a token to a string using self's reader
     pub fn token_to_str(token: &token::Token) -> ~str {
         token::to_str(token)