Advertisement
Guest User

Untitled

a guest
Mar 15th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.64 KB | None | 0 0
  1. {
  2.  
  3.  +  
  4.  +
  5.       let to_string = function
  6.       | PLUS -> sprintf "PLUS"
  7.       | STRING (str) -> sprintf "STRING(%s)" (str)
  8.  +    | INT (d) -> sprintf "INT(%d)" (d)
  9.  +    | MINUS -> sprintf "MINUS"
  10.  +    | TIMES -> sprintf "TIMES"
  11.  +    | _ -> "some shit"
  12.       ;;
  13.  
  14.  
  15.  let main () =
  16.      let lexbuf = set_filename "stdin" @@ L.from_channel stdin in
  17.      let rec loop acc =  function
  18.          | EOF   ->  to_string EOF :: acc |> List.rev
  19.          | x     ->  loop (to_string x :: acc) (mainlex lexbuf)
  20.      in
  21.           loop [] (mainlex lexbuf)
  22.           |> String.concat " "
  23.           |> print_endline
  24.  +
  25.  +    let () = main ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement