\ 4tH library - COMUS SKIP/SCAN - Copyright 2003,2007 J.L. Bezemer
\ You can redistribute this file and/or modify it under
\ the terms of the GNU General Public License

\ Load definitions when needed
[UNDEFINED] ?NOT [IF]
[NEEDS lib/yesno.4th]
[THEN]

[UNDEFINED] SPLIT [IF]
: (SCAN)
  IS ?NOT >R BEGIN DUP IF OVER C@ R@ = ?NOT ELSE DUP THEN
  WHILE CHOP REPEAT R> DROP ;
 
: SKIP ['] (YES) (SCAN) ; ( a1 n1 c -- a2 n2) ( G: SKIP CHARACTERS )
: SCAN ['] (NO)  (SCAN) ; ( a1 n1 c -- a2 n2) ( G: SCAN STRING )
: SPLIT >R 2DUP R> SCAN ROT >R ROT >R DUP 2R> ROT - ;
                          ( a1 n1 c -- a1 n3 a2 n4)
[DEFINED] 4TH# [IF]
hide (SCAN)
[THEN]
[THEN]
