File tree Expand file tree Collapse file tree 5 files changed +20
-8
lines changed Expand file tree Collapse file tree 5 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,13 @@ pub(in crate::parser) fn visit_relates_declaration(node: Node<'_>) -> Relates {
110
110
_ => unreachable ! ( "{}" , TypeQLError :: IllegalGrammar { input: related_label. to_string( ) } ) ,
111
111
} ;
112
112
let specialised = if children. try_consume_expected ( Rule :: AS ) . is_some ( ) {
113
- Some ( visit_label ( children. consume_expected ( Rule :: label) ) )
113
+ let node = children. consume_any ( ) ;
114
+ let specialised = match node. as_rule ( ) {
115
+ Rule :: label_list => TypeRefAny :: List ( visit_label_list ( node) ) ,
116
+ Rule :: label => TypeRefAny :: Type ( TypeRef :: Label ( visit_label ( node) ) ) ,
117
+ _ => unreachable ! ( "{}" , TypeQLError :: IllegalGrammar { input: node. to_string( ) } ) ,
118
+ } ;
119
+ Some ( specialised)
114
120
} else {
115
121
None
116
122
} ;
Original file line number Diff line number Diff line change @@ -127,7 +127,13 @@ fn visit_relates_constraint(node: Node<'_>) -> Relates {
127
127
} ;
128
128
129
129
let specialised = if children. try_consume_expected ( Rule :: AS ) . is_some ( ) {
130
- Some ( visit_type_ref ( children. consume_expected ( Rule :: type_ref) ) )
130
+ let next = children. consume_any ( ) ;
131
+ let specialised = match next. as_rule ( ) {
132
+ Rule :: type_ref => TypeRefAny :: Type ( visit_type_ref ( next) ) ,
133
+ Rule :: type_ref_list => TypeRefAny :: List ( visit_type_ref_list ( next) ) ,
134
+ _ => unreachable ! ( "{}" , TypeQLError :: IllegalGrammar { input: next. to_string( ) } ) ,
135
+ } ;
136
+ Some ( specialised)
131
137
} else {
132
138
None
133
139
} ;
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ label_constraint = { LABEL ~ ( label_scoped | label ) }
91
91
owns_constraint = { OWNS ~ type_ref_list
92
92
| OWNS ~ type_ref
93
93
}
94
- relates_constraint = { RELATES ~ type_ref_list
94
+ relates_constraint = { RELATES ~ type_ref_list ~ ( AS ~ type_ref_list )?
95
95
| RELATES ~ type_ref ~ ( AS ~ type_ref )?
96
96
}
97
97
plays_constraint = { PLAYS ~ type_ref }
@@ -211,7 +211,7 @@ owns_declaration = { OWNS ~ label_list
211
211
| OWNS ~ label
212
212
}
213
213
plays_declaration = { PLAYS ~ label_scoped }
214
- relates_declaration = { RELATES ~ label_list
214
+ relates_declaration = { RELATES ~ label_list ~ ( AS ~ label_list )?
215
215
| RELATES ~ label ~ ( AS ~ label )?
216
216
}
217
217
Original file line number Diff line number Diff line change @@ -126,11 +126,11 @@ impl fmt::Display for Owns {
126
126
pub struct Relates {
127
127
pub span : Option < Span > ,
128
128
pub related : TypeRefAny ,
129
- pub specialised : Option < Label > ,
129
+ pub specialised : Option < TypeRefAny > ,
130
130
}
131
131
132
132
impl Relates {
133
- pub fn new ( span : Option < Span > , related : TypeRefAny , specialised : Option < Label > ) -> Self {
133
+ pub fn new ( span : Option < Span > , related : TypeRefAny , specialised : Option < TypeRefAny > ) -> Self {
134
134
Self { span, related, specialised }
135
135
}
136
136
}
Original file line number Diff line number Diff line change @@ -248,11 +248,11 @@ impl fmt::Display for Owns {
248
248
pub struct Relates {
249
249
pub span : Option < Span > ,
250
250
pub related : TypeRefAny ,
251
- pub specialised : Option < TypeRef > ,
251
+ pub specialised : Option < TypeRefAny > ,
252
252
}
253
253
254
254
impl Relates {
255
- pub fn new ( span : Option < Span > , related : TypeRefAny , specialised : Option < TypeRef > ) -> Self {
255
+ pub fn new ( span : Option < Span > , related : TypeRefAny , specialised : Option < TypeRefAny > ) -> Self {
256
256
Self { span, related, specialised }
257
257
}
258
258
}
You can’t perform that action at this time.
0 commit comments