Commits

Yoshihiro Imai committed 497a7e4

typo

Comments (0)

Files changed (4)

 #!/bin/sh
-ocamlopt util.ml llist.ml ast.ml lexer.ml parserMonado.ml parser.ml rbString.ml rbInt.ml rbBool.ml eval.ml main.ml -o ocamlruby
-
+ocamlopt util.ml llist.ml ast.ml lexer.ml parserMonad.ml parser.ml rbString.ml rbInt.ml rbBool.ml eval.ml main.ml -o ocamlruby
+rm *.cm[iox] *.o
 open Util
 open Llist
 open Ast
-open ParserMonado
+open ParserMonad
 
-module P = ParserMonado.Make (struct
+module P = ParserMonad.Make (struct
   type ts = token llist
   type error = pos * string
   let eplus (p1, s1) (p2, s2) =
+open Util
+
+module Make
+    (T : sig
+      type ts
+      type error
+      val eplus : error -> error -> error
+    end) =
+  struct
+    type ts = T.ts
+    type error = T.error
+    type 'a m = ts -> ('a * ts, error) either
+
+    (* return : 'a -> 'a m *)
+    let return x = fun code -> Inl (x, code)
+      
+    (* (>>=) : 'a m -> ('a -> 'b m) -> 'b m *)
+    let (>>=) p f = fun code ->
+      match p code with
+      | Inl (x, ts) -> f x ts
+      | Inr err -> Inr err
+	  
+    (* (>>) : 'a m -> 'b m -> 'b m *)
+    let (>>) p1 p2 = p1 >>= fun _ -> p2
+      
+    (* (<|>) : 'a m -> 'a m -> 'a m *)
+    let (<|>) p1 p2 = fun code ->
+      match p1 code, p2 code with
+      | Inl (x1, ts), _ -> Inl (x1, ts)
+      | _, Inl (x2, ts) -> Inl (x2, ts)
+      | Inr (err1), Inr (err2) -> Inr (T.eplus err1 err2)
+	
+    (* many : 'a m -> 'a list m *)
+    let rec many p =
+      (p >>= fun x -> many p >>= fun xs -> return (x::xs))
+      <|> (return [])
+
+    (* opt : 'a m -> 'a opt m *)	  
+    let opt p =
+      (p >>= fun x -> return (Some x)) <|> (return None)
+  end
+
+

parserMonado.ml

-open Util
-
-module Make
-    (T : sig
-      type ts
-      type error
-      val eplus : error -> error -> error
-    end) =
-  struct
-    type ts = T.ts
-    type error = T.error
-    type 'a m = ts -> ('a * ts, error) either
-
-    (* return : 'a -> 'a m *)
-    let return x = fun code -> Inl (x, code)
-      
-    (* (>>=) : 'a m -> ('a -> 'b m) -> 'b m *)
-    let (>>=) p f = fun code ->
-      match p code with
-      | Inl (x, ts) -> f x ts
-      | Inr err -> Inr err
-	  
-    (* (>>) : 'a m -> 'b m -> 'b m *)
-    let (>>) p1 p2 = p1 >>= fun _ -> p2
-      
-    (* (<|>) : 'a m -> 'a m -> 'a m *)
-    let (<|>) p1 p2 = fun code ->
-      match p1 code, p2 code with
-      | Inl (x1, ts), _ -> Inl (x1, ts)
-      | _, Inl (x2, ts) -> Inl (x2, ts)
-      | Inr (err1), Inr (err2) -> Inr (T.eplus err1 err2)
-	
-    (* many : 'a m -> 'a list m *)
-    let rec many p =
-      (p >>= fun x -> many p >>= fun xs -> return (x::xs))
-      <|> (return [])
-
-    (* opt : 'a m -> 'a opt m *)	  
-    let opt p =
-      (p >>= fun x -> return (Some x)) <|> (return None)
-  end
-
-