neutralts/bif/
parse_bif_bool.rs1#![doc = include_str!("../../doc/bif-bool.md")]
2
3use crate::{bif::constants::*, bif::Bif, bif::BifError, constants::*, utils::*};
4
5impl<'a> Bif<'a> {
6 pub(crate) fn parse_bif_bool(&mut self) -> Result<(), BifError> {
10 if self.mod_filter {
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 let mut varname = self.params.as_str();
21 let mut schema = &self.shared.schema["data"];
22
23 if varname.starts_with("local::") {
24 schema = &self.shared.schema["__indir"][&self.inherit.indir]["data"];
25 varname = varname.strip_prefix("local::").unwrap_or(varname);
26 }
27
28 if is_bool_key(schema, varname) ^ self.mod_negate {
29 if self.code.contains(BIF_OPEN) {
30 self.code = new_child_parse!(self, &self.code, self.mod_scope);
31 }
32 self.out = self.code.to_string();
33 }
34
35 Ok(())
36 }
37}
38
39#[cfg(test)]
40#[path = "parse_bif_bool_tests.rs"]
41mod tests;