File: calc.ml

package info (click to toggle)
ocamlmakefile 6.37.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 320 kB
  • ctags: 64
  • sloc: ml: 180; makefile: 55; ansic: 7
file content (19 lines) | stat: -rw-r--r-- 627 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(* The function executed by some thread *)
let a_thread () = print_endline "A thread has been started!"

let _ =
  try
    let lexbuf = Lexing.from_channel stdin in
    while true do
      let result = Parser.main Lexer.token lexbuf in
      print_int result; print_newline();   (*  Prints calculator result  *)

      Test.f ();                           (* Tests the C-function *)

      let t = Thread.create a_thread () in (* Creates a thread *)
      Thread.join t;                       (* Waites for thread termination *)
      print_endline "Thread terminated!";

      flush stdout
    done
  with Lexer.Eof -> exit 0