diff options
author | Aleksey Kladov <[email protected]> | 2018-02-10 21:46:17 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-02-10 21:46:28 +0000 |
commit | b097090690f5edbe03f4aa9d042ba26c123699e4 (patch) | |
tree | 5bac76244148ce5b368bc8cb83a05cc184c452a7 | |
parent | b814d931514cdc250f9156dabd874edf685569d0 (diff) |
G: more types
25 files changed, 263 insertions, 67 deletions
diff --git a/grammar.ron b/grammar.ron index 0130b7b37..41d48f7b2 100644 --- a/grammar.ron +++ b/grammar.ron | |||
@@ -101,6 +101,11 @@ Grammar( | |||
101 | "IMPL_ITEM", | 101 | "IMPL_ITEM", |
102 | "TYPE_ITEM", | 102 | "TYPE_ITEM", |
103 | 103 | ||
104 | "PAREN_TYPE", | ||
105 | "TUPLE_TYPE", | ||
106 | "NEVER_TYPE", | ||
107 | "PATH_TYPE", | ||
108 | |||
104 | "EXTERN_BLOCK", | 109 | "EXTERN_BLOCK", |
105 | "ENUM_VARIANT", | 110 | "ENUM_VARIANT", |
106 | "NAMED_FIELD", | 111 | "NAMED_FIELD", |
diff --git a/src/parser/grammar/items/consts.rs b/src/parser/grammar/items/consts.rs index 8117af706..5f3cf58c2 100644 --- a/src/parser/grammar/items/consts.rs +++ b/src/parser/grammar/items/consts.rs | |||
@@ -14,7 +14,7 @@ fn const_or_static(p: &mut Parser, kw: SyntaxKind) { | |||
14 | p.eat(MUT_KW); // TODO: validator to forbid const mut | 14 | p.eat(MUT_KW); // TODO: validator to forbid const mut |
15 | name(p); | 15 | name(p); |
16 | p.expect(COLON); | 16 | p.expect(COLON); |
17 | types::type_ref(p); | 17 | types::ty(p); |
18 | p.expect(EQ); | 18 | p.expect(EQ); |
19 | expressions::expr(p); | 19 | expressions::expr(p); |
20 | p.expect(SEMI); | 20 | p.expect(SEMI); |
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs index 8bb821fb6..f1776e0e2 100644 --- a/src/parser/grammar/items/mod.rs +++ b/src/parser/grammar/items/mod.rs | |||
@@ -247,7 +247,7 @@ fn type_item(p: &mut Parser) { | |||
247 | type_params::where_clause(p); | 247 | type_params::where_clause(p); |
248 | 248 | ||
249 | p.expect(EQ); | 249 | p.expect(EQ); |
250 | types::type_ref(p); | 250 | types::ty(p); |
251 | p.expect(SEMI); | 251 | p.expect(SEMI); |
252 | } | 252 | } |
253 | 253 | ||
diff --git a/src/parser/grammar/items/structs.rs b/src/parser/grammar/items/structs.rs index eca0d2e64..ad18fd270 100644 --- a/src/parser/grammar/items/structs.rs +++ b/src/parser/grammar/items/structs.rs | |||
@@ -89,7 +89,7 @@ fn named_fields(p: &mut Parser) { | |||
89 | if p.at(IDENT) { | 89 | if p.at(IDENT) { |
90 | name(p); | 90 | name(p); |
91 | p.expect(COLON); | 91 | p.expect(COLON); |
92 | types::type_ref(p); | 92 | types::ty(p); |
93 | field.complete(p, NAMED_FIELD); | 93 | field.complete(p, NAMED_FIELD); |
94 | } else { | 94 | } else { |
95 | field.abandon(p); | 95 | field.abandon(p); |
@@ -105,7 +105,7 @@ fn pos_fields(p: &mut Parser) { | |||
105 | while !p.at(R_PAREN) && !p.at(EOF) { | 105 | while !p.at(R_PAREN) && !p.at(EOF) { |
106 | let pos_field = p.start(); | 106 | let pos_field = p.start(); |
107 | visibility(p); | 107 | visibility(p); |
108 | types::type_ref(p); | 108 | types::ty(p); |
109 | pos_field.complete(p, POS_FIELD); | 109 | pos_field.complete(p, POS_FIELD); |
110 | 110 | ||
111 | if !p.at(R_PAREN) { | 111 | if !p.at(R_PAREN) { |
diff --git a/src/parser/grammar/type_params.rs b/src/parser/grammar/type_params.rs index 8f62a471c..2462b260e 100644 --- a/src/parser/grammar/type_params.rs +++ b/src/parser/grammar/type_params.rs | |||
@@ -62,7 +62,7 @@ pub(super) fn list(p: &mut Parser) { | |||
62 | } | 62 | } |
63 | } | 63 | } |
64 | if p.at(EQ) { | 64 | if p.at(EQ) { |
65 | types::type_ref(p) | 65 | types::ty(p) |
66 | } | 66 | } |
67 | m.complete(p, TYPE_PARAM); | 67 | m.complete(p, TYPE_PARAM); |
68 | } | 68 | } |
diff --git a/src/parser/grammar/types.rs b/src/parser/grammar/types.rs index c798edd08..71801d8ef 100644 --- a/src/parser/grammar/types.rs +++ b/src/parser/grammar/types.rs | |||
@@ -1,14 +1,51 @@ | |||
1 | use super::*; | 1 | use super::*; |
2 | 2 | ||
3 | pub(super) fn type_ref(p: &mut Parser) { | 3 | pub(super) fn ty(p: &mut Parser) { |
4 | match p.current() { | 4 | match p.current() { |
5 | IDENT => p.bump(), | 5 | L_PAREN => paren_or_tuple_ty(p), |
6 | L_PAREN => { | 6 | IDENT => path_type(p), |
7 | p.bump(); | ||
8 | p.expect(R_PAREN); | ||
9 | } | ||
10 | _ => { | 7 | _ => { |
11 | p.error("expected type"); | 8 | p.error("expected type"); |
12 | } | 9 | } |
13 | } | 10 | } |
14 | } | 11 | } |
12 | |||
13 | fn paren_or_tuple_ty(p: &mut Parser) { | ||
14 | assert!(p.at(L_PAREN)); | ||
15 | let m = p.start(); | ||
16 | p.bump(); | ||
17 | let mut n_types: u32 = 0; | ||
18 | let mut trailing_comma: bool = false; | ||
19 | while !p.at(EOF) && !p.at(R_PAREN) { | ||
20 | n_types += 1; | ||
21 | ty(p); | ||
22 | if p.eat(COMMA) { | ||
23 | trailing_comma = true; | ||
24 | } else { | ||
25 | trailing_comma = false; | ||
26 | break; | ||
27 | } | ||
28 | } | ||
29 | p.expect(R_PAREN); | ||
30 | |||
31 | let kind = if n_types == 1 && !trailing_comma { | ||
32 | // test paren_type | ||
33 | // type T = (i32); | ||
34 | PAREN_TYPE | ||
35 | } else { | ||
36 | // test unit_type | ||
37 | // type T = (); | ||
38 | |||
39 | // test singleton_tuple_type | ||
40 | // type T = (i32,); | ||
41 | TUPLE_TYPE | ||
42 | }; | ||
43 | m.complete(p, kind); | ||
44 | } | ||
45 | |||
46 | fn path_type(p: &mut Parser) { | ||
47 | assert!(p.at(IDENT)); | ||
48 | let m = p.start(); | ||
49 | paths::type_path(p); | ||
50 | m.complete(p, PATH_TYPE); | ||
51 | } | ||
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs index 7450f9d6f..630d3d2a5 100644 --- a/src/syntax_kinds.rs +++ b/src/syntax_kinds.rs | |||
@@ -99,6 +99,10 @@ pub enum SyntaxKind { | |||
99 | TRAIT_ITEM, | 99 | TRAIT_ITEM, |
100 | IMPL_ITEM, | 100 | IMPL_ITEM, |
101 | TYPE_ITEM, | 101 | TYPE_ITEM, |
102 | PAREN_TYPE, | ||
103 | TUPLE_TYPE, | ||
104 | NEVER_TYPE, | ||
105 | PATH_TYPE, | ||
102 | EXTERN_BLOCK, | 106 | EXTERN_BLOCK, |
103 | ENUM_VARIANT, | 107 | ENUM_VARIANT, |
104 | NAMED_FIELD, | 108 | NAMED_FIELD, |
@@ -224,6 +228,10 @@ impl SyntaxKind { | |||
224 | TRAIT_ITEM => &SyntaxInfo { name: "TRAIT_ITEM" }, | 228 | TRAIT_ITEM => &SyntaxInfo { name: "TRAIT_ITEM" }, |
225 | IMPL_ITEM => &SyntaxInfo { name: "IMPL_ITEM" }, | 229 | IMPL_ITEM => &SyntaxInfo { name: "IMPL_ITEM" }, |
226 | TYPE_ITEM => &SyntaxInfo { name: "TYPE_ITEM" }, | 230 | TYPE_ITEM => &SyntaxInfo { name: "TYPE_ITEM" }, |
231 | PAREN_TYPE => &SyntaxInfo { name: "PAREN_TYPE" }, | ||
232 | TUPLE_TYPE => &SyntaxInfo { name: "TUPLE_TYPE" }, | ||
233 | NEVER_TYPE => &SyntaxInfo { name: "NEVER_TYPE" }, | ||
234 | PATH_TYPE => &SyntaxInfo { name: "PATH_TYPE" }, | ||
227 | EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" }, | 235 | EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" }, |
228 | ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" }, | 236 | ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" }, |
229 | NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" }, | 237 | NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" }, |
diff --git a/tests/data/parser/err/0000_struct_field_missing_comma.txt b/tests/data/parser/err/0000_struct_field_missing_comma.txt index f1c772b8d..5196fd718 100644 --- a/tests/data/parser/err/0000_struct_field_missing_comma.txt +++ b/tests/data/parser/err/0000_struct_field_missing_comma.txt | |||
@@ -11,15 +11,23 @@ FILE@[0; 34) | |||
11 | WHITESPACE@[10; 15) | 11 | WHITESPACE@[10; 15) |
12 | IDENT@[15; 16) "a" | 12 | IDENT@[15; 16) "a" |
13 | COLON@[16; 17) | 13 | COLON@[16; 17) |
14 | WHITESPACE@[17; 18) | 14 | PATH_TYPE@[17; 26) |
15 | IDENT@[18; 21) "u32" | 15 | PATH@[17; 26) |
16 | WHITESPACE@[21; 26) | 16 | PATH_SEGMENT@[17; 26) |
17 | NAME_REF@[17; 26) | ||
18 | WHITESPACE@[17; 18) | ||
19 | IDENT@[18; 21) "u32" | ||
20 | WHITESPACE@[21; 26) | ||
17 | err: `expected COMMA` | 21 | err: `expected COMMA` |
18 | NAMED_FIELD@[26; 33) | 22 | NAMED_FIELD@[26; 33) |
19 | NAME@[26; 27) | 23 | NAME@[26; 27) |
20 | IDENT@[26; 27) "b" | 24 | IDENT@[26; 27) "b" |
21 | COLON@[27; 28) | 25 | COLON@[27; 28) |
22 | WHITESPACE@[28; 29) | 26 | PATH_TYPE@[28; 33) |
23 | IDENT@[29; 32) "u32" | 27 | PATH@[28; 33) |
24 | WHITESPACE@[32; 33) | 28 | PATH_SEGMENT@[28; 33) |
29 | NAME_REF@[28; 33) | ||
30 | WHITESPACE@[28; 29) | ||
31 | IDENT@[29; 32) "u32" | ||
32 | WHITESPACE@[32; 33) | ||
25 | R_CURLY@[33; 34) | 33 | R_CURLY@[33; 34) |
diff --git a/tests/data/parser/err/0003_C++_semicolon.txt b/tests/data/parser/err/0003_C++_semicolon.txt index c835a1474..affe8fd09 100644 --- a/tests/data/parser/err/0003_C++_semicolon.txt +++ b/tests/data/parser/err/0003_C++_semicolon.txt | |||
@@ -11,16 +11,24 @@ FILE@[0; 40) | |||
11 | WHITESPACE@[10; 15) | 11 | WHITESPACE@[10; 15) |
12 | IDENT@[15; 16) "a" | 12 | IDENT@[15; 16) "a" |
13 | COLON@[16; 17) | 13 | COLON@[16; 17) |
14 | WHITESPACE@[17; 18) | 14 | PATH_TYPE@[17; 21) |
15 | IDENT@[18; 21) "i32" | 15 | PATH@[17; 21) |
16 | PATH_SEGMENT@[17; 21) | ||
17 | NAME_REF@[17; 21) | ||
18 | WHITESPACE@[17; 18) | ||
19 | IDENT@[18; 21) "i32" | ||
16 | COMMA@[21; 22) | 20 | COMMA@[21; 22) |
17 | NAMED_FIELD@[22; 36) | 21 | NAMED_FIELD@[22; 36) |
18 | NAME@[22; 28) | 22 | NAME@[22; 28) |
19 | WHITESPACE@[22; 27) | 23 | WHITESPACE@[22; 27) |
20 | IDENT@[27; 28) "b" | 24 | IDENT@[27; 28) "b" |
21 | COLON@[28; 29) | 25 | COLON@[28; 29) |
22 | WHITESPACE@[29; 30) | 26 | PATH_TYPE@[29; 36) |
23 | IDENT@[30; 36) "String" | 27 | PATH@[29; 36) |
28 | PATH_SEGMENT@[29; 36) | ||
29 | NAME_REF@[29; 36) | ||
30 | WHITESPACE@[29; 30) | ||
31 | IDENT@[30; 36) "String" | ||
24 | COMMA@[36; 37) | 32 | COMMA@[36; 37) |
25 | WHITESPACE@[37; 38) | 33 | WHITESPACE@[37; 38) |
26 | R_CURLY@[38; 39) | 34 | R_CURLY@[38; 39) |
diff --git a/tests/data/parser/err/0006_named_field_recovery.txt b/tests/data/parser/err/0006_named_field_recovery.txt index b772671e9..2dec74866 100644 --- a/tests/data/parser/err/0006_named_field_recovery.txt +++ b/tests/data/parser/err/0006_named_field_recovery.txt | |||
@@ -11,8 +11,12 @@ FILE@[0; 74) | |||
11 | WHITESPACE@[10; 15) | 11 | WHITESPACE@[10; 15) |
12 | IDENT@[15; 16) "f" | 12 | IDENT@[15; 16) "f" |
13 | COLON@[16; 17) | 13 | COLON@[16; 17) |
14 | WHITESPACE@[17; 18) | 14 | PATH_TYPE@[17; 21) |
15 | IDENT@[18; 21) "u32" | 15 | PATH@[17; 21) |
16 | PATH_SEGMENT@[17; 21) | ||
17 | NAME_REF@[17; 21) | ||
18 | WHITESPACE@[17; 18) | ||
19 | IDENT@[18; 21) "u32" | ||
16 | COMMA@[21; 22) | 20 | COMMA@[21; 22) |
17 | VISIBILITY@[22; 31) | 21 | VISIBILITY@[22; 31) |
18 | WHITESPACE@[22; 27) | 22 | WHITESPACE@[22; 27) |
@@ -42,16 +46,24 @@ FILE@[0; 74) | |||
42 | NAME@[52; 53) | 46 | NAME@[52; 53) |
43 | IDENT@[52; 53) "x" | 47 | IDENT@[52; 53) "x" |
44 | COLON@[53; 54) | 48 | COLON@[53; 54) |
45 | WHITESPACE@[54; 55) | 49 | PATH_TYPE@[54; 58) |
46 | IDENT@[55; 58) "u32" | 50 | PATH@[54; 58) |
51 | PATH_SEGMENT@[54; 58) | ||
52 | NAME_REF@[54; 58) | ||
53 | WHITESPACE@[54; 55) | ||
54 | IDENT@[55; 58) "u32" | ||
47 | COMMA@[58; 59) | 55 | COMMA@[58; 59) |
48 | NAMED_FIELD@[59; 70) | 56 | NAMED_FIELD@[59; 70) |
49 | NAME@[59; 65) | 57 | NAME@[59; 65) |
50 | WHITESPACE@[59; 64) | 58 | WHITESPACE@[59; 64) |
51 | IDENT@[64; 65) "z" | 59 | IDENT@[64; 65) "z" |
52 | COLON@[65; 66) | 60 | COLON@[65; 66) |
53 | WHITESPACE@[66; 67) | 61 | PATH_TYPE@[66; 70) |
54 | IDENT@[67; 70) "f64" | 62 | PATH@[66; 70) |
63 | PATH_SEGMENT@[66; 70) | ||
64 | NAME_REF@[66; 70) | ||
65 | WHITESPACE@[66; 67) | ||
66 | IDENT@[67; 70) "f64" | ||
55 | COMMA@[70; 71) | 67 | COMMA@[70; 71) |
56 | WHITESPACE@[71; 72) | 68 | WHITESPACE@[71; 72) |
57 | R_CURLY@[72; 73) | 69 | R_CURLY@[72; 73) |
diff --git a/tests/data/parser/inline/0014_type_item_type_params.txt b/tests/data/parser/inline/0014_type_item_type_params.txt index ca32faa42..98a71414e 100644 --- a/tests/data/parser/inline/0014_type_item_type_params.txt +++ b/tests/data/parser/inline/0014_type_item_type_params.txt | |||
@@ -11,8 +11,9 @@ FILE@[0; 21) | |||
11 | R_ANGLE@[13; 14) | 11 | R_ANGLE@[13; 14) |
12 | WHITESPACE@[14; 15) | 12 | WHITESPACE@[14; 15) |
13 | EQ@[15; 16) | 13 | EQ@[15; 16) |
14 | WHITESPACE@[16; 17) | 14 | TUPLE_TYPE@[16; 19) |
15 | L_PAREN@[17; 18) | 15 | WHITESPACE@[16; 17) |
16 | R_PAREN@[18; 19) | 16 | L_PAREN@[17; 18) |
17 | R_PAREN@[18; 19) | ||
17 | SEMI@[19; 20) | 18 | SEMI@[19; 20) |
18 | WHITESPACE@[20; 21) | 19 | WHITESPACE@[20; 21) |
diff --git a/tests/data/parser/inline/0015_type_item.txt b/tests/data/parser/inline/0015_type_item.txt index 3818fe25d..602298546 100644 --- a/tests/data/parser/inline/0015_type_item.txt +++ b/tests/data/parser/inline/0015_type_item.txt | |||
@@ -6,7 +6,11 @@ FILE@[0; 16) | |||
6 | IDENT@[5; 8) "Foo" | 6 | IDENT@[5; 8) "Foo" |
7 | WHITESPACE@[8; 9) | 7 | WHITESPACE@[8; 9) |
8 | EQ@[9; 10) | 8 | EQ@[9; 10) |
9 | WHITESPACE@[10; 11) | 9 | PATH_TYPE@[10; 14) |
10 | IDENT@[11; 14) "Bar" | 10 | PATH@[10; 14) |
11 | PATH_SEGMENT@[10; 14) | ||
12 | NAME_REF@[10; 14) | ||
13 | WHITESPACE@[10; 11) | ||
14 | IDENT@[11; 14) "Bar" | ||
11 | SEMI@[14; 15) | 15 | SEMI@[14; 15) |
12 | WHITESPACE@[15; 16) | 16 | WHITESPACE@[15; 16) |
diff --git a/tests/data/parser/inline/0016_type_item_where_clause.txt b/tests/data/parser/inline/0016_type_item_where_clause.txt index 12bbc752a..ff20c6255 100644 --- a/tests/data/parser/inline/0016_type_item_where_clause.txt +++ b/tests/data/parser/inline/0016_type_item_where_clause.txt | |||
@@ -14,8 +14,9 @@ FILE@[0; 31) | |||
14 | IDENT@[20; 24) "Copy" | 14 | IDENT@[20; 24) "Copy" |
15 | WHITESPACE@[24; 25) | 15 | WHITESPACE@[24; 25) |
16 | EQ@[25; 26) | 16 | EQ@[25; 26) |
17 | WHITESPACE@[26; 27) | 17 | TUPLE_TYPE@[26; 29) |
18 | L_PAREN@[27; 28) | 18 | WHITESPACE@[26; 27) |
19 | R_PAREN@[28; 29) | 19 | L_PAREN@[27; 28) |
20 | R_PAREN@[28; 29) | ||
20 | SEMI@[29; 30) | 21 | SEMI@[29; 30) |
21 | WHITESPACE@[30; 31) | 22 | WHITESPACE@[30; 31) |
diff --git a/tests/data/parser/inline/0017_paren_type.rs b/tests/data/parser/inline/0017_paren_type.rs new file mode 100644 index 000000000..6e1b25101 --- /dev/null +++ b/tests/data/parser/inline/0017_paren_type.rs | |||
@@ -0,0 +1 @@ | |||
type T = (i32); | |||
diff --git a/tests/data/parser/inline/0017_paren_type.txt b/tests/data/parser/inline/0017_paren_type.txt new file mode 100644 index 000000000..6ef9c9190 --- /dev/null +++ b/tests/data/parser/inline/0017_paren_type.txt | |||
@@ -0,0 +1,19 @@ | |||
1 | FILE@[0; 16) | ||
2 | TYPE_ITEM@[0; 16) | ||
3 | TYPE_KW@[0; 4) | ||
4 | NAME@[4; 7) | ||
5 | WHITESPACE@[4; 5) | ||
6 | IDENT@[5; 6) "T" | ||
7 | WHITESPACE@[6; 7) | ||
8 | EQ@[7; 8) | ||
9 | PAREN_TYPE@[8; 14) | ||
10 | WHITESPACE@[8; 9) | ||
11 | L_PAREN@[9; 10) | ||
12 | PATH_TYPE@[10; 13) | ||
13 | PATH@[10; 13) | ||
14 | PATH_SEGMENT@[10; 13) | ||
15 | NAME_REF@[10; 13) | ||
16 | IDENT@[10; 13) "i32" | ||
17 | R_PAREN@[13; 14) | ||
18 | SEMI@[14; 15) | ||
19 | WHITESPACE@[15; 16) | ||
diff --git a/tests/data/parser/inline/0018_unit_type.rs b/tests/data/parser/inline/0018_unit_type.rs new file mode 100644 index 000000000..c039cf7d3 --- /dev/null +++ b/tests/data/parser/inline/0018_unit_type.rs | |||
@@ -0,0 +1 @@ | |||
type T = (); | |||
diff --git a/tests/data/parser/inline/0018_unit_type.txt b/tests/data/parser/inline/0018_unit_type.txt new file mode 100644 index 000000000..707b6e53e --- /dev/null +++ b/tests/data/parser/inline/0018_unit_type.txt | |||
@@ -0,0 +1,14 @@ | |||
1 | FILE@[0; 13) | ||
2 | TYPE_ITEM@[0; 13) | ||
3 | TYPE_KW@[0; 4) | ||
4 | NAME@[4; 7) | ||
5 | WHITESPACE@[4; 5) | ||
6 | IDENT@[5; 6) "T" | ||
7 | WHITESPACE@[6; 7) | ||
8 | EQ@[7; 8) | ||
9 | TUPLE_TYPE@[8; 11) | ||
10 | WHITESPACE@[8; 9) | ||
11 | L_PAREN@[9; 10) | ||
12 | R_PAREN@[10; 11) | ||
13 | SEMI@[11; 12) | ||
14 | WHITESPACE@[12; 13) | ||
diff --git a/tests/data/parser/inline/0019_singleton_tuple_type.rs b/tests/data/parser/inline/0019_singleton_tuple_type.rs new file mode 100644 index 000000000..cb66bad24 --- /dev/null +++ b/tests/data/parser/inline/0019_singleton_tuple_type.rs | |||
@@ -0,0 +1 @@ | |||
type T = (i32,); | |||
diff --git a/tests/data/parser/inline/0019_singleton_tuple_type.txt b/tests/data/parser/inline/0019_singleton_tuple_type.txt new file mode 100644 index 000000000..cca96e7ea --- /dev/null +++ b/tests/data/parser/inline/0019_singleton_tuple_type.txt | |||
@@ -0,0 +1,20 @@ | |||
1 | FILE@[0; 17) | ||
2 | TYPE_ITEM@[0; 17) | ||
3 | TYPE_KW@[0; 4) | ||
4 | NAME@[4; 7) | ||
5 | WHITESPACE@[4; 5) | ||
6 | IDENT@[5; 6) "T" | ||
7 | WHITESPACE@[6; 7) | ||
8 | EQ@[7; 8) | ||
9 | TUPLE_TYPE@[8; 15) | ||
10 | WHITESPACE@[8; 9) | ||
11 | L_PAREN@[9; 10) | ||
12 | PATH_TYPE@[10; 13) | ||
13 | PATH@[10; 13) | ||
14 | PATH_SEGMENT@[10; 13) | ||
15 | NAME_REF@[10; 13) | ||
16 | IDENT@[10; 13) "i32" | ||
17 | COMMA@[13; 14) | ||
18 | R_PAREN@[14; 15) | ||
19 | SEMI@[15; 16) | ||
20 | WHITESPACE@[16; 17) | ||
diff --git a/tests/data/parser/ok/0002_struct_item_field.txt b/tests/data/parser/ok/0002_struct_item_field.txt index 31d3508db..7a395e14f 100644 --- a/tests/data/parser/ok/0002_struct_item_field.txt +++ b/tests/data/parser/ok/0002_struct_item_field.txt | |||
@@ -11,7 +11,11 @@ FILE@[0; 25) | |||
11 | WHITESPACE@[10; 15) | 11 | WHITESPACE@[10; 15) |
12 | IDENT@[15; 18) "foo" | 12 | IDENT@[15; 18) "foo" |
13 | COLON@[18; 19) | 13 | COLON@[18; 19) |
14 | WHITESPACE@[19; 20) | 14 | PATH_TYPE@[19; 24) |
15 | IDENT@[20; 23) "u32" | 15 | PATH@[19; 24) |
16 | WHITESPACE@[23; 24) | 16 | PATH_SEGMENT@[19; 24) |
17 | NAME_REF@[19; 24) | ||
18 | WHITESPACE@[19; 20) | ||
19 | IDENT@[20; 23) "u32" | ||
20 | WHITESPACE@[23; 24) | ||
17 | R_CURLY@[24; 25) | 21 | R_CURLY@[24; 25) |
diff --git a/tests/data/parser/ok/0016_struct_flavors.txt b/tests/data/parser/ok/0016_struct_flavors.txt index 15462b9b9..b5101c87d 100644 --- a/tests/data/parser/ok/0016_struct_flavors.txt +++ b/tests/data/parser/ok/0016_struct_flavors.txt | |||
@@ -36,8 +36,12 @@ FILE@[0; 97) | |||
36 | WHITESPACE@[45; 50) | 36 | WHITESPACE@[45; 50) |
37 | IDENT@[50; 51) "a" | 37 | IDENT@[50; 51) "a" |
38 | COLON@[51; 52) | 38 | COLON@[51; 52) |
39 | WHITESPACE@[52; 53) | 39 | PATH_TYPE@[52; 56) |
40 | IDENT@[53; 56) "u32" | 40 | PATH@[52; 56) |
41 | PATH_SEGMENT@[52; 56) | ||
42 | NAME_REF@[52; 56) | ||
43 | WHITESPACE@[52; 53) | ||
44 | IDENT@[53; 56) "u32" | ||
41 | COMMA@[56; 57) | 45 | COMMA@[56; 57) |
42 | NAMED_FIELD@[57; 73) | 46 | NAMED_FIELD@[57; 73) |
43 | VISIBILITY@[57; 66) | 47 | VISIBILITY@[57; 66) |
@@ -47,9 +51,13 @@ FILE@[0; 97) | |||
47 | NAME@[66; 67) | 51 | NAME@[66; 67) |
48 | IDENT@[66; 67) "b" | 52 | IDENT@[66; 67) "b" |
49 | COLON@[67; 68) | 53 | COLON@[67; 68) |
50 | WHITESPACE@[68; 69) | 54 | PATH_TYPE@[68; 73) |
51 | IDENT@[69; 72) "u32" | 55 | PATH@[68; 73) |
52 | WHITESPACE@[72; 73) | 56 | PATH_SEGMENT@[68; 73) |
57 | NAME_REF@[68; 73) | ||
58 | WHITESPACE@[68; 69) | ||
59 | IDENT@[69; 72) "u32" | ||
60 | WHITESPACE@[72; 73) | ||
53 | R_CURLY@[73; 74) | 61 | R_CURLY@[73; 74) |
54 | WHITESPACE@[74; 76) | 62 | WHITESPACE@[74; 76) |
55 | STRUCT_ITEM@[76; 97) | 63 | STRUCT_ITEM@[76; 97) |
@@ -62,11 +70,19 @@ FILE@[0; 97) | |||
62 | VISIBILITY@[85; 89) | 70 | VISIBILITY@[85; 89) |
63 | PUB_KW@[85; 88) | 71 | PUB_KW@[85; 88) |
64 | WHITESPACE@[88; 89) | 72 | WHITESPACE@[88; 89) |
65 | IDENT@[89; 90) "x" | 73 | PATH_TYPE@[89; 90) |
74 | PATH@[89; 90) | ||
75 | PATH_SEGMENT@[89; 90) | ||
76 | NAME_REF@[89; 90) | ||
77 | IDENT@[89; 90) "x" | ||
66 | COMMA@[90; 91) | 78 | COMMA@[90; 91) |
67 | POS_FIELD@[91; 93) | 79 | POS_FIELD@[91; 93) |
68 | WHITESPACE@[91; 92) | 80 | PATH_TYPE@[91; 93) |
69 | IDENT@[92; 93) "y" | 81 | PATH@[91; 93) |
82 | PATH_SEGMENT@[91; 93) | ||
83 | NAME_REF@[91; 93) | ||
84 | WHITESPACE@[91; 92) | ||
85 | IDENT@[92; 93) "y" | ||
70 | COMMA@[93; 94) | 86 | COMMA@[93; 94) |
71 | R_PAREN@[94; 95) | 87 | R_PAREN@[94; 95) |
72 | SEMI@[95; 96) | 88 | SEMI@[95; 96) |
diff --git a/tests/data/parser/ok/0018_struct_type_params.txt b/tests/data/parser/ok/0018_struct_type_params.txt index fe14effce..8e1feab38 100644 --- a/tests/data/parser/ok/0018_struct_type_params.txt +++ b/tests/data/parser/ok/0018_struct_type_params.txt | |||
@@ -23,7 +23,11 @@ FILE@[0; 290) | |||
23 | R_ANGLE@[25; 26) | 23 | R_ANGLE@[25; 26) |
24 | L_PAREN@[26; 27) | 24 | L_PAREN@[26; 27) |
25 | POS_FIELD@[27; 30) | 25 | POS_FIELD@[27; 30) |
26 | IDENT@[27; 30) "u32" | 26 | PATH_TYPE@[27; 30) |
27 | PATH@[27; 30) | ||
28 | PATH_SEGMENT@[27; 30) | ||
29 | NAME_REF@[27; 30) | ||
30 | IDENT@[27; 30) "u32" | ||
27 | R_PAREN@[30; 31) | 31 | R_PAREN@[30; 31) |
28 | SEMI@[31; 32) | 32 | SEMI@[31; 32) |
29 | WHITESPACE@[32; 33) | 33 | WHITESPACE@[32; 33) |
@@ -44,9 +48,13 @@ FILE@[0; 290) | |||
44 | WHITESPACE@[47; 48) | 48 | WHITESPACE@[47; 48) |
45 | IDENT@[48; 49) "u" | 49 | IDENT@[48; 49) "u" |
46 | COLON@[49; 50) | 50 | COLON@[49; 50) |
47 | WHITESPACE@[50; 51) | 51 | PATH_TYPE@[50; 55) |
48 | IDENT@[51; 54) "u32" | 52 | PATH@[50; 55) |
49 | WHITESPACE@[54; 55) | 53 | PATH_SEGMENT@[50; 55) |
54 | NAME_REF@[50; 55) | ||
55 | WHITESPACE@[50; 51) | ||
56 | IDENT@[51; 54) "u32" | ||
57 | WHITESPACE@[54; 55) | ||
50 | R_CURLY@[55; 56) | 58 | R_CURLY@[55; 56) |
51 | WHITESPACE@[56; 58) | 59 | WHITESPACE@[56; 58) |
52 | STRUCT_ITEM@[58; 71) | 60 | STRUCT_ITEM@[58; 71) |
diff --git a/tests/data/parser/ok/0019_enums.txt b/tests/data/parser/ok/0019_enums.txt index bad12bee3..09253dcea 100644 --- a/tests/data/parser/ok/0019_enums.txt +++ b/tests/data/parser/ok/0019_enums.txt | |||
@@ -81,8 +81,12 @@ FILE@[0; 182) | |||
81 | WHITESPACE@[104; 113) | 81 | WHITESPACE@[104; 113) |
82 | IDENT@[113; 114) "a" | 82 | IDENT@[113; 114) "a" |
83 | COLON@[114; 115) | 83 | COLON@[114; 115) |
84 | WHITESPACE@[115; 116) | 84 | PATH_TYPE@[115; 119) |
85 | IDENT@[116; 119) "u32" | 85 | PATH@[115; 119) |
86 | PATH_SEGMENT@[115; 119) | ||
87 | NAME_REF@[115; 119) | ||
88 | WHITESPACE@[115; 116) | ||
89 | IDENT@[116; 119) "u32" | ||
86 | COMMA@[119; 120) | 90 | COMMA@[119; 120) |
87 | NAMED_FIELD@[120; 139) | 91 | NAMED_FIELD@[120; 139) |
88 | VISIBILITY@[120; 133) | 92 | VISIBILITY@[120; 133) |
@@ -92,8 +96,12 @@ FILE@[0; 182) | |||
92 | NAME@[133; 134) | 96 | NAME@[133; 134) |
93 | IDENT@[133; 134) "b" | 97 | IDENT@[133; 134) "b" |
94 | COLON@[134; 135) | 98 | COLON@[134; 135) |
95 | WHITESPACE@[135; 136) | 99 | PATH_TYPE@[135; 139) |
96 | IDENT@[136; 139) "f64" | 100 | PATH@[135; 139) |
101 | PATH_SEGMENT@[135; 139) | ||
102 | NAME_REF@[135; 139) | ||
103 | WHITESPACE@[135; 136) | ||
104 | IDENT@[136; 139) "f64" | ||
97 | COMMA@[139; 140) | 105 | COMMA@[139; 140) |
98 | WHITESPACE@[140; 145) | 106 | WHITESPACE@[140; 145) |
99 | R_CURLY@[145; 146) | 107 | R_CURLY@[145; 146) |
@@ -110,7 +118,11 @@ FILE@[0; 182) | |||
110 | IDENT@[162; 163) "D" | 118 | IDENT@[162; 163) "D" |
111 | L_PAREN@[163; 164) | 119 | L_PAREN@[163; 164) |
112 | POS_FIELD@[164; 167) | 120 | POS_FIELD@[164; 167) |
113 | IDENT@[164; 167) "u32" | 121 | PATH_TYPE@[164; 167) |
122 | PATH@[164; 167) | ||
123 | PATH_SEGMENT@[164; 167) | ||
124 | NAME_REF@[164; 167) | ||
125 | IDENT@[164; 167) "u32" | ||
114 | COMMA@[167; 168) | 126 | COMMA@[167; 168) |
115 | R_PAREN@[168; 169) | 127 | R_PAREN@[168; 169) |
116 | COMMA@[169; 170) | 128 | COMMA@[169; 170) |
diff --git a/tests/data/parser/ok/0023_static_items.txt b/tests/data/parser/ok/0023_static_items.txt index 8872520c5..c9ecfb920 100644 --- a/tests/data/parser/ok/0023_static_items.txt +++ b/tests/data/parser/ok/0023_static_items.txt | |||
@@ -5,9 +5,13 @@ FILE@[0; 47) | |||
5 | WHITESPACE@[6; 7) | 5 | WHITESPACE@[6; 7) |
6 | IDENT@[7; 10) "FOO" | 6 | IDENT@[7; 10) "FOO" |
7 | COLON@[10; 11) | 7 | COLON@[10; 11) |
8 | WHITESPACE@[11; 12) | 8 | PATH_TYPE@[11; 16) |
9 | IDENT@[12; 15) "u32" | 9 | PATH@[11; 16) |
10 | WHITESPACE@[15; 16) | 10 | PATH_SEGMENT@[11; 16) |
11 | NAME_REF@[11; 16) | ||
12 | WHITESPACE@[11; 12) | ||
13 | IDENT@[12; 15) "u32" | ||
14 | WHITESPACE@[15; 16) | ||
11 | EQ@[16; 17) | 15 | EQ@[16; 17) |
12 | LITERAL@[17; 19) | 16 | LITERAL@[17; 19) |
13 | WHITESPACE@[17; 18) | 17 | WHITESPACE@[17; 18) |
@@ -22,9 +26,13 @@ FILE@[0; 47) | |||
22 | WHITESPACE@[31; 32) | 26 | WHITESPACE@[31; 32) |
23 | IDENT@[32; 35) "BAR" | 27 | IDENT@[32; 35) "BAR" |
24 | COLON@[35; 36) | 28 | COLON@[35; 36) |
25 | WHITESPACE@[36; 37) | 29 | PATH_TYPE@[36; 41) |
26 | IDENT@[37; 40) "i32" | 30 | PATH@[36; 41) |
27 | WHITESPACE@[40; 41) | 31 | PATH_SEGMENT@[36; 41) |
32 | NAME_REF@[36; 41) | ||
33 | WHITESPACE@[36; 37) | ||
34 | IDENT@[37; 40) "i32" | ||
35 | WHITESPACE@[40; 41) | ||
28 | EQ@[41; 42) | 36 | EQ@[41; 42) |
29 | LITERAL@[42; 45) | 37 | LITERAL@[42; 45) |
30 | WHITESPACE@[42; 43) | 38 | WHITESPACE@[42; 43) |
diff --git a/tests/data/parser/ok/0024_const_item.txt b/tests/data/parser/ok/0024_const_item.txt index 0f31d19d3..e37150ee4 100644 --- a/tests/data/parser/ok/0024_const_item.txt +++ b/tests/data/parser/ok/0024_const_item.txt | |||
@@ -5,9 +5,13 @@ FILE@[0; 46) | |||
5 | WHITESPACE@[5; 6) | 5 | WHITESPACE@[5; 6) |
6 | IDENT@[6; 9) "FOO" | 6 | IDENT@[6; 9) "FOO" |
7 | COLON@[9; 10) | 7 | COLON@[9; 10) |
8 | WHITESPACE@[10; 11) | 8 | PATH_TYPE@[10; 15) |
9 | IDENT@[11; 14) "u32" | 9 | PATH@[10; 15) |
10 | WHITESPACE@[14; 15) | 10 | PATH_SEGMENT@[10; 15) |
11 | NAME_REF@[10; 15) | ||
12 | WHITESPACE@[10; 11) | ||
13 | IDENT@[11; 14) "u32" | ||
14 | WHITESPACE@[14; 15) | ||
11 | EQ@[15; 16) | 15 | EQ@[15; 16) |
12 | LITERAL@[16; 19) | 16 | LITERAL@[16; 19) |
13 | WHITESPACE@[16; 17) | 17 | WHITESPACE@[16; 17) |
@@ -22,9 +26,13 @@ FILE@[0; 46) | |||
22 | WHITESPACE@[30; 31) | 26 | WHITESPACE@[30; 31) |
23 | IDENT@[31; 34) "BAR" | 27 | IDENT@[31; 34) "BAR" |
24 | COLON@[34; 35) | 28 | COLON@[34; 35) |
25 | WHITESPACE@[35; 36) | 29 | PATH_TYPE@[35; 40) |
26 | IDENT@[36; 39) "u32" | 30 | PATH@[35; 40) |
27 | WHITESPACE@[39; 40) | 31 | PATH_SEGMENT@[35; 40) |
32 | NAME_REF@[35; 40) | ||
33 | WHITESPACE@[35; 36) | ||
34 | IDENT@[36; 39) "u32" | ||
35 | WHITESPACE@[39; 40) | ||
28 | EQ@[40; 41) | 36 | EQ@[40; 41) |
29 | LITERAL@[41; 44) | 37 | LITERAL@[41; 44) |
30 | WHITESPACE@[41; 42) | 38 | WHITESPACE@[41; 42) |