Skip to content

Commit 8141914

Browse files
committed
Parse raw pointer types
1 parent e79186d commit 8141914

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

chalk-parse/src/ast.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ pub enum Ty {
193193
Scalar {
194194
ty: ScalarType,
195195
},
196+
Raw {
197+
mutability: Mutability,
198+
ty: Box<Ty>,
199+
}
196200
}
197201

198202
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
@@ -230,6 +234,12 @@ pub enum ScalarType {
230234
Float(FloatTy),
231235
}
232236

237+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
238+
pub enum Mutability {
239+
Mut,
240+
Not,
241+
}
242+
233243
#[derive(Clone, PartialEq, Eq, Debug)]
234244
pub enum Lifetime {
235245
Id { name: Identifier },

chalk-parse/src/parser.lalrpop

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ TyWithoutFor: Ty = {
205205
<n:Id> "<" <a:Comma<Parameter>> ">" => Ty::Apply { name: n, args: a },
206206
<p:ProjectionTy> => Ty::Projection { proj: p },
207207
"(" <t:TupleOrParensInner> ")" => t,
208+
"*" <m: Mutability> <t:Ty> => Ty::Raw{ mutability: m, ty: Box::new(t) },
208209
};
209210

210211
ScalarType: ScalarType = {
@@ -237,6 +238,11 @@ TupleOrParensInner: Ty = {
237238
() => Ty::Tuple { types: vec![] },
238239
};
239240

241+
Mutability: Mutability = {
242+
"mut" => Mutability::Mut,
243+
"const" => Mutability::Not,
244+
};
245+
240246
Lifetime: Lifetime = {
241247
<n:LifetimeId> => Lifetime::Id { name: n },
242248
};

0 commit comments

Comments
 (0)