diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-21 10:47:47 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-21 10:47:47 +0000 |
commit | 90ef070db3dce0a7acb9cd11d0b0d72de13c9d79 (patch) | |
tree | c6fcc8c77fe4948b356e397fb5fe1f8e8ac39037 /crates/ra_syntax/test_data/parser/inline | |
parent | 3ebf15c9b29b1fed6319d04f540ad48cd4bd6995 (diff) | |
parent | 4195c0e5f9a3db7646d4df28aa8c77a863c35759 (diff) |
Merge #2628
2628: Add macro 2.0 support in parser r=matklad a=edwin0cheng
This PR added a new syntax kind : `MACRO_DEF` and a keyword `MACRO_KW`
there are two syntax for declarative macro 2.0 :
1. Normal : `macro m { ($i:ident) => {} }` , which handle similar to legacy one.
2. Call like: `macro m($i:ident) {}`, it produces a single token tree which have two child token trees : `($i:ident)` and `{}`
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_syntax/test_data/parser/inline')
4 files changed, 66 insertions, 0 deletions
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 @@ | |||
1 | macro m { ($i:ident) => {} } | ||
2 | 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 @@ | |||
1 | SOURCE_FILE@[0; 50) | ||
2 | MACRO_DEF@[0; 28) | ||
3 | MACRO_KW@[0; 5) "macro" | ||
4 | WHITESPACE@[5; 6) " " | ||
5 | IDENT@[6; 7) "m" | ||
6 | WHITESPACE@[7; 8) " " | ||
7 | TOKEN_TREE@[8; 28) | ||
8 | L_CURLY@[8; 9) "{" | ||
9 | WHITESPACE@[9; 10) " " | ||
10 | TOKEN_TREE@[10; 20) | ||
11 | L_PAREN@[10; 11) "(" | ||
12 | DOLLAR@[11; 12) "$" | ||
13 | IDENT@[12; 13) "i" | ||
14 | COLON@[13; 14) ":" | ||
15 | IDENT@[14; 19) "ident" | ||
16 | R_PAREN@[19; 20) ")" | ||
17 | WHITESPACE@[20; 21) " " | ||
18 | EQ@[21; 22) "=" | ||
19 | R_ANGLE@[22; 23) ">" | ||
20 | WHITESPACE@[23; 24) " " | ||
21 | TOKEN_TREE@[24; 26) | ||
22 | L_CURLY@[24; 25) "{" | ||
23 | R_CURLY@[25; 26) "}" | ||
24 | WHITESPACE@[26; 27) " " | ||
25 | R_CURLY@[27; 28) "}" | ||
26 | WHITESPACE@[28; 29) "\n" | ||
27 | MACRO_DEF@[29; 49) | ||
28 | MACRO_KW@[29; 34) "macro" | ||
29 | WHITESPACE@[34; 35) " " | ||
30 | IDENT@[35; 36) "m" | ||
31 | TOKEN_TREE@[36; 49) | ||
32 | TOKEN_TREE@[36; 46) | ||
33 | L_PAREN@[36; 37) "(" | ||
34 | DOLLAR@[37; 38) "$" | ||
35 | IDENT@[38; 39) "i" | ||
36 | COLON@[39; 40) ":" | ||
37 | IDENT@[40; 45) "ident" | ||
38 | R_PAREN@[45; 46) ")" | ||
39 | WHITESPACE@[46; 47) " " | ||
40 | TOKEN_TREE@[47; 49) | ||
41 | L_CURLY@[47; 48) "{" | ||
42 | R_CURLY@[48; 49) "}" | ||
43 | 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 @@ | |||
1 | SOURCE_FILE@[0; 24) | ||
2 | MACRO_DEF@[0; 23) | ||
3 | VISIBILITY@[0; 3) | ||
4 | PUB_KW@[0; 3) "pub" | ||
5 | WHITESPACE@[3; 4) " " | ||
6 | MACRO_KW@[4; 9) "macro" | ||
7 | WHITESPACE@[9; 10) " " | ||
8 | IDENT@[10; 11) "m" | ||
9 | TOKEN_TREE@[11; 23) | ||
10 | TOKEN_TREE@[11; 20) | ||
11 | L_PAREN@[11; 12) "(" | ||
12 | DOLLAR@[12; 13) "$" | ||
13 | COLON@[13; 14) ":" | ||
14 | IDENT@[14; 19) "ident" | ||
15 | R_PAREN@[19; 20) ")" | ||
16 | WHITESPACE@[20; 21) " " | ||
17 | TOKEN_TREE@[21; 23) | ||
18 | L_CURLY@[21; 22) "{" | ||
19 | R_CURLY@[22; 23) "}" | ||
20 | WHITESPACE@[23; 24) "\n" | ||