! Copyright (C) 2005, 2009 Daniel Ehrenberg, Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors circular combinators.short-circuit fry io
-kernel locals math math.order sequences sorting.functor
-sorting.slots unicode.categories ;
+USING: accessors circular combinators.short-circuit io kernel
+math math.order sequences sequences.parser sequences.private
+sorting.functor sorting.slots unicode ;
IN: sequences.parser
TUPLE: sequence-parser sequence n ;
: <safe-slice> ( from to seq -- slice/f )
3dup {
[ 2drop 0 < ]
- [ [ drop ] 2dip length > ]
+ [ nipd length > ]
[ drop > ]
- } 3|| [ 3drop f ] [ slice boa ] if ; inline
+ } 3|| [ 3drop f ] [ <slice-unsafe> ] if ; inline
:: take-sequence ( sequence-parser sequence -- obj/f )
sequence-parser [ n>> dup sequence length + ] [ sequence>> ] bi