let calc op a b = op (int_of_string a) (int_of_string b)

let eval s = 
  s |> Str.split (Str.regexp " ") |>
  (function | [a; "+"; b] -> calc (+) a b
            | [a; "-"; b] -> calc (-) a b
            | [a; "*"; b] -> calc ( * ) a b
            | [a; "/"; b] -> calc (/) a b
            | _ -> failwith "illegal input")

let rec loop () =
  match read_line () with
  | s when String.contains s '?' -> ()
  | expr -> loop (print_int (eval expr); print_newline ())

let () = loop ()