Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

73 lines (55 sloc) 2.03 KB
Copyright © 2011 MLstate
This file is part of OPA.
OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.
OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.
You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <>.
(* CF mli *)
type filename = string
type line_number = int
let private_filename = ref ( "<unnamed file>" : filename )
let private_line_number = ref ( (-1) : line_number )
(* The last directive is set by BslRegisterLib,
so that the parser can make some context check *)
let private_last_directive = ref None
let set_last_directive directive = private_last_directive := Some directive
let get_last_directive () = !private_last_directive
let make_pos () = FilePos.make_pos_from_line !private_filename !private_line_number
let pp_citation fmt () =
let pos = make_pos () in
if FilePos.is_empty pos then
Format.fprintf fmt "File \"%s\", line %d@\n" !private_filename !private_line_number
FilePos.citation fmt pos
let warning fmt =
OManager.warning ~wclass:WarningClass.bsl_register ("@\n%a"^^fmt) pp_citation ()
let error fmt =
OManager.printf "%a" pp_citation () ;
OManager.error fmt
module TypeVar =
let tbl = Hashtbl.create 10
let var name =
try Hashtbl.find tbl name with
| Not_found ->
let typevar = ~name () in
Hashtbl.add tbl name typevar;
let fresh () = ()
let reset () =
Hashtbl.clear tbl
let init_file ~filename =
private_last_directive := None;
private_filename := filename
let init_line ~line_number =
TypeVar.reset ();
private_line_number := line_number
Jump to Line
Something went wrong with that request. Please try again.