-// 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.
//
}
}
+#[allow(non_snake_case_functions)]
#[test]
fn lookup_Rust() {
let abi = lookup("Rust");
/// 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
return result;
},
Mark(mark, tl) => {
- xorPush(&mut result, mark);
+ xor_push(&mut result, mark);
loopvar = tl;
},
Rename(_,name,tl) => {
// 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 {
#[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));
}
}
}
- #[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));
}
}
- #[test] fn test_marksof () {
+ #[test]
+ fn test_marksof () {
let stopname = 242;
let name1 = 243;
let mut t = new_sctable_internal();
}
- #[test] fn resolve_tests () {
+ #[test]
+ fn resolve_tests () {
let a = 40;
let mut t = new_sctable_internal();
let mut rt = HashMap::new();
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);
// 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);
-// 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.
//
}
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 {
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 {
-// 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.
//
// 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()
}
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
-// 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.
//
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
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 {
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:
}
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)