[gforth] / gforth / regexp.fs  

gforth: gforth/regexp.fs

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

version 1.16, Sat Sep 4 21:34:23 2010 UTC version 1.17, Sun Sep 5 19:09:55 2010 UTC
Line 101 
Line 101 
 : ` ( "char" -- ) \ regexp-pattern  : ` ( "char" -- ) \ regexp-pattern
     \G check for particular char      \G check for particular char
     ]] count [[  char ]] Literal <> ?LEAVE [[ ;  immediate      ]] count [[  char ]] Literal <> ?LEAVE [[ ;  immediate
   : -` ( "char" -- ) \ regexp-pattern
 \ A word for string comparison      \G check for particular char
       ]] count [[  char ]] Literal = ?LEAVE [[ ;  immediate
 : $= ( addr1 addr2 u -- f )  tuck compare ;  
 : ,=" ( addr u -- ) tuck ]] dup SLiteral $= ?LEAVE Literal + noop [[ ;  
 : =" ( <string>" -- ) \ regexp-pattern  
     \G check for string  
     '" parse ,=" ; immediate  
   
 \ loop stack  \ loop stack
   
Line 150 
Line 145 
     \G check for string end      \G check for string end
     ]] end-rex? ?LEAVE [[ ; immediate      ]] end-rex? ?LEAVE [[ ; immediate
   
   \ A word for string comparison
   
   : ,=" ( addr u -- ) tuck ]] dup SLiteral tuck compare ?LEAVE Literal + noop [[ ;
   : =" ( <string>" -- ) \ regexp-pattern
       \G check for string
       '" parse ,=" ; immediate
   
 \ regexp block  \ regexp block
   
 \ FORK/JOIN are like AHEAD THEN, but producing a call on AHEAD  \ FORK/JOIN are like AHEAD THEN, but producing a call on AHEAD
Line 263 
Line 265 
 0 Value >>ptr  0 Value >>ptr
 0 Value <<ptr  0 Value <<ptr
 Variable >>string  Variable >>string
 : >>  ( addr -- addr ) \ regexp-replace  : s>>  ( addr -- addr ) \ regexp-replace
     \G Start replace pattern region      \G Start replace pattern region
     dup to >>ptr ;      dup to >>ptr ;
 : << ( run-addr addr u -- run-addr ) \ regexp-replace  : << ( run-addr addr u -- run-addr ) \ regexp-replace
Line 283 
Line 285 
 : >>rest ( -- ) >>next >>string $+! ;  : >>rest ( -- ) >>next >>string $+! ;
 : s// ( addr u -- ptr )  : s// ( addr u -- ptr )
     \G start search/replace loop      \G start search/replace loop
     ]] >>string0 (( // >> [[ ; immediate      ]] >>string0 (( // s>> [[ ; immediate
   : >> ( addr -- addr )
       ]] <<ptr >>ptr u> ?LEAVE ?end [[ ; immediate
   : //s ( ptr -- )
       \G search end
       ]] )) drop >>rest >>string@ [[ ; immediate
 : //o ( ptr addr u -- addr' u' )  : //o ( ptr addr u -- addr' u' )
     \G end search/replace single loop      \G end search/replace single loop
     ]] << )) drop >>rest >>string@ [[ ; immediate      ]] << //s [[ ; immediate
 : //g ( ptr addr u -- addr' u' )  : //g ( ptr addr u -- addr' u' )
     \G end search/replace all loop      \G end search/replace all loop
     ]] << LEAVE )) drop >>rest >>string@ [[ ; immediate      ]] << LEAVE //s [[ ; immediate


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

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help