Backed out 5 changesets (bug 1890092, bug 1888683) for causing build bustages & crash...
[gecko.git] / third_party / rust / weedle2 / src / namespace.rs
blobed28573218dc0fafda1961275e18643174c05d21
1 use crate::argument::ArgumentList;
2 use crate::attribute::ExtendedAttributeList;
3 use crate::common::{Identifier, Parenthesized};
4 use crate::types::{AttributedType, ReturnType};
6 /// Parses namespace members declaration
7 pub type NamespaceMembers<'a> = Vec<NamespaceMember<'a>>;
9 ast_types! {
10     /// Parses namespace member declaration
11     enum NamespaceMember<'a> {
12         /// Parses `[attributes]? returntype identifier? (( args ));`
13         ///
14         /// (( )) means ( ) chars
15         Operation(struct OperationNamespaceMember<'a> {
16             attributes: Option<ExtendedAttributeList<'a>>,
17             return_type: ReturnType<'a>,
18             identifier: Option<Identifier<'a>>,
19             args: Parenthesized<ArgumentList<'a>>,
20             semi_colon: term!(;),
21         }),
22         /// Parses `[attribute]? readonly attributetype type identifier;`
23         Attribute(struct AttributeNamespaceMember<'a> {
24             attributes: Option<ExtendedAttributeList<'a>>,
25             readonly: term!(readonly),
26             attribute: term!(attribute),
27             type_: AttributedType<'a>,
28             identifier: Identifier<'a>,
29             semi_colon: term!(;),
30         }),
31     }
34 #[cfg(test)]
35 mod test {
36     use super::*;
37     use crate::Parse;
39     test!(should_parse_attribute_namespace_member { "readonly attribute short name;" =>
40         "";
41         AttributeNamespaceMember;
42         attributes.is_none();
43         identifier.0 == "name";
44     });
46     test!(should_parse_operation_namespace_member { "short (long a, long b);" =>
47         "";
48         OperationNamespaceMember;
49         attributes.is_none();
50         identifier.is_none();
51     });