Guest User

Untitled

a guest
Jan 5th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.75 KB | None | 0 0
  1. let env_program (prog : NAst.program) : Types.type_env =
  2.   let lcn = list_canonical_names prog in
  3.     let fcd = first_canonical_duplicate lcn in
  4.       if Option.is_some(fcd)
  5.       then
  6.         let fcd' = Option.get fcd in
  7.           raise(error_duplicate_variable
  8.             (CanonicalName.to_string
  9.               (fcd'.NAst.source_file_decl.NAst.type_canonical_name))
  10.             fcd'.NAst.source_file_decl.NAst.type_pos)
  11.       else
  12.         let m = TEnv.empty in
  13.           match prog with
  14.           | [] -> m
  15.           | _ -> List.fold_left
  16.                  (fun map sf ->
  17.                 TEnv.add
  18.               sf.NAst.source_file_decl.NAst.type_canonical_name
  19.               (env_type_decl sf.NAst.source_file_decl info)
  20.               map)
  21.              m
  22.              prog
Add Comment
Please, Sign In to add comment