[xsl] XPath and Recursive Descent Parsers

Subject: [xsl] XPath and Recursive Descent Parsers
From: martin@xxxxxxxx
Date: Thu, 10 Apr 2003 13:56:46 +0000 (GMT)
hi,

has anyone tried using recursive descent to parse XPath expressions?

I've written a recursive descent parser generator in XSLT, i want to
generate an XPath parser, but wondering if i'm going to run into problems
with my left-recursion eliminations.

to avoid infinite recursion i've rewritten left-recursive rules, for
example, from ->

relativeLocationPath ::= step
		| relativeLocationPath '/' step
		| relativeLocationPath '//' step

to ->

relativeLocationPath ::= step relativeLocationPathRest

relativeLocationPathRest ::= '/' step relativeLocationPathRest
		| '//' step relativeLocationPathRest
		|

pretty standard. however, this will make the expressions right-associative
instead of left, so i might end up with:

<relativeLocationPath>
	<step/>
	<relativeLocationPath>
		<step/>
	</relativeLocationPath>
<relativeLocationPath>

etc instead of

<relativeLocationPath>
	<relativeLocationPath>
		<step/>
	</relativeLocationPath>
	<step/>
<relativeLocationPath>

i'm not sure if this is really a problem for the semantic of the
expressions though.

just thought maybe someone's done this already and concluded it's not
feasible, would save me a lot of trouble!

cheers,

/m

Martin Klang
http://www.o-xml.org - the object-oriented XML programming language


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread