| : ` ( "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 |
| |
|
| \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 |
| 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 |
| \G Replace string from start of replace pattern region with |
\G Replace string from start of replace pattern region with |
| \G @var{addr} @var{u} |
\G @var{addr} @var{u} |
| <<ptr 0= IF start$ to <<ptr THEN |
|
| >>string @ 0= IF s" " >>string $! THEN |
|
| <<ptr >>ptr over - >>string $+! |
<<ptr >>ptr over - >>string $+! |
| >>string $+! dup to <<ptr ; |
>>string $+! dup to <<ptr ; |
| : <<" ( "string<">" -- ) \ regexp-replace |
: <<" ( "string<">" -- ) \ regexp-replace |
| \G @var{string} |
\G @var{string} |
| '" parse postpone SLiteral postpone << ; immediate |
'" parse postpone SLiteral postpone << ; immediate |
| : >>string@ ( -- addr u ) |
: >>string@ ( -- addr u ) |
| >>string $@ >>string off |
>>string $@ ; |
| 0 to >>ptr 0 to <<ptr ; |
: >>string0 ( addr u -- addr u ) s" " >>string $! |
| |
0 to >>ptr over to <<ptr ; |
| : >>next ( -- addr u ) <<ptr end$ over - ; |
: >>next ( -- addr u ) <<ptr end$ over - ; |
| : >>rest ( -- ) >>next >>string $+! ; |
: >>rest ( -- ) >>next >>string $+! ; |
| : s// ( addr u -- ptr ) |
: s// ( addr u -- ptr ) |
| \G start search/replace loop |
\G start search/replace loop |
| ]] (( // >> [[ ; 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 >>string@ [[ ; immediate |
]] << LEAVE //s [[ ; immediate |