Add .. and . to the path syntax.
[tatoo.git] / src / xpath / xpath_internal_parser.mly
index 72a07fb..9830e76 100644 (file)
@@ -15,7 +15,7 @@
 (***********************************************************************)
 
 (*
-  Time-stamp: <Last modified on 2013-03-13 12:11:04 CET by Kim Nguyen>
+  Time-stamp: <Last modified on 2013-03-13 14:21:53 CET by Kim Nguyen>
 *)
 
   open Ast
@@ -30,7 +30,7 @@
 %token <float> FLOAT
 %token <Ast.axis> AXIS
 %token RB LB LP RP
-%token SLASH SLASHSLASH COLONCOLON STAR PIPE
+%token SLASH SLASHSLASH COLONCOLON STAR PIPE DOT DOTDOT
 %token EQ NEQ LT GT LTE GTE OR AND ADD SUB DIV MOD
 %token NODE TEXT COMMENT
 %token COMMA
@@ -91,7 +91,9 @@ relative_path:
 ;
 
 step:
-  axis_test pred_list    {
+  DOT                    { [ (Self, (node, NodeKind.Node), []) ] }
+| DOTDOT                 { [ (Parent, (node, NodeKind.Node), []) ] }
+| axis_test pred_list    {
     match $1 with
       (a,b) :: r -> (a,b,$2) :: (List.map (fun (a,b) -> (a,b,[])) r)
     | [] -> assert false
@@ -136,10 +138,11 @@ test:
 | COMMENT             { Utils.QNameSet.singleton(Utils.QName.comment),
                         NodeKind.Comment
                       }
-| PI                  { Utils.QNameSet.singleton(
-                              Utils.QName.processing_instruction (
-                                Utils.QName.of_string $1)
-                         ), NodeKind.ProcessingInstruction
+| PI                  { (if $1 = "" then star
+                         else Utils.QNameSet.singleton(
+                           Utils.QName.processing_instruction (
+                             Utils.QName.of_string $1)
+                         )), NodeKind.ProcessingInstruction
                       }
 | TAG                 { Utils.QNameSet.singleton(Utils.QName.of_string $1),
                         NodeKind.Element