On Thu, 2 Oct 2008, Tim Bunce wrote:

On Wed, Oct 01, 2008 at 11:24:04PM -0400, Brandon S. Allbery KF8NH wrote:
On 2008 Oct 1, at 22:23, Timothy S. Nelson wrote:
On Wed, 1 Oct 2008, Brandon S. Allbery KF8NH wrote:
On 2008 Oct 1, at 22:14, Timothy S. Nelson wrote:
        Hi all.  I've enjoyed(?) reading over the February/March thread
entitled "Musings on operator overloading".  I've brought a few thoughts
along; if they're old news, please tell me
here to do more reading on it :).

The Perl6 way to do this is grammars; using an XML grammar to pull data
out of an XML document is one of Larry's favorite examples.

        Ok, great.  While I see how this does a great job of converting the
string of data into a plex, it doesn't solve the problem of selecting the
data from the plex in a glob-like (or XPath-like) fashion, which is what
I'm talking about here.  Have I missed something that will do that?

I could have sworn there was a short and elegant example of using a grammar
to extract arbitrary information from an XML document, but I don't see it
in the documentation.  I recall Trey Harris showing such an example on IRC
but not in a logged channel; maybe he'll see this message and jump in, or
if not I'll see if I can get him to write another example.

The key point Brandon is making, that I'm not sure you're answering,

        You probably mean "OtherTim" (ie. me) instead of "Brandon" here :).

is that he wants to extract elements of a tree-like data structure
(think DOM), not simply from a string representation of a structure
(such as an XML document in a string).

Thinking in terms of grammars, I'd ask the question: could grammars be
used to match tree-like data structures? I think the current answer is no.
Grammars are too tightly bound to the concept of a position in a linear
string.

I think Grammars would be great for turning a string into a tree. But I agree with you in that I don't see how they apply to what I'm talking about :).

But I have a nagging suspicion that this is a very powerful idea.
Applying the expressive power of a grammar-like mechanism to
search, backtrack, and match within a tree-like data structure.

Is this new or has anyone discussed it before?

Not sure what you mean by "backtrack" in this context; I was envisioning that the thing return an array of tree nodes (although, now that I think about it, it could be useful as an iterator too :) ). But that doesn't seem to be quite what you're thinking, and so I'd be interested in hearing more about that too.

        :)


---------------------------------------------------------------------
| Name: Tim Nelson                 | Because the Creator is,        |
| E-mail: [EMAIL PROTECTED]    | I am                           |
---------------------------------------------------------------------

----BEGIN GEEK CODE BLOCK----
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-
-----END GEEK CODE BLOCK-----

Reply via email to