aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-07-31 18:44:54 +0100
committerAleksey Kladov <[email protected]>2018-07-31 18:44:54 +0100
commit599ca1ad890f7b8e1e3919f1727c21dad353f595 (patch)
tree099b6ed3bd1075daa03594211f3f1246659a2467 /src
parentce3462ce8fed8bb86d887643479c73908fc326a3 (diff)
dref-expr
Diffstat (limited to 'src')
-rw-r--r--src/grammar.ron1
-rw-r--r--src/parser/grammar/expressions.rs13
-rw-r--r--src/syntax_kinds/generated.rs2
3 files changed, 16 insertions, 0 deletions
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(
129 "METHOD_CALL_EXPR", 129 "METHOD_CALL_EXPR",
130 "FIELD_EXPR", 130 "FIELD_EXPR",
131 "REF_EXPR", 131 "REF_EXPR",
132 "DEREF_EXPR",
132 "STRUCT_LIT", 133 "STRUCT_LIT",
133 "STRUCT_LIT_FIELD", 134 "STRUCT_LIT_FIELD",
134 135
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) {
48fn prefix_expr(p: &mut Parser) -> Option<CompletedMarker> { 48fn prefix_expr(p: &mut Parser) -> Option<CompletedMarker> {
49 match p.current() { 49 match p.current() {
50 AMPERSAND => Some(ref_expr(p)), 50 AMPERSAND => Some(ref_expr(p)),
51 STAR => Some(deref_expr(p)),
51 _ => atom_expr(p), 52 _ => atom_expr(p),
52 } 53 }
53} 54}
@@ -66,6 +67,18 @@ fn ref_expr(p: &mut Parser) -> CompletedMarker {
66 m.complete(p, REF_EXPR) 67 m.complete(p, REF_EXPR)
67} 68}
68 69
70// test deref_expr
71// fn foo() {
72// **&1;
73// }
74fn deref_expr(p: &mut Parser) -> CompletedMarker {
75 assert!(p.at(STAR));
76 let m = p.start();
77 p.bump();
78 expr(p);
79 m.complete(p, DEREF_EXPR)
80}
81
69fn atom_expr(p: &mut Parser) -> Option<CompletedMarker> { 82fn atom_expr(p: &mut Parser) -> Option<CompletedMarker> {
70 match literal(p) { 83 match literal(p) {
71 Some(m) => return Some(m), 84 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 {
120 METHOD_CALL_EXPR, 120 METHOD_CALL_EXPR,
121 FIELD_EXPR, 121 FIELD_EXPR,
122 REF_EXPR, 122 REF_EXPR,
123 DEREF_EXPR,
123 STRUCT_LIT, 124 STRUCT_LIT,
124 STRUCT_LIT_FIELD, 125 STRUCT_LIT_FIELD,
125 EXTERN_BLOCK, 126 EXTERN_BLOCK,
@@ -279,6 +280,7 @@ impl SyntaxKind {
279 METHOD_CALL_EXPR => &SyntaxInfo { name: "METHOD_CALL_EXPR" }, 280 METHOD_CALL_EXPR => &SyntaxInfo { name: "METHOD_CALL_EXPR" },
280 FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" }, 281 FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" },
281 REF_EXPR => &SyntaxInfo { name: "REF_EXPR" }, 282 REF_EXPR => &SyntaxInfo { name: "REF_EXPR" },
283 DEREF_EXPR => &SyntaxInfo { name: "DEREF_EXPR" },
282 STRUCT_LIT => &SyntaxInfo { name: "STRUCT_LIT" }, 284 STRUCT_LIT => &SyntaxInfo { name: "STRUCT_LIT" },
283 STRUCT_LIT_FIELD => &SyntaxInfo { name: "STRUCT_LIT_FIELD" }, 285 STRUCT_LIT_FIELD => &SyntaxInfo { name: "STRUCT_LIT_FIELD" },
284 EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" }, 286 EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" },