aboutsummaryrefslogtreecommitdiff
path: root/parsing
diff options
context:
space:
mode:
authorherbelin2004-01-22 18:16:45 +0000
committerherbelin2004-01-22 18:16:45 +0000
commit31f1b45eae17b85a4820502a6e4efcb68d239279 (patch)
treef38d365b7a4d0fdbcc68450b9ec74b6c81f83dca /parsing
parent2a52a7bab29b0c926382c29e560f7df48a097ecb (diff)
Protection table des locations lors de Load (pour coqdoc)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@5237 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'parsing')
-rw-r--r--parsing/lexer.ml412
-rw-r--r--parsing/lexer.mli7
2 files changed, 15 insertions, 4 deletions
diff --git a/parsing/lexer.ml4 b/parsing/lexer.ml4
index 95bd57ce67..6424cb3d9c 100644
--- a/parsing/lexer.ml4
+++ b/parsing/lexer.ml4
@@ -487,8 +487,10 @@ let loct_add loct i loc =
end;
!loct.(i) <- Some loc
-let current_location_function =
- ref (fun _ -> failwith "No location function is set")
+let current_location_table = ref (ref [||])
+
+let location_function n =
+ loct_func !current_location_table n
let func cs =
let loct = loct_create () in
@@ -498,9 +500,13 @@ let func cs =
let (tok, loc) = next_token cs in
loct_add loct i loc; Some tok)
in
- current_location_function := loct_func loct;
+ current_location_table := loct;
(ts, loct_func loct)
+type location_table = (int * int) option array ref
+let location_table () = !current_location_table
+let restore_location_table t = current_location_table := t
+
(* Names of tokens, for this lexer, used in Grammar error messages *)
let token_text = function
diff --git a/parsing/lexer.mli b/parsing/lexer.mli
index f1a97a163e..b44e62eb91 100644
--- a/parsing/lexer.mli
+++ b/parsing/lexer.mli
@@ -23,7 +23,12 @@ val add_keyword : string -> unit
val is_keyword : string -> bool
val func : char Stream.t -> (string * string) Stream.t * (int -> int * int)
-val current_location_function : (int -> int * int) ref
+val location_function : int -> int * int
+
+(* for coqdoc *)
+type location_table
+val location_table : unit -> location_table
+val restore_location_table : location_table -> unit
val check_ident : string -> unit
val check_special_token : string -> unit