Add function to query the memory usage of the BP structure.
[SXSI/xpathcomp.git] / src / grammar.mli
1 type t
2
3 type node = [ `Grammar ] Node.t
4
5 type p_type  = [ `Parameter ]
6 type n_type = [ `NonTerminal ]
7 type t_type = [ `Terminal ]
8 type any_type = [ p_type | n_type | t_type ]
9 type symbol = [ any_type ] Node.t
10
11 type p_symbol = p_type Node.t
12 type n_symbol = n_type Node.t
13 type t_symbol = t_type Node.t
14 type tn_symbol = [ n_type | t_type ] Node.t
15
16 type partial =
17  | Leaf of node
18  | Node of tn_symbol * partial array
19
20
21 val is_terminal : [< any_type ] Node.t -> bool
22 val is_non_terminal : [< any_type ] Node.t -> bool
23 val is_parameter : [< any_type ] Node.t -> bool
24
25 external get_symbol_at : t -> symbol -> node -> symbol = "caml_grammar_get_symbol_at"
26 external first_child : t -> symbol -> node -> node = "caml_grammar_first_child"
27 external next_sibling : t -> symbol -> node -> node = "caml_grammar_next_sibling"
28 external start_first_child : t -> node -> node = "caml_grammar_start_first_child"
29 external start_next_sibling : t -> node -> node = "caml_grammar_start_next_sibling"
30 external parameter : [< any_type ] Node.t -> p_symbol = "%identity"
31 external terminal : [< any_type ] Node.t -> t_symbol = "%identity"
32 external non_terminal : [< any_type ] Node.t -> n_symbol = "%identity"
33 external get_id1 : t -> n_symbol -> tn_symbol = "caml_grammar_get_id1"
34 external get_id2 : t -> n_symbol -> tn_symbol = "caml_grammar_get_id2"
35 val get_param_pos : n_symbol -> int
36 external nil_symbol : t -> t_symbol = "caml_grammar_nil_id"
37 val num_params : n_symbol -> int
38 val num_children : [< t_type | n_type ] Node.t -> int
39 external is_nil : t -> t_symbol -> bool = "caml_grammar_is_nil"
40
41 val tag : t_symbol -> Tag.t
42 val symbol : n_symbol -> int
43 val tag_operations : t -> Tag.operations
44
45
46 val load : string -> bool -> t