You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
991 B
Rust
51 lines
991 B
Rust
use proc_macro::TokenStream;
|
|
use quote::quote;
|
|
use syn::{parse_macro_input, token, Expr, Ident, Path};
|
|
|
|
mod compile;
|
|
mod parse;
|
|
|
|
pub fn invoke(input: TokenStream) -> TokenStream {
|
|
let input = parse_macro_input!(input as Body);
|
|
let output = quote! {
|
|
match (()) {
|
|
(()) => {
|
|
<
|
|
crate::view::Template as ::core::iter::FromIterator<crate::view::View<_>>
|
|
>::from_iter([
|
|
#input
|
|
])
|
|
}
|
|
}
|
|
};
|
|
output.into()
|
|
}
|
|
|
|
struct Body {
|
|
elements: Vec<Component>,
|
|
}
|
|
|
|
struct Component {
|
|
name: Path,
|
|
params: Option<Params>,
|
|
body: Option<Body>,
|
|
}
|
|
|
|
enum Params {
|
|
/// `name: value` style parameter list
|
|
Named(Vec<NamedParam>),
|
|
/// tuple style unnamed parameter list
|
|
Anon(Vec<Expr>),
|
|
}
|
|
|
|
struct NamedParam {
|
|
pub name: Ident,
|
|
pub colon: token::Colon,
|
|
pub val: Expr,
|
|
}
|
|
|
|
struct EventHandler {
|
|
pub name: Ident,
|
|
pub callback: Expr,
|
|
}
|