about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorKevin Butler <haqkrs@gmail.com>2014-05-26 00:27:36 +0100
committerKevin Butler <haqkrs@gmail.com>2014-05-30 17:55:41 +0100
commit190d8bdbc6df078e2dc65ccdb8ab17a99a4a6556 (patch)
tree14e71c75fc23296a7681a319dbba0037a4c60261 /src/libsyntax
parent16f15ce391b2b463d37ff7f5e764c7f55c33cc5d (diff)
downloadrust-190d8bdbc6df078e2dc65ccdb8ab17a99a4a6556.tar.gz
rust-190d8bdbc6df078e2dc65ccdb8ab17a99a4a6556.zip
libsyntax: Fix snake_case errors.
A number of functions/methods have been moved or renamed to align
better with rust standard conventions.

syntax::ext::mtwt::xorPush => xor_push
syntax::parse::parser::Parser => Parser::new

[breaking-change]
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/abi.rs3
-rw-r--r--src/libsyntax/ast.rs1
-rw-r--r--src/libsyntax/ext/mtwt.rs41
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs4
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs2
-rw-r--r--src/libsyntax/parse/mod.rs6
-rw-r--r--src/libsyntax/parse/obsolete.rs6
-rw-r--r--src/libsyntax/parse/parser.rs78
8 files changed, 73 insertions, 68 deletions
diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs
index bc53d2bec8d..089cd772bb4 100644
--- a/src/libsyntax/abi.rs
+++ b/src/libsyntax/abi.rs
@@ -1,4 +1,4 @@
-// Copyright 2012-2013 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.
 //
@@ -159,6 +159,7 @@ impl fmt::Show for Abi {
     }
 }
 
+#[allow(non_snake_case_functions)]
 #[test]
 fn lookup_Rust() {
     let abi = lookup("Rust");
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index d6af10ddc18..656ae80e12d 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -26,6 +26,7 @@ use serialize::{Encodable, Decodable, Encoder, Decoder};
 /// A pointer abstraction. FIXME(eddyb) #10676 use Rc<T> in the future.
 pub type P<T> = @T;
 
+#[allow(non_snake_case_functions)]
 /// Construct a P<T> from a T value.
 pub fn P<T: 'static>(value: T) -> P<T> {
     @value
diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs
index 6ac3becf0b6..fdaa3b5630a 100644
--- a/src/libsyntax/ext/mtwt.rs
+++ b/src/libsyntax/ext/mtwt.rs
@@ -223,7 +223,7 @@ fn marksof_internal(ctxt: SyntaxContext,
                 return result;
             },
             Mark(mark, tl) => {
-                xorPush(&mut result, mark);
+                xor_push(&mut result, mark);
                 loopvar = tl;
             },
             Rename(_,name,tl) => {
@@ -253,7 +253,7 @@ pub fn outer_mark(ctxt: SyntaxContext) -> Mrk {
 
 // Push a name... unless it matches the one on top, in which
 // case pop and discard (so two of the same marks cancel)
-fn xorPush(marks: &mut Vec<Mrk>, mark: Mrk) {
+fn xor_push(marks: &mut Vec<Mrk>, mark: Mrk) {
     if (marks.len() > 0) && (*marks.last().unwrap() == mark) {
         marks.pop().unwrap();
     } else {
@@ -264,26 +264,27 @@ fn xorPush(marks: &mut Vec<Mrk>, mark: Mrk) {
 #[cfg(test)]
 mod tests {
     use ast::*;
-    use super::{resolve, xorPush, new_mark_internal, new_sctable_internal};
+    use super::{resolve, xor_push, new_mark_internal, new_sctable_internal};
     use super::{new_rename_internal, marksof_internal, resolve_internal};
     use super::{SCTable, EmptyCtxt, Mark, Rename, IllegalCtxt};
     use collections::HashMap;
 
-    #[test] fn xorpush_test () {
+    #[test]
+    fn xorpush_test () {
         let mut s = Vec::new();
-        xorPush(&mut s, 14);
+        xor_push(&mut s, 14);
         assert_eq!(s.clone(), vec!(14));
-        xorPush(&mut s, 14);
+        xor_push(&mut s, 14);
         assert_eq!(s.clone(), Vec::new());
-        xorPush(&mut s, 14);
+        xor_push(&mut s, 14);
         assert_eq!(s.clone(), vec!(14));
-        xorPush(&mut s, 15);
+        xor_push(&mut s, 15);
         assert_eq!(s.clone(), vec!(14, 15));
-        xorPush(&mut s, 16);
+        xor_push(&mut s, 16);
         assert_eq!(s.clone(), vec!(14, 15, 16));
-        xorPush(&mut s, 16);
+        xor_push(&mut s, 16);
         assert_eq!(s.clone(), vec!(14, 15));
-        xorPush(&mut s, 15);
+        xor_push(&mut s, 15);
         assert_eq!(s.clone(), vec!(14));
     }
 
@@ -331,7 +332,8 @@ mod tests {
         }
     }
 
-    #[test] fn test_unfold_refold(){
+    #[test]
+    fn test_unfold_refold(){
         let mut t = new_sctable_internal();
 
         let test_sc = vec!(M(3),R(id(101,0),14),M(9));
@@ -364,7 +366,8 @@ mod tests {
         }
     }
 
-    #[test] fn test_marksof () {
+    #[test]
+    fn test_marksof () {
         let stopname = 242;
         let name1 = 243;
         let mut t = new_sctable_internal();
@@ -397,7 +400,8 @@ mod tests {
     }
 
 
-    #[test] fn resolve_tests () {
+    #[test]
+    fn resolve_tests () {
         let a = 40;
         let mut t = new_sctable_internal();
         let mut rt = HashMap::new();
@@ -447,13 +451,15 @@ mod tests {
          assert_eq!(resolve_internal(id(a,a50_to_a51_b),&mut t, &mut rt),50);}
     }
 
-    #[test] fn mtwt_resolve_test(){
+    #[test]
+    fn mtwt_resolve_test(){
         let a = 40;
         assert_eq!(resolve(id(a,EMPTY_CTXT)),a);
     }
 
 
-    #[test] fn hashing_tests () {
+    #[test]
+    fn hashing_tests () {
         let mut t = new_sctable_internal();
         assert_eq!(new_mark_internal(12,EMPTY_CTXT,&mut t),2);
         assert_eq!(new_mark_internal(13,EMPTY_CTXT,&mut t),3);
@@ -462,7 +468,8 @@ mod tests {
         // I'm assuming that the rename table will behave the same....
     }
 
-    #[test] fn resolve_table_hashing_tests() {
+    #[test]
+    fn resolve_table_hashing_tests() {
         let mut t = new_sctable_internal();
         let mut rt = HashMap::new();
         assert_eq!(rt.len(),0);
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index a92802aa338..65733793d6c 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.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.
 //
@@ -402,7 +402,7 @@ pub fn parse(sess: &ParseSess,
                 }
                 rdr.next_token();
             } else /* bb_eis.len() == 1 */ {
-                let mut rust_parser = Parser(sess, cfg.clone(), box rdr.clone());
+                let mut rust_parser = Parser::new(sess, cfg.clone(), box rdr.clone());
 
                 let mut ei = bb_eis.pop().unwrap();
                 match ei.elts.get(ei.idx).node {
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index c69e5f9ba0f..0622bf76ab9 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -171,7 +171,7 @@ fn generic_extension(cx: &ExtCtxt,
                 let trncbr = new_tt_reader(&cx.parse_sess().span_diagnostic,
                                            Some(named_matches),
                                            rhs);
-                let p = Parser(cx.parse_sess(), cx.cfg(), box trncbr);
+                let p = Parser::new(cx.parse_sess(), cx.cfg(), box trncbr);
                 // Let the context choose how to interpret the result.
                 // Weird, but useful for X-macros.
                 return box ParserAnyMacro {
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)