2 (***********************************************************************)
6 (* Kim Nguyen, LRI UMR8623 *)
7 (* Université Paris-Sud & CNRS *)
9 (* Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
10 (* Recherche Scientifique. All rights reserved. This file is *)
11 (* distributed under the terms of the GNU Lesser General Public *)
12 (* License, with the special exception on linking described in file *)
15 (***********************************************************************)
18 Time-stamp: <Last modified on 2013-03-13 09:56:09 CET by Kim Nguyen>
27 %token <string> ATTNAME
28 %token <string> STRING
31 %token <Ast.axis> AXIS
33 %token SLASH SLASHSLASH COLONCOLON STAR PIPE
34 %token EQ NEQ LT GT LTE GTE OR AND ADD SUB DIV MOD
35 %token NODE TEXT COMMENT
48 %type <Ast.path> xpath_query
57 path_rev { List.rev $1 }
61 simple_path { [ $1 ] }
62 | path_rev PIPE simple_path { $3 :: $1 }
67 absolute_path { Absolute (List.rev $1) }
68 | relative_path { Relative (List.rev $1) }
72 SLASH relative_path { $2 }
73 | SLASHSLASH relative_path { $2 @
75 (node, NodeKind.Node),
81 | relative_path SLASH step { $3 :: $1 }
82 | relative_path SLASHSLASH step { $3
84 (node, NodeKind.Node),
90 axis_test pred_list { let a, b = $1 in a, b, $2 }
94 AXIS COLONCOLON test { let a, (t,k) = $1, $3 in
96 if a == Attribute && Utils.QNameSet.is_finite t then
100 (Utils.QName.attribute t) a)
101 t Utils.QNameSet.empty
108 let _ = Format.flush_str_formatter () in
109 let () = Format.fprintf Format.str_formatter "%a" Ast.print_axis $1 in
110 let a = Format.flush_str_formatter () in
111 Child, (Utils.QNameSet.singleton (Utils.QName.of_string a),NodeKind.Element)
113 | ATTNAME { (Attribute,
114 (Utils.QNameSet.singleton (Utils.QName.of_string $1),
115 NodeKind.Attribute)) }
119 NODE { node, NodeKind.Node }
120 | TEXT { text, NodeKind.Text }
121 | STAR { star, NodeKind.Element }
122 | COMMENT { Utils.QNameSet.singleton(Utils.QName.comment),
125 | PI { Utils.QNameSet.singleton(
126 Utils.QName.processing_instruction (
127 Utils.QName.of_string $1)
128 ), NodeKind.ProcessingInstruction
130 | TAG { Utils.QNameSet.singleton(Utils.QName.of_string $1),
136 pred_list_rev { List.rev $1 }
141 | pred_list LB expr RB { $3 :: $1 }
145 INT { Number(`Int($1)) }
146 | FLOAT { Number(`Float($1)) }
147 | STRING { String $1 }
148 | SUB expr %prec uminus { Unop(Neg, $2) }
149 | expr AND expr { Binop($1, And, $3) }
150 | expr OR expr { Binop($1, Or, $3) }
151 | expr ADD expr { Binop($1, Add, $3) }
152 | expr SUB expr { Binop($1, Sub, $3) }
153 | expr STAR expr { Binop($1, Mult, $3) }
154 | expr DIV expr { Binop($1, Div, $3) }
155 | expr MOD expr { Binop($1, Mod, $3) }
156 | expr EQ expr { Binop($1, Eq, $3) }
157 | expr NEQ expr { Binop($1, Neq, $3) }
158 | expr LT expr { Binop($1, Lt, $3) }
159 | expr LTE expr { Binop($1, Lte, $3) }
160 | expr GT expr { Binop($1, Gt, $3) }
161 | expr GTE expr { Binop($1, Gte, $3) }
162 | TAG LP arg_list RP { Fun_call(Utils.QName.of_string $1, $3) }
169 | arg_list1 { List.rev $1 }
174 | arg_list1 COMMA expr { $3 :: $1 }