Skip to content

l4yton/webidl_rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webidl_rs

A Web IDL parser for rust, powered by nom. It supports converting parsed Web IDL back to a string.

Usage

Cargo.toml

[dependencies]
webidl_rs = { git = "https://github.com/l4yton/webidl_rs" }

src/main.rs

use webidl_rs::{Constructor, Definition, Member};

fn main() {
    let mut definitions =
        webidl_rs::parse("[Exposed=Window] interface Foo { };").unwrap();

    // Add a constructor to the first definition.
    if let Some(Definition::Interface(interface)) = definitions.first_mut() {
        interface.members.push(Member::Constructor(Constructor {
            ext_attrs: vec![],
            arguments: vec![],
        }))
    }

    // Print the Web IDL with the added constructor.
    print!("{}", webidl_rs::to_string(&definitions));
}

TODO

  • Better documentation
  • Add more tests
  • Replace asserts with custom errors in parser
  • Validate Web IDL semantically (more)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages