Implement Misses DSL compiler (parser + codegen)
- ast.rs: Full AST for .mrs files (MacroDef, Pattern, OutputBody, TemplateItem) - parser.rs: Hand-written recursive descent parser with line/col error reporting - codegen.rs: Transforms AST to Rust proc macro code using syn/quote/proc_macro2 - main.rs: CLI reads .mrs file, runs parse→codegen, writes to stdout or file - Cargo.toml: Workspace with syn, quote, proc-macro2, prettyplease deps - examples/: hello.mrs, derive_builder.mrs, declare_table.mrs reference examples All three reference examples parse and produce prettyplease-formatted Rust output. Generated code uses syn::parse::Parser closures for structural patterns, quote! for token templates, spread iteration via .iter().map().collect(), and format_ident! for identifier construction. https://claude.ai/code/session_01Tppkab4eLsL21asHGjQJoF
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
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