Merge remote-tracking branch 'remotes/origin/incoming' into incoming

This commit is contained in:
Erick Tryzelaar
2013-02-28 07:25:31 -08:00
42 changed files with 1304 additions and 810 deletions

View File

@@ -20,6 +20,9 @@ use core::option::{None, Option, Some};
use core::option;
use std::oldmap::HashMap;
use opt_vec;
use opt_vec::OptVec;
// SeqSep : a sequence separator (token)
// and whether a trailing separator is allowed.
pub struct SeqSep {
@@ -251,9 +254,9 @@ pub impl Parser {
fn parse_seq_to_before_gt<T: Copy>(
sep: Option<token::Token>,
f: fn(&Parser) -> T
) -> ~[T] {
) -> OptVec<T> {
let mut first = true;
let mut v = ~[];
let mut v = opt_vec::Empty;
while *self.token != token::GT
&& *self.token != token::BINOP(token::SHR) {
match sep {
@@ -265,33 +268,18 @@ pub impl Parser {
}
v.push(f(&self));
}
return v;
}
fn parse_seq_to_gt<T: Copy>(
sep: Option<token::Token>,
f: fn(&Parser) -> T
) -> ~[T] {
) -> OptVec<T> {
let v = self.parse_seq_to_before_gt(sep, f);
self.expect_gt();
return v;
}
// parse a sequence bracketed by '<' and '>'
fn parse_seq_lt_gt<T: Copy>(
sep: Option<token::Token>,
f: fn(&Parser) -> T
) -> spanned<~[T]> {
let lo = self.span.lo;
self.expect(&token::LT);
let result = self.parse_seq_to_before_gt::<T>(sep, f);
let hi = self.span.hi;
self.expect_gt();
return spanned(lo, hi, result);
}
// parse a sequence, including the closing delimiter. The function
// f must consume tokens until reaching the next separator or
// closing bracket.