blob: 06ac28f1f82c8d26ba9c456d8ec1b99225d6d0c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
(****************************************************************************)
(* *)
(* OCaml *)
(* *)
(* INRIA Rocquencourt *)
(* *)
(* Copyright 2006 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed under *)
(* the terms of the GNU Library General Public License, with the special *)
(* exception on linking described in LICENSE at the top of the OCaml *)
(* source tree. *)
(* *)
(****************************************************************************)
(* Authors:
* - Daniel de Rauglaudre: initial version
* - Nicolas Pouillard: refactoring
*)
module Make (Lexer : Sig.Lexer)
: Sig.Grammar.Dynamic with module Loc = Lexer.Loc
and module Token = Lexer.Token
= struct
module Structure = Structure.Make Lexer;
module Delete = Delete.Make Structure;
module Insert = Insert.Make Structure;
module Entry = Entry.Make Structure;
module Fold = Fold.Make Structure;
module Tools = Tools.Make Structure;
include Structure;
value mk () =
let gkeywords = Hashtbl.create 301 in
{
gkeywords = gkeywords;
gfilter = Token.Filter.mk (Hashtbl.mem gkeywords);
glexer = Lexer.mk ();
warning_verbose = ref True; (* FIXME *)
error_verbose = Camlp4_config.verbose
};
value get_filter g = g.gfilter;
value lex g loc cs = g.glexer loc cs;
value lex_string g loc str = lex g loc (Stream.of_string str);
value filter g ts = Tools.keep_prev_loc (Token.Filter.filter g.gfilter ts);
value parse_tokens_after_filter entry ts = Entry.parse_tokens_after_filter entry ts;
value parse_tokens_before_filter entry ts = parse_tokens_after_filter entry (filter entry.egram ts);
value parse entry loc cs = parse_tokens_before_filter entry (lex entry.egram loc cs);
value parse_string entry loc str =
parse_tokens_before_filter entry (lex_string entry.egram loc str);
value delete_rule = Delete.delete_rule;
value srules e rl =
let t =
List.fold_left
(fun tree (symbols, action) -> Insert.insert_tree e symbols action tree)
DeadEnd rl
in
Stree t;
value sfold0 = Fold.sfold0;
value sfold1 = Fold.sfold1;
value sfold0sep = Fold.sfold0sep;
(* value sfold1sep = Fold.sfold1sep; *)
value extend = Insert.extend;
end;
|