Commits

UENISHI Kota  committed 19d1fed

adding test data and tester.

  • Participants
  • Parent commits 9a3b9b5

Comments (0)

Files changed (5)

 OCAML_OTHER_LIBS += unix str
 OCAML_LIB_FLAGS +=
 
-.DEFAULT: $(OCamlProgram $(PROGRAM), $(FILES))
+.DEFAULT: $(OCamlProgram $(PROGRAM), $(FILES)) \
+	$(OCamlProgram termreader, termreader bert)
 
-#test: $(PROGRAM)
+test: $(PROGRAM) termreader
+	./termreader$(EXE)
 #	./$(PROGRAM)$(EXE)
 	  local_decode (String.sub bin 1 ((String.length bin)-1)); 
       | _ -> raise Unknown_type;
     end;;
+
+let print_erlterm term = 
+  print_endline " some term here:) ";;
   | None;;
 
 val decode_binary : string -> result
+val print_erlterm : erlterm -> unit
   
 exception Not_supported;;
 exception Unknown_type;;

File termreader.ml

+
+print_endline "termreader:"
+
+let _ = 
+  let load_file filename = 
+    let rec load channel data = 
+      try 
+	let line = Pervasives.input_line channel in
+	  load channel (String.concat "" [data; line])
+      with
+	| End_of_file ->  
+	    close_in channel;
+	    data
+    in
+    let fch = open_in filename in (* opening file channel *)
+      load fch ""
+  in
+  let result = Bert.decode_binary (load_file "termwriter.bert") in
+    begin match result with
+      | Bert.Ok(term, remain)->
+	  Bert.print_erlterm term;
+	  print_endline " all read.";
+      | _->
+	  print_endline " failed in decoding.";
+    end;;

File termwriter.eterm

+"hogehoge".
+234.