[gforth] / gforth / regexp.fs  

gforth: gforth/regexp.fs

Diff for /gforth/regexp.fs between version 1.23 and 1.24

version 1.23, Sun Sep 12 22:04:06 2010 UTC version 1.24, Sun Oct 10 19:34:16 2010 UTC
Line 226 
Line 226 
 \ idea: try to match one alternative and then the rest of regexp.  \ idea: try to match one alternative and then the rest of regexp.
 \ if that fails, jump back to second alternative  \ if that fails, jump back to second alternative
   
 : JOINs ( sys -- )  BEGIN  dup  WHILE  ]] JOIN [[  REPEAT  drop ;  : THENs ( sys -- )  BEGIN  dup  WHILE  ]] THEN [[  REPEAT  drop ;
   
 : {{ ( addr -- addr addr ) \ regexp-pattern  : {{ ( addr -- addr addr ) \ regexp-pattern
     \G Start of alternatives      \G Start of alternatives
     0 ]] dup BEGIN [[  vars @ ; immediate      0 ]] dup dup FORK  IF  2drop true ;S  BUT  JOIN [[ vars @ ; immediate
 : || ( addr addr -- addr addr ) \ regexp-pattern  : || ( addr addr -- addr addr ) \ regexp-pattern
     \G separator between alternatives      \G separator between alternatives
     vars @ varsmax @ max varsmax !      vars @ varsmax @ max varsmax !  vars !
     ]] dup FORK  IF  2drop true  ;S THEN  [[ >r >r >r vars !      ]] AHEAD  BUT  THEN  drop [[
     ]] DONE drop dup [[ r> r> r> ]] BEGIN [[ vars @ ; immediate      ]] dup dup FORK  IF  2drop true ;S  BUT  JOIN [[ vars @ ; immediate
 : }} ( addr addr -- addr ) \ regexp-pattern  : }} ( addr addr -- addr ) \ regexp-pattern
     \G end of alternatives      \G end of alternatives
     vars @ varsmax @ max vars !      vars @ varsmax @ max vars !  drop
     ]] dup FORK  IF  2drop true  ;S THEN drop dup [[ >r >r >r drop      ]] AHEAD  BUT  THEN  2drop false ;S [[  THENs ; immediate
     ]] DONE drop LEAVE ;S  [[ r> r> r> JOINs ; immediate  
   
 \ match variables  \ match variables
   


Generate output suitable for use with a patch program
Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help