mpl-macro 0.2.1

Derive parsers from MPL's one-rule grammar files. Includes the FastParse static-codegen backend (cascade detection, first-byte dispatch, Squirrel left recursion).
Documentation
mod generator;
mod mplg;

use proc_macro::TokenStream;

/// This macro creates
/// let ident = parser_ident.replace("Parser", "");
/// `{ident}Variable` enum,
/// `{ident}Rules` const {variable_i_ident}_RULE for each rule,
/// and impl Parser for `{parser_ident}`.
///
/// # Examples
///
/// ``` ignore
/// use mpl_macro::Parse;
///
/// #[derive(Parse)]
/// #[mplg = "{your path}/my.mplg"]
/// pub struct MyParser;
/// ```
#[proc_macro_derive(Parse, attributes(mplg))]
pub fn derive_parse(input: TokenStream) -> TokenStream {
    generator::derive_parser(input.into()).into()
}

/// Static-codegen variant of [`Parse`]. Emits one `fn` per grammar rule
/// and inherent `fast_recognize` / `fast_parse` methods on the parser
/// struct. The grammar file is read the same way (`#[mplg = "..."]`).
///
/// Uses `mpl::fast::ParserState` and the flat-token output instead of the
/// trait-based `Parser` API.
#[proc_macro_derive(FastParse, attributes(mplg))]
pub fn derive_fast_parse(input: TokenStream) -> TokenStream {
    generator::derive_fast_parser(input.into()).into()
}