From eb4c05d572ff0c4e92452232d6591d7a2796e785 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 11 Feb 2018 11:54:09 +0300 Subject: G: reference types --- src/parser/grammar/types.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/parser') diff --git a/src/parser/grammar/types.rs b/src/parser/grammar/types.rs index 4eb333b54..003341db5 100644 --- a/src/parser/grammar/types.rs +++ b/src/parser/grammar/types.rs @@ -6,6 +6,7 @@ pub(super) fn type_(p: &mut Parser) { EXCL => never_type(p), STAR => pointer_type(p), L_BRACK => array_or_slice_type(p), + AMPERSAND => reference_type(p), IDENT => path_type(p), _ => { p.error("expected type"); @@ -115,6 +116,20 @@ fn array_or_slice_type(p: &mut Parser) { m.complete(p, kind); } +// test reference_type; +// type A = &(); +// type B = &'static (); +// type C = &mut (); +fn reference_type(p: &mut Parser) { + assert!(p.at(AMPERSAND)); + let m = p.start(); + p.bump(); + p.eat(LIFETIME); + p.eat(MUT_KW); + type_no_plus(p); + m.complete(p, REFERENCE_TYPE); +} + fn path_type(p: &mut Parser) { assert!(p.at(IDENT)); let m = p.start(); -- cgit v1.2.3