[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Are XPath expressions parsed using compiler parsi

Subject: Re: Are XPath expressions parsed using compiler parsingtechniques?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 9 May 2022 22:42:43 -0000
Re:  Are XPath expressions parsed using compiler  parsi
The XPath parser used in Saxon is a hand-written hybrid of a recursive-descent
parser and a precedence parser.

The very first version was actually derived from James Clark's xt parser, and
over the years it evolved out of all recognition, but without ever being
redesigned from scratch. I have no idea if throwing it away and starting again
with a generated parser would give any benefits. I suspec that having a
hand-written parser gives us more control over diagnostics and error recovery,
and it also enables us to support multiple grammars (different versions of
XPath and XQuery, plus XSLT patterns) within a single parsing framework.

XPath (and even more so XQuery) has a lot of ad-hoc rules for resolving
ambiguities, for example the rule that in the expression (/ or /*), "or"
parses as an element name, not as a binary operator (I don't think this
ambiguity was even discovered for many years after XPath 1.0 was published).
Again, I think it's probably easier to implement such ad-hoc rules with a
hand-written parser. But someone who understands a particular parser generator
well could probably find a way to do it.

Michael Kay
Saxonica

> On 9 May 2022, at 21:35, Roger L Costello costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Roger wrote:
>
>>> Are XPath expressions parsed using
>>> compiler parsing algorithms?
>
> Michael Kay responded:
>
>> Yes, of course
>
> Hi Michael, does that mean each time Saxon encounters a place in an XSLT
program where an XPath expression is expected, Saxon sends the expression into
an XPath parser which tokenizes the expression, parses it into a syntax tree,
and then traverses the tree to evaluate the expression? Did you use a parser
generator to auto-generate the parser? If yes, which parser generator did you
use? If you didn't use a parser generator, why not?
>
> /Roger

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.