projects
/
tatoo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactor the Ata module:
[tatoo.git]
/
src
/
xpath
/
compile.ml
diff --git
a/src/xpath/compile.ml
b/src/xpath/compile.ml
index
0038506
..
c53057e
100644
(file)
--- a/
src/xpath/compile.ml
+++ b/
src/xpath/compile.ml
@@
-13,21
+13,15
@@
(* *)
(***********************************************************************)
(* *)
(***********************************************************************)
-(*
- Time-stamp: <Last modified on 2013-03-15 18:17:50 CET by Kim Nguyen>
-*)
-
open Ast
open Ast
-open Auto
-open Utils
let ( => ) a b = (a, b)
let ( => ) a b = (a, b)
-let ( ++ ) a b = Ata.
S
Formula.or_ a b
-let ( %% ) a b = Ata.
S
Formula.and_ a b
+let ( ++ ) a b = Ata.Formula.or_ a b
+let ( %% ) a b = Ata.Formula.and_ a b
let ( @: ) a b = StateSet.add a b
let ( @: ) a b = StateSet.add a b
-module F = Ata.
S
Formula
+module F = Ata.Formula
let node_set = QNameSet.remove QName.document QNameSet.any
let node_set = QNameSet.remove QName.document QNameSet.any
@@
-48,8
+42,8
@@
let root_set = QNameSet.singleton QName.document
let compile_axis_test axis (test,kind) phi trans states =
let q = State.make () in
let phi = match kind with
let compile_axis_test axis (test,kind) phi trans states =
let q = State.make () in
let phi = match kind with
- Tree.
Common.
NodeKind.Node -> phi
- | _ -> phi %% F.
mk_kind
kind
+ Tree.NodeKind.Node -> phi
+ | _ -> phi %% F.
is
kind
in
let phi', trans', states' =
match axis with
in
let phi', trans', states' =
match axis with
@@
-127,7
+121,7
@@
let rec compile_expr e trans states =
states2
| Fun_call (f, [ e0 ]) when (QName.to_string f) = "not" ->
let phi, trans0, states0 = compile_expr e0 trans states in
states2
| Fun_call (f, [ e0 ]) when (QName.to_string f) = "not" ->
let phi, trans0, states0 = compile_expr e0 trans states in
- (
Ata.SFormula
.not_ phi),
+ (
F
.not_ phi),
trans0,
states0
| Path p -> compile_path p trans states
trans0,
states0
| Path p -> compile_path p trans states
@@
-136,16
+130,16
@@
let rec compile_expr e trans states =
and compile_path paths trans states =
List.fold_left (fun (aphi, atrans, astates) p ->
let phi, ntrans, nstates = compile_single_path p atrans astates in
and compile_path paths trans states =
List.fold_left (fun (aphi, atrans, astates) p ->
let phi, ntrans, nstates = compile_single_path p atrans astates in
- (
Ata.SFormula
.or_ phi aphi),
+ (
F
.or_ phi aphi),
ntrans,
ntrans,
- nstates) (
Ata.SFormula
.false_,trans,states) paths
+ nstates) (
F
.false_,trans,states) paths
and compile_single_path p trans states =
let steps =
match p with
| Absolute steps ->
(Ancestor false, (QNameSet.singleton QName.document,
and compile_single_path p trans states =
let steps =
match p with
| Absolute steps ->
(Ancestor false, (QNameSet.singleton QName.document,
- Tree.
Common.
NodeKind.Node), [])
+ Tree.NodeKind.Node), [])
:: steps
| Relative steps -> steps
in
:: steps
| Relative steps -> steps
in
@@
-153,7
+147,7
@@
and compile_single_path p trans states =
and compile_step_list l trans states =
match l with
and compile_step_list l trans states =
match l with
- | [] ->
Ata.SFormula
.true_, trans, states
+ | [] ->
F
.true_, trans, states
| (axis, test, elist) :: ll ->
let phi0, trans0, states0 = compile_step_list ll trans states in
let phi1, trans1, states1 =
| (axis, test, elist) :: ll ->
let phi0, trans0, states0 = compile_step_list ll trans states in
let phi1, trans1, states1 =
@@
-181,14
+175,14
@@
let compile_top_level_step_list l trans states =
| (axis, (test,kind), elist) :: ll ->
let phi0, trans0, states0 =
compile_axis_test (invert_axis axis)
| (axis, (test,kind), elist) :: ll ->
let phi0, trans0, states0 =
compile_axis_test (invert_axis axis)
- (QNameSet.any, Tree.
Common.
NodeKind.Node)
+ (QNameSet.any, Tree.NodeKind.Node)
phi_above trans states
in
(* Only select attribute nodes if the previous axis
is attribute *)
let phi0 =
if axis != Attribute then
phi_above trans states
in
(* Only select attribute nodes if the previous axis
is attribute *)
let phi0 =
if axis != Attribute then
- phi0 %% (
Ata.SFormula.not_ Ata.SFormula
.is_attribute)
+ phi0 %% (
F.not_ F
.is_attribute)
else phi0
in
match ll with
else phi0
in
match ll with
@@
-219,8
+213,8
@@
let compile_top_level_step_list l trans states =
let phi0, trans0, states0 =
compile_axis_test
Self
let phi0, trans0, states0 =
compile_axis_test
Self
- (QNameSet.singleton QName.document, Tree.
Common.
NodeKind.Node)
-
Ata.SFormula
.true_
+ (QNameSet.singleton QName.document, Tree.NodeKind.Node)
+
F
.true_
trans
states
in
trans
states
in
@@
-235,11
+229,13
@@
let path p =
in
(StateSet.add ms ams), natrs, nasts) (StateSet.empty, [], StateSet.empty) p
in
in
(StateSet.add ms ams), natrs, nasts) (StateSet.empty, [], StateSet.empty) p
in
- let a = Ata.create states mstates in
+ let builder = Ata.Builder.make () in
+ StateSet.iter
+ (Ata.Builder.add_state builder ~selecting:true) mstates;
+ StateSet.iter
+ (Ata.Builder.add_state builder) states;
List.iter (fun (q, l) ->
List.iter (fun (lab, phi) ->
List.iter (fun (q, l) ->
List.iter (fun (lab, phi) ->
- Ata.
add_trans a
q lab phi
+ Ata.
Builder.add_trans builder
q lab phi
) l) trans;
) l) trans;
- Ata.complete_transitions a;
- Ata.normalize_negations a;
- a
+ Ata.Builder.finalize builder