From 53c94e3ad8782b2ab51bea1aeb5687ec34f7a96d Mon Sep 17 00:00:00 2001 From: csmoe Date: Sun, 30 Dec 2018 21:51:40 +0800 Subject: parse minus before number literal --- crates/ra_syntax/src/grammar/patterns.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/grammar/patterns.rs b/crates/ra_syntax/src/grammar/patterns.rs index 64cdf0b1b..692ffbb8c 100644 --- a/crates/ra_syntax/src/grammar/patterns.rs +++ b/crates/ra_syntax/src/grammar/patterns.rs @@ -48,11 +48,16 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option { // test literal_pattern // fn main() { // match () { + // -1 => (), // 92 => (), // 'c' => (), // "hello" => (), // } // } + if p.at(MINUS) && (p.nth(1) == INT_NUMBER || p.nth(1) == FLOAT_NUMBER) { + p.bump(); + } + if let Some(m) = expressions::literal(p) { return Some(m); } -- cgit v1.2.3