aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/grammar.ron1
-rw-r--r--src/grammar/expressions.rs24
-rw-r--r--src/syntax_kinds/generated.rs2
-rw-r--r--tests/data/parser/inline/0066_not_expr.rs3
-rw-r--r--tests/data/parser/inline/0066_not_expr.txt24
5 files changed, 49 insertions, 5 deletions
diff --git a/src/grammar.ron b/src/grammar.ron
index 9912f9698..782771830 100644
--- a/src/grammar.ron
+++ b/src/grammar.ron
@@ -132,6 +132,7 @@ Grammar(
132 "FIELD_EXPR", 132 "FIELD_EXPR",
133 "REF_EXPR", 133 "REF_EXPR",
134 "DEREF_EXPR", 134 "DEREF_EXPR",
135 "NOT_EXPR",
135 "LAMBDA_EXPR", 136 "LAMBDA_EXPR",
136 "STRUCT_LIT", 137 "STRUCT_LIT",
137 "STRUCT_LIT_FIELD", 138 "STRUCT_LIT_FIELD",
diff --git a/src/grammar/expressions.rs b/src/grammar/expressions.rs
index ed9236b02..c638e8b99 100644
--- a/src/grammar/expressions.rs
+++ b/src/grammar/expressions.rs
@@ -103,11 +103,13 @@ fn let_stmt(p: &mut Parser) {
103} 103}
104 104
105fn prefix_expr(p: &mut Parser) -> Option<CompletedMarker> { 105fn prefix_expr(p: &mut Parser) -> Option<CompletedMarker> {
106 match p.current() { 106 let done = match p.current() {
107 AMPERSAND => Some(ref_expr(p)), 107 AMPERSAND => ref_expr(p),
108 STAR => Some(deref_expr(p)), 108 STAR => deref_expr(p),
109 _ => atom_expr(p), 109 EXCL => not_expr(p),
110 } 110 _ => return atom_expr(p),
111 };
112 Some(done)
111} 113}
112 114
113// test ref_expr 115// test ref_expr
@@ -136,6 +138,18 @@ fn deref_expr(p: &mut Parser) -> CompletedMarker {
136 m.complete(p, DEREF_EXPR) 138 m.complete(p, DEREF_EXPR)
137} 139}
138 140
141// test not_expr
142// fn foo() {
143// !!true;
144// }
145fn not_expr(p: &mut Parser) -> CompletedMarker {
146 assert!(p.at(EXCL));
147 let m = p.start();
148 p.bump();
149 expr(p);
150 m.complete(p, NOT_EXPR)
151}
152
139fn atom_expr(p: &mut Parser) -> Option<CompletedMarker> { 153fn atom_expr(p: &mut Parser) -> Option<CompletedMarker> {
140 match literal(p) { 154 match literal(p) {
141 Some(m) => return Some(m), 155 Some(m) => return Some(m),
diff --git a/src/syntax_kinds/generated.rs b/src/syntax_kinds/generated.rs
index 35d9640fa..746316ed5 100644
--- a/src/syntax_kinds/generated.rs
+++ b/src/syntax_kinds/generated.rs
@@ -123,6 +123,7 @@ pub enum SyntaxKind {
123 FIELD_EXPR, 123 FIELD_EXPR,
124 REF_EXPR, 124 REF_EXPR,
125 DEREF_EXPR, 125 DEREF_EXPR,
126 NOT_EXPR,
126 LAMBDA_EXPR, 127 LAMBDA_EXPR,
127 STRUCT_LIT, 128 STRUCT_LIT,
128 STRUCT_LIT_FIELD, 129 STRUCT_LIT_FIELD,
@@ -287,6 +288,7 @@ impl SyntaxKind {
287 FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" }, 288 FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" },
288 REF_EXPR => &SyntaxInfo { name: "REF_EXPR" }, 289 REF_EXPR => &SyntaxInfo { name: "REF_EXPR" },
289 DEREF_EXPR => &SyntaxInfo { name: "DEREF_EXPR" }, 290 DEREF_EXPR => &SyntaxInfo { name: "DEREF_EXPR" },
291 NOT_EXPR => &SyntaxInfo { name: "NOT_EXPR" },
290 LAMBDA_EXPR => &SyntaxInfo { name: "LAMBDA_EXPR" }, 292 LAMBDA_EXPR => &SyntaxInfo { name: "LAMBDA_EXPR" },
291 STRUCT_LIT => &SyntaxInfo { name: "STRUCT_LIT" }, 293 STRUCT_LIT => &SyntaxInfo { name: "STRUCT_LIT" },
292 STRUCT_LIT_FIELD => &SyntaxInfo { name: "STRUCT_LIT_FIELD" }, 294 STRUCT_LIT_FIELD => &SyntaxInfo { name: "STRUCT_LIT_FIELD" },
diff --git a/tests/data/parser/inline/0066_not_expr.rs b/tests/data/parser/inline/0066_not_expr.rs
new file mode 100644
index 000000000..4c97fd9a6
--- /dev/null
+++ b/tests/data/parser/inline/0066_not_expr.rs
@@ -0,0 +1,3 @@
1fn foo() {
2 !!true;
3}
diff --git a/tests/data/parser/inline/0066_not_expr.txt b/tests/data/parser/inline/0066_not_expr.txt
new file mode 100644
index 000000000..3e950969e
--- /dev/null
+++ b/tests/data/parser/inline/0066_not_expr.txt
@@ -0,0 +1,24 @@
1FILE@[0; 25)
2 FN_ITEM@[0; 25)
3 FN_KW@[0; 2)
4 NAME@[2; 6)
5 WHITESPACE@[2; 3)
6 IDENT@[3; 6) "foo"
7 PARAM_LIST@[6; 9)
8 L_PAREN@[6; 7)
9 R_PAREN@[7; 8)
10 WHITESPACE@[8; 9)
11 BLOCK@[9; 25)
12 L_CURLY@[9; 10)
13 EXPR_STMT@[10; 23)
14 NOT_EXPR@[10; 21)
15 WHITESPACE@[10; 15)
16 EXCL@[15; 16)
17 NOT_EXPR@[16; 21)
18 EXCL@[16; 17)
19 LITERAL@[17; 21)
20 TRUE_KW@[17; 21)
21 SEMI@[21; 22)
22 WHITESPACE@[22; 23)
23 R_CURLY@[23; 24)
24 WHITESPACE@[24; 25)