From: Kim Nguyễn Date: Sat, 16 Nov 2013 22:06:32 +0000 (+0100) Subject: Remove useless cycles in the generated automaton. A state now only has at most one... X-Git-Tag: v0.1~36 X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=commitdiff_plain;h=8c4a23b0bb5883174e225e16d0ac9e5fe2c13032 Remove useless cycles in the generated automaton. A state now only has at most one trivial cycle with itself. --- diff --git a/src/xpath/compile.ml b/src/xpath/compile.ml index 1bfe292..e8ab6fc 100644 --- a/src/xpath/compile.ml +++ b/src/xpath/compile.ml @@ -66,11 +66,10 @@ let compile_axis_test axis (test,kind) phi trans states = states) | Descendant true -> let q' = State.make () in - (F.or_ (F.stay q) (F.first_child q'), - (q', [ test => phi; - QNameSet.any => F.first_child q' ++ F.next_sibling q'; - ]):: - (q, [ test => phi]):: trans, + (F.stay q ++ F.first_child q', + (q', [ QNameSet.any => F.stay q ++ F.first_child q' ++ F.next_sibling q'; + ]):: + (q, [ test => phi]):: trans, states) | Parent -> @@ -82,13 +81,12 @@ let compile_axis_test axis (test,kind) phi trans states = (q' @: states)) | Ancestor self -> - let q' = State.make () in - let move = F.parent q ++ F.previous_sibling q' in - (if self then F.stay q else move), - (q, [ test => phi; - QNameSet.any => move ]) - :: (q', [ QNameSet.any => move ]) :: trans, - (q' @: states) + let q' = State.make () in + let move = F.parent q' ++ F.previous_sibling q' in + (if self then F.stay q ++ F.stay q' else F.stay q'), + (q', [ QNameSet.any => move ++ F.parent q]) + :: (q, [ test => phi ]) :: trans, + (q' @: states) | FollowingSibling | PrecedingSibling -> let move =