Complete 1.02.p.1: Tiger lexer
[tiger.ml.git] / tiger / src / exe / tigerc.ml
diff --git a/tiger/src/exe/tigerc.ml b/tiger/src/exe/tigerc.ml
new file mode 100644 (file)
index 0000000..77eafb4
--- /dev/null
@@ -0,0 +1,15 @@
+open Printf
+
+let () =
+  let path_to_program_file = Sys.argv.(1) in
+  let ic = open_in path_to_program_file in
+  let lexbuf = Lexing.from_channel ic in
+  let rec parse_and_print () =
+    let token = Tiger.Lexer.token lexbuf in
+    printf "%s\n" (Tiger.Parser.Token.to_string token);
+    match token with
+    | Tiger.Parser.Token.EOF -> ()
+    | _ -> parse_and_print ()
+  in
+  parse_and_print ();
+  close_in ic;
This page took 0.021688 seconds and 4 git commands to generate.