1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs circular combinators continuations hashtables
4 hashtables.private io kernel math namespaces prettyprint
5 quotations sequences splitting html.parser.state strings
6 combinators.short-circuit ;
9 : string-parse-end? ( -- ? ) get-next not ;
11 : trim1 ( seq ch -- newseq )
12 [ [ ?head-slice drop ] [ ?tail-slice drop ] bi ] 2keep drop like ;
14 : quote? ( ch -- ? ) "'\"" member? ;
16 : single-quote ( str -- newstr ) "'" dup surround ;
18 : double-quote ( str -- newstr ) "\"" dup surround ;
20 : quote ( str -- newstr )
22 [ double-quote ] [ single-quote ] if ;
24 : quoted? ( str -- ? )
28 [ [ first ] [ peek ] bi = ]
31 : ?quote ( str -- newstr ) dup quoted? [ quote ] unless ;
33 : unquote ( str -- newstr )
34 dup quoted? [ but-last-slice rest-slice >string ] when ;