Crates.io | webidl-parser |
lib.rs | webidl-parser |
version | 0.2.0 |
source | src |
created_at | 2017-06-19 11:02:33.189756 |
updated_at | 2017-06-21 00:29:49.205591 |
description | A WebIDL parser |
homepage | https://github.com/sgodwincs/webidl-parser |
repository | https://github.com/sgodwincs/webidl-parser |
max_upload_size | |
id | 19496 |
size | 101,782 |
A lexer and parser for WebIDL in Rust.
use webidl_parser::*;
let lexer = Lexer::new("/* Example taken from emscripten site */\n\
enum EnumClass_EnumWithinClass {\n\
\"EnumClass::e_val\"\n\
};");
assert_eq!(lexer.collect::<Vec<_>>(),
vec![Ok((41, Token::Enum, 45)),
Ok((46, Token::Identifier("EnumClass_EnumWithinClass".to_string()), 71)),
Ok((72, Token::LeftBrace, 73)),
Ok((74, Token::StringLiteral("EnumClass::e_val".to_string()), 92)),
Ok((93, Token::RightBrace, 94)),
Ok((94, Token::Semicolon, 95))]);
use webidl_parser::*;
use webidl_parser::ast::*;
let result = Parser::parse_string("[Attribute] interface Node { };");
assert_eq!(result,
Ok(vec![Definition {
definition_type: DefinitionType::Interface(Interface {
members: vec![],
name: "Node".to_string(),
type_:
InterfaceType::NonPartial(None),
}),
extended_attributes: vec![
Box::new(ExtendedAttribute::Other {
other: Other::Identifier("Attribute".to_string()),
rest: None,
})],
}]));