From 498098a5d968f06f08fa093f1fd5a43a9a61ecf3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Aug 2018 03:55:16 +0300 Subject: cast expr --- src/grammar/expressions/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/grammar') 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 { m.complete(p, RANGE_EXPR) } QUESTION => try_expr(p, lhs), + AS_KW => cast_expr(p, lhs), _ => break, } } @@ -260,6 +261,18 @@ fn try_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { m.complete(p, TRY_EXPR) } +// test cast_expr +// fn foo() { +// 82 as i32; +// } +fn cast_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { + assert!(p.at(AS_KW)); + let m = lhs.precede(p); + p.bump(); + types::type_(p); + m.complete(p, CAST_EXPR) +} + fn arg_list(p: &mut Parser) { assert!(p.at(L_PAREN)); let m = p.start(); -- cgit v1.2.3