From 599ca1ad890f7b8e1e3919f1727c21dad353f595 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 31 Jul 2018 20:44:54 +0300 Subject: dref-expr --- src/parser/grammar/expressions.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/parser/grammar') diff --git a/src/parser/grammar/expressions.rs b/src/parser/grammar/expressions.rs index 5b18e2294..881d947ac 100644 --- a/src/parser/grammar/expressions.rs +++ b/src/parser/grammar/expressions.rs @@ -48,6 +48,7 @@ pub(super) fn expr(p: &mut Parser) { fn prefix_expr(p: &mut Parser) -> Option { match p.current() { AMPERSAND => Some(ref_expr(p)), + STAR => Some(deref_expr(p)), _ => atom_expr(p), } } @@ -66,6 +67,18 @@ fn ref_expr(p: &mut Parser) -> CompletedMarker { m.complete(p, REF_EXPR) } +// test deref_expr +// fn foo() { +// **&1; +// } +fn deref_expr(p: &mut Parser) -> CompletedMarker { + assert!(p.at(STAR)); + let m = p.start(); + p.bump(); + expr(p); + m.complete(p, DEREF_EXPR) +} + fn atom_expr(p: &mut Parser) -> Option { match literal(p) { Some(m) => return Some(m), -- cgit v1.2.3