Function exmex::parse_with_number_pattern[][src]

pub fn parse_with_number_pattern<'a, 'b, T>(
    text: &'b str,
    ops: &[Operator<'a, T>],
    number_regex_pattern: &str
) -> Result<FlatEx<T>, ExParseError> where
    <T as FromStr>::Err: Debug,
    T: Copy + FromStr + Debug
Expand description

Parses a string and a vector of operators and a regex pattern that defines the looks of a number into an expression that can be evaluated.

Errors

An ExParseError is returned, if

  • the argument number_regex_pattern cannot be compiled,
  • the argument text contained a character that did not match any regex (e.g., if there is a Δ in text but no operator with repr equal to Δ is given),
  • the to-be-parsed string is empty,
  • a number or variable is next to another one, e.g., 2 {x},
  • wlog a number or variable is on the right of a closing parenthesis, e.g., )5,
  • a binary operator is next to another binary operator, e.g., 2*/4,
  • wlog a closing parenthesis is next to an opening one, e.g., )( or (),
  • too many closing parentheses at some position, e.g., (4+6) - 5)*2,
  • the last element is an operator, e.g., 1+,
  • the number of opening and closing parenthesis do not match, e.g., ((4-2),
  • in parsed_tokens a closing parentheses is directly following an operator, e.g., +), or
  • a unary operator is followed directly by a binary operator, e.g., sin*.