rustc: Implement optional fat-arrow syntax for alt (transitional change)

This commit is contained in:
Patrick Walton 2012-06-04 18:34:10 -07:00
parent 7803488a43
commit ae6d8d1b4d
3 changed files with 9 additions and 1 deletions

View File

@ -389,7 +389,12 @@ fn next_token_inner(rdr: reader) -> token::token {
if rdr.curr == '=' {
rdr.bump();
ret token::EQEQ;
} else { ret token::EQ; }
} else if rdr.curr == '>' {
rdr.bump();
ret token::FAT_ARROW;
} else {
ret token::EQ;
}
}
'!' {
rdr.bump();

View File

@ -1281,6 +1281,7 @@ class parser {
let pats = self.parse_pats();
let mut guard = none;
if self.eat_keyword("if") { guard = some(self.parse_expr()); }
if self.token == token::FAT_ARROW { self.bump(); }
let blk = self.parse_block();
arms += [{pats: pats, guard: guard, body: blk}];
}

View File

@ -45,6 +45,7 @@ enum token {
RARROW,
LARROW,
DARROW,
FAT_ARROW,
LPAREN,
RPAREN,
LBRACKET,
@ -111,6 +112,7 @@ fn to_str(in: interner<str>, t: token) -> str {
RARROW { ret "->"; }
LARROW { ret "<-"; }
DARROW { ret "<->"; }
FAT_ARROW { ret "=>"; }
LPAREN { ret "("; }
RPAREN { ret ")"; }
LBRACKET { ret "["; }