Commits

Anonymous committed e5ef075

term format test implement .. .

Comments (0)

Files changed (3)

 
 FILES[] =
      tcp_server
-#    file2
+     erbo
 
 PROGRAM = tcp_server
 OCAML_LIBS +=
   fun      - not supported 
   binary   - just an string, maybe
   port     - not supported
-
-
-
+type term =
+  Int of int
+  | Float of float
+  | Atom of string 
+  | List of term list
+  | Tuple of term list
+  | Binary of string
+  | None;;
 
+type result = 
+  | Ok of term * string 
+  | More of int 
+  | None;;
+
+(*
+class pid = let a in 1;;
+class ref = let a in 1;;
+class port = Not_supported;;
+*)
+
+exception Not_supported;;
+exception Unknown_type;;
+
+(* binary -> (decoded tuple, remain), (more, Length), (error, Reason)
+   throws exceptions: Not_supported | Unknown_type
+   when more binaries 
+*)
+
+
+let decode_binary bin = 
+  let local_decode local_bin = Ok( Int(131), "" ) in
+  match bin[0] with
+    | 131 -> (* magic number for BERT term; *)
+	local_decode bin
+    | _ -> raise Unknown_type;;
+