Commits

UENISHI Kota  committed b8bd721

don't know how to make library

  • Participants
  • Parent commits 0c35e71

Comments (0)

Files changed (4)

 # The standard OMakefile.
 # You will usually need to modify this file for your project.
 
-# Delete this line once you have configured this file
-# eprintln($(CWD)/OMakefile is not configured)
-
 ########################################################################
 # Phony targets are scoped, so you probably want to declare them first.
 #
 # Build an OCaml library
 #
 
-# FILES[] =
-#    file1
+FILES[] =
+    bert
 #    file2
 #
-# LIB = main
-#
-# .DEFAULT: $(OCamlLibrary $(LIB), $(FILES))
+LIB = ocamlbert
+
+.DEFAULT: $(OCamlLibrary $(LIB), $(FILES))
 
 ################################################
 # Build an OCaml program
 
 FILES[] =
      tcp_server
+PROGRAM = tcp_server 
 
-PROGRAM = tcp_server
-OCAML_LIBS +=
+FILES2[] =
+     termreader
+
+OCAML_LIBS += ocamlbert
 OCAML_CLIBS +=
 OCAML_OTHER_LIBS += unix str
 OCAML_LIB_FLAGS +=
 
 .DEFAULT: $(OCamlProgram $(PROGRAM), $(FILES)) \
-	$(OCamlProgram termreader, termreader bert)
+	$(OCamlProgram termreader, $(FILES2))
 
 test: $(PROGRAM) termreader
 	./termreader$(EXE)
 #	./$(PROGRAM)$(EXE)
+
 exception Not_supported;;
 exception Unknown_type;;
 
+let print_binary bin = 
+  let rec print_ n =
+    if n < String.length bin then begin 
+      print_int (int_of_char (String.get bin n));
+      print_ (n+1);
+    end else 
+      print_endline " ahoge  .. "
+  in
+    print_ 0;;
+
 let make_small_bigint bin len =
   let rec make_small_bigint_ i prod v = 
     if i < len then

File bert.mli

-type erlterm =
-    Int of int
-  | Float of float
-      (*  | Atom of string *) 
-  | Tuple of erlterm list (* type of tuple is different btw Erlang and OCaml *)
-  | List of erlterm list 
-  | String of string
-  | Binary of string
-  | None;;
-
-type result = 
-  | Ok of erlterm * string
-  | More of int
-  | None;;
-
-val decode_binary : string -> result
-val print_erlterm : erlterm -> unit
-  
-exception Not_supported;;
-exception Unknown_type;;
-

File termreader.ml

 	    close_in channel;
 	    data
     in
-    let fch = open_in filename in (* opening file channel *)
+    let fch = open_in_bin filename in (* opening file channel *)
       load fch ""
   in
-  let result = Bert.decode_binary (load_file filename) in
+  let bin = load_file filename in
+  let result = Bert.decode_binary bin in
+    Bert.print_binary bin;
     Printf.printf "reading %s: \n" filename;
     begin match result with
       | Bert.Ok(term, remain)->