1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Objective Caml *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
1995-07-02 09:47:24 -07:00
|
|
|
(* Auxiliary functions for parsing *)
|
|
|
|
|
|
|
|
type error =
|
|
|
|
Unbound of string
|
|
|
|
|
|
|
|
exception Error of error
|
|
|
|
|
1996-04-30 07:53:58 -07:00
|
|
|
let tbl_ident = (Hashtbl.create 57 : (string, Ident.t) Hashtbl.t)
|
1995-07-02 09:47:24 -07:00
|
|
|
|
|
|
|
let bind_ident s =
|
1996-04-30 07:53:58 -07:00
|
|
|
let id = Ident.create s in
|
1995-07-02 09:47:24 -07:00
|
|
|
Hashtbl.add tbl_ident s id;
|
|
|
|
id
|
|
|
|
|
|
|
|
let find_ident s =
|
|
|
|
try
|
|
|
|
Hashtbl.find tbl_ident s
|
|
|
|
with Not_found ->
|
|
|
|
raise(Error(Unbound s))
|
|
|
|
|
|
|
|
let unbind_ident id =
|
|
|
|
Hashtbl.remove tbl_ident (Ident.name id)
|
|
|
|
|
|
|
|
let report_error = function
|
|
|
|
Unbound s ->
|
|
|
|
prerr_string "Unbound identifier "; prerr_string s; prerr_endline "."
|