From 4a7e19946a60b4cba6ef9d9916ae0fbec65c74da Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 20 Dec 2019 23:11:07 +0800 Subject: Fix parser for macro call in pattern position --- crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'crates/ra_syntax/test_data/parser/inline/ok') diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.txt index 4a714ad6b..b05ccc0ed 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.txt @@ -16,11 +16,10 @@ SOURCE_FILE@[0; 33) LET_KW@[16; 19) "let" WHITESPACE@[19; 20) " " MACRO_CALL@[20; 25) - PATH_PAT@[20; 21) - PATH@[20; 21) - PATH_SEGMENT@[20; 21) - NAME_REF@[20; 21) - IDENT@[20; 21) "m" + PATH@[20; 21) + PATH_SEGMENT@[20; 21) + NAME_REF@[20; 21) + IDENT@[20; 21) "m" EXCL@[21; 22) "!" TOKEN_TREE@[22; 25) L_PAREN@[22; 23) "(" -- cgit v1.2.3 From bea8f581186bb8d933357599468dd7d862ae847b Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 21 Dec 2019 18:29:14 +0800 Subject: Add macro 2.0 support in parser --- .../test_data/parser/inline/ok/0147_macro_def.rs | 2 + .../test_data/parser/inline/ok/0147_macro_def.txt | 43 ++++++++++++++++++++++ .../parser/inline/ok/0148_pub_macro_def.rs | 1 + .../parser/inline/ok/0148_pub_macro_def.txt | 20 ++++++++++ 4 files changed, 66 insertions(+) create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.rs create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.txt create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.rs create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.txt (limited to 'crates/ra_syntax/test_data/parser/inline/ok') diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.rs b/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.rs new file mode 100644 index 000000000..319a4e2aa --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.rs @@ -0,0 +1,2 @@ +macro m { ($i:ident) => {} } +macro m($i:ident) {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.txt b/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.txt new file mode 100644 index 000000000..af1122bfa --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.txt @@ -0,0 +1,43 @@ +SOURCE_FILE@[0; 50) + MACRO_DEF@[0; 28) + MACRO_KW@[0; 5) "macro" + WHITESPACE@[5; 6) " " + IDENT@[6; 7) "m" + WHITESPACE@[7; 8) " " + TOKEN_TREE@[8; 28) + L_CURLY@[8; 9) "{" + WHITESPACE@[9; 10) " " + TOKEN_TREE@[10; 20) + L_PAREN@[10; 11) "(" + DOLLAR@[11; 12) "$" + IDENT@[12; 13) "i" + COLON@[13; 14) ":" + IDENT@[14; 19) "ident" + R_PAREN@[19; 20) ")" + WHITESPACE@[20; 21) " " + EQ@[21; 22) "=" + R_ANGLE@[22; 23) ">" + WHITESPACE@[23; 24) " " + TOKEN_TREE@[24; 26) + L_CURLY@[24; 25) "{" + R_CURLY@[25; 26) "}" + WHITESPACE@[26; 27) " " + R_CURLY@[27; 28) "}" + WHITESPACE@[28; 29) "\n" + MACRO_DEF@[29; 49) + MACRO_KW@[29; 34) "macro" + WHITESPACE@[34; 35) " " + IDENT@[35; 36) "m" + TOKEN_TREE@[36; 49) + TOKEN_TREE@[36; 46) + L_PAREN@[36; 37) "(" + DOLLAR@[37; 38) "$" + IDENT@[38; 39) "i" + COLON@[39; 40) ":" + IDENT@[40; 45) "ident" + R_PAREN@[45; 46) ")" + WHITESPACE@[46; 47) " " + TOKEN_TREE@[47; 49) + L_CURLY@[47; 48) "{" + R_CURLY@[48; 49) "}" + WHITESPACE@[49; 50) "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.rs b/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.rs new file mode 100644 index 000000000..3b2be597f --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.rs @@ -0,0 +1 @@ +pub macro m($:ident) {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.txt b/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.txt new file mode 100644 index 000000000..985f61f89 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.txt @@ -0,0 +1,20 @@ +SOURCE_FILE@[0; 24) + MACRO_DEF@[0; 23) + VISIBILITY@[0; 3) + PUB_KW@[0; 3) "pub" + WHITESPACE@[3; 4) " " + MACRO_KW@[4; 9) "macro" + WHITESPACE@[9; 10) " " + IDENT@[10; 11) "m" + TOKEN_TREE@[11; 23) + TOKEN_TREE@[11; 20) + L_PAREN@[11; 12) "(" + DOLLAR@[12; 13) "$" + COLON@[13; 14) ":" + IDENT@[14; 19) "ident" + R_PAREN@[19; 20) ")" + WHITESPACE@[20; 21) " " + TOKEN_TREE@[21; 23) + L_CURLY@[21; 22) "{" + R_CURLY@[22; 23) "}" + WHITESPACE@[23; 24) "\n" -- cgit v1.2.3 From b04d4a88d1ba7f04445e807b6a816930b1e9bbf2 Mon Sep 17 00:00:00 2001 From: roblabla Date: Sun, 22 Dec 2019 00:38:23 +0000 Subject: Parse const generics Fixes #1574 Fixes #2281 --- .../test_data/parser/inline/ok/0147_const_param.rs | 1 + .../parser/inline/ok/0147_const_param.txt | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rs create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.txt (limited to 'crates/ra_syntax/test_data/parser/inline/ok') diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rs b/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rs new file mode 100644 index 000000000..8cdb3b703 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rs @@ -0,0 +1 @@ +struct S; diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.txt b/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.txt new file mode 100644 index 000000000..f81de7bac --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.txt @@ -0,0 +1,23 @@ +SOURCE_FILE@[0; 24) + STRUCT_DEF@[0; 23) + STRUCT_KW@[0; 6) "struct" + WHITESPACE@[6; 7) " " + NAME@[7; 8) + IDENT@[7; 8) "S" + TYPE_PARAM_LIST@[8; 22) + L_ANGLE@[8; 9) "<" + CONST_PARAM@[9; 21) + CONST_KW@[9; 14) "const" + WHITESPACE@[14; 15) " " + NAME@[15; 16) + IDENT@[15; 16) "N" + COLON@[16; 17) ":" + WHITESPACE@[17; 18) " " + PATH_TYPE@[18; 21) + PATH@[18; 21) + PATH_SEGMENT@[18; 21) + NAME_REF@[18; 21) + IDENT@[18; 21) "u32" + R_ANGLE@[21; 22) ">" + SEMI@[22; 23) ";" + WHITESPACE@[23; 24) "\n" -- cgit v1.2.3 From 737045c1eac87ab78f0042340f0311d3679158b0 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sun, 22 Dec 2019 11:11:10 +0800 Subject: Use name instead of ident for macro 2.0 sytnax --- crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.txt | 6 ++++-- crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.txt | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'crates/ra_syntax/test_data/parser/inline/ok') diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.txt b/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.txt index af1122bfa..3556099bd 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.txt @@ -2,7 +2,8 @@ SOURCE_FILE@[0; 50) MACRO_DEF@[0; 28) MACRO_KW@[0; 5) "macro" WHITESPACE@[5; 6) " " - IDENT@[6; 7) "m" + NAME@[6; 7) + IDENT@[6; 7) "m" WHITESPACE@[7; 8) " " TOKEN_TREE@[8; 28) L_CURLY@[8; 9) "{" @@ -27,7 +28,8 @@ SOURCE_FILE@[0; 50) MACRO_DEF@[29; 49) MACRO_KW@[29; 34) "macro" WHITESPACE@[34; 35) " " - IDENT@[35; 36) "m" + NAME@[35; 36) + IDENT@[35; 36) "m" TOKEN_TREE@[36; 49) TOKEN_TREE@[36; 46) L_PAREN@[36; 37) "(" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.txt b/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.txt index 985f61f89..cfd79d9c2 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.txt @@ -5,7 +5,8 @@ SOURCE_FILE@[0; 24) WHITESPACE@[3; 4) " " MACRO_KW@[4; 9) "macro" WHITESPACE@[9; 10) " " - IDENT@[10; 11) "m" + NAME@[10; 11) + IDENT@[10; 11) "m" TOKEN_TREE@[11; 23) TOKEN_TREE@[11; 20) L_PAREN@[11; 12) "(" -- cgit v1.2.3