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-02-14 14:18:34 CET by Kim Nguyen>
26 %token <string> STRING
29 %token <Ast.axis> AXIS
31 %token SLASH SLASHSLASH COLONCOLON STAR PIPE
32 %token EQ NEQ LT GT LTE GTE OR AND ADD SUB DIV MOD
46 %type <Ast.path> xpath_query
55 path_rev { List.rev $1 }
59 simple_path { [ $1 ] }
60 | path_rev PIPE simple_path { $3 :: $1 }
65 absolute_path { Absolute (List.rev $1) }
66 | relative_path { Relative (List.rev $1) }
70 SLASH relative_path { $2 }
71 | SLASHSLASH relative_path { (Descendant true, node, []) :: $2 }
76 | relative_path SLASH step { $3 :: $1 }
77 | relative_path SLASHSLASH step { $3
78 :: (Descendant true, node, [])
83 axis_test pred_list { let a, b = $1 in a, b, $2 }
87 AXIS COLONCOLON test { $1, $3 }
90 let _ = Format.flush_str_formatter () in
91 let () = Format.fprintf Format.str_formatter "%a" Ast.print_axis $1 in
92 let a = Format.flush_str_formatter () in
93 Child, Utils.QNameSet.singleton (Utils.QName.of_string a)
101 | TAG { Utils.QNameSet.singleton(Utils.QName.of_string $1) }
105 pred_list_rev { List.rev $1 }
110 | pred_list LB expr RB { $3 :: $1 }
114 INT { Number(`Int($1)) }
115 | FLOAT { Number(`Float($1)) }
116 | STRING { String $1 }
117 | SUB expr %prec uminus { Unop(Neg, $2) }
118 | expr AND expr { Binop($1, And, $3) }
119 | expr OR expr { Binop($1, Or, $3) }
120 | expr ADD expr { Binop($1, Add, $3) }
121 | expr SUB expr { Binop($1, Sub, $3) }
122 | expr STAR expr { Binop($1, Mult, $3) }
123 | expr DIV expr { Binop($1, Div, $3) }
124 | expr MOD expr { Binop($1, Mod, $3) }
125 | expr EQ expr { Binop($1, Eq, $3) }
126 | expr NEQ expr { Binop($1, Neq, $3) }
127 | expr LT expr { Binop($1, Lt, $3) }
128 | expr LTE expr { Binop($1, Lte, $3) }
129 | expr GT expr { Binop($1, Gt, $3) }
130 | expr GTE expr { Binop($1, Gte, $3) }
131 | TAG LP arg_list RP { Fun_call(Utils.QName.of_string $1, $3) }
138 | arg_list1 { List.rev $1 }
143 | arg_list1 COMMA expr { $3 :: $1 }