diff options
author | Aleksey Kladov <[email protected]> | 2018-02-11 08:54:09 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-02-11 08:54:09 +0000 |
commit | eb4c05d572ff0c4e92452232d6591d7a2796e785 (patch) | |
tree | 371136f9c2ad04ff1fca3db94e73872988395fa1 /src/parser/grammar | |
parent | 555c4ae37560493fd901aad41951ad1664043459 (diff) |
G: reference types
Diffstat (limited to 'src/parser/grammar')
-rw-r--r-- | src/parser/grammar/types.rs | 15 |
1 files changed, 15 insertions, 0 deletions
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) { | |||
6 | EXCL => never_type(p), | 6 | EXCL => never_type(p), |
7 | STAR => pointer_type(p), | 7 | STAR => pointer_type(p), |
8 | L_BRACK => array_or_slice_type(p), | 8 | L_BRACK => array_or_slice_type(p), |
9 | AMPERSAND => reference_type(p), | ||
9 | IDENT => path_type(p), | 10 | IDENT => path_type(p), |
10 | _ => { | 11 | _ => { |
11 | p.error("expected type"); | 12 | p.error("expected type"); |
@@ -115,6 +116,20 @@ fn array_or_slice_type(p: &mut Parser) { | |||
115 | m.complete(p, kind); | 116 | m.complete(p, kind); |
116 | } | 117 | } |
117 | 118 | ||
119 | // test reference_type; | ||
120 | // type A = &(); | ||
121 | // type B = &'static (); | ||
122 | // type C = &mut (); | ||
123 | fn reference_type(p: &mut Parser) { | ||
124 | assert!(p.at(AMPERSAND)); | ||
125 | let m = p.start(); | ||
126 | p.bump(); | ||
127 | p.eat(LIFETIME); | ||
128 | p.eat(MUT_KW); | ||
129 | type_no_plus(p); | ||
130 | m.complete(p, REFERENCE_TYPE); | ||
131 | } | ||
132 | |||
118 | fn path_type(p: &mut Parser) { | 133 | fn path_type(p: &mut Parser) { |
119 | assert!(p.at(IDENT)); | 134 | assert!(p.at(IDENT)); |
120 | let m = p.start(); | 135 | let m = p.start(); |