diff options
author | Alex Auvolat <alex.auvolat@ansys.com> | 2014-06-13 14:17:22 +0200 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ansys.com> | 2014-06-13 14:17:22 +0200 |
commit | dedc98b0c14262c53e8573d7fe1dcaa370e43fb5 (patch) | |
tree | ac02f7271b054247984caa8aac13451ba98dc15b /libs | |
parent | f7868083de2f351b5195149870e6e77398da44f9 (diff) | |
download | scade-analyzer-dedc98b0c14262c53e8573d7fe1dcaa370e43fb5.tar.gz scade-analyzer-dedc98b0c14262c53e8573d7fe1dcaa370e43fb5.zip |
Move a lot of things.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/util.ml | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/libs/util.ml b/libs/util.ml index 522c3ec..494faac 100644 --- a/libs/util.ml +++ b/libs/util.ml @@ -1,11 +1,30 @@ -exception TypeError +(* Locations *) + +type position = Lexing.position +let position_unknown = Lexing.dummy_pos + +type extent = position * position +let extent_unknown = (position_unknown, position_unknown) + + +(* Exceptions *) + +exception NoLocError of string +let error x = raise (NoLocError x) + +exception LocError of extent list * string +let loc_error l f x = + try f x with + | NoLocError e -> raise (LocError([l], e)) + | LocError(q, e) -> raise (LocError(l::q, e)) + +(* Varmaps *) module VarMap = Mapext.Make(String) -exception Duplicate of string let disjoint_union k a b = match a, b with | Some x, None -> Some x | None, Some y -> Some y - | _ -> raise (Duplicate k) + | _ -> error ("Duplicate name in disjoint union: " ^ k) let rec fix equal f s = let fs = f s in |