All pastes #238492 Raw Edit

Something

public text v1 · immutable
·published 2006-11-05 00:28 UTC
rendered paste body
: unparsed-start ( -- addr )
    source drop >in @ + ;

: input-eof ( -- 0 | -1 )
    unparsed-start source + = ;

: next-input-character ( -- char )
    unparsed-start c@ >in @ 1+ >in ! ;

\ search the character char
\ addr1: start of the input buffer (unparsed on word enter)
\ addr2: address of the character or end of input buffer
: search-char ( char -- addr1 addr2 )
    >r unparsed-start
    begin
        input-eof if r> drop unparsed-start exit then
        next-input-character r@ = if r> drop unparsed-start 1- exit then
    again ;

\ same as Forth "parse", see http://claymore.engineer.gvsu.edu/~steriana/Software/pf11/ANS/dpans6.htm#6.2.2008
: parse
    search-char
    over - ;

\ usage example
char ' parse ab'