diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/grammar.ron | 1 | ||||
-rw-r--r-- | src/grammar/expressions/mod.rs | 13 | ||||
-rw-r--r-- | src/syntax_kinds/generated.rs | 2 |
3 files changed, 16 insertions, 0 deletions
diff --git a/src/grammar.ron b/src/grammar.ron index ca37eb80b..b525476c2 100644 --- a/src/grammar.ron +++ b/src/grammar.ron | |||
@@ -162,6 +162,7 @@ Grammar( | |||
162 | "METHOD_CALL_EXPR", | 162 | "METHOD_CALL_EXPR", |
163 | "FIELD_EXPR", | 163 | "FIELD_EXPR", |
164 | "TRY_EXPR", | 164 | "TRY_EXPR", |
165 | "CAST_EXPR", | ||
165 | 166 | ||
166 | // unary | 167 | // unary |
167 | "REF_EXPR", | 168 | "REF_EXPR", |
diff --git a/src/grammar/expressions/mod.rs b/src/grammar/expressions/mod.rs index e0b4ced74..c137fe654 100644 --- a/src/grammar/expressions/mod.rs +++ b/src/grammar/expressions/mod.rs | |||
@@ -183,6 +183,7 @@ fn postfix_expr(p: &mut Parser, mut lhs: CompletedMarker) -> CompletedMarker { | |||
183 | m.complete(p, RANGE_EXPR) | 183 | m.complete(p, RANGE_EXPR) |
184 | } | 184 | } |
185 | QUESTION => try_expr(p, lhs), | 185 | QUESTION => try_expr(p, lhs), |
186 | AS_KW => cast_expr(p, lhs), | ||
186 | _ => break, | 187 | _ => break, |
187 | } | 188 | } |
188 | } | 189 | } |
@@ -260,6 +261,18 @@ fn try_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | |||
260 | m.complete(p, TRY_EXPR) | 261 | m.complete(p, TRY_EXPR) |
261 | } | 262 | } |
262 | 263 | ||
264 | // test cast_expr | ||
265 | // fn foo() { | ||
266 | // 82 as i32; | ||
267 | // } | ||
268 | fn cast_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | ||
269 | assert!(p.at(AS_KW)); | ||
270 | let m = lhs.precede(p); | ||
271 | p.bump(); | ||
272 | types::type_(p); | ||
273 | m.complete(p, CAST_EXPR) | ||
274 | } | ||
275 | |||
263 | fn arg_list(p: &mut Parser) { | 276 | fn arg_list(p: &mut Parser) { |
264 | assert!(p.at(L_PAREN)); | 277 | assert!(p.at(L_PAREN)); |
265 | let m = p.start(); | 278 | let m = p.start(); |
diff --git a/src/syntax_kinds/generated.rs b/src/syntax_kinds/generated.rs index 3c5071126..005f4a9dc 100644 --- a/src/syntax_kinds/generated.rs +++ b/src/syntax_kinds/generated.rs | |||
@@ -150,6 +150,7 @@ pub enum SyntaxKind { | |||
150 | METHOD_CALL_EXPR, | 150 | METHOD_CALL_EXPR, |
151 | FIELD_EXPR, | 151 | FIELD_EXPR, |
152 | TRY_EXPR, | 152 | TRY_EXPR, |
153 | CAST_EXPR, | ||
153 | REF_EXPR, | 154 | REF_EXPR, |
154 | DEREF_EXPR, | 155 | DEREF_EXPR, |
155 | NOT_EXPR, | 156 | NOT_EXPR, |
@@ -383,6 +384,7 @@ impl SyntaxKind { | |||
383 | METHOD_CALL_EXPR => &SyntaxInfo { name: "METHOD_CALL_EXPR" }, | 384 | METHOD_CALL_EXPR => &SyntaxInfo { name: "METHOD_CALL_EXPR" }, |
384 | FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" }, | 385 | FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" }, |
385 | TRY_EXPR => &SyntaxInfo { name: "TRY_EXPR" }, | 386 | TRY_EXPR => &SyntaxInfo { name: "TRY_EXPR" }, |
387 | CAST_EXPR => &SyntaxInfo { name: "CAST_EXPR" }, | ||
386 | REF_EXPR => &SyntaxInfo { name: "REF_EXPR" }, | 388 | REF_EXPR => &SyntaxInfo { name: "REF_EXPR" }, |
387 | DEREF_EXPR => &SyntaxInfo { name: "DEREF_EXPR" }, | 389 | DEREF_EXPR => &SyntaxInfo { name: "DEREF_EXPR" }, |
388 | NOT_EXPR => &SyntaxInfo { name: "NOT_EXPR" }, | 390 | NOT_EXPR => &SyntaxInfo { name: "NOT_EXPR" }, |