From c48e8d91ae302ffc24844b78a4c61eeef2043801 Mon Sep 17 00:00:00 2001 From: Timothy Washington Date: Tue, 2 Dec 2008 01:17:44 -0500 Subject: [PATCH] -- can now use expression ./child::node()[ @name='tim' ] --- cc/xpath.sablecc | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/cc/xpath.sablecc b/cc/xpath.sablecc index d305062..c6937e2 100755 --- a/cc/xpath.sablecc +++ b/cc/xpath.sablecc @@ -62,11 +62,12 @@ ancestor-or-self::node() ./child::node()[ @asdf='' ] ./child::node()/child::service/child::port/child::soap:address/attribute::location ./child::node()[]/child::service/child::port/child::soap:address/attribute::location -[x] ./child::node()[ @name='tim' ] Error: [1,24] Unknown token: 't +./child::node()[ @name='tim' ] Error: [1,24] Unknown token: 't [x] ./child::node()[ 1 ] Error: [1,18] expecting: 'for', 'if', 'some', 'every', ',', '$', '(', ']', '+', '-', '*', '/', '//', '@', '..', '.', 'child', 'descendant', 'attribute', 'self', 'descendant-or-self', 'following-sibling', 'following', 'namespace', 'parent', 'ancestor', 'preceding-sibling', 'preceding', 'ancestor-or-self', 'comment', 'document-node', 'element', 'node', 'processing-instruction', 'schema-attribute', 'schema-element', 'text', letter, '_', integerliteral, decimalliteral, doubleliteral, stringliteral +./child::node()[ 12 ] [x] ./child::node()[ 1 ]/child::service/child::port/child::soap:address/attribute::location /GPS/memory[text()=""] -[x] /GPS/memory[text()="64MB"] +/GPS/memory[text()="64MB"] --> for @@ -127,7 +128,7 @@ $myaddress treat as element(*, USAddress) */ Helpers - + basechar = [0x0041..0x005A] | [0x0061..0x007A] | [0x00C0..0x00D6] | [0x00D8..0x00F6] | [0x00F8..0x00FF] | [0x0100..0x0131] | [0x0134..0x013E] | [0x0141..0x0148] | [0x014A..0x017E] | @@ -246,15 +247,17 @@ Helpers nmtoken = (namechar)+; nmtokens = nmtoken (0x20 nmtoken)*; char = 0x9 | 0xA | 0xD | [0x20-0xD7FF] | [0xE000-0xFFFD] | [0x10000-0x10FFFF]; - digits = [0-9]+; + digits = ['0' .. '9']*; escapequot = '""'; doubleliteral_helper = (('.' digits) | (digits ('.' [0-9]*)?)) ('e' | 'E') ('+' | '-')? digits; - stringliteral_helper = ( 0x22 (escapequot)* 0x22 ) | - (''' ('''''')* '''); + stringliteral_helper = ( 0x22 (namechar)* 0x22 ) | (''' (namechar)* '''); + + //stringliteral_helper = ( 0x22 (escapequot)* 0x22 ) | + // (''' ('''''')* '''); //doubleliteral_helper = (('.' digits) | // (digits ('.' [0-9]*)?)) ('e' | 'E') ('+' | '-')? digits; //stringliteral_helper = ( 0x22 (escapequot | [char - 0x22])* 0x22 ) | @@ -433,9 +436,9 @@ Tokens underscore = '_'; - integerliteral = digits; + integerliteral = digits+; - decimalliteral = ('.' digits) | (digits '.' [0-9]*); + decimalliteral = ('.' digits+) | (digits+ '.' digits*); doubleliteral = doubleliteral_helper; @@ -593,11 +596,11 @@ Productions forwardaxis_part_eight = T.axis_namespace T.axis_delim; abbrevforwardstep = T.abbrev_attrib? nodetest; - + reversestep = {reverse} reversestep_part | {abbrevreverse} abbrevreversestep; reversestep_part = reverseaxis nodetest; - + reverseaxis = {reverse1} reverseaxis_part_one | {reverse2} reverseaxis_part_two | {reverse3} reverseaxis_part_three | @@ -608,10 +611,10 @@ Productions reverseaxis_part_three = T.axis_preceding_sibling T.axis_delim; reverseaxis_part_four = T.axis_preceding T.axis_delim; reverseaxis_part_five = T.axis_ancestor_or_self T.axis_delim; - - + + abbrevreversestep = T.abbrev_reversestep; - + nodetest = {kind} kindtest | {name} nametest; @@ -700,23 +703,23 @@ Productions texttest = T.fn_text T.lparenth T.rparenth; - + commenttest = T.fn_comment T.lparenth T.rparenth; pitest = T.fn_processing_instruction T.lparenth pitest_part? T.rparenth; pitest_part = {ncname} ncname | {stringlit} stringliteral; - attributetest = T.axis_attribute T.lparenth attributetest_part? T.rparenth; //fn_attribute doesn't work + attributetest = T.axis_attribute T.lparenth attributetest_part? T.rparenth; //fn_attribute doesn't work attributetest_part = attribnameorwildcard attributetest_part_part?; attributetest_part_part = T.comma typename; attribnameorwildcard = {attrib} attributename | {star} T.star; - + schemaattributetest = T.fn_schema_attribute T.lparenth attributedeclaration T.rparenth; - + attributedeclaration = attributename; elementtest = T.fn_element T.lparenth elementtest_part? T.rparenth; @@ -764,9 +767,8 @@ Productions ncname = ncnamestartchar ncnamechar*; /* An XML Name, minus the ":" */ - + ncnamestartchar = {letter} T.letter | {underscore} T.underscore ; - - \ No newline at end of file + -- 2.11.4.GIT