Trait arithmetic_eval::exec::CompilerExt  
source · pub trait CompilerExt<'a> {
    // Required method
    fn undefined_variables(
        &self,
    ) -> Result<HashMap<&'a str, Spanned<'a>>, Error>;
}Expand description
Compiler extensions defined for some AST nodes, most notably, Block.
§Examples
use arithmetic_parser::grammars::{F32Grammar, Parse, Untyped};
use arithmetic_eval::exec::CompilerExt;
let block = "x = sin(0.5) / PI; y = x * E; (x, y)";
let block = Untyped::<F32Grammar>::parse_statements(block)?;
let undefined_vars = block.undefined_variables()?;
assert_eq!(
    undefined_vars.keys().copied().collect::<HashSet<_>>(),
    HashSet::from_iter(vec!["sin", "PI", "E"])
);
assert_eq!(undefined_vars["PI"].location_offset(), 15);Required Methods§
sourcefn undefined_variables(&self) -> Result<HashMap<&'a str, Spanned<'a>>, Error>
 
fn undefined_variables(&self) -> Result<HashMap<&'a str, Spanned<'a>>, Error>
Returns variables not defined within the AST node, together with the span of their first occurrence.
§Errors
- Returns an error if the AST is intrinsically malformed. This may be the case if it
contains destructuring with the same variable on left-hand side,
such as 
(x, x) = .... 
The fact that an error is not returned does not guarantee that the AST node will evaluate successfully if all variables are assigned.