summaryrefslogtreecommitdiff
path: root/camlsim/netlist.ml
blob: b1d7932eab53d1477ba784af36c0a24cbe6c7ccc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
exception Parse_error of string

let find_file filename =
  try
    open_in filename
  with
    | _ -> raise (Parse_error "No such file '%s'")

let read_file filename =
  let ic = find_file filename in
  let lexbuf = Lexing.from_channel ic in
  lexbuf.Lexing.lex_curr_p <- { lexbuf.Lexing.lex_curr_p with Lexing.pos_fname = filename };
  try
    Netlist_parser.program Netlist_lexer.token lexbuf
  with
    | e -> raise (Parse_error ("Syntax error (exception: "^(Printexc.to_string e)^")"))