Commit | Line | Data |
---|---|---|
78c9eca5 SK |
1 | let () = |
2 | let path_to_program_file = Sys.argv.(1) in | |
3 | let ic = open_in path_to_program_file in | |
4 | let lexbuf = Lexing.from_channel ic in | |
543d3420 SK |
5 | (match Tiger.Parser.program Tiger.Lexer.token lexbuf with |
6 | | exception Parsing.Parse_error -> | |
7 | let | |
8 | Lexing.({lex_curr_p = {pos_lnum; pos_bol; pos_cnum; _}; _}) = lexbuf | |
9 | in | |
10 | Printf.printf | |
11 | "Syntax error in file %S, around line: %d, column: %d\n" | |
12 | path_to_program_file pos_lnum (pos_cnum - pos_bol) | |
13 | | program -> | |
14 | print_endline program | |
15 | ); | |
78c9eca5 | 16 | close_in ic; |