diff options
author | Aleksey Kladov <[email protected]> | 2019-09-09 12:52:31 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-09-10 13:46:39 +0100 |
commit | 40170885e799ebdefb24ed00865cd1c7800af491 (patch) | |
tree | 1b7a6f1eaaa70e1db70dd5763377fd877636a55d /crates/ra_syntax | |
parent | e2ebb467bdf3ebb7d29260adb95c56594c6db282 (diff) |
WIP: switch to fully decomposed tokens internally
Diffstat (limited to 'crates/ra_syntax')
3 files changed, 146 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/tests.rs b/crates/ra_syntax/src/tests.rs index fa5d2d5d8..458920607 100644 --- a/crates/ra_syntax/src/tests.rs +++ b/crates/ra_syntax/src/tests.rs | |||
@@ -16,6 +16,18 @@ fn lexer_tests() { | |||
16 | } | 16 | } |
17 | 17 | ||
18 | #[test] | 18 | #[test] |
19 | fn parse_smoke_test() { | ||
20 | let code = r##" | ||
21 | fn main() { | ||
22 | println!("Hello, world!") | ||
23 | } | ||
24 | "##; | ||
25 | |||
26 | let parse = SourceFile::parse(code); | ||
27 | assert!(parse.ok().is_ok()); | ||
28 | } | ||
29 | |||
30 | #[test] | ||
19 | fn parser_tests() { | 31 | fn parser_tests() { |
20 | dir_tests(&test_data_dir(), &["parser/inline/ok", "parser/ok"], |text, path| { | 32 | dir_tests(&test_data_dir(), &["parser/inline/ok", "parser/ok"], |text, path| { |
21 | let parse = SourceFile::parse(text); | 33 | let parse = SourceFile::parse(text); |
@@ -75,7 +87,9 @@ fn self_hosting_parsing() { | |||
75 | { | 87 | { |
76 | count += 1; | 88 | count += 1; |
77 | let text = read_text(entry.path()); | 89 | let text = read_text(entry.path()); |
78 | SourceFile::parse(&text).ok().expect("There should be no errors in the file"); | 90 | if let Err(errors) = SourceFile::parse(&text).ok() { |
91 | panic!("Parsing errors:\n{:?}\n{}\n", errors, entry.path().display()); | ||
92 | } | ||
79 | } | 93 | } |
80 | assert!( | 94 | assert!( |
81 | count > 30, | 95 | count > 30, |
diff --git a/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rs b/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rs new file mode 100644 index 000000000..0d3f5722a --- /dev/null +++ b/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rs | |||
@@ -0,0 +1,5 @@ | |||
1 | fn a() -> Foo<bar::Baz> {} | ||
2 | |||
3 | fn b(_: impl FnMut(x::Y)) {} | ||
4 | |||
5 | fn c(_: impl FnMut(&x::Y)) {} | ||
diff --git a/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.txt b/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.txt new file mode 100644 index 000000000..7e1af254c --- /dev/null +++ b/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.txt | |||
@@ -0,0 +1,126 @@ | |||
1 | SOURCE_FILE@[0; 88) | ||
2 | FN_DEF@[0; 26) | ||
3 | FN_KW@[0; 2) "fn" | ||
4 | WHITESPACE@[2; 3) " " | ||
5 | NAME@[3; 4) | ||
6 | IDENT@[3; 4) "a" | ||
7 | PARAM_LIST@[4; 6) | ||
8 | L_PAREN@[4; 5) "(" | ||
9 | R_PAREN@[5; 6) ")" | ||
10 | WHITESPACE@[6; 7) " " | ||
11 | RET_TYPE@[7; 23) | ||
12 | THIN_ARROW@[7; 9) "->" | ||
13 | WHITESPACE@[9; 10) " " | ||
14 | PATH_TYPE@[10; 23) | ||
15 | PATH@[10; 23) | ||
16 | PATH_SEGMENT@[10; 23) | ||
17 | NAME_REF@[10; 13) | ||
18 | IDENT@[10; 13) "Foo" | ||
19 | TYPE_ARG_LIST@[13; 23) | ||
20 | L_ANGLE@[13; 14) "<" | ||
21 | TYPE_ARG@[14; 22) | ||
22 | PATH_TYPE@[14; 22) | ||
23 | PATH@[14; 22) | ||
24 | PATH@[14; 17) | ||
25 | PATH_SEGMENT@[14; 17) | ||
26 | NAME_REF@[14; 17) | ||
27 | IDENT@[14; 17) "bar" | ||
28 | COLONCOLON@[17; 19) "::" | ||
29 | PATH_SEGMENT@[19; 22) | ||
30 | NAME_REF@[19; 22) | ||
31 | IDENT@[19; 22) "Baz" | ||
32 | R_ANGLE@[22; 23) ">" | ||
33 | WHITESPACE@[23; 24) " " | ||
34 | BLOCK_EXPR@[24; 26) | ||
35 | BLOCK@[24; 26) | ||
36 | L_CURLY@[24; 25) "{" | ||
37 | R_CURLY@[25; 26) "}" | ||
38 | WHITESPACE@[26; 28) "\n\n" | ||
39 | FN_DEF@[28; 56) | ||
40 | FN_KW@[28; 30) "fn" | ||
41 | WHITESPACE@[30; 31) " " | ||
42 | NAME@[31; 32) | ||
43 | IDENT@[31; 32) "b" | ||
44 | PARAM_LIST@[32; 53) | ||
45 | L_PAREN@[32; 33) "(" | ||
46 | PARAM@[33; 52) | ||
47 | PLACEHOLDER_PAT@[33; 34) | ||
48 | UNDERSCORE@[33; 34) "_" | ||
49 | COLON@[34; 35) ":" | ||
50 | WHITESPACE@[35; 36) " " | ||
51 | IMPL_TRAIT_TYPE@[36; 52) | ||
52 | IMPL_KW@[36; 40) "impl" | ||
53 | WHITESPACE@[40; 41) " " | ||
54 | TYPE_BOUND_LIST@[41; 52) | ||
55 | TYPE_BOUND@[41; 52) | ||
56 | PATH_TYPE@[41; 52) | ||
57 | PATH@[41; 52) | ||
58 | PATH_SEGMENT@[41; 52) | ||
59 | NAME_REF@[41; 46) | ||
60 | IDENT@[41; 46) "FnMut" | ||
61 | PARAM_LIST@[46; 52) | ||
62 | L_PAREN@[46; 47) "(" | ||
63 | PARAM@[47; 51) | ||
64 | PATH_TYPE@[47; 51) | ||
65 | PATH@[47; 51) | ||
66 | PATH@[47; 48) | ||
67 | PATH_SEGMENT@[47; 48) | ||
68 | NAME_REF@[47; 48) | ||
69 | IDENT@[47; 48) "x" | ||
70 | COLONCOLON@[48; 50) "::" | ||
71 | PATH_SEGMENT@[50; 51) | ||
72 | NAME_REF@[50; 51) | ||
73 | IDENT@[50; 51) "Y" | ||
74 | R_PAREN@[51; 52) ")" | ||
75 | R_PAREN@[52; 53) ")" | ||
76 | WHITESPACE@[53; 54) " " | ||
77 | BLOCK_EXPR@[54; 56) | ||
78 | BLOCK@[54; 56) | ||
79 | L_CURLY@[54; 55) "{" | ||
80 | R_CURLY@[55; 56) "}" | ||
81 | WHITESPACE@[56; 58) "\n\n" | ||
82 | FN_DEF@[58; 87) | ||
83 | FN_KW@[58; 60) "fn" | ||
84 | WHITESPACE@[60; 61) " " | ||
85 | NAME@[61; 62) | ||
86 | IDENT@[61; 62) "c" | ||
87 | PARAM_LIST@[62; 84) | ||
88 | L_PAREN@[62; 63) "(" | ||
89 | PARAM@[63; 83) | ||
90 | PLACEHOLDER_PAT@[63; 64) | ||
91 | UNDERSCORE@[63; 64) "_" | ||
92 | COLON@[64; 65) ":" | ||
93 | WHITESPACE@[65; 66) " " | ||
94 | IMPL_TRAIT_TYPE@[66; 83) | ||
95 | IMPL_KW@[66; 70) "impl" | ||
96 | WHITESPACE@[70; 71) " " | ||
97 | TYPE_BOUND_LIST@[71; 83) | ||
98 | TYPE_BOUND@[71; 83) | ||
99 | PATH_TYPE@[71; 83) | ||
100 | PATH@[71; 83) | ||
101 | PATH_SEGMENT@[71; 83) | ||
102 | NAME_REF@[71; 76) | ||
103 | IDENT@[71; 76) "FnMut" | ||
104 | PARAM_LIST@[76; 83) | ||
105 | L_PAREN@[76; 77) "(" | ||
106 | PARAM@[77; 82) | ||
107 | REFERENCE_TYPE@[77; 82) | ||
108 | AMP@[77; 78) "&" | ||
109 | PATH_TYPE@[78; 82) | ||
110 | PATH@[78; 82) | ||
111 | PATH@[78; 79) | ||
112 | PATH_SEGMENT@[78; 79) | ||
113 | NAME_REF@[78; 79) | ||
114 | IDENT@[78; 79) "x" | ||
115 | COLONCOLON@[79; 81) "::" | ||
116 | PATH_SEGMENT@[81; 82) | ||
117 | NAME_REF@[81; 82) | ||
118 | IDENT@[81; 82) "Y" | ||
119 | R_PAREN@[82; 83) ")" | ||
120 | R_PAREN@[83; 84) ")" | ||
121 | WHITESPACE@[84; 85) " " | ||
122 | BLOCK_EXPR@[85; 87) | ||
123 | BLOCK@[85; 87) | ||
124 | L_CURLY@[85; 86) "{" | ||
125 | R_CURLY@[86; 87) "}" | ||
126 | WHITESPACE@[87; 88) "\n" | ||