[gforth] / gforth / regexp.fs  

gforth: gforth/regexp.fs

Diff for /gforth/regexp.fs between version 1.17 and 1.18

version 1.17, Sun Sep 5 19:09:55 2010 UTC version 1.18, Sun Sep 5 22:18:54 2010 UTC
Line 223 
Line 223 
 \ 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
   
 : THENs ( sys -- )  BEGIN  dup  WHILE  ]] THEN [[  REPEAT  drop ;  : JOINs ( sys -- )  BEGIN  dup  WHILE  ]] JOIN [[  REPEAT  drop ;
   
 : {{ ( addr -- addr addr ) \ regexp-pattern  : {{ ( addr -- addr addr ) \ regexp-pattern
     \G Start of alternatives      \G Start of alternatives
Line 231 
Line 231 
 : || ( 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 !
     ]] nip AHEAD [[ >r >r >r vars !      ]] dup FORK  IF  2drop true  EXIT THEN  drop dup [[ >r >r >r vars !
     ]] DONE drop dup [[ r> r> r> ]] BEGIN [[ vars @ ; immediate      ]] DONE drop dup [[ r> r> r> ]] BEGIN [[ vars @ ; immediate
 : }} ( addr addr -- addr addr ) \ regexp-pattern  : }} ( addr addr -- addr addr ) \ regexp-pattern
     \G end of alternatives      \G end of alternatives
     vars @ varsmax @ max vars !      vars @ varsmax @ max vars !
     ]] nip AHEAD [[ >r >r >r drop      ]] dup FORK  IF  2drop true  EXIT THEN  drop dup [[ >r >r >r drop
     ]] DONE drop LEAVE [[ r> r> r> THENs ; immediate      ]] DONE drop LEAVE [[ r> r> r> JOINs ; immediate
   
 \ match variables  \ match variables
   


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

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help