diff options
author | DJMcNab <[email protected]> | 2018-12-17 22:34:18 +0000 |
---|---|---|
committer | DJMcNab <[email protected]> | 2018-12-19 20:12:18 +0000 |
commit | 20bbe0127cc6bfac3ced0c7ed1de4f0526f3bbed (patch) | |
tree | 7be28cc0c1f3848a024474fb52cc5663725c2700 /crates/ra_syntax/src/grammar | |
parent | 0bd9d87e87c6435d439de3f682b83bc74d784de3 (diff) |
Fix parsing of inclusive ranges (#214)
I'm not certain that this is correct, so extra eyes would be good
Diffstat (limited to 'crates/ra_syntax/src/grammar')
-rw-r--r-- | crates/ra_syntax/src/grammar/expressions.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar/patterns.rs | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/crates/ra_syntax/src/grammar/expressions.rs b/crates/ra_syntax/src/grammar/expressions.rs index a9449c7bf..bca32f707 100644 --- a/crates/ra_syntax/src/grammar/expressions.rs +++ b/crates/ra_syntax/src/grammar/expressions.rs | |||
@@ -143,7 +143,7 @@ fn current_op(p: &Parser) -> (u8, Op) { | |||
143 | 143 | ||
144 | let bp = match p.current() { | 144 | let bp = match p.current() { |
145 | EQ => 1, | 145 | EQ => 1, |
146 | DOTDOT => 2, | 146 | DOTDOT | DOTDOTEQ => 2, |
147 | EQEQ | NEQ | L_ANGLE | R_ANGLE => 5, | 147 | EQEQ | NEQ | L_ANGLE | R_ANGLE => 5, |
148 | PIPE => 6, | 148 | PIPE => 6, |
149 | CARET => 7, | 149 | CARET => 7, |
@@ -173,7 +173,7 @@ fn expr_bp(p: &mut Parser, r: Restrictions, bp: u8) -> BlockLike { | |||
173 | }; | 173 | }; |
174 | 174 | ||
175 | loop { | 175 | loop { |
176 | let is_range = p.current() == DOTDOT; | 176 | let is_range = p.current() == DOTDOT || p.current() == DOTDOTEQ; |
177 | let (op_bp, op) = current_op(p); | 177 | let (op_bp, op) = current_op(p); |
178 | if op_bp < bp { | 178 | if op_bp < bp { |
179 | break; | 179 | break; |
diff --git a/crates/ra_syntax/src/grammar/patterns.rs b/crates/ra_syntax/src/grammar/patterns.rs index 10fa0e0be..64cdf0b1b 100644 --- a/crates/ra_syntax/src/grammar/patterns.rs +++ b/crates/ra_syntax/src/grammar/patterns.rs | |||
@@ -14,9 +14,13 @@ pub(super) fn pattern_r(p: &mut Parser, recovery_set: TokenSet) { | |||
14 | if let Some(lhs) = atom_pat(p, recovery_set) { | 14 | if let Some(lhs) = atom_pat(p, recovery_set) { |
15 | // test range_pat | 15 | // test range_pat |
16 | // fn main() { | 16 | // fn main() { |
17 | // match 92 { 0 ... 100 => () } | 17 | // match 92 { |
18 | // 0 ... 100 => (), | ||
19 | // 101 ..= 200 => (), | ||
20 | // 200 .. 301=> (), | ||
21 | // } | ||
18 | // } | 22 | // } |
19 | if p.at(DOTDOTDOT) { | 23 | if p.at(DOTDOTDOT) || p.at(DOTDOTEQ) || p.at(DOTDOT) { |
20 | let m = lhs.precede(p); | 24 | let m = lhs.precede(p); |
21 | p.bump(); | 25 | p.bump(); |
22 | atom_pat(p, recovery_set); | 26 | atom_pat(p, recovery_set); |