Add examples with cargo run --example support
- Move .mrs files into misses-compiler/examples/ alongside .rs runners - Add lib.rs exposing parse/codegen for use by example binaries and main.rs - Fix parser: #[attr] vs #[a => b] disambiguation (look for => before ]) - Fix parser: `for` keyword in `impl Foo for Bar` no longer triggers spread (is_spread_for lookahead: must match `for <ident> in $<ident> =>`) - Add derive_getters.mrs: getter methods via spread iteration - Add make_id_type.mrs: newtype u64 wrapper with From impls, derive attrs Run with: cargo run --example hello|derive_builder|declare_table|derive_getters|make_id_type https://claude.ai/code/session_01Tppkab4eLsL21asHGjQJoF
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
// declare_table.mrs — DSL-to-struct mapping
|
||||
// Demonstrates: $body:tt raw token capture, escape block calling misses_rt,
|
||||
// expression injection of a &str
|
||||
macro declare_table! {
|
||||
$name:ident { $body:tt } => {
|
||||
@{
|
||||
let table_str = misses_rt::to_table_name(&name);
|
||||
}
|
||||
T~{
|
||||
pub struct $name {
|
||||
pub id: u64,
|
||||
}
|
||||
impl $name {
|
||||
pub const TABLE: &'static str = ${ table_str.as_str() };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user