Allow istrs as patterns. Issue #855

This commit is contained in:
Brian Anderson 2011-08-31 22:34:41 -07:00
parent 4c25d81041
commit 7924368268
3 changed files with 50 additions and 14 deletions

View file

@ -1497,6 +1497,22 @@ fn parse_pat(p: &parser) -> @ast::pat {
pat = ast::pat_tup(fields);
}
}
token::TILDE. {
p.bump();
alt p.peek() {
token::LIT_STR(s) {
let sp = p.get_span();
p.bump();
let lit =
@{node: ast::lit_str(p.get_str(s),
ast::sk_unique),
span: sp};
hi = lit.span.hi;
pat = ast::pat_lit(lit);
}
_ { p.fatal(~"expected string literal"); }
}
}
tok {
if !is_ident(tok) || is_word(p, ~"true") || is_word(p, ~"false") {
let lit = parse_lit(p);