+ // get a line from input and evaluate it
+ let mut expr = String::new ();
+
+ // loop until a blank line is received
+ loop {
+ expr.clear ();
+ print!("{}", Style::new().bold().paint("evpf>"));
+ io::stdout().flush ().expect (ERR_FLUSHING);
+ // read a line of text
+ io::stdin().read_line (&mut expr).expect (ERR_READING_LINE);
+ // trim the text
+ let expr = expr.trim ();
+
+ if expr == "q" || expr == "Q" {
+ // quit if the expression is q or Qs
+ break;
+ } else if expr == "?" || expr == "h" || expr == "H" {
+ // display help text
+ for text in HELP_TEXT.iter() {
+ println! ("{}", Colour::Cyan.paint(*text));
+ }
+
+ continue;
+ } else if expr == "" {
+ // continue without proceeding
+ continue;
+ }
+
+ // Evaluate result
+ let res = evaluate (&expr, &match_num);
+
+ // if Result is OK then print the result in green
+ if res.is_ok () {
+ let restxt = format! ("{}: {}", RESULT,
+ res.unwrap());
+ println! ("{}", Colour::Green.paint (restxt));
+ } else {
+ // print the error in purple
+ let errtxt = format! ("{}: {}", ERROR,
+ res.unwrap_err());
+ eprintln! ("{}", Colour::Purple.paint (errtxt));
+ eprintln! ("{}", Colour::Purple.paint (ERROR_HELP));
+ }
+ }