Hi,
In the lack of any good free XPath 2.0 implementations for .Net build upon Linq to XML I have thought about implementing my own (also for the experience). But just to be clear (and not building something that exists) these are the XPath 2.0 implementations I have found:
- Saxon .Net
- Query Machine - I had problems with this - exceptions with the examples
- XQSharp - may be good, but is commercial (single developer ~300 $)
Now, I want some thoughts on how difficult it is to implementing some language such as XPath 2.0 expressions. I have found this link which have a EBNF for XPath 2.0 expression: http://www.w3.org/TR/2007/REC-xpath20-20070123/#id-grammar and I'm thinking of making it in F# with the fslex/fsyacc combination.
My background (subjective): I have played with these tools before, but only for some simple expressions and a very simple programming language. Furthermore, I have read most of the Dragon book and Appel´s Modern compiler implementation in ML - but unfortunately, I have not put the theory in practice while reading. I've studied computer science in a year now where I have completed courses with theory about ex finite automaton
, CFL
and algorithms but I have been a developer for years before university (a few years with professional jobs - back-end of websites mainly).
Now, the steps of parsing and what I tend to cover:
- Lex - Parsing - Reductions: FsLex/FsYacc. I will properly not cover ALL of Xpath 2.0 at first but at least all of what XPath 1.0 can do + a little more.
- Sematic analysis - I'm not sure about how much there is to this
- Optimization - I do not tend to cover this (at least not at first)
- Actual traversing etc.
- ...?
Now, the concrete questions in addition to the above:
- How difficult is it to make a parser of this size? based on my background, would I could to it?
- Is there any crucial steps I have missed in regards to XPath 2.0 in particular?
- Is there any technology I have missed; Do I have to cover more than just XPath 2.0 and
XDocument
etc. to be able to make the parser?
To be clear: I want to make a XPath 2.0 expression parser and traverse XDocument
etc. with this parsed expression. Which I guess combined is a query engine.
Update: I found this: http://www.w3.org/2007/01/applets/xpathApplet.html which contains code to parsing and traversing. I think it would be a nice start or reference :-)
Your answers will be appreciated.