aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-02-11 08:54:09 +0000
committerAleksey Kladov <[email protected]>2018-02-11 08:54:09 +0000
commiteb4c05d572ff0c4e92452232d6591d7a2796e785 (patch)
tree371136f9c2ad04ff1fca3db94e73872988395fa1 /src
parent555c4ae37560493fd901aad41951ad1664043459 (diff)
G: reference types
Diffstat (limited to 'src')
-rw-r--r--src/parser/grammar/types.rs15
-rw-r--r--src/syntax_kinds.rs2
2 files changed, 17 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 ();
123fn 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
118fn path_type(p: &mut Parser) { 133fn 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();
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs
index 54200f2d1..597550a32 100644
--- a/src/syntax_kinds.rs
+++ b/src/syntax_kinds.rs
@@ -106,6 +106,7 @@ pub enum SyntaxKind {
106 POINTER_TYPE, 106 POINTER_TYPE,
107 ARRAY_TYPE, 107 ARRAY_TYPE,
108 SLICE_TYPE, 108 SLICE_TYPE,
109 REFERENCE_TYPE,
109 EXTERN_BLOCK, 110 EXTERN_BLOCK,
110 ENUM_VARIANT, 111 ENUM_VARIANT,
111 NAMED_FIELD, 112 NAMED_FIELD,
@@ -238,6 +239,7 @@ impl SyntaxKind {
238 POINTER_TYPE => &SyntaxInfo { name: "POINTER_TYPE" }, 239 POINTER_TYPE => &SyntaxInfo { name: "POINTER_TYPE" },
239 ARRAY_TYPE => &SyntaxInfo { name: "ARRAY_TYPE" }, 240 ARRAY_TYPE => &SyntaxInfo { name: "ARRAY_TYPE" },
240 SLICE_TYPE => &SyntaxInfo { name: "SLICE_TYPE" }, 241 SLICE_TYPE => &SyntaxInfo { name: "SLICE_TYPE" },
242 REFERENCE_TYPE => &SyntaxInfo { name: "REFERENCE_TYPE" },
241 EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" }, 243 EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" },
242 ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" }, 244 ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" },
243 NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" }, 245 NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" },