Wednesday 18 February, 2004
#I have an almost working XPath grammar. Yay!
D:\work\JezUK\Arabica\xpathic>Debug\xpathic.exe
Hello
'text' parses OK
'comment' parses OK
'text()' parses OK
'processing-instruction('poo')' parses OK
'processing-instruction("poo")' parses OK
'processing-instruction()' parses OK
'self::name' parses OK
'@fruit' parses OK
'one/two' parses OK
'one/@fruit' parses OK
'one/@fruit[1]' parses OK
'one/descendant-or-self::woot[1]' parses OK
'one/two/three' parses OK
'one/two/three[1]' parses OK
'one/two[1]/three' parses OK
'/one/two' parses OK
'/one[1]/two[2]/comment()' parses OK
'/one[1]/two[2][1]' parses OK
'//one' parses OK
'//one/two' parses OK
'//one/two//@id' parses OK
'one/two/three[@attr]' parses OK
'one/two/three[@attr][1]' parses OK
'one/two/three[four/@attr]' parses OK
'one/two/three[@attr='nob']' fails Parsing
'one/two/three[position() = first()]' fails Parsing
'one/two/three[(@attr) or (@id)]' fails Parsing
If you're interested, the code is in the CVS as xpath-dev-sandbox. You'll need a current version on Boost, or Spirit 1.6.
So far, it is just the grammar, but everything else is just a simple matter of programming ...