Skip to main content

typescript_webidl/
debug.rs

1/// 调试工具
2use crate::parse;
3
4/// 调试解析行为
5pub fn debug_parse() {
6    // 尝试不同的 WebIDL 格式
7    let webidl1 = r#"interface TestInterface { void test(); };"#;
8    let webidl2 = r#"interface TestInterface {
9    void test();
10};
11"#;
12    let webidl3 = r#"module TestModule {
13    interface TestInterface {
14        void test();
15    };
16};
17"#;
18
19    let webidls = vec![("Simple", webidl1), ("Formatted", webidl2), ("Module", webidl3)];
20
21    for (name, webidl) in webidls {
22        println!("\nTesting typescript_webidl parser with {} format...", name);
23        println!("Input: {}", webidl);
24        
25        match parse(webidl) {
26            Ok(root) => {
27                println!("Parsing successful!");
28                println!("Items count: {}", root.items.len());
29                for (i, item) in root.items.iter().enumerate() {
30                    println!("Item {}: {:?}", i, item);
31                }
32            }
33            Err(error) => {
34                println!("Parsing failed: {}", error);
35            }
36        }
37    }
38}