From 4b5e86cc5fa3e62a1cb7d29acf79ffb314194efa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kim=20Nguy=E1=BB=85n?= Date: Tue, 1 Oct 2013 22:12:27 +0200 Subject: [PATCH] Fix a bug in the compilation of * tests. --- src/html.ml | 9 +++++++-- src/xpath/ast.ml | 6 +++--- src/xpath/compile.ml | 2 +- src/xpath/xpath_internal_parser.mly | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/html.ml b/src/html.ml index f049195..236ee39 100644 --- a/src/html.ml +++ b/src/html.ml @@ -87,8 +87,13 @@ let gen_trace (type s) = fun auto t tree -> in let pc = if !max_round == 0 then 1. else float_of_int last_round /. float_of_int !max_round in let scolor, tcolor = - let { sat ; todo; _ } = List.hd(M.find last_round m) in - let c = (last_round, sat, todo) in color c, text_color c + let { sat ; todo; _ } = + match M.find last_round m with + [] -> { sat = StateSet.empty; todo= StateSet.empty; msg = "ERROR" } + | [ e ] -> e + | l -> List.hd (List.tl (List.rev l)) + in + let c = (last_round, StateSet.union sat todo, StateSet.empty) in color c, text_color c in let tag = QName.to_string (T.tag tree node) in let lbox = (String.length tag + 2) * 10 in diff --git a/src/xpath/ast.ml b/src/xpath/ast.ml index 9a0d4d7..21ab5df 100644 --- a/src/xpath/ast.ml +++ b/src/xpath/ast.ml @@ -127,8 +127,9 @@ and print_test fmt (ts,kind) = Text -> pp fmt "%s" "text()" | Element | Attribute -> pp fmt "%s" begin - if ts == star then "*" - else QName.to_string (QName.remove_prefix (QNameSet.choose ts)) + if QNameSet.is_finite ts then + QName.to_string (QName.remove_prefix (QNameSet.choose ts)) + else "*" end | Comment -> pp fmt "%s" "comment()" | ProcessingInstruction -> @@ -181,4 +182,3 @@ let invert_axis = function | Preceding -> Following | Following -> Preceding ;; - diff --git a/src/xpath/compile.ml b/src/xpath/compile.ml index cd887b7..1bfe292 100644 --- a/src/xpath/compile.ml +++ b/src/xpath/compile.ml @@ -39,7 +39,7 @@ let root_set = QNameSet.singleton QName.document holds. *) -let compile_axis_test axis (test,kind) phi trans states= +let compile_axis_test axis (test,kind) phi trans states = let q = State.make () in let phi = match kind with Tree.NodeKind.Node -> phi diff --git a/src/xpath/xpath_internal_parser.mly b/src/xpath/xpath_internal_parser.mly index d9c46a7..e5c0700 100644 --- a/src/xpath/xpath_internal_parser.mly +++ b/src/xpath/xpath_internal_parser.mly @@ -130,7 +130,7 @@ axis_test: test: NODE { node, NodeKind.Node } | TEXT { text, NodeKind.Text } -| STAR { star, NodeKind.Element } +| STAR { node, NodeKind.Element } | COMMENT { QNameSet.singleton(QName.comment), NodeKind.Comment } -- 2.17.1