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/mod.rs6
-rw-r--r--src/libsyntax/parse/obsolete.rs6
-rw-r--r--src/libsyntax/parse/parser.rs78
3 files changed, 43 insertions, 47 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index ce89a7dec39..3132f91c09b 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -256,7 +256,7 @@ pub fn filemap_to_tts(sess: &ParseSess, filemap: Rc<FileMap>)
     // parsing tt's probably shouldn't require a parser at all.
     let cfg = Vec::new();
     let srdr = lexer::new_string_reader(&sess.span_diagnostic, filemap);
-    let mut p1 = Parser(sess, cfg, box srdr);
+    let mut p1 = Parser::new(sess, cfg, box srdr);
     p1.parse_all_token_trees()
 }
 
@@ -265,7 +265,7 @@ 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, box trdr)
+    Parser::new(sess, cfg, box trdr)
 }
 
 // abort if necessary
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index 6a0a3c9ff81..f045a7fe120 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -19,7 +19,7 @@ removed.
 
 use ast::{Expr, ExprLit, LitNil};
 use codemap::{Span, respan};
-use parse::parser::Parser;
+use parse::parser;
 use parse::token;
 
 /// The specific types of unsupported syntax
@@ -45,7 +45,7 @@ pub trait ParserObsoleteMethods {
     fn eat_obsolete_ident(&mut self, ident: &str) -> bool;
 }
 
-impl<'a> ParserObsoleteMethods for Parser<'a> {
+impl<'a> ParserObsoleteMethods for parser::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 9f8b3172a80..00c07ce59f9 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -278,50 +278,11 @@ struct ParsedItemsAndViewItems {
     attrs_remaining: Vec<Attribute> ,
     view_items: Vec<ViewItem> ,
     items: Vec<@Item> ,
-    foreign_items: Vec<@ForeignItem> }
+    foreign_items: Vec<@ForeignItem>
+}
 
 /* ident is handled by common.rs */
 
-pub fn Parser<'a>(
-              sess: &'a ParseSess,
-              cfg: ast::CrateConfig,
-              mut rdr: Box<Reader:>)
-              -> Parser<'a> {
-    let tok0 = rdr.next_token();
-    let span = tok0.sp;
-    let placeholder = TokenAndSpan {
-        tok: token::UNDERSCORE,
-        sp: span,
-    };
-
-    Parser {
-        reader: rdr,
-        interner: token::get_ident_interner(),
-        sess: sess,
-        cfg: cfg,
-        token: tok0.tok,
-        span: span,
-        last_span: span,
-        last_token: None,
-        buffer: [
-            placeholder.clone(),
-            placeholder.clone(),
-            placeholder.clone(),
-            placeholder.clone(),
-        ],
-        buffer_start: 0,
-        buffer_end: 0,
-        tokens_consumed: 0,
-        restriction: UNRESTRICTED,
-        quote_depth: 0,
-        obsolete_set: HashSet::new(),
-        mod_path_stack: Vec::new(),
-        open_braces: Vec::new(),
-        owns_directory: true,
-        root_module_name: None,
-    }
-}
-
 pub struct Parser<'a> {
     pub sess: &'a ParseSess,
     // the current token:
@@ -362,6 +323,41 @@ fn is_plain_ident_or_underscore(t: &token::Token) -> bool {
 }
 
 impl<'a> Parser<'a> {
+    pub fn new(sess: &'a ParseSess, cfg: ast::CrateConfig, mut rdr: Box<Reader:>) -> Parser<'a> {
+        let tok0 = rdr.next_token();
+        let span = tok0.sp;
+        let placeholder = TokenAndSpan {
+            tok: token::UNDERSCORE,
+            sp: span,
+        };
+
+        Parser {
+            reader: rdr,
+            interner: token::get_ident_interner(),
+            sess: sess,
+            cfg: cfg,
+            token: tok0.tok,
+            span: span,
+            last_span: span,
+            last_token: None,
+            buffer: [
+                placeholder.clone(),
+                placeholder.clone(),
+                placeholder.clone(),
+                placeholder.clone(),
+            ],
+            buffer_start: 0,
+            buffer_end: 0,
+            tokens_consumed: 0,
+            restriction: UNRESTRICTED,
+            quote_depth: 0,
+            obsolete_set: HashSet::new(),
+            mod_path_stack: Vec::new(),
+            open_braces: Vec::new(),
+            owns_directory: true,
+            root_module_name: None,
+        }
+    }
     // convert a token to a string using self's reader
     pub fn token_to_str(token: &token::Token) -> String {
         token::to_str(token)