-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the Bug
Weedle seems to be unable to parse extended attributes that contain a tuple of quoted values.
Steps to Reproduce
For example, this parses correctly:
fn parse_non_quoted() {
let data: &str = r#"
[Attribute=(hello, there)]
interface HTMLImageElement : HTMLElement {
};
"#;
match weedle::parse(data) {
Ok(v) => println!(" parsed! \n\n{:?}", v),
Err(e) => println!(" could not parse: {}", e),
};
}
With the result:
[Interface(InterfaceDefinition { attributes: Some(Bracketed { open_bracket: OpenBracket, body: Punctuated { list: [IdentList(ExtendedAttributeIdentList { identifier: Identifier("Attribute"), assign: Assign, list: Parenthesized { open_paren: OpenParen, body: Punctuated { list: [Identifier("hello"), Identifier("there")], separator: Comma }, close_paren: CloseParen } })], separator: Comma }, close_bracket: CloseBracket }), interface: Interface, identifier: Identifier("HTMLImageElement"), inheritance: Some(Inheritance { colon: Colon, identifier: Identifier("HTMLElement") }), members: Braced { open_brace: OpenBrace, body: [], close_brace: CloseBrace }, semi_colon: SemiColon })]
while quoted tuple values do not parse correctly:
fn parse_quoted() {
let data: &str = r#"
[Attribute=("hello", "there")]
interface Test {
};
"#;
match weedle::parse(data) {
Ok(v) => println!(" parsed! \n\n{:?}", v),
Err(e) => println!(" could not parse: {}", e),
};
}
This is also observed while parsing chrome IDLs:
Source Data
src/main.rs
extern crate weedle;
fn parse_non_quoted() {
let data: &str = r#"
[Attribute=(hello, there)]
interface HTMLImageElement : HTMLElement {
};
"#;
match weedle::parse(data) {
Ok(v) => println!(" parsed! \n\n{:?}", v),
Err(e) => println!(" could not parse: {}", e),
};
}
fn parse_quoted() {
let data: &str = r#"
[Attribute=("hello", "there")]
interface Test {
};
"#;
match weedle::parse(data) {
Ok(v) => println!(" parsed! \n\n{:?}", v),
Err(e) => println!(" could not parse: {}", e),
};
}
fn main() {
println!("Parsing extended attribute with non-quoted values in tuple");
parse_non_quoted();
println!("Parsing extended attribute with quoted values in tuple");
parse_quoted();
}
Cargo.toml
[package]
name = "weedle_test"
version = "0.1.0"
authors = ["James Johnson <[email protected]>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
weedle = "0.11.0"
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working