neutralts/bif/
parse_bif_filled.rs

1#![doc = include_str!("../../doc/bif-filled.md")]
2
3use crate::{bif::constants::*, bif::Bif, bif::BifError, constants::*, utils::*};
4
5impl<'a> Bif<'a> {
6    /*
7        {:filled; varname >> ... :}
8
9        *** It is only not filled if it has nothing "", if it is not defined
10        or is null, the rest "false", "0" etc. is something.
11    */
12    pub(crate) fn parse_bif_filled(&mut self) -> Result<(), BifError> {
13        if self.mod_filter {
14            return Err(self.bif_error(BIF_ERROR_MODIFIER_NOT_ALLOWED));
15        }
16
17        self.extract_params_code(true);
18
19        if !self.flags.is_empty() {
20            return Err(self.bif_error(BIF_ERROR_FLAGS_NOT_ALLOWED));
21        }
22
23        let mut varname = self.params.as_str();
24        let mut schema = &self.shared.schema["data"];
25
26        if varname.starts_with("local::") {
27            schema = &self.shared.schema["__indir"][&self.inherit.indir]["data"];
28            varname = varname.strip_prefix("local::").unwrap_or(varname);
29        }
30
31        if !is_empty_key(schema, varname) ^ self.mod_negate {
32            if self.code.contains(BIF_OPEN) {
33                self.code = new_child_parse!(self, &self.code, self.mod_scope);
34            }
35
36            self.out = self.code.to_string();
37        }
38
39        Ok(())
40    }
41}
42
43#[cfg(test)]
44#[path = "parse_bif_filled_tests.rs"]
45mod tests;