pub fn core_c(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 2 {
            print_error(chunk, i, "c requires two arguments");
            return 0;
        }

        let regex_rr = self.stack.pop().unwrap();
        let regex_str_rr_opt = to_string_value(regex_rr);
        if regex_str_rr_opt.is_none() {
            print_error(chunk, i, "regex must be a string");
            return 0;
        }
        let regex_str_rr = regex_str_rr_opt.unwrap();

        {
            let mut regex_str_rrb = regex_str_rr.borrow_mut();
            let res = regex_str_rrb.gen_regex(chunk, i);
            if !res {
                return 0;
            }
        }
        let regex_str_rrb = regex_str_rr.borrow();
        let regex_opt = regex_str_rrb.to_regex();

        let str_rr = self.stack.pop().unwrap();
        let str_rrb = str_rr.borrow();
        let str_pre = str_rrb.to_string();
        let str_opt = to_string_2(&str_pre);

        match (regex_opt, str_opt) {
            (Some(regex), Some(s)) => {
                let captures = regex.captures_iter(s);
                let mut lst = VecDeque::new();
                for capture in captures {
                    lst.push_back(Rc::new(RefCell::new(Value::String(
                        capture.get(0).unwrap().as_str().to_string(),
                        None,
                    ))));
                }
                self.stack.push(Rc::new(RefCell::new(Value::List(lst))));
            }
            (_, Some(_)) => {
                print_error(chunk, i, "first c argument must be string");
                return 0;
            }
            (_, _) => {
                print_error(chunk, i, "second c argument must be string");
                return 0;
            }
        }
        return 1;
    }
/// Takes a value that can be stringified and a regex string as
/// its arguments.  Gets the regex captures from the value, puts
/// them into a list, and then puts that list onto the stack. 
Takes a value that can be stringified and a regex string as
its arguments.  Gets the regex captures from the value, puts
them into a list, and then puts that list onto the stack.
Takes a value that can be stringified and a regex string as its arguments . Gets the regex captures from the value puts them into a list and then puts that list onto the stack .
pub fn core_c(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 2 {
            print_error(chunk, i, "c requires two arguments");
            return 0;
        }
        let regex_rr = self.stack.pop().unwrap();
        let regex_str_rr_opt = to_string_value(regex_rr);
        if regex_str_rr_opt.is_none() {
            print_error(chunk, i, "regex must be a string");
            return 0;
        }
        let regex_str_rr = regex_str_rr_opt.unwrap();
        {
            let mut regex_str_rrb = regex_str_rr.borrow_mut();
            let res = regex_str_rrb.gen_regex(chunk, i);
            if !res {
                return 0;
            }
        }
        let regex_str_rrb = regex_str_rr.borrow();
        let regex_opt = regex_str_rrb.to_regex();
        let str_rr = self.stack.pop().unwrap();
        let str_rrb = str_rr.borrow();
        let str_pre = str_rrb.to_string();
        let str_opt = to_string_2(&str_pre);
        match (regex_opt, str_opt) {
            (Some(regex), Some(s)) => {
                let captures = regex.captures_iter(s);
                let mut lst = VecDeque::new();
                for capture in captures {
                    lst.push_back(Rc::new(RefCell::new(Value::String(
                        capture.get(0).unwrap().as_str().to_string(),
                        None,
                    ))));
                }
                self.stack.push(Rc::new(RefCell::new(Value::List(lst))));
            }
            (_, Some(_)) => {
                print_error(chunk, i, "first c argument must be string");
                return 0;
            }
            (_, _) => {
                print_error(chunk, i, "second c argument must be string");
                return 0;
            }
        }
        return 1;
    }
pub fn core_c ( & mut self , chunk : & Chunk , i : usize ) -> i32 { if self . stack . len ( ) < 2 { print_error ( chunk , i , " " ) ; return 0 ; } let regex_rr = self . stack . pop ( ) . unwrap ( ) ; let regex_str_rr_opt = to_string_value ( regex_rr ) ; if regex_str_rr_opt . is_none ( ) { print_error ( chunk , i , " " ) ; return 0 ; } let regex_str_rr = regex_str_rr_opt . unwrap ( ) ; { let mut regex_str_rrb = regex_str_rr . borrow_mut ( ) ; let res = regex_str_rrb . gen_regex ( chunk , i ) ; if ! res { return 0 ; } } let regex_str_rrb = regex_str_rr . borrow ( ) ; let regex_opt = regex_str_rrb . to_regex ( ) ; let str_rr = self . stack . pop ( ) . unwrap ( ) ; let str_rrb = str_rr . borrow ( ) ; let str_pre = str_rrb . to_string ( ) ; let str_opt = to_string_2 ( & str_pre ) ; match ( regex_opt , str_opt ) { ( Some ( regex ) , Some ( s ) ) => { let captures = regex . captures_iter ( s ) ; let mut lst = VecDeque :: new ( ) ; for capture in captures { lst . push_back ( Rc :: new ( RefCell :: new ( Value :: String ( capture . get ( 0 ) . unwrap ( ) . as_str ( ) . to_string ( ) , None , ) ) ) ) ; } self . stack . push ( Rc :: new ( RefCell :: new ( Value :: List ( lst ) ) ) ) ; } ( _ , Some ( _ ) ) => { print_error ( chunk , i , " " ) ; return 0 ; } ( _ , _ ) => { print_error ( chunk , i , " " ) ; return 0 ; } } return 1 ; }
Takes a value that can be stringified and a regex string as
its arguments.
Takes a value that can be stringified and a regex string as its arguments .
&mut self
chunk
&Chunk
i
usize