diff options
Diffstat (limited to 'src/grammar')
-rw-r--r-- | src/grammar/expressions/mod.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/grammar/expressions/mod.rs b/src/grammar/expressions/mod.rs index e0b4ced74..c137fe654 100644 --- a/src/grammar/expressions/mod.rs +++ b/src/grammar/expressions/mod.rs | |||
@@ -183,6 +183,7 @@ fn postfix_expr(p: &mut Parser, mut lhs: CompletedMarker) -> CompletedMarker { | |||
183 | m.complete(p, RANGE_EXPR) | 183 | m.complete(p, RANGE_EXPR) |
184 | } | 184 | } |
185 | QUESTION => try_expr(p, lhs), | 185 | QUESTION => try_expr(p, lhs), |
186 | AS_KW => cast_expr(p, lhs), | ||
186 | _ => break, | 187 | _ => break, |
187 | } | 188 | } |
188 | } | 189 | } |
@@ -260,6 +261,18 @@ fn try_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | |||
260 | m.complete(p, TRY_EXPR) | 261 | m.complete(p, TRY_EXPR) |
261 | } | 262 | } |
262 | 263 | ||
264 | // test cast_expr | ||
265 | // fn foo() { | ||
266 | // 82 as i32; | ||
267 | // } | ||
268 | fn cast_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | ||
269 | assert!(p.at(AS_KW)); | ||
270 | let m = lhs.precede(p); | ||
271 | p.bump(); | ||
272 | types::type_(p); | ||
273 | m.complete(p, CAST_EXPR) | ||
274 | } | ||
275 | |||
263 | fn arg_list(p: &mut Parser) { | 276 | fn arg_list(p: &mut Parser) { |
264 | assert!(p.at(L_PAREN)); | 277 | assert!(p.at(L_PAREN)); |
265 | let m = p.start(); | 278 | let m = p.start(); |