----- Original Message -----
From: "Chris Pine" <nemo / hellotree.com>
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Wednesday, April 16, 2003 10:57 AM
Subject: Re: regular expressions


> ----- Original Message -----
> From: "Hal E. Fulton" <hal9000 / hypermetrics.com>
>
> <snip>
> I would have done it something like this:
>
>   myreg = RegexLang.new(<<EOF)
>   # This would be a full-featured regex
>   # language "script" with keywords instead
>   # of punctuation; comments allowed; etc.
>   blah blah blah...
>   EOF
> ----------------------------
>
> That's very much like what I was thinking of, too!  I was thinking that we
> should also send a binding along, so we could use local variables if we
> wanted to.
>
> About Rockit:
>
> It seems like Rockit might indeed be the way to *implement* this, but that
> says nothing about the syntax/grammar to use in the heredoc.
>
> Also, this means we could get rid of the delimiters altogether, which is
> nice.  The only thing I don't like is that we wouldn't be able to toss a
> small one on one line, and we would have to precede them all with:
>
>   RegexLang.new(binding,<<EOF)
>
> or something.

Glad we're thinking alike... maybe this idea
is not dead after all?

Passing in a binding is a good idea. But I
think it should be the second param and default
to nil.

I also think there should be a debugging option,
so we can print out submatches and such, if we
need to.

And I favor a way to bind submatches to Ruby
variables within the notation, so that we might
almost never need to call #match and do explicit
assignments.

If the notation is "Ruby-like" (i.e., with
statement terminators allowed but optional)
we could still do one-liners. So these two
would be equivalent:

  pattern = RegexLang.new(<<EOF)
  foo
  bar
  baz
  EOF

  pattern2 = RegexLang.new("foo;bar;baz")

Now, your thoughts? Or those of others?

Hal