Simplify the automaton encoding a bit (remove redundant predicates in formulae).
[tatoo.git] / src / xpath / ast.ml
index 64c6c8d..5b322a4 100644 (file)
 (*                                                                     *)
 (***********************************************************************)
 
-(*
-  Time-stamp: <Last modified on 2013-03-13 10:59:20 CET by Kim Nguyen>
-*)
-
-open Utils
-
 type path = single_path list
 and single_path = Absolute of step list | Relative of step list
 and step = axis * test * expr list
@@ -30,7 +24,7 @@ and axis = Self | Attribute | Child
            | PrecedingSibling
            | Preceding | Following
 
-and test = QNameSet.t * Tree.Common.NodeKind.t
+and test = QNameSet.t * Tree.NodeKind.t
 
 and binop = Eq | Neq | Lt | Gt | Lte | Gte | Or | And | Add | Sub | Mult | Div | Mod
 and unop =  Neg
@@ -128,20 +122,21 @@ and print_axis fmt a = pp fmt "%s" begin
 end
 
 and print_test fmt (ts,kind) =
-  let open Tree.Common.NodeKind in
+  let open Tree.NodeKind in
     match kind with
       Text -> pp fmt "%s" "text()"
     | Element | Attribute ->
         pp fmt "%s" begin
-          if ts == star then "*"
-          else QName.to_string (QNameSet.choose ts)
+          if QNameSet.is_finite ts then
+            QName.to_string (QNameSet.choose ts)
+          else "*"
         end
     | Comment -> pp fmt "%s" "comment()"
     | ProcessingInstruction ->
         pp fmt "processing-instruction(%s)"
           begin
             if ts == star then ""
-            else "'" ^ (QName.to_string (QNameSet.choose ts)) ^ "'"
+            else "\"" ^ (QName.to_string  (QNameSet.choose ts)) ^ "\""
           end
     | Node -> pp fmt "%s" "node()"
     | Document -> pp fmt "%s" "<DOCUMENT>"
@@ -187,4 +182,3 @@ let invert_axis = function
 | Preceding -> Following
 | Following -> Preceding
 ;;
-