From 238dc42c2cb6324b103585556c3f5f9150ee221e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kim=20Nguy=E1=BB=85n?= Date: Sun, 10 Mar 2013 19:10:46 +0100 Subject: [PATCH] Allow the @id syntax in XPath expressions. --- src/xpath/ulexer.ml | 8 ++++---- src/xpath/xpath_internal_parser.mly | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/xpath/ulexer.ml b/src/xpath/ulexer.ml index 2153e18..3e71c5a 100644 --- a/src/xpath/ulexer.ml +++ b/src/xpath/ulexer.ml @@ -14,7 +14,7 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) 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 = - 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') @@ -123,6 +123,8 @@ let rec token = lexer | "!=" -> 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 @@ -165,5 +167,3 @@ and string start double = lexer | _ -> store_lexeme lexbuf; string start double lexbuf - - diff --git a/src/xpath/xpath_internal_parser.mly b/src/xpath/xpath_internal_parser.mly index fe38f67..3651d2c 100644 --- a/src/xpath/xpath_internal_parser.mly +++ b/src/xpath/xpath_internal_parser.mly @@ -15,7 +15,7 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) open Ast @@ -23,6 +23,7 @@ %} %token TAG +%token ATTNAME %token STRING %token INT %token FLOAT @@ -85,7 +86,7 @@ step: 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 @@ -101,6 +102,8 @@ axis_test: 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: @@ -151,4 +154,3 @@ arg_list1: expr { [ $1 ] } | arg_list1 COMMA expr { $3 :: $1 } ; - -- 2.17.1