Skip to content

Commit b004e48

Browse files
committed
---
yaml --- r: 140761 b: refs/heads/try2 c: db0693a h: refs/heads/master i: 140759: a456d59 v: v3
1 parent 93bab52 commit b004e48

File tree

4 files changed

+54
-27
lines changed

4 files changed

+54
-27
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 5d3559e6455757c5508bba5b5add69477ebac53e
8+
refs/heads/try2: db0693ac8d06202a289f451c223eb6f514819ffe
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/num/strconv.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,11 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
486486
}
487487
}
488488

489-
let (start, accum_positive) = match buf[0] {
490-
'-' as u8 if !negative => return None,
491-
'-' as u8 => (1u, false),
492-
'+' as u8 => (1u, true),
493-
_ => (0u, true)
489+
let (start, accum_positive) = match buf[0] as char {
490+
'-' if !negative => return None,
491+
'-' => (1u, false),
492+
'+' => (1u, true),
493+
_ => (0u, true)
494494
};
495495

496496
// Initialize accumulator with signed zero for floating point parsing to

branches/try2/src/libcore/unstable/extfmt.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,12 @@ pub mod ct {
257257
let mut flags = ~[];
258258

259259
while i < lim {
260-
let f = match s[i] {
261-
'-' as u8 => FlagLeftJustify,
262-
'0' as u8 => FlagLeftZeroPad,
263-
' ' as u8 => FlagSpaceForSign,
264-
'+' as u8 => FlagSignAlways,
265-
'#' as u8 => FlagAlternate,
260+
let f = match s[i] as char {
261+
'-' => FlagLeftJustify,
262+
'0' => FlagLeftZeroPad,
263+
' ' => FlagSpaceForSign,
264+
'+' => FlagSignAlways,
265+
'#' => FlagAlternate,
266266
_ => break
267267
};
268268

@@ -313,18 +313,18 @@ pub mod ct {
313313

314314
// FIXME (#2249): Do we really want two signed types here?
315315
// How important is it to be printf compatible?
316-
let t = match s[i] {
317-
'b' as u8 => TyBool,
318-
's' as u8 => TyStr,
319-
'c' as u8 => TyChar,
320-
'd' as u8 | 'i' as u8 => TyInt(Signed),
321-
'u' as u8 => TyInt(Unsigned),
322-
'x' as u8 => TyHex(CaseLower),
323-
'X' as u8 => TyHex(CaseUpper),
324-
't' as u8 => TyBits,
325-
'o' as u8 => TyOctal,
326-
'f' as u8 => TyFloat,
327-
'?' as u8 => TyPoly,
316+
let t = match s[i] as char {
317+
'b' => TyBool,
318+
's' => TyStr,
319+
'c' => TyChar,
320+
'd' | 'i' => TyInt(Signed),
321+
'u' => TyInt(Unsigned),
322+
'x' => TyHex(CaseLower),
323+
'X' => TyHex(CaseUpper),
324+
't' => TyBits,
325+
'o' => TyOctal,
326+
'f' => TyFloat,
327+
'?' => TyPoly,
328328
_ => err(~"unknown type in conversion: " + s.substr(i, 1))
329329
};
330330

branches/try2/src/libsyntax/parse/parser.rs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,24 @@ pub impl Parser {
915915
codemap::spanned { node: lit, span: mk_sp(lo, self.last_span.hi) }
916916
}
917917

918+
// matches '-' lit | lit
919+
fn parse_literal_maybe_minus(&self) -> @expr {
920+
let minus_lo = self.span.lo;
921+
let minus_present = self.eat(&token::BINOP(token::MINUS));
922+
923+
let lo = self.span.lo;
924+
let literal = @self.parse_lit();
925+
let hi = self.span.hi;
926+
let expr = self.mk_expr(lo, hi, expr_lit(literal));
927+
928+
if minus_present {
929+
let minus_hi = self.span.hi;
930+
self.mk_expr(minus_lo, minus_hi, expr_unary(neg, expr))
931+
} else {
932+
expr
933+
}
934+
}
935+
918936
// parse a path into a vector of idents, whether the path starts
919937
// with ::, and a span.
920938
fn parse_path(&self) -> (~[ast::ident],bool,span) {
@@ -2360,10 +2378,19 @@ pub impl Parser {
23602378
|| self.is_keyword(&~"true")
23612379
|| self.is_keyword(&~"false")
23622380
{
2363-
// parse an expression pattern or exp .. exp
2364-
let val = self.parse_expr_res(RESTRICT_NO_BAR_OP);
2381+
// Parse an expression pattern or exp .. exp.
2382+
//
2383+
// These expressions are limited to literals (possibly
2384+
// preceded by unary-minus) or identifiers.
2385+
let val = self.parse_literal_maybe_minus();
23652386
if self.eat(&token::DOTDOT) {
2366-
let end = self.parse_expr_res(RESTRICT_NO_BAR_OP);
2387+
let end = if is_ident_or_path(&tok) {
2388+
let path = self.parse_path_with_tps(true);
2389+
let hi = self.span.hi;
2390+
self.mk_expr(lo, hi, expr_path(path))
2391+
} else {
2392+
self.parse_literal_maybe_minus()
2393+
};
23672394
pat = pat_range(val, end);
23682395
} else {
23692396
pat = pat_lit(val);

0 commit comments

Comments
 (0)