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 {
110110 _ => unreachable ! ( "{}" , TypeQLError :: IllegalGrammar { input: related_label. to_string( ) } ) ,
111111 } ;
112112 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)
114120 } else {
115121 None
116122 } ;
Original file line number Diff line number Diff line change @@ -127,7 +127,13 @@ fn visit_relates_constraint(node: Node<'_>) -> Relates {
127127 } ;
128128
129129 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)
131137 } else {
132138 None
133139 } ;
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ label_constraint = { LABEL ~ ( label_scoped | label ) }
9191owns_constraint = { OWNS ~ type_ref_list
9292 | OWNS ~ type_ref
9393 }
94- relates_constraint = { RELATES ~ type_ref_list
94+ relates_constraint = { RELATES ~ type_ref_list ~ ( AS ~ type_ref_list )?
9595 | RELATES ~ type_ref ~ ( AS ~ type_ref )?
9696 }
9797plays_constraint = { PLAYS ~ type_ref }
@@ -211,7 +211,7 @@ owns_declaration = { OWNS ~ label_list
211211 | OWNS ~ label
212212 }
213213plays_declaration = { PLAYS ~ label_scoped }
214- relates_declaration = { RELATES ~ label_list
214+ relates_declaration = { RELATES ~ label_list ~ ( AS ~ label_list )?
215215 | RELATES ~ label ~ ( AS ~ label )?
216216 }
217217
Original file line number Diff line number Diff line change @@ -126,11 +126,11 @@ impl fmt::Display for Owns {
126126pub struct Relates {
127127 pub span : Option < Span > ,
128128 pub related : TypeRefAny ,
129- pub specialised : Option < Label > ,
129+ pub specialised : Option < TypeRefAny > ,
130130}
131131
132132impl 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 {
134134 Self { span, related, specialised }
135135 }
136136}
Original file line number Diff line number Diff line change @@ -248,11 +248,11 @@ impl fmt::Display for Owns {
248248pub struct Relates {
249249 pub span : Option < Span > ,
250250 pub related : TypeRefAny ,
251- pub specialised : Option < TypeRef > ,
251+ pub specialised : Option < TypeRefAny > ,
252252}
253253
254254impl 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 {
256256 Self { span, related, specialised }
257257 }
258258}
You can’t perform that action at this time.
0 commit comments