Commit e2f80161 authored by gerd's avatar gerd

Added emulation of get_lexer_set for WDialog


git-svn-id: https://godirepo.camlcity.org/svn/lib-pxp/trunk@702 dbe99aee-44db-0310-b2b3-d33182c8eb97
parent 4be43acf
......@@ -222,3 +222,8 @@ object
method lexeme_strlen : int
method sub_lexeme : int -> int -> string
end
type lexer_set =
{ scan_name_string : Lexing.lexbuf -> token }
(* DEPRECATED. Only exists because WDialog needs it. *)
......@@ -221,3 +221,8 @@ object
* For some implementations, this function is very ineffecient.
*)
end
type lexer_set =
{ scan_name_string : Lexing.lexbuf -> token }
(* DEPRECATED. Only exists because WDialog needs it. *)
......@@ -35,3 +35,39 @@ let get_lexer_factory enc =
failwith ("Pxp_lexers: This type of internal encoding is not supported: " ^ Netconversion.string_of_encoding (enc :> encoding) ^ " - maybe missing lexing module?")
;;
(* The following emulation of get_lexer_set works _only_ for WDialog!
* We can assume that get_lexer_set is called every time a new buffer
* is to be scanned. Furthermore, we know that the lexbuf was created
* with Lexing.from_string.
*)
open Pxp_reader;;
let get_lexer_set (enc : rep_encoding) = (* DEPRECATED *)
let enc' = (enc :> encoding) in
let factory = get_lexer_factory enc in
let old_obj = ref None in
let open_obj buf =
match !old_obj with
None ->
let src = { lsrc_lexbuf =
lazy buf;
lsrc_unicode_lexbuf =
lazy(Netulex.ULB.from_string enc' buf.Lexing.lex_buffer)
} in
let obj = factory # open_source src in
old_obj := Some obj;
obj
| Some obj -> obj
in
let scan_name_string buf =
let lobj = open_obj buf in
lobj # scan_name_string()
in
{ scan_name_string = scan_name_string }
;;
......@@ -20,3 +20,12 @@ class false_factory : string -> lexer_factory
(** A factory that always fails with the passed string when it is
* tried to open a source
*)
val get_lexer_set : rep_encoding -> lexer_set
(* DEPRECATED. Only exists because WDialog needs it. This function
* is only emulated to the level that WDialog can use it.
*)
(* Return the set of lexer functions that is able to handle the passed
* encoding.
*)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment