Files
misses/misses-compiler/examples/component.mrs
T
Claude e8d835e196 Add misses-rt crate, component example, README, and fix codegen for non-keyword literal tokens
- misses-rt: add Buffer/Markup HTML helpers, name/type helpers, parse_sections/parse_kv, and template AST
- codegen: add is_syn_keyword() — non-keyword idents in patterns now generate parse+compare instead of syn::Token![…]
- parser: split punct vs ident chars in literal pattern tokens so `props:` becomes two tokens
- examples: add component.mrs/.rs demonstrating named literal tokens and tt capture
- README: comprehensive guide covering .mrs syntax, running the compiler, misses-rt helpers, and examples

https://claude.ai/code/session_01Tppkab4eLsL21asHGjQJoF
2026-03-07 19:23:53 +00:00

33 lines
1.0 KiB
Plaintext

// component.mrs — Vue-like component macro generator
// Demonstrates: named literal tokens, variadic binding, $body:tt capture,
// escape block using misses_rt, expression injection
macro component! {
$name:ident { $($prop_name:ident : $prop_type:ty),* } $body:tt => {
@{
let struct_name = format_ident!("{}", name.to_string());
}
T~{
pub struct $name {
for prop in $prop_names =>
pub $prop_name.name: $prop_name.ty,
}
impl $name {
pub fn new(${ struct_name }(
for prop in $prop_names =>
$prop_name.name: $prop_name.ty,
)) -> Self {
Self {
for prop in $prop_names =>
$prop_name.name,
}
}
pub fn render(&self) -> misses_rt::Markup {
misses_rt::parse_template($body)
}
}
}
}
}