Markus
10/5/2004 3:15:00 PM
On Tue, 2004-10-05 at 07:04, James Edward Gray II wrote:
> On Oct 5, 2004, at 4:09 AM, Brian Schröder wrote:
>
> > Regular expressions are not able to "count" more than a finite number
> > of states, and the number of states is fixed at compile time. That is
> > because regular expressions map to finite automata. So it is
> > impossible to match opening and closing braces in an unknown
> > expression. For this to work always you need a model that can enter
> > unbounded many states.
>
> Just for the sake of clarity, you are speaking of Ruby's regular
> expressions here. Perl's regex engine has no such limitation. Using
> the (?? ... ) construct, Perl regular expressions can parse balanced
> delimiters. I miss this feature and would love to see Ruby add
> something similar in the future.
I think Brian's point is true of regular expressions in general,
not any particular implementation. If the perl idiom you mention can in
fact do general purpose matching of unbounded depth, it doesn't mean
that "regular expressions" can do this, but rather that Larry has
implemented a more powerful parser and (incorrectly) called it "regular
expressions."
If this isn't clear, consider an analogy: if I write a language and
include a trailing-dot-digit idiom, such that 1.6 can be used as an
integer, does it mean that '1.6' is an now integer or that I've
implemented some form of reals numbers and mislabeled them 'integers'?
-- Markus