Source

lambda-translator / main.ml

Full commit
(**
  $ ocamllex lexer.mll
  $ ocamlc lexer.ml main.ml
**)

open Lexer

let stoken = function
  | LAMBDA -> "LAMBDA"
  | DOT -> "DOT"
  | Ident s -> "var:" ^ s
  | OPEN -> "OPEN"
  | CLOSE -> "CLOSE"
  | INT i -> "int:" ^ string_of_int i
  | EOL -> "EOL"

let _ =
  try
    let lexbuf = Lexing.from_channel stdin in
    while true do
      let t =  Lexer.token lexbuf in
      prerr_endline (stoken t);
      flush stderr;
    done
  with
  | Lexer.Eof ->
      prerr_endline "eof"; exit 0
  | e -> prerr_endline ( "ERRR: " ^ Printexc.to_string e)