blob: 0e975ce77901309f425c50ec99863673fd2f7894 (
plain) (
tree)
|
|
open Ast
open Ast_printer
open Lexing
let parse_file (filename : string) : prog =
let f = open_in filename in
let lex = from_channel f in
try
lex.lex_curr_p <- { lex.lex_curr_p with pos_fname = filename; };
Parser.file Lexer.token lex
with
| Parser.Error ->
Printf.eprintf "Parse error (invalid syntax) near %s\n"
(string_of_position lex.lex_start_p);
failwith "Parse error"
| Failure "lexing: empty token" ->
Printf.eprintf "Parse error (invalid token) near %s\n"
(string_of_position lex.lex_start_p);
failwith "Parse error"
|