1 unstable release

0.1.0 Feb 23, 2022

#146 in #compile

MIT license

49KB
558 lines

wxml-parser

wean-wxml rust version, compile wxml source to fre jsx code.

Usage

pub mod lexer;
pub mod parser;
pub mod generator;

fn main() {
    let mut parser = parser::Parser::new("<view wx:for=\"{{list}}\">
    hello {{item}}!
    <text wx:if=\"{{a}}\">a</text>
    <text wx:elseif=\"{{b}}\">b</text>
    <text wx:else />
</view>");
    let ast = parser.parse_all().unwrap();
    let mut gen = generator::Generator::new(ast);
    let code = gen.generate_fre();
    println!("{:#?}", code)
    // <>{list.map((item)=><View>hello {item}!{a?<Text>a</Text>:b?<Text>b</Text>:ture?<Text/>:null}</View>)}</>
}

Dependencies

~0.7–1.3MB
~27K SLoC