open Parser;; test letter "hello world";; test digit "hello world";; test digit "1234hello world";; test (sat (fun t -> t = 'h')) "hello world";; test (sat (fun t -> t = 'H')) "hello world";; test (eoi) "hello world";; test (eoi) "";; (<=);; '0' <= '1';; oneof;; test digit "1234hello world";; test digit "hello world";; test (digit <|> letter) "hello world";; test (digit <|> letter) "1234hello world";; test (digit <|> letter) "?=)(1234hello world";; test (digit <|> letter <|> oneof "=)?") "?=)(1234hello world";; test (digit <|> letter <|> oneof "=)") "?=)(1234hello world";; test (digit >>= fun d1 -> (digit >>= fun d2 -> return [d2;d1])) "123";; test (digit >>= (fun d1 -> (digit >>= (fun d2 -> return [d2;d1])))) "123";; test (digit >>= fun d1 -> digit >>= fun d2 -> return [d2;d1]) "123";; test (digit >>= fun d1 -> letter >>= fun d2 -> return [d2;d1]) "123";; test (digit >>= fun d1 -> letter >>= fun d2 -> return [d2;d1]) "1c3";; let rec count_spaces = (space >> count_spaces >>= fun i -> return (i+1)) <|> (any >> count_spaces >>= fun i -> return i) <|> (eoi >> return 0);; let rec a = a;; let rec a _ = a ();; a ();; let rec count_spaces () = (space >> count_spaces () >>= fun i -> return (i+1)) <|> (any >> count_spaces () >>= fun i -> return i) <|> (eoi >> return 0);; test (count_spaces ()) "hello world";; let (>>>) a b = ();; (print_int 1) >>> (print_int 2);; let rec count_spaces () = (space >>= fun _ -> count_spaces () >>= fun i -> return (i+1)) <|> (any >>= fun _ -> count_spaces () >>= fun i -> return i) <|> (eoi >> return 0);; test (count_spaces ()) "hello world";; test (count_spaces ()) " hello world ";; test (many space) " hello world ";; let word = many letter;; test letter "hello world ";; test word "hello world ";; test (word >>= fun h -> space >> word >>= fun w -> return [h;w]) "hello world ";; test (word >>= fun h -> space >> word >>= fun w -> eoi >> return [h;w]) "hello world ";; test (word >>= fun h -> space >> word >>= fun w -> eoi >> return [h;w]) "hello world";; let rec e() = (e() >>= fun e1 -> char '+' >> t() >>= fun e2 -> return(Add(e1,e2))) <|> (t()) and t() = (t() >>= fun t1 -> char '*' >> f() >>= fun t2 -> return(Mul(t1,t2))) <|> (f()) and f() = ( char '(' >>= fun _ -> e() >>= fun e1 -> char ')' >> return e1 ) <|> n and n = many1 digit >>= fun r -> return(Num (int_of_string (Strng.to_string r)));; type t = Num of int | Add of t * t | Mul of t * t;; let rec e() = (e() >>= fun e1 -> char '+' >> t() >>= fun e2 -> return(Add(e1,e2))) <|> (t()) and t() = (t() >>= fun t1 -> char '*' >> f() >>= fun t2 -> return(Mul(t1,t2))) <|> (f()) and f() = ( char '(' >>= fun _ -> e() >>= fun e1 -> char ')' >> return e1 ) <|> n and n = many1 digit >>= fun r -> return(Num (int_of_string (Strng.to_string r)));; test (e ()) "2+3*5";; open AriParser;; test (e ()) "2+3*5";; (print_int 3; return 3) >> (print_int 2;return 2);; open Parser;; (print_int 3; return 3) >> (print_int 2;return 2);; (print_int 3; return 3) >>= (fun _ -> print_int 2;return 2);; (print_int 1;1)::(print_int 2;[]);; let ls = IntLst.range 1 100000;;