Allow the @id syntax in XPath expressions.
authorKim Nguyễn <kn@lri.fr>
Sun, 10 Mar 2013 18:10:46 +0000 (19:10 +0100)
committerKim Nguyễn <kn@lri.fr>
Sun, 10 Mar 2013 18:10:46 +0000 (19:10 +0100)
src/xpath/ulexer.ml
src/xpath/xpath_internal_parser.mly

index 2153e18..3e71c5a 100644 (file)
@@ -14,7 +14,7 @@
 (***********************************************************************)
 
 (*
 (***********************************************************************)
 
 (*
-  Time-stamp: <Last modified on 2013-02-14 15:38:56 CET by Kim Nguyen>
+  Time-stamp: <Last modified on 2013-03-10 14:34:41 CET by Kim Nguyen>
 *)
 
 open Xpath_internal_parser
 *)
 
 open Xpath_internal_parser
@@ -54,7 +54,7 @@ let return lexbuf tok = (tok, L.loc lexbuf)
 let return_loc i j tok = (tok, (i,j))
 
 let regexp ncname_char =
 let return_loc i j tok = (tok, (i,j))
 
 let regexp ncname_char =
-  xml_letter | xml_digit | [ '-' '_' ] | xml_combining_char | xml_extender | "\\."
+  xml_letter | xml_digit | [ '-' '_' '.'] | xml_combining_char | xml_extender
 
 let hexa_digit = function
   | '0'..'9' as c -> (Char.code c) - (Char.code '0')
 
 let hexa_digit = function
   | '0'..'9' as c -> (Char.code c) - (Char.code '0')
@@ -123,6 +123,8 @@ let rec token = lexer
  | "!=" -> NEQ
  | "node()" -> NODE
  | "text()" -> TEXT
  | "!=" -> NEQ
  | "node()" -> NODE
  | "text()" -> TEXT
+ | '@' ncname -> ATTNAME (L.utf8_lexeme lexbuf)
+
  | ncname -> keyword_or_tag (L.utf8_lexeme lexbuf)
  | float ->
      let s = L.utf8_lexeme lexbuf in
  | ncname -> keyword_or_tag (L.utf8_lexeme lexbuf)
  | float ->
      let s = L.utf8_lexeme lexbuf in
@@ -165,5 +167,3 @@ and string start double = lexer
   | _ ->
       store_lexeme lexbuf;
       string start double lexbuf
   | _ ->
       store_lexeme lexbuf;
       string start double lexbuf
-
-
index fe38f67..3651d2c 100644 (file)
@@ -15,7 +15,7 @@
 (***********************************************************************)
 
 (*
 (***********************************************************************)
 
 (*
-  Time-stamp: <Last modified on 2013-03-09 19:24:28 CET by Kim Nguyen>
+  Time-stamp: <Last modified on 2013-03-10 14:31:48 CET by Kim Nguyen>
 *)
 
   open Ast
 *)
 
   open Ast
@@ -23,6 +23,7 @@
 %}
 
 %token <string> TAG
 %}
 
 %token <string> TAG
+%token <string> ATTNAME
 %token <string> STRING
 %token <int>  INT
 %token <float> FLOAT
 %token <string> STRING
 %token <int>  INT
 %token <float> FLOAT
@@ -85,7 +86,7 @@ step:
 
 axis_test:
   AXIS COLONCOLON test  { let a, t = $1, $3 in
 
 axis_test:
   AXIS COLONCOLON test  { let a, t = $1, $3 in
-                          if a == Attribute && Utils.QNameSet.is_finite t then 
+                          if a == Attribute && Utils.QNameSet.is_finite t then
                             (a, Utils.QNameSet.fold
                               (fun t a ->
                                 Utils.QNameSet.add
                             (a, Utils.QNameSet.fold
                               (fun t a ->
                                 Utils.QNameSet.add
@@ -101,6 +102,8 @@ axis_test:
   let a = Format.flush_str_formatter () in
   Child, Utils.QNameSet.singleton (Utils.QName.of_string a)
 }
   let a = Format.flush_str_formatter () in
   Child, Utils.QNameSet.singleton (Utils.QName.of_string a)
 }
+| ATTNAME             {  (Attribute,
+                          Utils.QNameSet.singleton (Utils.QName.of_string $1)) }
 ;
 
 test:
 ;
 
 test:
@@ -151,4 +154,3 @@ arg_list1:
   expr                     { [ $1 ] }
 | arg_list1 COMMA expr     { $3 :: $1 }
 ;
   expr                     { [ $1 ] }
 | arg_list1 COMMA expr     { $3 :: $1 }
 ;
-