diff options
author | Aleksey Kladov <[email protected]> | 2018-08-07 01:55:16 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-07 01:55:16 +0100 |
commit | 498098a5d968f06f08fa093f1fd5a43a9a61ecf3 (patch) | |
tree | 79311ef5a12ee1625657101570bad758c63c0a75 /src/grammar | |
parent | 66bd1ffa327b4b1691a260107ef53a7ef112c8ea (diff) |
cast expr
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(); |