Redesigning regex syntax (Was: Re: RFC for recursive regexps)

2000-08-03 Thread Johan Vromans

Damian Conway [EMAIL PROTECTED] writes:

 Of course, that example might in itself be sufficient reason
 to completely redesign the regex syntax!

Perl uses the term "pattern matching" since day one. This opens the
possibility of extending pattern matching with other, not neccessarily
regex based, mechanisms.

In particular, I'd like to be  able to tack variables and functions to
pattern elements. For example (the syntax is irrelevant):

  (:func($x1,$x2,$x3): # will be called if this pattern succeeds
 (:$x1:...pattern...)  # $x1 gets the value of this sub match 
 ...maybe more...
 (:$x2:...pattern...)  # $x2 gets the value of this sub match 
 (:$x3:...pattern...)  # $x3 gets the value of this sub match 
 ...you get the idea by now...
  )

Two cases are possible: one that does the assignments and calls only
when the complete pattern succeeds, and one that does it when the
sub-pattern succeeds (which may be multiple times is backtracking is
involved). 

SNOBOL lovers will recognize the behavior of the '.' and '$' operators
that tie variables to pattern elements.

-- Johan



Re: RFC for recursive regexps

2000-08-02 Thread Damian Conway

In perl5,

  /(??{ $FOO })/

delays the interpolation of $FOO, so as to be able to have
recursively defined regexps.

Of course, that example might in itself be sufficient reason
to completely redesign the regex syntax!


Damian

PS: I'll probably have a RFC on that issue ;-)