>>>>> "SC" == Simon Cozens <[EMAIL PROTECTED]> writes:

  SC> OK, here's how you do it. Run perl -Mre=debug -e '/your regexp/',
  SC> and use Perl to parse the bit in the middle. That's a state machine,
  SC> so we can emulate it with subroutines.

  SC> So, for instance: perl -Mre=debug -e '/fo+bar/'
  SC> ...
  SC>    1: EXACT <f>(3)
  SC>    3: PLUS(6)
  SC>    4:   EXACT <o>(0)
  SC>    6: EXACT <bar>(8)
  SC>    8: END(0)
  SC> ...

  SC> Now we translate that to something like this:
  SC>     sub node_1 { 
  SC>         $state = shift; 
  SC>         while ($_ = substr($state->{string},0,1,"")) {
  SC>             if ($_ eq "f") {
  SC>                 return success if $state->node_3;
  SC>             }
  SC>         }
  SC>         return failure; 
  SC>     }
  SC>     ... and so on ...

  SC> In keeping with tradition, implementation is left as an exercise for
  SC> the reader. :)

that doesn't address larry's point which is very important. the regex
compiler needs to be able to generate the equvilent of the above
directly into perl ops. it would eliminate the separation of the regex
runtime as a black box. we could create special ops that support node
making and traversal and others that execute the low level matches. an
optimizer could then combine some ops into fewer and more specialized
ones.

then regexes can be also debugged in detail with the perl debugger.
that assumes the debugger has access to single stepping ops which is an
intriguing idea. BTW this is the kind of feature that dan wanted the
debugger PDD to have. having this feature supported and running early
on, would allow us to debug the compiler and optimizer using our own
tool. in fact if the debugger supported remote control as well as
internal, then it could be developed in parallel in perl5. this would be
a very useful thing to have during the development of the full perl 6.

uri

-- 
Uri Guttman  ---------  [EMAIL PROTECTED]  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html

Reply via email to