simplify unary expr grammar

This commit is contained in:
Aleksey Kladov 2018-08-07 14:52:03 +03:00
parent ba21da5274
commit 1a25cb0b1e
6 changed files with 11 additions and 27 deletions

View file

@ -171,9 +171,7 @@ Grammar(
// unary
"REF_EXPR",
"DEREF_EXPR",
"NOT_EXPR",
"NEG_EXPR",
"PREFIX_EXPR",
"RANGE_EXPR", // just weird
"BIN_EXPR",

View file

@ -130,28 +130,18 @@ fn lhs(p: &mut Parser, r: Restrictions) -> Option<CompletedMarker> {
// fn foo() {
// **&1;
// }
STAR => {
m = p.start();
p.bump();
DEREF_EXPR
}
// test not_expr
// fn foo() {
// !!true;
// }
EXCL => {
m = p.start();
p.bump();
NOT_EXPR
}
// test neg_expr
// fn foo() {
// --1;
// }
MINUS => {
STAR | EXCL | MINUS => {
m = p.start();
p.bump();
NEG_EXPR
PREFIX_EXPR
}
DOTDOT => {
m = p.start();

View file

@ -157,9 +157,7 @@ pub enum SyntaxKind {
TRY_EXPR,
CAST_EXPR,
REF_EXPR,
DEREF_EXPR,
NOT_EXPR,
NEG_EXPR,
PREFIX_EXPR,
RANGE_EXPR,
BIN_EXPR,
EXTERN_BLOCK_EXPR,
@ -397,9 +395,7 @@ impl SyntaxKind {
TRY_EXPR => &SyntaxInfo { name: "TRY_EXPR" },
CAST_EXPR => &SyntaxInfo { name: "CAST_EXPR" },
REF_EXPR => &SyntaxInfo { name: "REF_EXPR" },
DEREF_EXPR => &SyntaxInfo { name: "DEREF_EXPR" },
NOT_EXPR => &SyntaxInfo { name: "NOT_EXPR" },
NEG_EXPR => &SyntaxInfo { name: "NEG_EXPR" },
PREFIX_EXPR => &SyntaxInfo { name: "PREFIX_EXPR" },
RANGE_EXPR => &SyntaxInfo { name: "RANGE_EXPR" },
BIN_EXPR => &SyntaxInfo { name: "BIN_EXPR" },
EXTERN_BLOCK_EXPR => &SyntaxInfo { name: "EXTERN_BLOCK_EXPR" },

View file

@ -12,9 +12,9 @@ FILE@[0; 23)
L_CURLY@[9; 10)
WHITESPACE@[10; 15)
EXPR_STMT@[15; 20)
DEREF_EXPR@[15; 19)
PREFIX_EXPR@[15; 19)
STAR@[15; 16)
DEREF_EXPR@[16; 19)
PREFIX_EXPR@[16; 19)
STAR@[16; 17)
REF_EXPR@[17; 19)
AMP@[17; 18)

View file

@ -12,9 +12,9 @@ FILE@[0; 25)
L_CURLY@[9; 10)
WHITESPACE@[10; 15)
EXPR_STMT@[15; 22)
NOT_EXPR@[15; 21)
PREFIX_EXPR@[15; 21)
EXCL@[15; 16)
NOT_EXPR@[16; 21)
PREFIX_EXPR@[16; 21)
EXCL@[16; 17)
LITERAL@[17; 21)
TRUE_KW@[17; 21)

View file

@ -12,9 +12,9 @@ FILE@[0; 22)
L_CURLY@[9; 10)
WHITESPACE@[10; 15)
EXPR_STMT@[15; 19)
NEG_EXPR@[15; 18)
PREFIX_EXPR@[15; 18)
MINUS@[15; 16)
NEG_EXPR@[16; 18)
PREFIX_EXPR@[16; 18)
MINUS@[16; 17)
LITERAL@[17; 18)
INT_NUMBER@[17; 18) "1"