not expr
This commit is contained in:
parent
a750135a0a
commit
2bbd4c510d
@ -132,6 +132,7 @@ Grammar(
|
||||
"FIELD_EXPR",
|
||||
"REF_EXPR",
|
||||
"DEREF_EXPR",
|
||||
"NOT_EXPR",
|
||||
"LAMBDA_EXPR",
|
||||
"STRUCT_LIT",
|
||||
"STRUCT_LIT_FIELD",
|
||||
|
@ -103,11 +103,13 @@ fn let_stmt(p: &mut Parser) {
|
||||
}
|
||||
|
||||
fn prefix_expr(p: &mut Parser) -> Option<CompletedMarker> {
|
||||
match p.current() {
|
||||
AMPERSAND => Some(ref_expr(p)),
|
||||
STAR => Some(deref_expr(p)),
|
||||
_ => atom_expr(p),
|
||||
}
|
||||
let done = match p.current() {
|
||||
AMPERSAND => ref_expr(p),
|
||||
STAR => deref_expr(p),
|
||||
EXCL => not_expr(p),
|
||||
_ => return atom_expr(p),
|
||||
};
|
||||
Some(done)
|
||||
}
|
||||
|
||||
// test ref_expr
|
||||
@ -136,6 +138,18 @@ fn deref_expr(p: &mut Parser) -> CompletedMarker {
|
||||
m.complete(p, DEREF_EXPR)
|
||||
}
|
||||
|
||||
// test not_expr
|
||||
// fn foo() {
|
||||
// !!true;
|
||||
// }
|
||||
fn not_expr(p: &mut Parser) -> CompletedMarker {
|
||||
assert!(p.at(EXCL));
|
||||
let m = p.start();
|
||||
p.bump();
|
||||
expr(p);
|
||||
m.complete(p, NOT_EXPR)
|
||||
}
|
||||
|
||||
fn atom_expr(p: &mut Parser) -> Option<CompletedMarker> {
|
||||
match literal(p) {
|
||||
Some(m) => return Some(m),
|
||||
|
@ -123,6 +123,7 @@ pub enum SyntaxKind {
|
||||
FIELD_EXPR,
|
||||
REF_EXPR,
|
||||
DEREF_EXPR,
|
||||
NOT_EXPR,
|
||||
LAMBDA_EXPR,
|
||||
STRUCT_LIT,
|
||||
STRUCT_LIT_FIELD,
|
||||
@ -287,6 +288,7 @@ pub(crate) fn info(self) -> &'static SyntaxInfo {
|
||||
FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" },
|
||||
REF_EXPR => &SyntaxInfo { name: "REF_EXPR" },
|
||||
DEREF_EXPR => &SyntaxInfo { name: "DEREF_EXPR" },
|
||||
NOT_EXPR => &SyntaxInfo { name: "NOT_EXPR" },
|
||||
LAMBDA_EXPR => &SyntaxInfo { name: "LAMBDA_EXPR" },
|
||||
STRUCT_LIT => &SyntaxInfo { name: "STRUCT_LIT" },
|
||||
STRUCT_LIT_FIELD => &SyntaxInfo { name: "STRUCT_LIT_FIELD" },
|
||||
|
3
tests/data/parser/inline/0066_not_expr.rs
Normal file
3
tests/data/parser/inline/0066_not_expr.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn foo() {
|
||||
!!true;
|
||||
}
|
24
tests/data/parser/inline/0066_not_expr.txt
Normal file
24
tests/data/parser/inline/0066_not_expr.txt
Normal file
@ -0,0 +1,24 @@
|
||||
FILE@[0; 25)
|
||||
FN_ITEM@[0; 25)
|
||||
FN_KW@[0; 2)
|
||||
NAME@[2; 6)
|
||||
WHITESPACE@[2; 3)
|
||||
IDENT@[3; 6) "foo"
|
||||
PARAM_LIST@[6; 9)
|
||||
L_PAREN@[6; 7)
|
||||
R_PAREN@[7; 8)
|
||||
WHITESPACE@[8; 9)
|
||||
BLOCK@[9; 25)
|
||||
L_CURLY@[9; 10)
|
||||
EXPR_STMT@[10; 23)
|
||||
NOT_EXPR@[10; 21)
|
||||
WHITESPACE@[10; 15)
|
||||
EXCL@[15; 16)
|
||||
NOT_EXPR@[16; 21)
|
||||
EXCL@[16; 17)
|
||||
LITERAL@[17; 21)
|
||||
TRUE_KW@[17; 21)
|
||||
SEMI@[21; 22)
|
||||
WHITESPACE@[22; 23)
|
||||
R_CURLY@[23; 24)
|
||||
WHITESPACE@[24; 25)
|
Loading…
Reference in New Issue
Block a user