diff options
author | Aleksey Kladov <[email protected]> | 2018-08-07 12:52:03 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-07 12:52:03 +0100 |
commit | 1a25cb0b1e0f81e7b76c0b41b94d18eca3bd3bfb (patch) | |
tree | 3683c0849bccbe1aaf0d0b4373beebf5b62999f2 | |
parent | ba21da52741bf207db5081811e00eacf45796429 (diff) |
simplify unary expr grammar
-rw-r--r-- | src/grammar.ron | 4 | ||||
-rw-r--r-- | src/grammar/expressions/mod.rs | 14 | ||||
-rw-r--r-- | src/syntax_kinds/generated.rs | 8 | ||||
-rw-r--r-- | tests/data/parser/inline/0062_deref_expr.txt | 4 | ||||
-rw-r--r-- | tests/data/parser/inline/0066_not_expr.txt | 4 | ||||
-rw-r--r-- | tests/data/parser/inline/0085_neg_expr.txt | 4 |
6 files changed, 11 insertions, 27 deletions
diff --git a/src/grammar.ron b/src/grammar.ron index 5181e296e..960838c97 100644 --- a/src/grammar.ron +++ b/src/grammar.ron | |||
@@ -171,9 +171,7 @@ Grammar( | |||
171 | 171 | ||
172 | // unary | 172 | // unary |
173 | "REF_EXPR", | 173 | "REF_EXPR", |
174 | "DEREF_EXPR", | 174 | "PREFIX_EXPR", |
175 | "NOT_EXPR", | ||
176 | "NEG_EXPR", | ||
177 | 175 | ||
178 | "RANGE_EXPR", // just weird | 176 | "RANGE_EXPR", // just weird |
179 | "BIN_EXPR", | 177 | "BIN_EXPR", |
diff --git a/src/grammar/expressions/mod.rs b/src/grammar/expressions/mod.rs index 739c2f80f..853a9411c 100644 --- a/src/grammar/expressions/mod.rs +++ b/src/grammar/expressions/mod.rs | |||
@@ -130,28 +130,18 @@ fn lhs(p: &mut Parser, r: Restrictions) -> Option<CompletedMarker> { | |||
130 | // fn foo() { | 130 | // fn foo() { |
131 | // **&1; | 131 | // **&1; |
132 | // } | 132 | // } |
133 | STAR => { | ||
134 | m = p.start(); | ||
135 | p.bump(); | ||
136 | DEREF_EXPR | ||
137 | } | ||
138 | // test not_expr | 133 | // test not_expr |
139 | // fn foo() { | 134 | // fn foo() { |
140 | // !!true; | 135 | // !!true; |
141 | // } | 136 | // } |
142 | EXCL => { | ||
143 | m = p.start(); | ||
144 | p.bump(); | ||
145 | NOT_EXPR | ||
146 | } | ||
147 | // test neg_expr | 137 | // test neg_expr |
148 | // fn foo() { | 138 | // fn foo() { |
149 | // --1; | 139 | // --1; |
150 | // } | 140 | // } |
151 | MINUS => { | 141 | STAR | EXCL | MINUS => { |
152 | m = p.start(); | 142 | m = p.start(); |
153 | p.bump(); | 143 | p.bump(); |
154 | NEG_EXPR | 144 | PREFIX_EXPR |
155 | } | 145 | } |
156 | DOTDOT => { | 146 | DOTDOT => { |
157 | m = p.start(); | 147 | m = p.start(); |
diff --git a/src/syntax_kinds/generated.rs b/src/syntax_kinds/generated.rs index c8ddf333c..cf286a0f1 100644 --- a/src/syntax_kinds/generated.rs +++ b/src/syntax_kinds/generated.rs | |||
@@ -157,9 +157,7 @@ pub enum SyntaxKind { | |||
157 | TRY_EXPR, | 157 | TRY_EXPR, |
158 | CAST_EXPR, | 158 | CAST_EXPR, |
159 | REF_EXPR, | 159 | REF_EXPR, |
160 | DEREF_EXPR, | 160 | PREFIX_EXPR, |
161 | NOT_EXPR, | ||
162 | NEG_EXPR, | ||
163 | RANGE_EXPR, | 161 | RANGE_EXPR, |
164 | BIN_EXPR, | 162 | BIN_EXPR, |
165 | EXTERN_BLOCK_EXPR, | 163 | EXTERN_BLOCK_EXPR, |
@@ -397,9 +395,7 @@ impl SyntaxKind { | |||
397 | TRY_EXPR => &SyntaxInfo { name: "TRY_EXPR" }, | 395 | TRY_EXPR => &SyntaxInfo { name: "TRY_EXPR" }, |
398 | CAST_EXPR => &SyntaxInfo { name: "CAST_EXPR" }, | 396 | CAST_EXPR => &SyntaxInfo { name: "CAST_EXPR" }, |
399 | REF_EXPR => &SyntaxInfo { name: "REF_EXPR" }, | 397 | REF_EXPR => &SyntaxInfo { name: "REF_EXPR" }, |
400 | DEREF_EXPR => &SyntaxInfo { name: "DEREF_EXPR" }, | 398 | PREFIX_EXPR => &SyntaxInfo { name: "PREFIX_EXPR" }, |
401 | NOT_EXPR => &SyntaxInfo { name: "NOT_EXPR" }, | ||
402 | NEG_EXPR => &SyntaxInfo { name: "NEG_EXPR" }, | ||
403 | RANGE_EXPR => &SyntaxInfo { name: "RANGE_EXPR" }, | 399 | RANGE_EXPR => &SyntaxInfo { name: "RANGE_EXPR" }, |
404 | BIN_EXPR => &SyntaxInfo { name: "BIN_EXPR" }, | 400 | BIN_EXPR => &SyntaxInfo { name: "BIN_EXPR" }, |
405 | EXTERN_BLOCK_EXPR => &SyntaxInfo { name: "EXTERN_BLOCK_EXPR" }, | 401 | EXTERN_BLOCK_EXPR => &SyntaxInfo { name: "EXTERN_BLOCK_EXPR" }, |
diff --git a/tests/data/parser/inline/0062_deref_expr.txt b/tests/data/parser/inline/0062_deref_expr.txt index e67d2d96d..71be78bc2 100644 --- a/tests/data/parser/inline/0062_deref_expr.txt +++ b/tests/data/parser/inline/0062_deref_expr.txt | |||
@@ -12,9 +12,9 @@ FILE@[0; 23) | |||
12 | L_CURLY@[9; 10) | 12 | L_CURLY@[9; 10) |
13 | WHITESPACE@[10; 15) | 13 | WHITESPACE@[10; 15) |
14 | EXPR_STMT@[15; 20) | 14 | EXPR_STMT@[15; 20) |
15 | DEREF_EXPR@[15; 19) | 15 | PREFIX_EXPR@[15; 19) |
16 | STAR@[15; 16) | 16 | STAR@[15; 16) |
17 | DEREF_EXPR@[16; 19) | 17 | PREFIX_EXPR@[16; 19) |
18 | STAR@[16; 17) | 18 | STAR@[16; 17) |
19 | REF_EXPR@[17; 19) | 19 | REF_EXPR@[17; 19) |
20 | AMP@[17; 18) | 20 | AMP@[17; 18) |
diff --git a/tests/data/parser/inline/0066_not_expr.txt b/tests/data/parser/inline/0066_not_expr.txt index 10ac23757..005a5bcf2 100644 --- a/tests/data/parser/inline/0066_not_expr.txt +++ b/tests/data/parser/inline/0066_not_expr.txt | |||
@@ -12,9 +12,9 @@ FILE@[0; 25) | |||
12 | L_CURLY@[9; 10) | 12 | L_CURLY@[9; 10) |
13 | WHITESPACE@[10; 15) | 13 | WHITESPACE@[10; 15) |
14 | EXPR_STMT@[15; 22) | 14 | EXPR_STMT@[15; 22) |
15 | NOT_EXPR@[15; 21) | 15 | PREFIX_EXPR@[15; 21) |
16 | EXCL@[15; 16) | 16 | EXCL@[15; 16) |
17 | NOT_EXPR@[16; 21) | 17 | PREFIX_EXPR@[16; 21) |
18 | EXCL@[16; 17) | 18 | EXCL@[16; 17) |
19 | LITERAL@[17; 21) | 19 | LITERAL@[17; 21) |
20 | TRUE_KW@[17; 21) | 20 | TRUE_KW@[17; 21) |
diff --git a/tests/data/parser/inline/0085_neg_expr.txt b/tests/data/parser/inline/0085_neg_expr.txt index 8eeb0b1e6..65855555c 100644 --- a/tests/data/parser/inline/0085_neg_expr.txt +++ b/tests/data/parser/inline/0085_neg_expr.txt | |||
@@ -12,9 +12,9 @@ FILE@[0; 22) | |||
12 | L_CURLY@[9; 10) | 12 | L_CURLY@[9; 10) |
13 | WHITESPACE@[10; 15) | 13 | WHITESPACE@[10; 15) |
14 | EXPR_STMT@[15; 19) | 14 | EXPR_STMT@[15; 19) |
15 | NEG_EXPR@[15; 18) | 15 | PREFIX_EXPR@[15; 18) |
16 | MINUS@[15; 16) | 16 | MINUS@[15; 16) |
17 | NEG_EXPR@[16; 18) | 17 | PREFIX_EXPR@[16; 18) |
18 | MINUS@[16; 17) | 18 | MINUS@[16; 17) |
19 | LITERAL@[17; 18) | 19 | LITERAL@[17; 18) |
20 | INT_NUMBER@[17; 18) "1" | 20 | INT_NUMBER@[17; 18) "1" |