Files
swaits bc7e17e58e chore: prepare 0.1.0 for crates.io publish
Add LICENSE-MIT and LICENSE-APACHE at workspace root and in each member package so the dual MIT OR Apache-2.0 license ships in the published .crate.

Fill in publish metadata (authors, repository, homepage, readme, keywords, categories) across the workspace and both members.

Add CHANGELOG.md with a 0.1.0 initial release entry.

Fix clippy lints: unused enumerate index, collapsible if, Default impls for TimerTable, SimRadio, and Ctx, use RangeInclusive::contains.

Exclude examples/microwave_tui.rs from the published package. The file stays in-tree but has known unawaited async log futures that need a dedicated pass before it ships.

Apply cargo fmt across the workspace.
2026-04-22 09:13:04 -06:00

30 lines
879 B
Rust

//! Proc-macro backing for the `hsmc` crate. The sole public item is the
//! [`statechart!`] macro which generates a state machine from a declarative
//! description.
use proc_macro::TokenStream;
mod codegen;
mod ir;
mod parse;
mod validate;
/// See the `hsmc` crate for documentation.
#[proc_macro]
pub fn statechart(input: TokenStream) -> TokenStream {
let input = proc_macro2::TokenStream::from(input);
match statechart_impl(input) {
Ok(ts) => ts.into(),
Err(e) => e.to_compile_error().into(),
}
}
fn statechart_impl(input: proc_macro2::TokenStream) -> syn::Result<proc_macro2::TokenStream> {
let parsed = syn::parse2::<parse::StatechartInput>(input)?;
validate::validate_parse_tree(&parsed)?;
let mut ir = ir::build_ir(parsed)?;
ir::resolve_transitions(&mut ir)?;
validate::validate(&ir)?;
Ok(codegen::generate(&ir))
}