| 1 | let lexbuf_set_filename lb filename : unit = |
| 2 | let Lexing.({lex_start_p; lex_curr_p; _}) = lb in |
| 3 | lb.Lexing.lex_start_p <- {lex_start_p with Lexing.pos_fname = filename}; |
| 4 | lb.Lexing.lex_curr_p <- {lex_curr_p with Lexing.pos_fname = filename} |
| 5 | |
| 6 | let () = |
| 7 | let path_to_program_file = Sys.argv.(1) in |
| 8 | let ic = open_in path_to_program_file in |
| 9 | let lexbuf = Lexing.from_channel ic in |
| 10 | lexbuf_set_filename lexbuf path_to_program_file; |
| 11 | (match Tiger.Parser.program Tiger.Lexer.token lexbuf with |
| 12 | | exception Tiger.Error.T error -> |
| 13 | Printf.eprintf "%s\n" (Tiger.Error.to_string error); |
| 14 | exit 1; |
| 15 | | absyn -> |
| 16 | Tiger.Semant.transProg absyn; |
| 17 | print_endline (Tiger.Absyn.to_string absyn) |
| 18 | ); |
| 19 | close_in ic; |