use super::mapping::get_module_rule_with_name;
use super::prelude::*;
pub const BLOCK_MODULE: BlockRule = BlockRule {
name: "block-module",
accepts_names: &["module", "module654"],
accepts_special: false,
accepts_newlines: true,
parse_fn,
};
fn parse_fn<'r, 't>(
log: &slog::Logger,
parser: &mut Parser<'r, 't>,
name: &'t str,
special: bool,
in_head: bool,
) -> ParseResult<'r, 't, Elements<'t>> {
debug!(log, "Parsing module block"; "in-head" => in_head);
assert_eq!(special, false, "Module doesn't allow special variant");
assert_block_name(&BLOCK_MODULE, name);
let (subname, arguments) = parser.get_head_name_map(&BLOCK_MODULE, in_head)?;
let module_rule = match get_module_rule_with_name(subname) {
Some(rule) => rule,
None => return Err(parser.make_warn(ParseWarningKind::NoSuchModule)),
};
parser.set_module(module_rule);
let (module, exceptions) =
(module_rule.parse_fn)(log, parser, subname, arguments)?.into();
ok!(module.map(Element::Module), exceptions)
}