From d645b8bf30064e94ee9777d793854eebc921dfe0 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Mon, 11 Oct 2004 19:16:52 +0000 Subject: [PATCH] moved utf8 macro handling to the new module Utf8Macros --- helm/ocaml/cic_disambiguation/.depend | 8 +- helm/ocaml/cic_disambiguation/Makefile | 55 +- .../cic_disambiguation/cicTextualLexer2.ml | 4 +- .../cic_disambiguation/cicTextualParser2.ml | 12 +- .../cicTextualParser2Macro.ml | 33 - .../cicTextualParser2Macro.mli | 32 - helm/ocaml/cic_disambiguation/macro_table.mli | 27 - .../macros/dictionary-tex.xml | 378 --- .../macros/entities-table.xml | 2081 ----------------- .../macros/extra-entities.xml | 5 - helm/ocaml/cic_disambiguation/make_table.ml | 120 - 11 files changed, 25 insertions(+), 2730 deletions(-) delete mode 100644 helm/ocaml/cic_disambiguation/cicTextualParser2Macro.ml delete mode 100644 helm/ocaml/cic_disambiguation/cicTextualParser2Macro.mli delete mode 100644 helm/ocaml/cic_disambiguation/macro_table.mli delete mode 100644 helm/ocaml/cic_disambiguation/macros/dictionary-tex.xml delete mode 100644 helm/ocaml/cic_disambiguation/macros/entities-table.xml delete mode 100644 helm/ocaml/cic_disambiguation/macros/extra-entities.xml delete mode 100644 helm/ocaml/cic_disambiguation/make_table.ml diff --git a/helm/ocaml/cic_disambiguation/.depend b/helm/ocaml/cic_disambiguation/.depend index 2a5719e54..eeb856c66 100644 --- a/helm/ocaml/cic_disambiguation/.depend +++ b/helm/ocaml/cic_disambiguation/.depend @@ -5,12 +5,8 @@ disambiguateTypes.cmo: disambiguateTypes.cmi disambiguateTypes.cmx: disambiguateTypes.cmi disambiguateChoices.cmo: disambiguateTypes.cmi disambiguateChoices.cmi disambiguateChoices.cmx: disambiguateTypes.cmx disambiguateChoices.cmi -macro_table.cmo: macro_table.cmi -macro_table.cmx: macro_table.cmi -cicTextualParser2Macro.cmo: macro_table.cmi cicTextualParser2Macro.cmi -cicTextualParser2Macro.cmx: macro_table.cmx cicTextualParser2Macro.cmi -cicTextualLexer2.cmo: cicTextualParser2Macro.cmi cicTextualLexer2.cmi -cicTextualLexer2.cmx: cicTextualParser2Macro.cmx cicTextualLexer2.cmi +cicTextualLexer2.cmo: cicTextualLexer2.cmi +cicTextualLexer2.cmx: cicTextualLexer2.cmi cicTextualParser2.cmo: cicTextualLexer2.cmi disambiguateChoices.cmi \ disambiguateTypes.cmi cicTextualParser2.cmi cicTextualParser2.cmx: cicTextualLexer2.cmx disambiguateChoices.cmx \ diff --git a/helm/ocaml/cic_disambiguation/Makefile b/helm/ocaml/cic_disambiguation/Makefile index 932008160..de0cf3ba2 100644 --- a/helm/ocaml/cic_disambiguation/Makefile +++ b/helm/ocaml/cic_disambiguation/Makefile @@ -1,15 +1,14 @@ PACKAGE = cic_textual_parser2 REQUIRES = \ - helm-tactics helm-logger helm-cic_unification helm-cic_transformations helm-pxp \ - ulex camlp4.gramlib + helm-tactics helm-logger helm-cic_unification helm-cic_transformations \ + helm-pxp helm-utf8_macros \ + ulex NOTATIONS = logic arit tex # NOTATIONS = logic arit INTERFACE_FILES = \ disambiguateTypes.mli \ disambiguateChoices.mli \ - macro_table.mli \ - cicTextualParser2Macro.mli \ cicTextualLexer2.mli \ cicTextualParser2.mli \ disambiguate.mli @@ -17,36 +16,21 @@ IMPLEMENTATION_FILES = \ $(patsubst %.mli, %.ml, $(INTERFACE_FILES)) \ $(patsubst %,%_notation.ml,$(NOTATIONS)) -ULEXDIR := $(shell ocamlfind query ulex) - -LEXER_P4_OPTS = -I $(ULEXDIR) pa_ulex.cma -PARSER_P4_OPTS = \ - pa_extend.cmo \ - ./macro_table.cmo \ - ./cicTextualParser2Macro.cmo \ - ./pa_unicode_macro.cmo -PA_P4_OPTS = q_MLast.cmo pa_extend.cmo - all: cicTextualLexer2.cmo: cicTextualLexer2.ml - $(OCAMLC) -pp "camlp4o $(LEXER_P4_OPTS)" -c $< -cicTextualParser2.cmo: cicTextualParser2.ml cicTextualParser2Macro.cmo pa_unicode_macro.cmo - $(OCAMLC) -pp "camlp4o $(PARSER_P4_OPTS)" -c $< + $(OCAMLC_P4) -c $< +cicTextualParser2.cmo: cicTextualParser2.ml + $(OCAMLC_P4) -c $< cicTextualLexer2.cmx: cicTextualLexer2.ml - $(OCAMLOPT) -pp "camlp4o $(LEXER_P4_OPTS)" -c $< -cicTextualParser2.cmx: cicTextualParser2.ml cicTextualParser2Macro.cmo pa_unicode_macro.cmo - $(OCAMLOPT) -pp "camlp4o $(PARSER_P4_OPTS)" -c $< - -%_notation.cmo: %_notation.ml cicTextualParser2.cmo - $(OCAMLC) -pp "camlp4o $(PARSER_P4_OPTS)" -c $< -%_notation.cmx: %_notation.ml cicTextualParser2.cmx - $(OCAMLOPT) -pp "camlp4o $(PARSER_P4_OPTS)" -c $< + $(OCAMLOPT_P4) -c $< +cicTextualParser2.cmx: cicTextualParser2.ml + $(OCAMLOPT_P4) -c $< -pa_unicode_macro.cmo: pa_unicode_macro.ml cicTextualParser2Macro.cmo - $(OCAMLC) -pp "camlp4o $(PA_P4_OPTS)" -c $< -pa_unicode_macro.cmx: pa_unicode_macro.ml cicTextualParser2Macro.cmx - $(OCAMLOPT) -pp "camlp4o $(PA_P4_OPTS)" -c $< +%_notation.cmo: %_notation.ml + $(OCAMLC_P4) -c $< +%_notation.cmx: %_notation.ml + $(OCAMLOPT_P4) -c $< LOCAL_LINKOPTS = -linkpkg $(PACKAGE).cma test: test_lexer test_parser @@ -54,27 +38,16 @@ test_lexer: test_lexer.ml $(PACKAGE).cma $(OCAMLC) $(LOCAL_LINKOPTS) -o $@ $< test_parser: test_parser.ml $(PACKAGE).cma $(OCAMLC) $(LOCAL_LINKOPTS) -o $@ $< -make_table: make_table.ml - $(OCAMLFIND) ocamlc -package helm-pxp -linkpkg -o $@ $^ - -macro_table.ml: make_table - ./make_table $@ -macro_table.cmo: macro_table.ml - $(OCAMLFIND) ocamlc -c $< clean: extra_clean distclean: extra_clean rm -f macro_table.dump extra_clean: - rm -f test_lexer test_parser make_table + rm -f test_lexer test_parser include ../Makefile.common OCAMLARCHIVEOPTIONS += -linkall -.PHONY: depend -depend: cicTextualParser2Macro.cmi cicTextualParser2Macro.cmo pa_unicode_macro.cmi pa_unicode_macro.cmo - $(OCAMLDEP) -pp "camlp4o $(PARSER_P4_OPTS) $(LEXER_P4_OPTS)" $(INTERFACE_FILES) $(IMPLEMENTATION_FILES) > .depend - disambiguateTypes.cmi: disambiguateTypes.mli $(OCAMLC) -c -rectypes $< disambiguateTypes.cmo: disambiguateTypes.ml disambiguateTypes.cmi diff --git a/helm/ocaml/cic_disambiguation/cicTextualLexer2.ml b/helm/ocaml/cic_disambiguation/cicTextualLexer2.ml index 6c2986eaa..2cb13cb33 100644 --- a/helm/ocaml/cic_disambiguation/cicTextualLexer2.ml +++ b/helm/ocaml/cic_disambiguation/cicTextualLexer2.ml @@ -120,8 +120,8 @@ let rec token = lexer Ulexing.utf8_sub_lexeme lexbuf 1 (Ulexing.lexeme_length lexbuf - 1) in (try - return lexbuf ("SYMBOL", CicTextualParser2Macro.expand macro) - with CicTextualParser2Macro.Macro_not_found _ -> + return lexbuf ("SYMBOL", Utf8Macro.expand macro) + with Utf8Macro.Macro_not_found _ -> return lexbuf ("SYMBOL", Ulexing.utf8_lexeme lexbuf)) | eof -> return lexbuf ("EOI", "") | _ -> error lexbuf "Invalid character" diff --git a/helm/ocaml/cic_disambiguation/cicTextualParser2.ml b/helm/ocaml/cic_disambiguation/cicTextualParser2.ml index a539fef6c..634e8e291 100644 --- a/helm/ocaml/cic_disambiguation/cicTextualParser2.ml +++ b/helm/ocaml/cic_disambiguation/cicTextualParser2.ml @@ -245,9 +245,10 @@ EXTEND | "whd" -> `Whd ] ]; tactic: [ - [ [ IDENT "absurd" | IDENT "Absurd" ] -> return_tactic loc TacticAst.Absurd - | [ IDENT "apply" | IDENT "Apply" ]; - t = tactic_term -> return_tactic loc (TacticAst.Apply t) + [ [ IDENT "absurd" | IDENT "Absurd" ]; t = tactic_term -> + return_tactic loc (TacticAst.Absurd t) + | [ IDENT "apply" | IDENT "Apply" ]; t = tactic_term -> + return_tactic loc (TacticAst.Apply t) | [ IDENT "assumption" | IDENT "Assumption" ] -> return_tactic loc TacticAst.Assumption | [ IDENT "change" | IDENT "Change" ]; @@ -265,8 +266,7 @@ EXTEND | [ IDENT "discriminate" | IDENT "Discriminate" ]; hyp = IDENT -> return_tactic loc (TacticAst.Discriminate hyp) - | [ IDENT "elim" | IDENT "Elim" ]; IDENT "type"; - t = tactic_term -> + | [ IDENT "elimType" | IDENT "ElimType" ]; t = tactic_term -> return_tactic loc (TacticAst.ElimType t) | [ IDENT "elim" | IDENT "Elim" ]; t1 = tactic_term; @@ -369,6 +369,8 @@ EXTEND return_command loc (TacticAst.Undo (int_opt steps)) | [ IDENT "redo" | IDENT "Redo" ]; steps = OPT NUM -> return_command loc (TacticAst.Redo (int_opt steps)) + | [ IDENT "check" | IDENT "Check" ]; t = term -> + return_command loc (TacticAst.Check t) ] ]; END diff --git a/helm/ocaml/cic_disambiguation/cicTextualParser2Macro.ml b/helm/ocaml/cic_disambiguation/cicTextualParser2Macro.ml deleted file mode 100644 index 972f50501..000000000 --- a/helm/ocaml/cic_disambiguation/cicTextualParser2Macro.ml +++ /dev/null @@ -1,33 +0,0 @@ -(* Copyright (C) 2004, HELM Team. - * - * This file is part of HELM, an Hypertextual, Electronic - * Library of Mathematics, developed at the Computer Science - * Department, University of Bologna, Italy. - * - * HELM is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * HELM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with HELM; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - * For details, see the HELM World-Wide-Web page, - * http://helm.cs.unibo.it/ - *) - -exception Macro_not_found of string -exception Utf8_not_found of string - -let expand macro = - try - Hashtbl.find Macro_table.macro2utf8 macro - with Not_found -> raise (Macro_not_found macro) - diff --git a/helm/ocaml/cic_disambiguation/cicTextualParser2Macro.mli b/helm/ocaml/cic_disambiguation/cicTextualParser2Macro.mli deleted file mode 100644 index bf3fc16b4..000000000 --- a/helm/ocaml/cic_disambiguation/cicTextualParser2Macro.mli +++ /dev/null @@ -1,32 +0,0 @@ -(* Copyright (C) 2004, HELM Team. - * - * This file is part of HELM, an Hypertextual, Electronic - * Library of Mathematics, developed at the Computer Science - * Department, University of Bologna, Italy. - * - * HELM is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * HELM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with HELM; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - * For details, see the HELM World-Wide-Web page, - * http://helm.cs.unibo.it/ - *) - -exception Macro_not_found of string -exception Utf8_not_found of string - - (* @param macro name - @return utf8 string *) -val expand: string -> string - diff --git a/helm/ocaml/cic_disambiguation/macro_table.mli b/helm/ocaml/cic_disambiguation/macro_table.mli deleted file mode 100644 index 729797fd8..000000000 --- a/helm/ocaml/cic_disambiguation/macro_table.mli +++ /dev/null @@ -1,27 +0,0 @@ -(* Copyright (C) 2004, HELM Team. - * - * This file is part of HELM, an Hypertextual, Electronic - * Library of Mathematics, developed at the Computer Science - * Department, University of Bologna, Italy. - * - * HELM is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * HELM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with HELM; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - * For details, see the HELM World-Wide-Web page, - * http://helm.cs.unibo.it/ - *) - -val macro2utf8: (string, string) Hashtbl.t - diff --git a/helm/ocaml/cic_disambiguation/macros/dictionary-tex.xml b/helm/ocaml/cic_disambiguation/macros/dictionary-tex.xml deleted file mode 100644 index 47995454f..000000000 --- a/helm/ocaml/cic_disambiguation/macros/dictionary-tex.xml +++ /dev/null @@ -1,378 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/helm/ocaml/cic_disambiguation/macros/entities-table.xml b/helm/ocaml/cic_disambiguation/macros/entities-table.xml deleted file mode 100644 index ca0bdabcf..000000000 --- a/helm/ocaml/cic_disambiguation/macros/entities-table.xml +++ /dev/null @@ -1,2081 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/helm/ocaml/cic_disambiguation/macros/extra-entities.xml b/helm/ocaml/cic_disambiguation/macros/extra-entities.xml deleted file mode 100644 index 991c2d84b..000000000 --- a/helm/ocaml/cic_disambiguation/macros/extra-entities.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/helm/ocaml/cic_disambiguation/make_table.ml b/helm/ocaml/cic_disambiguation/make_table.ml deleted file mode 100644 index 13301bce7..000000000 --- a/helm/ocaml/cic_disambiguation/make_table.ml +++ /dev/null @@ -1,120 +0,0 @@ -(* Copyright (C) 2004, HELM Team. - * - * This file is part of HELM, an Hypertextual, Electronic - * Library of Mathematics, developed at the Computer Science - * Department, University of Bologna, Italy. - * - * HELM is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * HELM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with HELM; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - * For details, see the HELM World-Wide-Web page, - * http://helm.cs.unibo.it/ - *) - -open Printf -open Pxp_types -open Pxp_ev_parser - -let debug = false -let debug_print s = if debug then prerr_endline s - - (* source files for tables xml parsing (if unmarshall=false) *) -let xml_tables = [ -(* - `Entities, "/usr/share/gtkmathview/entities-table.xml"; - `Dictionary, "/usr/share/editex/dictionary-tex.xml" -*) - `Entities, "macros/entities-table.xml"; - `Dictionary, "macros/dictionary-tex.xml"; - `Entities, "macros/extra-entities.xml"; -] - - -let rec find_first_tag pull_parser = - match pull_parser () with - | Some (E_start_tag _ as e) -> e - | None -> assert false - | _ -> find_first_tag pull_parser - -let iter_entities_file f pull_parser = - ignore (find_first_tag pull_parser); (* *) - let rec aux () = - match pull_parser () with - | Some (E_start_tag ("entity", attrs, _, _)) -> - (try - let name = List.assoc "name" attrs in - let value = List.assoc "value" attrs in - f name value - with Not_found -> ()); - aux () - | None -> () - | _ -> aux () - in - aux () - -let iter_dictionary_file f pull_parser = - ignore (find_first_tag pull_parser); (* *) - let rec aux () = - match pull_parser () with - | Some (E_start_tag ("entry", attrs, _, _)) -> - (try - let name = List.assoc "name" attrs in - let value = List.assoc "val" attrs in - f name value - with Not_found -> ()); - aux () - | None -> () - | _ -> aux () - in - aux () - -let parse_from_xml () = - let (macro2utf8, utf82macro) = (Hashtbl.create 2000, Hashtbl.create 2000) in - let add_macro macro utf8 = - debug_print (sprintf "Adding macro %s = '%s'" macro utf8); - Hashtbl.add macro2utf8 macro utf8; -(* Hashtbl.add utf82macro utf8 macro *) - in - let fill_table () = - List.iter - (fun (typ, fname) -> - let entry = `Entry_document [ `Extend_dtd_fully; `Parse_xml_decl ] in - let config = PxpHelmConf.pxp_config in - let entity_manager = - create_entity_manager ~is_document:true config (from_file fname) - in - let pull_parser = create_pull_parser config entry entity_manager in - match typ with - | `Entities -> iter_entities_file add_macro pull_parser - | `Dictionary -> iter_dictionary_file add_macro pull_parser) - xml_tables - in - fill_table (); - macro2utf8 - -let main () = - let oc = open_out Sys.argv.(1) in - output_string oc "(* GENERATED by make_table: DO NOT EDIT! *)\n"; - output_string oc "let macro2utf8 = Hashtbl.create 2000\n"; - let macro2utf8 = parse_from_xml () in - Hashtbl.iter - (fun macro utf8 -> - fprintf oc "let _ = Hashtbl.add macro2utf8 \"%s\" \"%s\"\n" - macro (String.escaped utf8)) - macro2utf8; - close_out oc - -let _ = main () - -- 2.39.2