diff options
author | Aleksey Kladov <[email protected]> | 2018-08-07 22:59:16 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-07 22:59:16 +0100 |
commit | 678882d4f844135cc5df33de1f6da326ec96a78b (patch) | |
tree | a6a185b14fc8eb018f11a5e5b069a96934a48fb2 | |
parent | 64a65a4ff40e0c9b6d9453af79bba013afde2ffa (diff) |
literal pattern
-rw-r--r-- | src/grammar/patterns.rs | 12 | ||||
-rw-r--r-- | tests/data/parser/inline/0092_literal_pattern.rs | 7 | ||||
-rw-r--r-- | tests/data/parser/inline/0092_literal_pattern.txt | 59 |
3 files changed, 78 insertions, 0 deletions
diff --git a/src/grammar/patterns.rs b/src/grammar/patterns.rs index 36ead7561..f23addfa3 100644 --- a/src/grammar/patterns.rs +++ b/src/grammar/patterns.rs | |||
@@ -13,6 +13,18 @@ pub(super) fn pattern(p: &mut Parser) { | |||
13 | return; | 13 | return; |
14 | } | 14 | } |
15 | 15 | ||
16 | // test literal_pattern | ||
17 | // fn main() { | ||
18 | // match () { | ||
19 | // 92 => (), | ||
20 | // 'c' => (), | ||
21 | // "hello" => (), | ||
22 | // } | ||
23 | // } | ||
24 | if expressions::literal(p).is_some() { | ||
25 | return; | ||
26 | } | ||
27 | |||
16 | match la0 { | 28 | match la0 { |
17 | UNDERSCORE => placeholder_pat(p), | 29 | UNDERSCORE => placeholder_pat(p), |
18 | AMP => ref_pat(p), | 30 | AMP => ref_pat(p), |
diff --git a/tests/data/parser/inline/0092_literal_pattern.rs b/tests/data/parser/inline/0092_literal_pattern.rs new file mode 100644 index 000000000..16f674d9d --- /dev/null +++ b/tests/data/parser/inline/0092_literal_pattern.rs | |||
@@ -0,0 +1,7 @@ | |||
1 | fn main() { | ||
2 | match () { | ||
3 | 92 => (), | ||
4 | 'c' => (), | ||
5 | "hello" => (), | ||
6 | } | ||
7 | } | ||
diff --git a/tests/data/parser/inline/0092_literal_pattern.txt b/tests/data/parser/inline/0092_literal_pattern.txt new file mode 100644 index 000000000..08ade31fb --- /dev/null +++ b/tests/data/parser/inline/0092_literal_pattern.txt | |||
@@ -0,0 +1,59 @@ | |||
1 | FILE@[0; 95) | ||
2 | FN_ITEM@[0; 94) | ||
3 | FN_KW@[0; 2) | ||
4 | WHITESPACE@[2; 3) | ||
5 | NAME@[3; 7) | ||
6 | IDENT@[3; 7) "main" | ||
7 | PARAM_LIST@[7; 9) | ||
8 | L_PAREN@[7; 8) | ||
9 | R_PAREN@[8; 9) | ||
10 | WHITESPACE@[9; 10) | ||
11 | BLOCK_EXPR@[10; 94) | ||
12 | L_CURLY@[10; 11) | ||
13 | WHITESPACE@[11; 16) | ||
14 | MATCH_EXPR@[16; 92) | ||
15 | MATCH_KW@[16; 21) | ||
16 | WHITESPACE@[21; 22) | ||
17 | TUPLE_EXPR@[22; 24) | ||
18 | L_PAREN@[22; 23) | ||
19 | R_PAREN@[23; 24) | ||
20 | WHITESPACE@[24; 25) | ||
21 | L_CURLY@[25; 26) | ||
22 | WHITESPACE@[26; 35) | ||
23 | MATCH_ARM@[35; 43) | ||
24 | LITERAL@[35; 37) | ||
25 | INT_NUMBER@[35; 37) "92" | ||
26 | WHITESPACE@[37; 38) | ||
27 | FAT_ARROW@[38; 40) | ||
28 | WHITESPACE@[40; 41) | ||
29 | TUPLE_EXPR@[41; 43) | ||
30 | L_PAREN@[41; 42) | ||
31 | R_PAREN@[42; 43) | ||
32 | COMMA@[43; 44) | ||
33 | WHITESPACE@[44; 53) | ||
34 | MATCH_ARM@[53; 62) | ||
35 | LITERAL@[53; 56) | ||
36 | CHAR@[53; 56) | ||
37 | WHITESPACE@[56; 57) | ||
38 | FAT_ARROW@[57; 59) | ||
39 | WHITESPACE@[59; 60) | ||
40 | TUPLE_EXPR@[60; 62) | ||
41 | L_PAREN@[60; 61) | ||
42 | R_PAREN@[61; 62) | ||
43 | COMMA@[62; 63) | ||
44 | WHITESPACE@[63; 72) | ||
45 | MATCH_ARM@[72; 85) | ||
46 | LITERAL@[72; 79) | ||
47 | STRING@[72; 79) | ||
48 | WHITESPACE@[79; 80) | ||
49 | FAT_ARROW@[80; 82) | ||
50 | WHITESPACE@[82; 83) | ||
51 | TUPLE_EXPR@[83; 85) | ||
52 | L_PAREN@[83; 84) | ||
53 | R_PAREN@[84; 85) | ||
54 | COMMA@[85; 86) | ||
55 | WHITESPACE@[86; 91) | ||
56 | R_CURLY@[91; 92) | ||
57 | WHITESPACE@[92; 93) | ||
58 | R_CURLY@[93; 94) | ||
59 | WHITESPACE@[94; 95) | ||