From: Eric Mahurin Date: 2005-08-21T04:28:12+09:00 Subject: Re: object pattern matching --- "Ara.T.Howard" wrote: > On Sun, 21 Aug 2005, Phil Tomson wrote: > > > In article <43076BDE.2070103@neurogami.com>, > > James Britt wrote: > >> Ara.T.Howard wrote: > >>> On Sun, 21 Aug 2005, James Britt wrote: > >>> > >>>> ... > >>>> > >>>> Isn't there a Ruby project that allows one to run > regexen over object > >>>> hierarchies? > >>> > >>> > >>> dunno... i seem to recall something too but searching > the raa didn't > >>> bring up > >>> any hits? > >>> > >> > >> I was selling some folks on Ruby recently, and mentioned > this project, > >> and I swore I had saved off the initial announcement > because it struck > >> me as one of those things that did solve any immediate > problems but > >> seemed so slick that I knew it would come in handy. > >> > >> > >> Now I can't find it. :( > >> > >> > > > > I think you're looking for Reg: > > > > http://rubyforge.org/projects/reg/ > > > > Reg is a library for pattern matching in ruby data > structures. Reg > > provides Regexp-like match and match-and-replace for all > data structures > > (particularly Arrays, Objects, and Hashes), not just > Strings. From my communications with Caleb, I believe he'll be changing the interface to look more like Regexp. This will help in places where you have ducked-type places that deal with Regexp-like objects. An example is some of the scan_pattern* methods I'll be adding to Cursor (not released yet). I think he might add the ability to operate on a Cursor directly also, but I'm not sure about that. A Cursor by the way is something generic that can look kind of like a Array, String, IO, C++ iterator, Java stream, etc. all rolled into one API. I have many derived classes that operate on a variety of sequential data structures. In addition I'm putting together Grammar which will also be able to operate on any sequential data structure - as long as you can give it a subset of the Cursor API. You'll be able to write a lexer (operates on characters) and a parser (operates on tokens) in a uniform way. Similar to ANTLR, but more unification. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com