libsyntax: Stop parsing bare functions in preparation for switching them over
This commit is contained in:
parent
d18f785457
commit
bd2d17e4a1
8 changed files with 40 additions and 9 deletions
|
@ -599,7 +599,9 @@ pub mod linear {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Visit the values representing the intersection
|
/// Visit the values representing the intersection
|
||||||
pure fn intersection(&self, other: &LinearSet<T>, f: &fn(&T) -> bool) {
|
pure fn intersection(&self,
|
||||||
|
other: &LinearSet<T>,
|
||||||
|
f: &fn(&T) -> bool) {
|
||||||
for self.each |v| {
|
for self.each |v| {
|
||||||
if other.contains(v) {
|
if other.contains(v) {
|
||||||
if !f(v) { return }
|
if !f(v) { return }
|
||||||
|
|
|
@ -67,7 +67,10 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T }
|
||||||
* Iterate over the range [`start`,`start`+`step`..`stop`)
|
* Iterate over the range [`start`,`start`+`step`..`stop`)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
pub pure fn range_step(start: T, stop: T, step: T_SIGNED, it: &fn(T) -> bool) {
|
pub pure fn range_step(start: T,
|
||||||
|
stop: T,
|
||||||
|
step: T_SIGNED,
|
||||||
|
it: &fn(T) -> bool) {
|
||||||
let mut i = start;
|
let mut i = start;
|
||||||
if step == 0 {
|
if step == 0 {
|
||||||
fail!(~"range_step called with step == 0");
|
fail!(~"range_step called with step == 0");
|
||||||
|
|
|
@ -491,7 +491,10 @@ pub pure fn split(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] {
|
||||||
* Splits a string into substrings using a character function, cutting at
|
* Splits a string into substrings using a character function, cutting at
|
||||||
* most `count` times.
|
* most `count` times.
|
||||||
*/
|
*/
|
||||||
pub pure fn splitn(s: &str, sepfn: &fn(char) -> bool, count: uint) -> ~[~str] {
|
pub pure fn splitn(s: &str,
|
||||||
|
sepfn: &fn(char) -> bool,
|
||||||
|
count: uint)
|
||||||
|
-> ~[~str] {
|
||||||
split_inner(s, sepfn, count, true)
|
split_inner(s, sepfn, count, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1246,8 +1249,11 @@ pub pure fn find_from(s: &str, start: uint, f: &fn(char)
|
||||||
* or equal to `len(s)`. `start` must be the index of a character
|
* or equal to `len(s)`. `start` must be the index of a character
|
||||||
* boundary, as defined by `is_char_boundary`.
|
* boundary, as defined by `is_char_boundary`.
|
||||||
*/
|
*/
|
||||||
pub pure fn find_between(s: &str, start: uint, end: uint, f: &fn(char) -> bool)
|
pub pure fn find_between(s: &str,
|
||||||
-> Option<uint> {
|
start: uint,
|
||||||
|
end: uint,
|
||||||
|
f: &fn(char) -> bool)
|
||||||
|
-> Option<uint> {
|
||||||
fail_unless!(start <= end);
|
fail_unless!(start <= end);
|
||||||
fail_unless!(end <= len(s));
|
fail_unless!(end <= len(s));
|
||||||
fail_unless!(is_char_boundary(s, start));
|
fail_unless!(is_char_boundary(s, start));
|
||||||
|
|
|
@ -81,7 +81,10 @@ impl<T> Map<uint, T> for TrieMap<T> {
|
||||||
|
|
||||||
/// Visit all values in order
|
/// Visit all values in order
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn each_value(&self, f: &fn(&T) -> bool) { self.each(|&(_, v)| f(v)) }
|
pure fn each_value(&self,
|
||||||
|
f: &fn(&T) -> bool) {
|
||||||
|
self.each(|&(_, v)| f(v))
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the value corresponding to the key in the map
|
/// Return the value corresponding to the key in the map
|
||||||
#[inline(hint)]
|
#[inline(hint)]
|
||||||
|
|
|
@ -68,7 +68,7 @@ pub unsafe fn read(prompt: ~str) -> Option<~str> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type CompletionCb = @fn(~str, fn(~str));
|
pub type CompletionCb<'self> = @fn(~str, &'self fn(~str));
|
||||||
|
|
||||||
fn complete_key(_v: @CompletionCb) {}
|
fn complete_key(_v: @CompletionCb) {}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,9 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
|
||||||
pure fn each_key(&self, f: &fn(&K) -> bool) { self.each(|&(k, _)| f(k)) }
|
pure fn each_key(&self, f: &fn(&K) -> bool) { self.each(|&(k, _)| f(k)) }
|
||||||
|
|
||||||
/// Visit all values in order
|
/// Visit all values in order
|
||||||
pure fn each_value(&self, f: &fn(&V) -> bool) { self.each(|&(_, v)| f(v)) }
|
pure fn each_value(&self, f: &fn(&V) -> bool) {
|
||||||
|
self.each(|&(_, v)| f(v))
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the value corresponding to the key in the map
|
/// Return the value corresponding to the key in the map
|
||||||
pure fn find(&self, key: &K) -> Option<&self/V> {
|
pure fn find(&self, key: &K) -> Option<&self/V> {
|
||||||
|
|
|
@ -53,6 +53,7 @@ pub enum ObsoleteSyntax {
|
||||||
ObsoleteRecordPattern,
|
ObsoleteRecordPattern,
|
||||||
ObsoleteAssertion,
|
ObsoleteAssertion,
|
||||||
ObsoletePostFnTySigil,
|
ObsoletePostFnTySigil,
|
||||||
|
ObsoleteBareFnType,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for ObsoleteSyntax {
|
impl to_bytes::IterBytes for ObsoleteSyntax {
|
||||||
|
@ -166,6 +167,10 @@ pub impl Parser {
|
||||||
"Rather than `fn@`, `fn~`, or `fn&`, \
|
"Rather than `fn@`, `fn~`, or `fn&`, \
|
||||||
write `@fn`, `~fn`, and `&fn` respectively"
|
write `@fn`, `~fn`, and `&fn` respectively"
|
||||||
),
|
),
|
||||||
|
ObsoleteBareFnType => (
|
||||||
|
"bare function type",
|
||||||
|
"use `&fn` or `extern fn` instead"
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report(sp, kind, kind_str, desc);
|
self.report(sp, kind, kind_str, desc);
|
||||||
|
|
|
@ -76,7 +76,11 @@ use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax};
|
||||||
use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer};
|
use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer};
|
||||||
use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility};
|
use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility};
|
||||||
use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern};
|
use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern};
|
||||||
|
<<<<<<< HEAD
|
||||||
use parse::obsolete::{ObsoleteAssertion, ObsoletePostFnTySigil};
|
use parse::obsolete::{ObsoleteAssertion, ObsoletePostFnTySigil};
|
||||||
|
=======
|
||||||
|
use parse::obsolete::{ObsoleteAssertion, ObsoleteBareFnType};
|
||||||
|
>>>>>>> libsyntax: Stop parsing bare functions in preparation for switching them over
|
||||||
use parse::prec::{as_prec, token_to_binop};
|
use parse::prec::{as_prec, token_to_binop};
|
||||||
use parse::token::{can_begin_expr, is_ident, is_ident_or_path};
|
use parse::token::{can_begin_expr, is_ident, is_ident_or_path};
|
||||||
use parse::token::{is_plain_ident, INTERPOLATED, special_idents};
|
use parse::token::{is_plain_ident, INTERPOLATED, special_idents};
|
||||||
|
@ -647,8 +651,14 @@ pub impl Parser {
|
||||||
} else if self.eat_keyword(&~"extern") {
|
} else if self.eat_keyword(&~"extern") {
|
||||||
self.parse_ty_bare_fn()
|
self.parse_ty_bare_fn()
|
||||||
} else if self.token_is_closure_keyword(© *self.token) {
|
} else if self.token_is_closure_keyword(© *self.token) {
|
||||||
|
<<<<<<< HEAD
|
||||||
// self.warn(fmt!("Old-school closure keyword"));
|
// self.warn(fmt!("Old-school closure keyword"));
|
||||||
self.parse_ty_closure(ast::BorrowedSigil, None)
|
self.parse_ty_closure(ast::BorrowedSigil, None)
|
||||||
|
=======
|
||||||
|
let result = self.parse_ty_closure(None, None);
|
||||||
|
self.obsolete(*self.last_span, ObsoleteBareFnType);
|
||||||
|
result
|
||||||
|
>>>>>>> libsyntax: Stop parsing bare functions in preparation for switching them over
|
||||||
} else if *self.token == token::MOD_SEP
|
} else if *self.token == token::MOD_SEP
|
||||||
|| is_ident_or_path(&*self.token) {
|
|| is_ident_or_path(&*self.token) {
|
||||||
let path = self.parse_path_with_tps(colons_before_params);
|
let path = self.parse_path_with_tps(colons_before_params);
|
||||||
|
@ -2813,7 +2823,7 @@ pub impl Parser {
|
||||||
fn parse_fn_decl_with_self(
|
fn parse_fn_decl_with_self(
|
||||||
&self,
|
&self,
|
||||||
parse_arg_fn:
|
parse_arg_fn:
|
||||||
fn(&Parser) -> arg_or_capture_item
|
&fn(&Parser) -> arg_or_capture_item
|
||||||
) -> (self_ty, fn_decl) {
|
) -> (self_ty, fn_decl) {
|
||||||
fn maybe_parse_self_ty(
|
fn maybe_parse_self_ty(
|
||||||
cnstr: &fn(+v: mutability) -> ast::self_ty_,
|
cnstr: &fn(+v: mutability) -> ast::self_ty_,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue