On Thu, Feb 16, 2012 at 6:53 PM, Brian Candler <b.candler / pobox.com> wrote:
> Is there some existing code (preferably ruby) which can take a regular
> expression and
> build a parse tree from it? e.g. I want to turn
>
> "^(foo|(bar|baz)*|qux)$"
>
> into something like this:
>
> =A0 =A0 <seq>
> =A0 =A0/ =A0| =A0\
> <bol> =A0| =A0 <eol>
> =A0 =A0 <alt>
> =A0 / =A0 | =A0 \
> foo =A0 <*> =A0 qux
> =A0 =A0 =A0 |
> =A0 =A0 <alt>
> =A0 =A0 / =A0 \
> =A0 bar =A0 baz
>
> or some equivalent representation of the regular expression itself.
>
> (The trouble is, when you google for 'ruby regular expression parser'
> you get all sorts of parsers written *using* regular expressions, not
> parsers *for* regular expressions!)

I don't have a good answer for your problem, but this question
reminded me of an old rubyquiz I have fond memories of :)

http://www.rubyquiz.com/quiz143.html

Jesus.