mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
rustc: Implement optional fat-arrow syntax for alt (transitional change)
This commit is contained in:
parent
7803488a43
commit
ae6d8d1b4d
@ -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();
|
||||
|
@ -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}];
|
||||
}
|
||||
|
@ -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 "["; }
|
||||
|
Loading…
Reference in New Issue
Block a user