aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/grammar/items/nominal.rs
diff options
context:
space:
mode:
authordarksv <[email protected]>2018-09-14 21:51:12 +0100
committerdarksv <[email protected]>2018-09-14 21:51:12 +0100
commit100968b68999231368fbacf62e8b8f242fbfdd3a (patch)
tree7b07ab4d4206bdaf5c8c41fe4bdcb5c11ad5c3f5 /crates/libsyntax2/src/grammar/items/nominal.rs
parentb6f8037a6f8fbcb4f127e1d2b518279650b1f5ea (diff)
Support for unions
Diffstat (limited to 'crates/libsyntax2/src/grammar/items/nominal.rs')
-rw-r--r--crates/libsyntax2/src/grammar/items/nominal.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/crates/libsyntax2/src/grammar/items/nominal.rs b/crates/libsyntax2/src/grammar/items/nominal.rs
index 11c43e371..8d02ad555 100644
--- a/crates/libsyntax2/src/grammar/items/nominal.rs
+++ b/crates/libsyntax2/src/grammar/items/nominal.rs
@@ -1,8 +1,8 @@
1use super::*; 1use super::*;
2 2
3pub(super) fn struct_def(p: &mut Parser) { 3pub(super) fn struct_def(p: &mut Parser, kind: SyntaxKind) {
4 assert!(p.at(STRUCT_KW)); 4 assert!(p.at(STRUCT_KW) || p.at_contextual_kw("union"));
5 p.bump(); 5 p.bump_remap(kind);
6 6
7 name_r(p, ITEM_RECOVERY_SET); 7 name_r(p, ITEM_RECOVERY_SET);
8 type_params::opt_type_param_list(p); 8 type_params::opt_type_param_list(p);
@@ -22,19 +22,23 @@ pub(super) fn struct_def(p: &mut Parser) {
22 } 22 }
23 } 23 }
24 } 24 }
25 SEMI => { 25 SEMI if kind == STRUCT_KW => {
26 p.bump(); 26 p.bump();
27 return; 27 return;
28 } 28 }
29 L_CURLY => named_field_def_list(p), 29 L_CURLY => named_field_def_list(p),
30 L_PAREN => { 30 L_PAREN if kind == STRUCT_KW => {
31 pos_field_list(p); 31 pos_field_list(p);
32 p.expect(SEMI); 32 p.expect(SEMI);
33 } 33 }
34 _ => { 34 _ if kind == STRUCT_KW => {
35 p.error("expected `;`, `{`, or `(`"); 35 p.error("expected `;`, `{`, or `(`");
36 return; 36 return;
37 } 37 }
38 _ => {
39 p.error("expected `{`");
40 return;
41 }
38 } 42 }
39} 43}
40 44