From 599ca1ad890f7b8e1e3919f1727c21dad353f595 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 31 Jul 2018 20:44:54 +0300 Subject: dref-expr --- src/grammar.ron | 1 + src/parser/grammar/expressions.rs | 13 +++++++++++++ src/syntax_kinds/generated.rs | 2 ++ 3 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/grammar.ron b/src/grammar.ron index 564249200..aa01cb205 100644 --- a/src/grammar.ron +++ b/src/grammar.ron @@ -129,6 +129,7 @@ Grammar( "METHOD_CALL_EXPR", "FIELD_EXPR", "REF_EXPR", + "DEREF_EXPR", "STRUCT_LIT", "STRUCT_LIT_FIELD", diff --git a/src/parser/grammar/expressions.rs b/src/parser/grammar/expressions.rs index 5b18e2294..881d947ac 100644 --- a/src/parser/grammar/expressions.rs +++ b/src/parser/grammar/expressions.rs @@ -48,6 +48,7 @@ pub(super) fn expr(p: &mut Parser) { fn prefix_expr(p: &mut Parser) -> Option { match p.current() { AMPERSAND => Some(ref_expr(p)), + STAR => Some(deref_expr(p)), _ => atom_expr(p), } } @@ -66,6 +67,18 @@ fn ref_expr(p: &mut Parser) -> CompletedMarker { m.complete(p, REF_EXPR) } +// test deref_expr +// fn foo() { +// **&1; +// } +fn deref_expr(p: &mut Parser) -> CompletedMarker { + assert!(p.at(STAR)); + let m = p.start(); + p.bump(); + expr(p); + m.complete(p, DEREF_EXPR) +} + fn atom_expr(p: &mut Parser) -> Option { match literal(p) { Some(m) => return Some(m), diff --git a/src/syntax_kinds/generated.rs b/src/syntax_kinds/generated.rs index 655764528..a37fdea0b 100644 --- a/src/syntax_kinds/generated.rs +++ b/src/syntax_kinds/generated.rs @@ -120,6 +120,7 @@ pub enum SyntaxKind { METHOD_CALL_EXPR, FIELD_EXPR, REF_EXPR, + DEREF_EXPR, STRUCT_LIT, STRUCT_LIT_FIELD, EXTERN_BLOCK, @@ -279,6 +280,7 @@ impl SyntaxKind { METHOD_CALL_EXPR => &SyntaxInfo { name: "METHOD_CALL_EXPR" }, FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" }, REF_EXPR => &SyntaxInfo { name: "REF_EXPR" }, + DEREF_EXPR => &SyntaxInfo { name: "DEREF_EXPR" }, STRUCT_LIT => &SyntaxInfo { name: "STRUCT_LIT" }, STRUCT_LIT_FIELD => &SyntaxInfo { name: "STRUCT_LIT_FIELD" }, EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" }, -- cgit v1.2.3