[antlr-interest] Tree Parser vs XPath

Jason Aaron Osgood mrosgood at yahoo.com
Wed Sep 14 13:38:42 PDT 2005


Hi Terr, Everybody-


I've got another goofy idea.  I think all those marshalling and O/R
tools are mightily overwraught.  I want something a lot easier and
lighter.  

I don't know what to call my idea.  "Event triggering streaming parser"
is the best I've come up with.  So I'll describe how I'd like it to
work:

 - Read XML document
 - Fire SAX events
 - Streaming (no in-memory representation)
 - Some XPaths for pattern matching
 - Fire an event (e.g. call a method) whenever there's a match
 - Use templates and stuff for sub-patterns (selecting rulesets)

That's my ideal.  Right now, I'm using SAXON's XSLT and my own
extensions, which just wrap JDBC.  It's tremendously ugly and a pain in
the ass to debug.  But the cool part is I go directly from XML to JDBC
with no intermediate marshalling.  It's pretty fast.

I've been reading up on streaming XPath, XQuery, transducers and the
like.  I don't quite grasp the ideas yet.  But what I've gathered thus
far is that everyone's reading in XML and then emitting XML.  It
shouldn't be *too hard* something to do method calls instead.

However.  I don't want to reinvent.  Much.  Whatever I do, it has to be
easy to customize.  Some users seem to be able to kinda grasp XPath. 
But expecting them to learn ANLTR is expecting too much.  Also, say I
was to blend XPath with method calls.  Pretty soon my new language
would start looking an awful lot like ANTLR, no?

So I've got some questions.

What's the formal difference between ANTLR Tree Parser and XPath?  I
know they're both languages.  Tree Parser is LL(k), right?  What is
XPath?

ANTLR's grammar is like a super-EBNF, right?  Couldn't the rules also
be expressed as XPath-like queries?

Wouldn't it be cool if Parser and Tree Parser permitted streaming?


Cheers, Jason Aaron Osgood / Seattle WA

zappini.blogspot.com


More information about the antlr-interest mailing list