neutralts/bif/
parse_bif_declare.rs1#![doc = include_str!("../../doc/bif-declare.md")]
2
3use crate::{bif::constants::*, bif::Bif, bif::BifError, constants::*, json};
4
5impl<'a> Bif<'a> {
6 pub(crate) fn parse_bif_declare(&mut self) -> Result<(), BifError> {
10 if self.mod_filter || self.mod_negate || self.mod_scope {
11 return Err(self.bif_error(BIF_ERROR_MODIFIER_NOT_ALLOWED));
12 }
13
14 self.extract_params_code(true);
15
16 if !self.flags.is_empty() {
17 return Err(self.bif_error(BIF_ERROR_FLAGS_NOT_ALLOWED));
18 }
19
20 if self.inherit.current_file.contains(SNIPPETS_FILES) {
21 self.inherit.create_block_schema(self.shared);
22 if self.code.contains(BIF_OPEN) {
23 self.code = new_child_parse!(self, &self.code, false);
24 self.code = self.code.replace(UNPRINTABLE, "");
25 }
26 self.shared.schema["__indir"][&self.inherit.indir]["declare"][&self.params] =
27 json!(&self.code);
28
29 self.out = EMPTY_STRING;
30 } else {
31 return Err(self.bif_error(BIF_ERROR_DECLARE_SET_HERE));
32 }
33
34 Ok(())
35 }
36}
37
38#[cfg(test)]
39#[path = "parse_bif_declare_tests.rs"]
40mod tests;