factor: CHAR: -> char:
parent
b9d2e154c5
commit
a85ae72783
|
@ -503,7 +503,7 @@ M: double-2-rep rep-component-type drop double ;
|
|||
GENERIC: pointer-string ( pointer -- string/f )
|
||||
M: object pointer-string drop f ;
|
||||
M: word pointer-string name>> ;
|
||||
M: pointer pointer-string to>> pointer-string [ CHAR: * suffix ] [ f ] if* ;
|
||||
M: pointer pointer-string to>> pointer-string [ char: * suffix ] [ f ] if* ;
|
||||
|
||||
GENERIC: c-type-string ( c-type -- string )
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ CONSTANT: mach-map {
|
|||
mach-map cpu of { "libc6" } or ;
|
||||
|
||||
: name-matches? ( lib triple -- ? )
|
||||
first swap ?head [ ?first CHAR: . = ] [ drop f ] if ;
|
||||
first swap ?head [ ?first char: . = ] [ drop f ] if ;
|
||||
|
||||
: arch-matches? ( lib triple -- ? )
|
||||
[ drop ldconfig-arch ] [ second swap subset? ] bi* ;
|
||||
|
|
|
@ -21,7 +21,7 @@ ERROR: bad-array-type ;
|
|||
: (parse-c-type) ( string -- type )
|
||||
{
|
||||
{ [ "*" ?tail ] [ (parse-c-type) <pointer> ] }
|
||||
{ [ CHAR: ] over member? ] [ parse-array-type ] }
|
||||
{ [ char: ] over member? ] [ parse-array-type ] }
|
||||
{ [ dup search ] [ parse-word ] }
|
||||
[ parse-word ]
|
||||
} cond ;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
USING: ascii kernel math sequences strings tools.test ;
|
||||
|
||||
{ t } [ CHAR: a letter? ] unit-test
|
||||
{ f } [ CHAR: A letter? ] unit-test
|
||||
{ f } [ CHAR: a LETTER? ] unit-test
|
||||
{ t } [ CHAR: A LETTER? ] unit-test
|
||||
{ t } [ CHAR: 0 digit? ] unit-test
|
||||
{ f } [ CHAR: x digit? ] unit-test
|
||||
{ t } [ char: a letter? ] unit-test
|
||||
{ f } [ char: A letter? ] unit-test
|
||||
{ f } [ char: a LETTER? ] unit-test
|
||||
{ t } [ char: A LETTER? ] unit-test
|
||||
{ t } [ char: 0 digit? ] unit-test
|
||||
{ f } [ char: x digit? ] unit-test
|
||||
|
||||
{ 4 } [
|
||||
0 "There are Four Upper Case characters"
|
||||
[ LETTER? [ 1 + ] when ] each
|
||||
] unit-test
|
||||
|
||||
{ t f } [ CHAR: \s ascii? 400 ascii? ] unit-test
|
||||
{ t f } [ char: \s ascii? 400 ascii? ] unit-test
|
||||
|
||||
{ "HELLO HOW ARE YOU?" } [ "hellO hOw arE YOU?" >upper ] unit-test
|
||||
{ "i'm good thx bai" } [ "I'm Good THX bai" >lower ] unit-test
|
||||
|
|
|
@ -6,10 +6,10 @@ IN: ascii
|
|||
|
||||
: ascii? ( ch -- ? ) 0 127 between? ; inline
|
||||
: blank? ( ch -- ? ) " \t\n\r" member? ; inline
|
||||
: letter? ( ch -- ? ) CHAR: a CHAR: z between? ; inline
|
||||
: LETTER? ( ch -- ? ) CHAR: A CHAR: Z between? ; inline
|
||||
: digit? ( ch -- ? ) CHAR: 0 CHAR: 9 between? ; inline
|
||||
: printable? ( ch -- ? ) CHAR: \s CHAR: ~ between? ; inline
|
||||
: letter? ( ch -- ? ) char: a char: z between? ; inline
|
||||
: LETTER? ( ch -- ? ) char: A char: Z between? ; inline
|
||||
: digit? ( ch -- ? ) char: 0 char: 9 between? ; inline
|
||||
: printable? ( ch -- ? ) char: \s char: ~ between? ; inline
|
||||
: control? ( ch -- ? ) { [ 0 0x1F between? ] [ 0x7F = ] } 1|| ; inline
|
||||
: quotable? ( ch -- ? ) { [ printable? ] [ "\"\\" member? not ] } 1&& ; inline
|
||||
: Letter? ( ch -- ? ) { [ letter? ] [ LETTER? ] } 1|| ; inline
|
||||
|
|
|
@ -23,13 +23,13 @@ CONSTANT: alphabet
|
|||
alphabet nth ; inline
|
||||
|
||||
: base64>ch ( ch -- ch )
|
||||
$[ alphabet alphabet-inverse 0 CHAR: = pick set-nth ] nth
|
||||
$[ alphabet alphabet-inverse 0 char: = pick set-nth ] nth
|
||||
[ malformed-base64 ] unless* ; inline
|
||||
|
||||
: (write-lines) ( column byte-array -- column' )
|
||||
output-stream get dup '[
|
||||
_ stream-write1 1 + dup 76 = [
|
||||
drop B{ CHAR: \r CHAR: \n } _ stream-write 0
|
||||
drop B{ char: \r char: \n } _ stream-write 0
|
||||
] when
|
||||
] each ; inline
|
||||
|
||||
|
@ -43,7 +43,7 @@ CONSTANT: alphabet
|
|||
|
||||
: encode-pad ( seq n -- byte-array )
|
||||
[ 3 0 pad-tail encode3 ] [ 1 + ] bi* head-slice
|
||||
4 CHAR: = pad-tail ; inline
|
||||
4 char: = pad-tail ; inline
|
||||
|
||||
: (encode-base64) ( stream column -- )
|
||||
3 pick stream-read dup length {
|
||||
|
@ -77,7 +77,7 @@ PRIVATE>
|
|||
|
||||
: decode4 ( seq -- )
|
||||
[ 0 [ base64>ch swap 6 shift bitor ] reduce 3 >be ]
|
||||
[ [ CHAR: = = ] count ] bi
|
||||
[ [ char: = = ] count ] bi
|
||||
[ write ] [ head-slice* write ] if-zero ; inline
|
||||
|
||||
: (decode-base64) ( stream -- )
|
||||
|
|
|
@ -14,11 +14,11 @@ MACRO: formatted ( spec -- quot )
|
|||
} cond
|
||||
] map [ cleave ] curry ;
|
||||
|
||||
: pad-00 ( n -- str ) number>string 2 CHAR: 0 pad-head ;
|
||||
: pad-00 ( n -- str ) number>string 2 char: 0 pad-head ;
|
||||
|
||||
: pad-0000 ( n -- str ) number>string 4 CHAR: 0 pad-head ;
|
||||
: pad-0000 ( n -- str ) number>string 4 char: 0 pad-head ;
|
||||
|
||||
: pad-00000 ( n -- str ) number>string 5 CHAR: 0 pad-head ;
|
||||
: pad-00000 ( n -- str ) number>string 5 char: 0 pad-head ;
|
||||
|
||||
: write-00 ( n -- ) pad-00 write ;
|
||||
|
||||
|
|
|
@ -28,16 +28,16 @@ ERROR: invalid-timestamp-format ;
|
|||
: read-sp ( -- token ) " " read-token ;
|
||||
|
||||
: signed-gmt-offset ( dt ch -- dt' )
|
||||
{ { CHAR: + [ 1 ] } { CHAR: - [ -1 ] } } case time* ;
|
||||
{ { char: + [ 1 ] } { char: - [ -1 ] } } case time* ;
|
||||
|
||||
: read-rfc3339-gmt-offset ( ch -- dt )
|
||||
{
|
||||
{ f [ instant ] }
|
||||
{ CHAR: Z [ instant ] }
|
||||
{ char: Z [ instant ] }
|
||||
[
|
||||
[
|
||||
read-00 hours
|
||||
read1 { { CHAR: : [ read-00 ] } { f [ 0 ] } } case minutes
|
||||
read1 { { char: : [ read-00 ] } { f [ 0 ] } } case minutes
|
||||
time+
|
||||
] dip signed-gmt-offset
|
||||
]
|
||||
|
@ -58,7 +58,7 @@ ERROR: invalid-timestamp-format ;
|
|||
read-ymd
|
||||
"Tt \t" expect
|
||||
read-hms
|
||||
read1 { { CHAR: . [ read-rfc3339-seconds ] } [ ] } case
|
||||
read1 { { char: . [ read-rfc3339-seconds ] } [ ] } case
|
||||
read-rfc3339-gmt-offset
|
||||
<timestamp> ;
|
||||
|
||||
|
@ -66,7 +66,7 @@ ERROR: invalid-timestamp-format ;
|
|||
[ (rfc3339>timestamp) ] with-string-reader ;
|
||||
|
||||
: parse-rfc822-military-offset ( string -- dt )
|
||||
first CHAR: A - {
|
||||
first char: A - {
|
||||
-1 -2 -3 -4 -5 -6 -7 -8 -9 f -10 -11 -12
|
||||
1 2 3 4 5 6 7 8 9 10 11 12 0
|
||||
} nth hours ;
|
||||
|
@ -101,7 +101,7 @@ CONSTANT: rfc822-named-zones H{
|
|||
|
||||
: (rfc822>timestamp) ( -- timestamp )
|
||||
"," read-token day-abbreviations3 member? check-timestamp drop
|
||||
read1 CHAR: \s assert=
|
||||
read1 char: \s assert=
|
||||
read-sp checked-number
|
||||
read-sp month-abbreviations index 1 + check-timestamp
|
||||
read-sp checked-number -rot swap
|
||||
|
@ -117,7 +117,7 @@ CONSTANT: rfc822-named-zones H{
|
|||
|
||||
: (cookie-string>timestamp-1) ( -- timestamp )
|
||||
"," read-token check-day-name
|
||||
read1 CHAR: \s assert=
|
||||
read1 char: \s assert=
|
||||
"-" read-token checked-number
|
||||
"-" read-token month-abbreviations index 1 + check-timestamp
|
||||
read-sp checked-number -rot swap
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
USING: checksums checksums.adler-32 strings tools.test ;
|
||||
|
||||
{ 300286872 } [ "Wikipedia" adler-32 checksum-bytes ] unit-test
|
||||
{ 2679885283 } [ 10000 CHAR: a <string> adler-32 checksum-bytes ] unit-test
|
||||
{ 2679885283 } [ 10000 char: a <string> adler-32 checksum-bytes ] unit-test
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
USING: checksums checksums.bsd strings tools.test ;
|
||||
|
||||
{ 15816 } [ "Wikipedia" bsd checksum-bytes ] unit-test
|
||||
{ 47937 } [ 10000 CHAR: a <string> bsd checksum-bytes ] unit-test
|
||||
{ 47937 } [ 10000 char: a <string> bsd checksum-bytes ] unit-test
|
||||
|
|
|
@ -36,5 +36,5 @@ M: crc16 checksum-bytes
|
|||
|
||||
M: crc16 checksum-lines
|
||||
init-crc16
|
||||
[ [ (crc16) ] each CHAR: \n (crc16) ] each
|
||||
[ [ (crc16) ] each char: \n (crc16) ] each
|
||||
finish-crc16 ; inline
|
||||
|
|
|
@ -8,7 +8,7 @@ IN: checksums.sha.tests
|
|||
|
||||
{ "a9993e364706816aba3e25717850c26c9cd0d89d" } [ "abc" sha1 checksum-bytes bytes>hex-string ] unit-test
|
||||
{ "84983e441c3bd26ebaae4aa1f95129e5e54670f1" } [ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" sha1 checksum-bytes bytes>hex-string ] unit-test
|
||||
! [ "34aa973cd4c4daa4f61eeb2bdbad27316534016f" ] [ 1000000 CHAR: a fill string>sha1str ] unit-test ! takes a long time...
|
||||
! [ "34aa973cd4c4daa4f61eeb2bdbad27316534016f" ] [ 1000000 char: a fill string>sha1str ] unit-test ! takes a long time...
|
||||
{ "dea356a2cddd90c7a7ecedc5ebb563934f460452" } [ "0123456701234567012345670123456701234567012345670123456701234567"
|
||||
10 swap <array> concat sha1 checksum-bytes bytes>hex-string ] unit-test
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ IN: circular.tests
|
|||
{ 0 } [ { 0 1 2 3 4 } <circular> 0 swap virtual@ drop ] unit-test
|
||||
{ 2 } [ { 0 1 2 3 4 } <circular> 2 swap virtual@ drop ] unit-test
|
||||
|
||||
{ CHAR: t } [ "test" <circular> 0 swap nth ] unit-test
|
||||
{ char: t } [ "test" <circular> 0 swap nth ] unit-test
|
||||
{ "test" } [ "test" <circular> >string ] unit-test
|
||||
|
||||
{ CHAR: e } [ "test" <circular> 5 swap nth-unsafe ] unit-test
|
||||
{ char: e } [ "test" <circular> 5 swap nth-unsafe ] unit-test
|
||||
|
||||
{ [ 1 2 3 ] } [ { 1 2 3 } <circular> [ ] like ] unit-test
|
||||
{ [ 2 3 1 ] } [ { 1 2 3 } <circular> [ rotate-circular ] keep [ ] like ] unit-test
|
||||
|
@ -19,9 +19,9 @@ IN: circular.tests
|
|||
{ [ 3 1 2 ] } [ { 1 2 3 } <circular> 1 over change-circular-start 1 over change-circular-start [ ] like ] unit-test
|
||||
{ [ 3 1 2 ] } [ { 1 2 3 } <circular> -100 over change-circular-start [ ] like ] unit-test
|
||||
|
||||
{ "fob" } [ "foo" <circular> CHAR: b 2 pick set-nth >string ] unit-test
|
||||
{ "boo" } [ "foo" <circular> CHAR: b 3 pick set-nth-unsafe >string ] unit-test
|
||||
{ "ornact" } [ "factor" <circular> 4 over change-circular-start CHAR: n 2 pick set-nth >string ] unit-test
|
||||
{ "fob" } [ "foo" <circular> char: b 2 pick set-nth >string ] unit-test
|
||||
{ "boo" } [ "foo" <circular> char: b 3 pick set-nth-unsafe >string ] unit-test
|
||||
{ "ornact" } [ "factor" <circular> 4 over change-circular-start char: n 2 pick set-nth >string ] unit-test
|
||||
|
||||
{ "bcd" } [ 3 <circular-string> "abcd" [ over circular-push ] each >string ] unit-test
|
||||
|
||||
|
@ -29,7 +29,7 @@ IN: circular.tests
|
|||
|
||||
! This no longer fails
|
||||
! [ "test" <circular> 5 swap nth ] must-fail
|
||||
! [ "foo" <circular> CHAR: b 3 rot set-nth ] must-fail
|
||||
! [ "foo" <circular> char: b 3 rot set-nth ] must-fail
|
||||
|
||||
{ { } } [ 3 <growing-circular> >array ] unit-test
|
||||
{ { 1 2 } } [
|
||||
|
|
|
@ -197,7 +197,7 @@ cell {
|
|||
assoc-union alien>objc-types set-global
|
||||
|
||||
: objc-struct-type ( i string -- ctype )
|
||||
[ CHAR: = ] 2keep index-from swap subseq
|
||||
[ char: = ] 2keep index-from swap subseq
|
||||
objc>struct-types get at* [ drop void* ] unless ;
|
||||
|
||||
ERROR: no-objc-type name ;
|
||||
|
@ -209,9 +209,9 @@ ERROR: no-objc-type name ;
|
|||
: (parse-objc-type) ( i string -- ctype )
|
||||
[ [ 1 + ] dip ] [ nth ] 2bi {
|
||||
{ [ dup "rnNoORV" member? ] [ drop (parse-objc-type) ] }
|
||||
{ [ dup CHAR: ^ = ] [ 3drop void* ] }
|
||||
{ [ dup CHAR: { = ] [ drop objc-struct-type ] }
|
||||
{ [ dup CHAR: [ = ] [ 3drop void* ] }
|
||||
{ [ dup char: ^ = ] [ 3drop void* ] }
|
||||
{ [ dup char: { = ] [ drop objc-struct-type ] }
|
||||
{ [ dup char: [ = ] [ 3drop void* ] }
|
||||
[ 2nip decode-type ]
|
||||
} cond ;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ IN: colors.constants
|
|||
: parse-color ( line -- name color )
|
||||
first4
|
||||
[ [ string>number 255 /f ] tri@ 1.0 <rgba> ] dip
|
||||
[ blank? ] trim-head H{ { CHAR: \s CHAR: - } } substitute swap ;
|
||||
[ blank? ] trim-head H{ { char: \s char: - } } substitute swap ;
|
||||
|
||||
: parse-colors ( lines -- assoc )
|
||||
[ "!" head? ] reject
|
||||
|
|
|
@ -14,8 +14,8 @@ IN: compiler.cfg.linear-scan.debugger
|
|||
allocate-registers drop ;
|
||||
|
||||
: picture ( uses -- str )
|
||||
dup last 1 + CHAR: space <string>
|
||||
[ '[ CHAR: * swap _ set-nth ] each ] keep ;
|
||||
dup last 1 + char: space <string>
|
||||
[ '[ char: * swap _ set-nth ] each ] keep ;
|
||||
|
||||
: interval-picture ( interval -- str )
|
||||
[ uses>> picture ]
|
||||
|
|
|
@ -42,12 +42,12 @@ IN: compiler.tests.intrinsics
|
|||
! Write barrier hits on the wrong value were causing segfaults
|
||||
[ -3 ] [ -3 1 2 [ 2array [ 3 set-slot ] keep ] compile-call second ] unit-test
|
||||
|
||||
[ CHAR: a ] [ 0 "abc" [ string-nth ] compile-call ] unit-test
|
||||
[ CHAR: a ] [ 0 [ "abc" string-nth ] compile-call ] unit-test
|
||||
[ CHAR: a ] [ [ 0 "abc" string-nth ] compile-call ] unit-test
|
||||
[ CHAR: b ] [ 1 "abc" [ string-nth ] compile-call ] unit-test
|
||||
[ CHAR: b ] [ 1 [ "abc" string-nth ] compile-call ] unit-test
|
||||
[ CHAR: b ] [ [ 1 "abc" string-nth ] compile-call ] unit-test
|
||||
[ char: a ] [ 0 "abc" [ string-nth ] compile-call ] unit-test
|
||||
[ char: a ] [ 0 [ "abc" string-nth ] compile-call ] unit-test
|
||||
[ char: a ] [ [ 0 "abc" string-nth ] compile-call ] unit-test
|
||||
[ char: b ] [ 1 "abc" [ string-nth ] compile-call ] unit-test
|
||||
[ char: b ] [ 1 [ "abc" string-nth ] compile-call ] unit-test
|
||||
[ char: b ] [ [ 1 "abc" string-nth ] compile-call ] unit-test
|
||||
|
||||
[ 0x123456 ] [ 0 "\u123456bc" [ string-nth ] compile-call ] unit-test
|
||||
[ 0x123456 ] [ 0 [ "\u123456bc" string-nth ] compile-call ] unit-test
|
||||
|
|
|
@ -46,7 +46,7 @@ HELP: write-csv
|
|||
{ $description "Writes a sequence of sequences of comma-separated-values to the output stream, escaping where necessary." } ;
|
||||
|
||||
HELP: with-delimiter
|
||||
{ $values { "ch" "field delimiter (e.g. CHAR: \\t)" }
|
||||
{ $values { "ch" "field delimiter (e.g. char: \\t)" }
|
||||
{ "quot" quotation } }
|
||||
{ $description "Sets the field delimiter for read-csv, read-row, write-csv, or write-row words." } ;
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ IN: csv.tests
|
|||
|
||||
"allows setting of delimiting character"
|
||||
[ { { "foo" "bah" "baz" } } ]
|
||||
[ "foo\tbah\tbaz\n" CHAR: \t [ string>csv ] with-delimiter ] named-unit-test
|
||||
[ "foo\tbah\tbaz\n" char: \t [ string>csv ] with-delimiter ] named-unit-test
|
||||
|
||||
"Quoted field followed immediately by newline"
|
||||
[ { { "foo" "bar" }
|
||||
|
|
|
@ -7,7 +7,7 @@ IN: csv
|
|||
|
||||
SYMBOL: delimiter
|
||||
|
||||
CHAR: , delimiter set-global
|
||||
char: , delimiter set-global
|
||||
|
||||
<PRIVATE
|
||||
|
||||
|
@ -20,9 +20,9 @@ DEFER: quoted-field,
|
|||
2over stream-read1 swap over =
|
||||
[ nip ] [
|
||||
{
|
||||
{ CHAR: \" [ [ CHAR: \" , ] when quoted-field, ] }
|
||||
{ CHAR: \n [ ] } ! Error: cr inside string?
|
||||
{ CHAR: \r [ ] } ! Error: lf inside string?
|
||||
{ char: \" [ [ char: \" , ] when quoted-field, ] }
|
||||
{ char: \n [ ] } ! Error: cr inside string?
|
||||
{ char: \r [ ] } ! Error: lf inside string?
|
||||
[ [ , drop f maybe-escaped-quote ] when* ]
|
||||
} case
|
||||
] if ; inline recursive
|
||||
|
@ -45,7 +45,7 @@ DEFER: quoted-field,
|
|||
swap ?trim [ drop ] 2dip ; inline
|
||||
|
||||
: field ( delimiter stream field-seps quote-seps -- sep/f field )
|
||||
pick stream-read-until dup CHAR: \" = [
|
||||
pick stream-read-until dup char: \" = [
|
||||
drop [ drop quoted-field ] [ continue-field ] if-empty
|
||||
] [ [ 3drop ] 2dip swap ?trim ] if ;
|
||||
|
||||
|
@ -89,10 +89,10 @@ PRIVATE>
|
|||
'[ dup "\n\"\r" member? [ drop t ] [ _ = ] if ] any? ; inline
|
||||
|
||||
: escape-quotes ( cell stream -- )
|
||||
CHAR: \" over stream-write1 swap [
|
||||
char: \" over stream-write1 swap [
|
||||
[ over stream-write1 ]
|
||||
[ dup CHAR: \" = [ over stream-write1 ] [ drop ] if ] bi
|
||||
] each CHAR: \" swap stream-write1 ;
|
||||
[ dup char: \" = [ over stream-write1 ] [ drop ] if ] bi
|
||||
] each char: \" swap stream-write1 ;
|
||||
|
||||
: escape-if-required ( cell delimiter stream -- )
|
||||
[ dupd needs-escaping? ] dip
|
||||
|
|
|
@ -117,7 +117,7 @@ M: postgresql-db-connection <prepared-statement> ( sql in out -- statement )
|
|||
<simple-statement> dup prepare-statement ;
|
||||
|
||||
: bind-name% ( -- )
|
||||
CHAR: $ 0,
|
||||
char: $ 0,
|
||||
sql-counter [ inc ] [ get 0# ] bi ;
|
||||
|
||||
M: postgresql-db-connection bind% ( spec -- )
|
||||
|
|
|
@ -8,7 +8,7 @@ IN: db.tester
|
|||
|
||||
: postgresql-test-db-name ( -- string )
|
||||
cpu name>> "-" "factor-test" 3append
|
||||
H{ { CHAR: - CHAR: _ } { CHAR: . CHAR: _ } } substitute ;
|
||||
H{ { char: - char: _ } { char: . char: _ } } substitute ;
|
||||
|
||||
: postgresql-test-db ( -- postgresql-db )
|
||||
\ postgresql-db get-global clone postgresql-test-db-name >>database ;
|
||||
|
|
|
@ -305,7 +305,7 @@ TUPLE: exam id name score ;
|
|||
|
||||
: random-exam ( -- exam )
|
||||
f
|
||||
6 [ CHAR: a CHAR: z [a,b] random ] replicate >string
|
||||
6 [ char: a char: z [a,b] random ] replicate >string
|
||||
100 random
|
||||
exam boa ;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ os unix? [
|
|||
{ f } [ "factor-test-key-1" os-env ] unit-test
|
||||
|
||||
{ } [
|
||||
32766 CHAR: a <string> "factor-test-key-long" set-os-env
|
||||
32766 char: a <string> "factor-test-key-long" set-os-env
|
||||
] unit-test
|
||||
{ 32766 } [ "factor-test-key-long" os-env length ] unit-test
|
||||
{ } [ "factor-test-key-long" unset-os-env ] unit-test
|
||||
|
|
|
@ -63,11 +63,11 @@ DEFER: (parse-paragraph)
|
|||
|
||||
: delimiter-class ( delimiter -- class )
|
||||
H{
|
||||
{ CHAR: * strong }
|
||||
{ CHAR: _ emphasis }
|
||||
{ CHAR: ^ superscript }
|
||||
{ CHAR: ~ subscript }
|
||||
{ CHAR: % inline-code }
|
||||
{ char: * strong }
|
||||
{ char: _ emphasis }
|
||||
{ char: ^ superscript }
|
||||
{ char: ~ subscript }
|
||||
{ char: % inline-code }
|
||||
} at ;
|
||||
|
||||
: or-simple-title ( ... url title/f quot: ( ... title -- ... title' ) -- ... url title' )
|
||||
|
@ -82,9 +82,9 @@ DEFER: (parse-paragraph)
|
|||
] dip [ (parse-paragraph) cons ] [ 1list ] if* ;
|
||||
|
||||
: parse-big-link ( before after -- link rest )
|
||||
dup ?first CHAR: [ =
|
||||
dup ?first char: [ =
|
||||
[ parse-link ]
|
||||
[ [ CHAR: [ suffix ] [ (parse-paragraph) ] bi* ]
|
||||
[ [ char: [ suffix ] [ (parse-paragraph) ] bi* ]
|
||||
if ;
|
||||
|
||||
: escape ( before after -- before' after' )
|
||||
|
@ -94,8 +94,8 @@ DEFER: (parse-paragraph)
|
|||
[ nil ] [
|
||||
[ "*_^~%[\\" member? ] find-cut [
|
||||
{
|
||||
{ CHAR: [ [ parse-big-link ] }
|
||||
{ CHAR: \\ [ escape ] }
|
||||
{ char: [ [ parse-big-link ] }
|
||||
{ char: \\ [ escape ] }
|
||||
[ dup delimiter-class parse-delimiter ]
|
||||
} case cons
|
||||
] [ drop "" like 1list ] if*
|
||||
|
@ -124,10 +124,10 @@ DEFER: (parse-paragraph)
|
|||
V{ } clone (take-until) ;
|
||||
|
||||
: count= ( string -- n )
|
||||
dup <reversed> [ [ CHAR: = = not ] find drop 0 or ] bi@ min ;
|
||||
dup <reversed> [ [ char: = = not ] find drop 0 or ] bi@ min ;
|
||||
|
||||
: trim= ( string -- string' )
|
||||
[ CHAR: = = ] trim ;
|
||||
[ char: = = ] trim ;
|
||||
|
||||
: make-heading ( string class -- heading )
|
||||
[ trim= parse-paragraph ] dip boa ; inline
|
||||
|
@ -149,14 +149,14 @@ DEFER: (parse-paragraph)
|
|||
: coalesce ( rows -- rows' )
|
||||
V{ } clone [
|
||||
'[
|
||||
_ dup ?last ?last CHAR: \\ =
|
||||
_ dup ?last ?last char: \\ =
|
||||
[ [ pop "|" rot 3append ] keep ] when
|
||||
push
|
||||
] each
|
||||
] keep ;
|
||||
|
||||
: parse-table ( state -- state' table )
|
||||
CHAR: | take-lines [
|
||||
char: | take-lines [
|
||||
"|" split
|
||||
trim-row
|
||||
coalesce
|
||||
|
@ -175,13 +175,13 @@ DEFER: (parse-paragraph)
|
|||
] dip boa ; inline
|
||||
|
||||
: parse-ul ( state -- state' ul )
|
||||
CHAR: - unordered-list parse-list ;
|
||||
char: - unordered-list parse-list ;
|
||||
|
||||
: parse-ol ( state -- state' ul )
|
||||
CHAR: # ordered-list parse-list ;
|
||||
char: # ordered-list parse-list ;
|
||||
|
||||
: parse-code ( state -- state' item )
|
||||
dup 1 look CHAR: [ =
|
||||
dup 1 look char: [ =
|
||||
[ unclip-slice make-paragraph ] [
|
||||
dup "{" take-until [
|
||||
[ nip rest ] dip
|
||||
|
@ -192,12 +192,12 @@ DEFER: (parse-paragraph)
|
|||
|
||||
: parse-item ( state -- state' item )
|
||||
dup 0 look {
|
||||
{ CHAR: = [ parse-heading ] }
|
||||
{ CHAR: | [ parse-table ] }
|
||||
{ CHAR: _ [ parse-line ] }
|
||||
{ CHAR: - [ parse-ul ] }
|
||||
{ CHAR: # [ parse-ol ] }
|
||||
{ CHAR: [ [ parse-code ] }
|
||||
{ char: = [ parse-heading ] }
|
||||
{ char: | [ parse-table ] }
|
||||
{ char: _ [ parse-line ] }
|
||||
{ char: - [ parse-ul ] }
|
||||
{ char: # [ parse-ol ] }
|
||||
{ char: [ [ parse-code ] }
|
||||
{ f [ rest-slice f ] }
|
||||
[ drop unclip-slice make-paragraph ]
|
||||
} case ;
|
||||
|
@ -212,7 +212,7 @@ CONSTANT: invalid-url "javascript:alert('Invalid URL in farkup');"
|
|||
{ [ dup empty? ] [ drop invalid-url ] }
|
||||
{ [ dup [ 127 > ] any? ] [ drop invalid-url ] }
|
||||
{ [ dup first "/\\" member? ] [ drop invalid-url ] }
|
||||
{ [ CHAR: : over member? ] [ dup absolute-url? [ drop invalid-url ] unless ] }
|
||||
{ [ char: : over member? ] [ dup absolute-url? [ drop invalid-url ] unless ] }
|
||||
[ relative-link-prefix get prepend "" like url-encode ]
|
||||
} cond ;
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ IN: formatting.tests
|
|||
{ "2008-09-10" } [ 2008 9 10 "%04d-%02d-%02d" sprintf ] unit-test
|
||||
{ "Hello, World!" } [ "Hello, World!" "%s" sprintf ] unit-test
|
||||
{ "printf test" } [ "printf test" sprintf ] unit-test
|
||||
{ "char a = 'a'" } [ CHAR: a "char %c = 'a'" sprintf ] unit-test
|
||||
{ "char a = 'a'" } [ char: a "char %c = 'a'" sprintf ] unit-test
|
||||
{ "00" } [ 0x0 "%02x" sprintf ] unit-test
|
||||
{ "ff" } [ 0xff "%02x" sprintf ] unit-test
|
||||
{ "0 message(s)" } [ 0 "message" "%d %s(s)" sprintf ] unit-test
|
||||
|
|
|
@ -14,12 +14,12 @@ IN: formatting
|
|||
[ ] [ compose ] reduce ; inline
|
||||
|
||||
: fix-sign ( string -- string )
|
||||
dup first CHAR: 0 = [
|
||||
dup [ [ CHAR: 0 = not ] [ digit? ] bi and ] find
|
||||
dup first char: 0 = [
|
||||
dup [ [ char: 0 = not ] [ digit? ] bi and ] find
|
||||
[
|
||||
1 - swap 2dup nth {
|
||||
{ CHAR: - [ remove-nth "-" prepend ] }
|
||||
{ CHAR: + [ remove-nth "+" prepend ] }
|
||||
{ char: - [ remove-nth "-" prepend ] }
|
||||
{ char: + [ remove-nth "+" prepend ] }
|
||||
[ drop nip ]
|
||||
} case
|
||||
] [ drop ] if
|
||||
|
@ -39,15 +39,15 @@ ERROR: unknown-printf-directive ;
|
|||
|
||||
EBNF: parse-printf
|
||||
|
||||
zero = "0" => [[ CHAR: 0 ]]
|
||||
zero = "0" => [[ char: 0 ]]
|
||||
char = "'" (.) => [[ second ]]
|
||||
|
||||
pad-char = (zero|char)? => [[ CHAR: \s or ]]
|
||||
pad-char = (zero|char)? => [[ char: \s or ]]
|
||||
pad-align = ("-")? => [[ \ pad-tail \ pad-head ? ]]
|
||||
pad-width = ([0-9])* => [[ >digits ]]
|
||||
pad = pad-align pad-char pad-width => [[ <reversed> >quotation dup first 0 = [ drop [ ] ] when ]]
|
||||
|
||||
sign_ = [+ ] => [[ '[ dup CHAR: - swap index [ _ prefix ] unless ] ]]
|
||||
sign_ = [+ ] => [[ '[ dup char: - swap index [ _ prefix ] unless ] ]]
|
||||
sign = (sign_)? => [[ [ ] or ]]
|
||||
|
||||
width_ = "." ([0-9])* => [[ second >digits '[ _ short head ] ]]
|
||||
|
@ -123,10 +123,10 @@ MACRO: sprintf ( format-string -- quot )
|
|||
<PRIVATE
|
||||
|
||||
: pad-00 ( n -- string )
|
||||
number>string 2 CHAR: 0 pad-head ; inline
|
||||
number>string 2 char: 0 pad-head ; inline
|
||||
|
||||
: pad-000 ( n -- string )
|
||||
number>string 3 CHAR: 0 pad-head ; inline
|
||||
number>string 3 char: 0 pad-head ; inline
|
||||
|
||||
: >time ( timestamp -- string )
|
||||
[ hour>> ] [ minute>> ] [ second>> floor ] tri
|
||||
|
|
|
@ -11,7 +11,7 @@ IN: ftp.client
|
|||
3 head string>number ;
|
||||
|
||||
: ftp-response-code ( string -- n/f )
|
||||
dup fourth CHAR: - = [ drop f ] [ (ftp-response-code) ] if ;
|
||||
dup fourth char: - = [ drop f ] [ (ftp-response-code) ] if ;
|
||||
|
||||
: read-response-loop ( ftp-response -- ftp-response )
|
||||
readln
|
||||
|
@ -22,7 +22,7 @@ IN: ftp.client
|
|||
<ftp-response> readln
|
||||
[ (ftp-response-code) >>n ]
|
||||
[ add-response-line ]
|
||||
[ fourth CHAR: - = ] tri
|
||||
[ fourth char: - = ] tri
|
||||
[ read-response-loop ] when ;
|
||||
|
||||
ERROR: ftp-error got expected ;
|
||||
|
|
|
@ -6,26 +6,26 @@ IN: ftp.client.listing-parser
|
|||
|
||||
: ch>file-type ( ch -- type )
|
||||
{
|
||||
{ CHAR: b [ +block-device+ ] }
|
||||
{ CHAR: c [ +character-device+ ] }
|
||||
{ CHAR: d [ +directory+ ] }
|
||||
{ CHAR: l [ +symbolic-link+ ] }
|
||||
{ CHAR: s [ +socket+ ] }
|
||||
{ CHAR: p [ +fifo+ ] }
|
||||
{ CHAR: - [ +regular-file+ ] }
|
||||
{ char: b [ +block-device+ ] }
|
||||
{ char: c [ +character-device+ ] }
|
||||
{ char: d [ +directory+ ] }
|
||||
{ char: l [ +symbolic-link+ ] }
|
||||
{ char: s [ +socket+ ] }
|
||||
{ char: p [ +fifo+ ] }
|
||||
{ char: - [ +regular-file+ ] }
|
||||
[ drop +unknown+ ]
|
||||
} case ;
|
||||
|
||||
: file-type>ch ( type -- string )
|
||||
{
|
||||
{ +block-device+ [ CHAR: b ] }
|
||||
{ +character-device+ [ CHAR: c ] }
|
||||
{ +directory+ [ CHAR: d ] }
|
||||
{ +symbolic-link+ [ CHAR: l ] }
|
||||
{ +socket+ [ CHAR: s ] }
|
||||
{ +fifo+ [ CHAR: p ] }
|
||||
{ +regular-file+ [ CHAR: - ] }
|
||||
[ drop CHAR: - ]
|
||||
{ +block-device+ [ char: b ] }
|
||||
{ +character-device+ [ char: c ] }
|
||||
{ +directory+ [ char: d ] }
|
||||
{ +symbolic-link+ [ char: l ] }
|
||||
{ +socket+ [ char: s ] }
|
||||
{ +fifo+ [ char: p ] }
|
||||
{ +regular-file+ [ char: - ] }
|
||||
[ drop char: - ]
|
||||
} case ;
|
||||
|
||||
: parse-permissions ( remote-file str -- remote-file )
|
||||
|
|
|
@ -111,7 +111,7 @@ TUPLE: couchdb-auth-provider
|
|||
url>user ;
|
||||
|
||||
: strip-hash ( hash1 -- hash2 )
|
||||
[ drop first CHAR: _ = ] assoc-reject ;
|
||||
[ drop first char: _ = ] assoc-reject ;
|
||||
|
||||
: at-or-k ( key hash -- newkey )
|
||||
dupd at [ nip ] when* ;
|
||||
|
|
|
@ -70,7 +70,7 @@ PREDICATE: fixed-size-array-type < c-array-type fixed-size>> >boolean ;
|
|||
|
||||
: qualified-type-name ( data-type -- name )
|
||||
[ name>> ] keep {
|
||||
[ name>> CHAR: . swap member? ]
|
||||
[ name>> char: . swap member? ]
|
||||
[ none-type? ]
|
||||
[ standard-type? ]
|
||||
} 1|| [ qualified-name ] unless ;
|
||||
|
|
|
@ -15,19 +15,19 @@ IN: help.html
|
|||
: escape-char ( ch -- )
|
||||
dup ascii? [
|
||||
dup H{
|
||||
{ CHAR: \" "__quo__" }
|
||||
{ CHAR: * "__star__" }
|
||||
{ CHAR: : "__colon__" }
|
||||
{ CHAR: < "__lt__" }
|
||||
{ CHAR: > "__gt__" }
|
||||
{ CHAR: ? "__que__" }
|
||||
{ CHAR: \\ "__back__" }
|
||||
{ CHAR: | "__pipe__" }
|
||||
{ CHAR: / "__slash__" }
|
||||
{ CHAR: , "__comma__" }
|
||||
{ CHAR: @ "__at__" }
|
||||
{ CHAR: # "__hash__" }
|
||||
{ CHAR: % "__percent__" }
|
||||
{ char: \" "__quo__" }
|
||||
{ char: * "__star__" }
|
||||
{ char: : "__colon__" }
|
||||
{ char: < "__lt__" }
|
||||
{ char: > "__gt__" }
|
||||
{ char: ? "__que__" }
|
||||
{ char: \\ "__back__" }
|
||||
{ char: | "__pipe__" }
|
||||
{ char: / "__slash__" }
|
||||
{ char: , "__comma__" }
|
||||
{ char: @ "__at__" }
|
||||
{ char: # "__hash__" }
|
||||
{ char: % "__percent__" }
|
||||
} at [ % ] [ , ] ?if
|
||||
] [ number>string "__" "__" surround % ] if ;
|
||||
|
||||
|
@ -87,7 +87,7 @@ M: pathname url-of
|
|||
XML] ;
|
||||
|
||||
: bijective-base26 ( n -- name )
|
||||
[ dup 0 > ] [ 1 - 26 /mod CHAR: a + ] "" produce-as nip reverse! ;
|
||||
[ dup 0 > ] [ 1 - 26 /mod char: a + ] "" produce-as nip reverse! ;
|
||||
|
||||
: css-class ( style classes -- name )
|
||||
dup '[ drop _ assoc-size 1 + bijective-base26 ] cache ;
|
||||
|
|
|
@ -142,7 +142,7 @@ $nl
|
|||
"We begin by writing a word which removes blanks and non-alphabetical characters from a string, and then converts the string to lower case. We call this word " { $snippet "normalize" } ". To figure out how to write this word, we begin with some interactive experimentation in the listener."
|
||||
$nl
|
||||
"Start by pushing a character on the stack; notice that characters are really just integers:"
|
||||
{ $code "CHAR: a" }
|
||||
{ $code "char: a" }
|
||||
$nl
|
||||
"Now, use the " { $link Letter? } " word to test if it is an alphabetical character, upper or lower case:"
|
||||
{ $unchecked-example "Letter? ." "t" }
|
||||
|
@ -151,7 +151,7 @@ $nl
|
|||
"This gives the expected result."
|
||||
$nl
|
||||
"Now try with a non-alphabetical character:"
|
||||
{ $code "CHAR: #" }
|
||||
{ $code "char: #" }
|
||||
{ $unchecked-example "Letter? ." "f" }
|
||||
$nl
|
||||
"What we want to do is given a string, remove all characters which do not match the " { $link Letter? } " predicate. Let's push a string on the stack:"
|
||||
|
|
|
@ -14,7 +14,7 @@ IN: html.streams.tests
|
|||
] unit-test
|
||||
|
||||
{ "a" } [
|
||||
[ CHAR: a write1 ] make-html-string
|
||||
[ char: a write1 ] make-html-string
|
||||
] unit-test
|
||||
|
||||
{ "<" } [
|
||||
|
|
|
@ -36,7 +36,7 @@ TUPLE: html-sub-stream < html-writer style parent ;
|
|||
|
||||
: hex-color, ( color -- )
|
||||
[ red>> ] [ green>> ] [ blue>> ] tri
|
||||
[ 255 * >integer >hex 2 CHAR: 0 pad-head % ] tri@ ;
|
||||
[ 255 * >integer >hex 2 char: 0 pad-head % ] tri@ ;
|
||||
|
||||
: fg-css, ( color -- )
|
||||
"color: #" % hex-color, "; " % ;
|
||||
|
|
|
@ -10,7 +10,7 @@ IN: html.templates.chloe.tests
|
|||
|
||||
: run-template ( quot -- string )
|
||||
with-string-writer [ "\r\n\t" member? ] reject
|
||||
[ CHAR: \s = ] trim ; inline
|
||||
[ char: \s = ] trim ; inline
|
||||
|
||||
: test-template ( name -- template )
|
||||
"vocab:html/templates/chloe/test/"
|
||||
|
|
|
@ -16,7 +16,7 @@ TUPLE: template-lexer < lexer ;
|
|||
M: template-lexer skip-word
|
||||
[
|
||||
{
|
||||
{ [ 2dup nth CHAR: \" = ] [ drop 1 + ] }
|
||||
{ [ 2dup nth char: \" = ] [ drop 1 + ] }
|
||||
{ [ 2dup swap tail-slice "%>" head? ] [ drop 2 + ] }
|
||||
[ f skip ]
|
||||
} cond
|
||||
|
|
|
@ -97,7 +97,7 @@ PEG: parse-response-line ( string -- triple )
|
|||
[ " \t" member? ] satisfy repeat1 ;
|
||||
|
||||
: qdtext-parser ( -- parser )
|
||||
{ [ CHAR: \" = ] [ control? ] } except-these ;
|
||||
{ [ char: \" = ] [ control? ] } except-these ;
|
||||
|
||||
: quoted-char-parser ( -- parser )
|
||||
"\\" token hide any-char 2seq ;
|
||||
|
|
|
@ -147,7 +147,7 @@ M: stdin dispose*
|
|||
] with-destructors ;
|
||||
|
||||
: wait-for-stdin ( stdin -- size )
|
||||
[ control>> CHAR: X over io:stream-write1 io:stream-flush ]
|
||||
[ control>> char: X over io:stream-write1 io:stream-flush ]
|
||||
[ size>> ssize_t heap-size swap io:stream-read ssize_t deref ]
|
||||
bi ;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ io.buffers kernel libc namespaces sequences strings tools.test ;
|
|||
dup buffer-read-all >string swap dispose
|
||||
] unit-test
|
||||
|
||||
{ CHAR: e } [
|
||||
{ char: e } [
|
||||
"hello" string>buffer
|
||||
1 over buffer-consume [ buffer-pop ] keep dispose
|
||||
] unit-test
|
||||
|
@ -58,11 +58,11 @@ io.buffers kernel libc namespaces sequences strings tools.test ;
|
|||
"b" get dispose
|
||||
|
||||
"hello world" string>buffer "b" set
|
||||
{ "hello" CHAR: \s } [ " " "b" get buffer-read-until [ >string ] dip ] unit-test
|
||||
{ "hello" char: \s } [ " " "b" get buffer-read-until [ >string ] dip ] unit-test
|
||||
"b" get dispose
|
||||
|
||||
"hello world" string>buffer "b" set
|
||||
{ "hello worl" CHAR: d } [ "d" "b" get buffer-read-until [ >string ] dip ] unit-test
|
||||
{ "hello worl" char: d } [ "d" "b" get buffer-read-until [ >string ] dip ] unit-test
|
||||
"b" get dispose
|
||||
|
||||
"hello world" string>buffer "b" set
|
||||
|
|
|
@ -8,14 +8,14 @@ IN: io.crlf
|
|||
|
||||
: read-crlf ( -- seq )
|
||||
"\r" read-until
|
||||
[ CHAR: \r assert= read1 CHAR: \n assert= ] [ f like ] if* ;
|
||||
[ char: \r assert= read1 char: \n assert= ] [ f like ] if* ;
|
||||
|
||||
: read-?crlf ( -- seq )
|
||||
"\r\n" read-until
|
||||
[ CHAR: \r = [ read1 CHAR: \n assert= ] when ] [ f like ] if* ;
|
||||
[ char: \r = [ read1 char: \n assert= ] when ] [ f like ] if* ;
|
||||
|
||||
: crlf>lf ( str -- str' )
|
||||
CHAR: \r swap remove ;
|
||||
char: \r swap remove ;
|
||||
|
||||
: lf>crlf ( str -- str' )
|
||||
"\n" split "\r\n" join ;
|
||||
|
|
|
@ -3,12 +3,12 @@ io.encodings.8-bit.private tools.test strings arrays
|
|||
io.encodings.8-bit.latin1 io.encodings.8-bit.windows-1252 ;
|
||||
IN: io.encodings.8-bit.tests
|
||||
|
||||
{ B{ CHAR: f CHAR: o CHAR: o } } [ "foo" latin1 encode ] unit-test
|
||||
{ B{ char: f char: o char: o } } [ "foo" latin1 encode ] unit-test
|
||||
[ { 256 } >string latin1 encode ] must-fail
|
||||
{ B{ 255 } } [ { 255 } >string latin1 encode ] unit-test
|
||||
|
||||
{ "bar" } [ "bar" latin1 decode ] unit-test
|
||||
{ { CHAR: b 233 CHAR: r } } [ B{ CHAR: b 233 CHAR: r } latin1 decode >array ] unit-test
|
||||
{ { char: b 233 char: r } } [ B{ char: b 233 char: r } latin1 decode >array ] unit-test
|
||||
{ { 0xfffd 0x20AC } } [ B{ 0x81 0x80 } windows-1252 decode >array ] unit-test
|
||||
|
||||
{ t } [ \ latin1 8-bit-encoding? ] unit-test
|
||||
|
|
|
@ -47,4 +47,4 @@ IN: io.encodings.euc.tests
|
|||
|
||||
{ t } [ phrase-euc-kr 3 head* euc-kr decode phrase-unicode 2 head* = ] unit-test
|
||||
|
||||
{ t } [ phrase-euc-kr 2 head* euc-kr decode phrase-unicode 2 head* CHAR: replacement-character suffix = ] unit-test
|
||||
{ t } [ phrase-euc-kr 2 head* euc-kr decode phrase-unicode 2 head* char: replacement-character suffix = ] unit-test
|
||||
|
|
|
@ -9,15 +9,15 @@ IN: io.encodings.gb18030.tests
|
|||
[ B{ 0xB7 0xB8 } >string gb18030 encode ] unit-test
|
||||
{ { 0xB7 0xB8 } }
|
||||
[ B{ 0xA1 0xA4 0x81 0x30 0x86 0x30 } gb18030 decode >array ] unit-test
|
||||
{ { 0xB7 CHAR: replacement-character } }
|
||||
{ { 0xB7 char: replacement-character } }
|
||||
[ B{ 0xA1 0xA4 0x81 0x30 0x86 } gb18030 decode >array ] unit-test
|
||||
{ { 0xB7 CHAR: replacement-character } }
|
||||
{ { 0xB7 char: replacement-character } }
|
||||
[ B{ 0xA1 0xA4 0x81 0x30 } gb18030 decode >array ] unit-test
|
||||
{ { 0xB7 CHAR: replacement-character } }
|
||||
{ { 0xB7 char: replacement-character } }
|
||||
[ B{ 0xA1 0xA4 0x81 } gb18030 decode >array ] unit-test
|
||||
{ { 0xB7 } }
|
||||
[ B{ 0xA1 0xA4 } gb18030 decode >array ] unit-test
|
||||
{ { CHAR: replacement-character } }
|
||||
{ { char: replacement-character } }
|
||||
[ B{ 0xA1 } >string gb18030 decode >array ] unit-test
|
||||
{ { 0x44D7 0x464B } }
|
||||
[ B{ 0x82 0x33 0xA3 0x39 0x82 0x33 0xC9 0x31 }
|
||||
|
|
|
@ -7,30 +7,30 @@ IN: io.encodings.iso2022
|
|||
{ "hello" } [ "hello" >byte-array iso2022 decode ] unit-test
|
||||
{ "hello" } [ "hello" iso2022 encode >string ] unit-test
|
||||
|
||||
{ "hi" } [ B{ CHAR: h $ ESC CHAR: ( CHAR: B CHAR: i } iso2022 decode ] unit-test
|
||||
{ "hi" } [ B{ CHAR: h CHAR: i $ ESC CHAR: ( CHAR: B } iso2022 decode ] unit-test
|
||||
{ "hi\u00fffd" } [ B{ CHAR: h CHAR: i $ ESC CHAR: ( } iso2022 decode ] unit-test
|
||||
{ "hi\u00fffd" } [ B{ CHAR: h CHAR: i $ ESC } iso2022 decode ] unit-test
|
||||
{ "hi" } [ B{ char: h $ ESC char: ( char: B char: i } iso2022 decode ] unit-test
|
||||
{ "hi" } [ B{ char: h char: i $ ESC char: ( char: B } iso2022 decode ] unit-test
|
||||
{ "hi\u00fffd" } [ B{ char: h char: i $ ESC char: ( } iso2022 decode ] unit-test
|
||||
{ "hi\u00fffd" } [ B{ char: h char: i $ ESC } iso2022 decode ] unit-test
|
||||
|
||||
{ B{ CHAR: h $ ESC CHAR: ( CHAR: J 0xD8 } } [ "h\u00ff98" iso2022 encode ] unit-test
|
||||
{ "h\u00ff98" } [ B{ CHAR: h $ ESC CHAR: ( CHAR: J 0xD8 } iso2022 decode ] unit-test
|
||||
{ "hi" } [ B{ CHAR: h $ ESC CHAR: ( CHAR: J CHAR: i } iso2022 decode ] unit-test
|
||||
{ "h" } [ B{ CHAR: h $ ESC CHAR: ( CHAR: J } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ CHAR: h $ ESC CHAR: ( CHAR: J 0x80 } iso2022 decode ] unit-test
|
||||
{ B{ char: h $ ESC char: ( char: J 0xD8 } } [ "h\u00ff98" iso2022 encode ] unit-test
|
||||
{ "h\u00ff98" } [ B{ char: h $ ESC char: ( char: J 0xD8 } iso2022 decode ] unit-test
|
||||
{ "hi" } [ B{ char: h $ ESC char: ( char: J char: i } iso2022 decode ] unit-test
|
||||
{ "h" } [ B{ char: h $ ESC char: ( char: J } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ char: h $ ESC char: ( char: J 0x80 } iso2022 decode ] unit-test
|
||||
|
||||
{ B{ CHAR: h $ ESC CHAR: $ CHAR: B 0x3E 0x47 } } [ "h\u007126" iso2022 encode ] unit-test
|
||||
{ "h\u007126" } [ B{ CHAR: h $ ESC CHAR: $ CHAR: B 0x3E 0x47 } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ CHAR: h $ ESC CHAR: $ CHAR: B 0x3E } iso2022 decode ] unit-test
|
||||
{ "h" } [ B{ CHAR: h $ ESC CHAR: $ CHAR: B } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ CHAR: h $ ESC CHAR: $ } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ CHAR: h $ ESC } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ CHAR: h $ ESC CHAR: $ CHAR: B 0x80 0x80 } iso2022 decode ] unit-test
|
||||
{ B{ char: h $ ESC char: $ char: B 0x3E 0x47 } } [ "h\u007126" iso2022 encode ] unit-test
|
||||
{ "h\u007126" } [ B{ char: h $ ESC char: $ char: B 0x3E 0x47 } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ char: h $ ESC char: $ char: B 0x3E } iso2022 decode ] unit-test
|
||||
{ "h" } [ B{ char: h $ ESC char: $ char: B } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ char: h $ ESC char: $ } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ char: h $ ESC } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ char: h $ ESC char: $ char: B 0x80 0x80 } iso2022 decode ] unit-test
|
||||
|
||||
{ B{ CHAR: h $ ESC CHAR: $ CHAR: ( CHAR: D 0x38 0x54 } } [ "h\u0058ce" iso2022 encode ] unit-test
|
||||
{ "h\u0058ce" } [ B{ CHAR: h $ ESC CHAR: $ CHAR: ( CHAR: D 0x38 0x54 } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ CHAR: h $ ESC CHAR: $ CHAR: ( CHAR: D 0x38 } iso2022 decode ] unit-test
|
||||
{ "h" } [ B{ CHAR: h $ ESC CHAR: $ CHAR: ( CHAR: D } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ CHAR: h $ ESC CHAR: $ CHAR: ( } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ CHAR: h $ ESC CHAR: $ CHAR: ( CHAR: D 0x70 0x70 } iso2022 decode ] unit-test
|
||||
{ B{ char: h $ ESC char: $ char: ( char: D 0x38 0x54 } } [ "h\u0058ce" iso2022 encode ] unit-test
|
||||
{ "h\u0058ce" } [ B{ char: h $ ESC char: $ char: ( char: D 0x38 0x54 } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ char: h $ ESC char: $ char: ( char: D 0x38 } iso2022 decode ] unit-test
|
||||
{ "h" } [ B{ char: h $ ESC char: $ char: ( char: D } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ char: h $ ESC char: $ char: ( } iso2022 decode ] unit-test
|
||||
{ "h\u00fffd" } [ B{ char: h $ ESC char: $ char: ( char: D 0x70 0x70 } iso2022 decode ] unit-test
|
||||
|
||||
[ "\u{syriac-music}" iso2022 encode ] must-fail
|
||||
|
|
|
@ -33,10 +33,10 @@ M: iso2022 <decoder>
|
|||
|
||||
CONSTANT: ESC 0x16
|
||||
|
||||
CONSTANT: switch-ascii B{ $ ESC CHAR: ( CHAR: B }
|
||||
CONSTANT: switch-jis201 B{ $ ESC CHAR: ( CHAR: J }
|
||||
CONSTANT: switch-jis208 B{ $ ESC CHAR: $ CHAR: B }
|
||||
CONSTANT: switch-jis212 B{ $ ESC CHAR: $ CHAR: ( CHAR: D }
|
||||
CONSTANT: switch-ascii B{ $ ESC char: ( char: B }
|
||||
CONSTANT: switch-jis201 B{ $ ESC char: ( char: J }
|
||||
CONSTANT: switch-jis208 B{ $ ESC char: $ char: B }
|
||||
CONSTANT: switch-jis212 B{ $ ESC char: $ char: ( char: D }
|
||||
|
||||
: find-type ( char -- code type )
|
||||
{
|
||||
|
@ -62,19 +62,19 @@ M:: iso2022-state encode-char ( char stream encoding -- )
|
|||
|
||||
: read-escape ( stream -- type/f )
|
||||
dup stream-read1 {
|
||||
{ CHAR: ( [
|
||||
{ char: ( [
|
||||
stream-read1 {
|
||||
{ CHAR: B [ ascii get-global ] }
|
||||
{ CHAR: J [ jis201 get-global ] }
|
||||
{ char: B [ ascii get-global ] }
|
||||
{ char: J [ jis201 get-global ] }
|
||||
[ drop f ]
|
||||
} case
|
||||
] }
|
||||
{ CHAR: $ [
|
||||
{ char: $ [
|
||||
dup stream-read1 {
|
||||
{ CHAR: @ [ drop jis208 get-global ] } ! want: JIS X 0208-1978
|
||||
{ CHAR: B [ drop jis208 get-global ] }
|
||||
{ CHAR: ( [
|
||||
stream-read1 CHAR: D = jis212 get-global f ?
|
||||
{ char: @ [ drop jis208 get-global ] } ! want: JIS X 0208-1978
|
||||
{ char: B [ drop jis208 get-global ] }
|
||||
{ char: ( [
|
||||
stream-read1 char: D = jis212 get-global f ?
|
||||
] }
|
||||
[ 2drop f ]
|
||||
} case
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
USING: io.encodings.shift-jis tools.test io.encodings.string arrays strings ;
|
||||
IN: io.encodings.shift-jis.tests
|
||||
|
||||
{ { CHAR: replacement-character } } [ { 141 } shift-jis decode >array ] unit-test
|
||||
{ { char: replacement-character } } [ { 141 } shift-jis decode >array ] unit-test
|
||||
{ "" } [ "" shift-jis decode >string ] unit-test
|
||||
{ "" } [ "" shift-jis encode >string ] unit-test
|
||||
[ { CHAR: replacement-character } shift-jis encode ] must-fail
|
||||
{ "ab¥ィ" } [ { CHAR: a CHAR: b 0x5C 0xA8 } shift-jis decode ] unit-test
|
||||
{ { CHAR: a CHAR: b 0x5C 0xA8 } } [ "ab¥ィ" shift-jis encode >array ] unit-test
|
||||
{ "ab\\ィ" } [ { CHAR: a CHAR: b 0x5C 0xA8 } windows-31j decode ] unit-test
|
||||
{ { CHAR: a CHAR: b 0x5C 0xA8 } } [ "ab\\ィ" windows-31j encode >array ] unit-test
|
||||
{ "\u000081\u0000c8" } [ CHAR: logical-and 1string windows-31j encode >string ] unit-test
|
||||
{ "\u000081\u0000c8" } [ CHAR: logical-and 1string shift-jis encode >string ] unit-test
|
||||
{ { CHAR: logical-and } } [ "\u000081\u0000c8" windows-31j decode >array ] unit-test
|
||||
{ { CHAR: logical-and } } [ "\u000081\u0000c8" shift-jis decode >array ] unit-test
|
||||
[ { char: replacement-character } shift-jis encode ] must-fail
|
||||
{ "ab¥ィ" } [ { char: a char: b 0x5C 0xA8 } shift-jis decode ] unit-test
|
||||
{ { char: a char: b 0x5C 0xA8 } } [ "ab¥ィ" shift-jis encode >array ] unit-test
|
||||
{ "ab\\ィ" } [ { char: a char: b 0x5C 0xA8 } windows-31j decode ] unit-test
|
||||
{ { char: a char: b 0x5C 0xA8 } } [ "ab\\ィ" windows-31j encode >array ] unit-test
|
||||
{ "\u000081\u0000c8" } [ char: logical-and 1string windows-31j encode >string ] unit-test
|
||||
{ "\u000081\u0000c8" } [ char: logical-and 1string shift-jis encode >string ] unit-test
|
||||
{ { char: logical-and } } [ "\u000081\u0000c8" windows-31j decode >array ] unit-test
|
||||
{ { char: logical-and } } [ "\u000081\u0000c8" shift-jis decode >array ] unit-test
|
||||
|
|
|
@ -5,25 +5,25 @@ io.streams.byte-array sequences io.encodings io strings
|
|||
io.encodings.string alien.c-types alien.strings accessors classes ;
|
||||
IN: io.encodings.utf32.tests
|
||||
|
||||
{ { CHAR: x } } [ B{ 0 0 0 CHAR: x } utf32be decode >array ] unit-test
|
||||
{ { char: x } } [ B{ 0 0 0 char: x } utf32be decode >array ] unit-test
|
||||
{ { 0x1D11E } } [ B{ 0 1 0xD1 0x1E } utf32be decode >array ] unit-test
|
||||
{ { CHAR: replacement-character } } [ B{ 0 1 0xD1 } utf32be decode >array ] unit-test
|
||||
{ { CHAR: replacement-character } } [ B{ 0 1 } utf32be decode >array ] unit-test
|
||||
{ { CHAR: replacement-character } } [ B{ 0 } utf32be decode >array ] unit-test
|
||||
{ { char: replacement-character } } [ B{ 0 1 0xD1 } utf32be decode >array ] unit-test
|
||||
{ { char: replacement-character } } [ B{ 0 1 } utf32be decode >array ] unit-test
|
||||
{ { char: replacement-character } } [ B{ 0 } utf32be decode >array ] unit-test
|
||||
{ { } } [ { } utf32be decode >array ] unit-test
|
||||
|
||||
{ B{ 0 0 0 CHAR: x 0 1 0xD1 0x1E } } [ { CHAR: x 0x1d11e } >string utf32be encode ] unit-test
|
||||
{ B{ 0 0 0 char: x 0 1 0xD1 0x1E } } [ { char: x 0x1d11e } >string utf32be encode ] unit-test
|
||||
|
||||
{ { CHAR: x } } [ B{ CHAR: x 0 0 0 } utf32le decode >array ] unit-test
|
||||
{ { char: x } } [ B{ char: x 0 0 0 } utf32le decode >array ] unit-test
|
||||
{ { 0x1d11e } } [ B{ 0x1e 0xd1 1 0 } utf32le decode >array ] unit-test
|
||||
{ { CHAR: replacement-character } } [ B{ 0x1e 0xd1 1 } utf32le decode >array ] unit-test
|
||||
{ { CHAR: replacement-character } } [ B{ 0x1e 0xd1 } utf32le decode >array ] unit-test
|
||||
{ { CHAR: replacement-character } } [ B{ 0x1e } utf32le decode >array ] unit-test
|
||||
{ { char: replacement-character } } [ B{ 0x1e 0xd1 1 } utf32le decode >array ] unit-test
|
||||
{ { char: replacement-character } } [ B{ 0x1e 0xd1 } utf32le decode >array ] unit-test
|
||||
{ { char: replacement-character } } [ B{ 0x1e } utf32le decode >array ] unit-test
|
||||
{ { } } [ { } utf32le decode >array ] unit-test
|
||||
|
||||
{ B{ 120 0 0 0 0x1e 0xd1 1 0 } } [ { CHAR: x 0x1d11e } >string utf32le encode ] unit-test
|
||||
{ B{ 120 0 0 0 0x1e 0xd1 1 0 } } [ { char: x 0x1d11e } >string utf32le encode ] unit-test
|
||||
|
||||
{ { CHAR: x } } [ B{ 0xff 0xfe 0 0 CHAR: x 0 0 0 } utf32 decode >array ] unit-test
|
||||
{ { CHAR: x } } [ B{ 0 0 0xfe 0xff 0 0 0 CHAR: x } utf32 decode >array ] unit-test
|
||||
{ { char: x } } [ B{ 0xff 0xfe 0 0 char: x 0 0 0 } utf32 decode >array ] unit-test
|
||||
{ { char: x } } [ B{ 0 0 0xfe 0xff 0 0 0 char: x } utf32 decode >array ] unit-test
|
||||
|
||||
{ B{ 0xff 0xfe 0 0 120 0 0 0 0x1e 0xd1 1 0 } } [ { CHAR: x 0x1d11e } >string utf32 encode ] unit-test
|
||||
{ B{ 0xff 0xfe 0 0 120 0 0 0 0x1e 0xd1 1 0 } } [ { char: x 0x1d11e } >string utf32 encode ] unit-test
|
||||
|
|
|
@ -13,20 +13,20 @@ TUPLE: utf7codec dialect buffer ;
|
|||
: utf7 ( -- utf7codec )
|
||||
{
|
||||
{ { } { } }
|
||||
{ { CHAR: + } { CHAR: - } }
|
||||
{ { char: + } { char: - } }
|
||||
} V{ } utf7codec boa ;
|
||||
|
||||
: utf7imap4 ( -- utf7codec )
|
||||
{
|
||||
{ { CHAR: / } { CHAR: , } }
|
||||
{ { CHAR: & } { CHAR: - } }
|
||||
{ { char: / } { char: , } }
|
||||
{ { char: & } { char: - } }
|
||||
} V{ } utf7codec boa ;
|
||||
|
||||
: >raw-base64 ( bytes -- bytes' )
|
||||
>string utf16be encode >base64 [ CHAR: = = ] trim-tail ;
|
||||
>string utf16be encode >base64 [ char: = = ] trim-tail ;
|
||||
|
||||
: raw-base64> ( str -- str' )
|
||||
dup length 4 / ceiling 4 * CHAR: = pad-tail base64> utf16be decode ;
|
||||
dup length 4 / ceiling 4 * char: = pad-tail base64> utf16be decode ;
|
||||
|
||||
: encode-chunk ( repl-pair surround-pair chunk ascii? -- bytes )
|
||||
[ swap [ first ] [ concat ] bi replace nip ]
|
||||
|
|
|
@ -65,7 +65,7 @@ frequency pass-number ;
|
|||
} cleave ;
|
||||
|
||||
: parse-mtab ( -- array )
|
||||
CHAR: \s [ "/etc/mtab" utf8 file>csv ] with-delimiter
|
||||
char: \s [ "/etc/mtab" utf8 file>csv ] with-delimiter
|
||||
[ mtab-csv>mtab-entry ] map ;
|
||||
|
||||
: mtab-entry>file-system-info ( mtab-entry -- file-system-info/f )
|
||||
|
|
|
@ -242,26 +242,26 @@ M: string set-file-group ( path string -- )
|
|||
|
||||
: ch>file-type ( ch -- type )
|
||||
{
|
||||
{ CHAR: b [ +block-device+ ] }
|
||||
{ CHAR: c [ +character-device+ ] }
|
||||
{ CHAR: d [ +directory+ ] }
|
||||
{ CHAR: l [ +symbolic-link+ ] }
|
||||
{ CHAR: s [ +socket+ ] }
|
||||
{ CHAR: p [ +fifo+ ] }
|
||||
{ CHAR: - [ +regular-file+ ] }
|
||||
{ char: b [ +block-device+ ] }
|
||||
{ char: c [ +character-device+ ] }
|
||||
{ char: d [ +directory+ ] }
|
||||
{ char: l [ +symbolic-link+ ] }
|
||||
{ char: s [ +socket+ ] }
|
||||
{ char: p [ +fifo+ ] }
|
||||
{ char: - [ +regular-file+ ] }
|
||||
[ drop +unknown+ ]
|
||||
} case ;
|
||||
|
||||
: file-type>ch ( type -- ch )
|
||||
{
|
||||
{ +block-device+ [ CHAR: b ] }
|
||||
{ +character-device+ [ CHAR: c ] }
|
||||
{ +directory+ [ CHAR: d ] }
|
||||
{ +symbolic-link+ [ CHAR: l ] }
|
||||
{ +socket+ [ CHAR: s ] }
|
||||
{ +fifo+ [ CHAR: p ] }
|
||||
{ +regular-file+ [ CHAR: - ] }
|
||||
[ drop CHAR: - ]
|
||||
{ +block-device+ [ char: b ] }
|
||||
{ +character-device+ [ char: c ] }
|
||||
{ +directory+ [ char: d ] }
|
||||
{ +symbolic-link+ [ char: l ] }
|
||||
{ +socket+ [ char: s ] }
|
||||
{ +fifo+ [ char: p ] }
|
||||
{ +regular-file+ [ char: - ] }
|
||||
[ drop char: - ]
|
||||
} case ;
|
||||
|
||||
<PRIVATE
|
||||
|
|
|
@ -147,7 +147,7 @@ ERROR: not-absolute-path ;
|
|||
unicode-prefix ?head drop
|
||||
dup {
|
||||
[ length 2 >= ]
|
||||
[ second CHAR: : = ]
|
||||
[ second char: : = ]
|
||||
[ first Letter? ]
|
||||
} 1&& [ 2 head "\\" append ] [ not-absolute-path ] if ;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ IN: io.files.unique.tests
|
|||
{ 123 } [
|
||||
[
|
||||
"core" ".test" [
|
||||
[ [ 123 CHAR: a <string> ] dip ascii set-file-contents ]
|
||||
[ [ 123 char: a <string> ] dip ascii set-file-contents ]
|
||||
[ file-info size>> ] bi
|
||||
] cleanup-unique-file
|
||||
] with-temp-directory
|
||||
|
|
|
@ -320,7 +320,7 @@ M: windows root-directory? ( path -- ? )
|
|||
{ [ dup empty? ] [ drop f ] }
|
||||
{ [ dup [ path-separator? ] all? ] [ drop t ] }
|
||||
{ [ dup trim-tail-separators { [ length 2 = ]
|
||||
[ second CHAR: : = ] } 1&& ] [ drop t ] }
|
||||
[ second char: : = ] } 1&& ] [ drop t ] }
|
||||
{ [ dup unicode-prefix head? ]
|
||||
[ trim-tail-separators length unicode-prefix length 2 + = ] }
|
||||
[ drop f ]
|
||||
|
|
|
@ -57,17 +57,17 @@ TUPLE: CreateProcess-args
|
|||
|
||||
: fix-trailing-backslashes ( str -- str' )
|
||||
0 count-trailing-backslashes
|
||||
2 * CHAR: \\ <repetition> append ;
|
||||
2 * char: \\ <repetition> append ;
|
||||
|
||||
! Find groups of \, groups of \ followed by ", or naked "
|
||||
: escape-double-quote ( str -- newstr )
|
||||
[
|
||||
{ [ drop CHAR: \ = ] [ nip "\\\"" member? ] } 2&&
|
||||
{ [ drop char: \ = ] [ nip "\\\"" member? ] } 2&&
|
||||
] monotonic-split [
|
||||
dup last CHAR: \" = [
|
||||
dup last char: \" = [
|
||||
dup length 1 > [
|
||||
! String of backslashes + double-quote
|
||||
length 1 - 2 * CHAR: \\ <repetition> "\\\"" append
|
||||
length 1 - 2 * char: \\ <repetition> "\\\"" append
|
||||
] [
|
||||
! Single double-quote
|
||||
drop "\\\""
|
||||
|
@ -81,7 +81,7 @@ TUPLE: CreateProcess-args
|
|||
! See http://msdn.microsoft.com/en-us/library/ms647232.aspx
|
||||
: escape-argument ( str -- newstr )
|
||||
escape-double-quote
|
||||
CHAR: \s over member? [
|
||||
char: \s over member? [
|
||||
fix-trailing-backslashes "\"" dup surround
|
||||
] when ;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ SPECIALIZED-ARRAY: uint
|
|||
|
||||
[| path |
|
||||
"12345" path ascii set-file-contents
|
||||
{ } [ path [ char <mapped-array> CHAR: 2 0 pick set-nth drop ] with-mapped-file ] unit-test
|
||||
{ } [ path [ char <mapped-array> char: 2 0 pick set-nth drop ] with-mapped-file ] unit-test
|
||||
{ 5 } [ path [ char <mapped-array> length ] with-mapped-file ] unit-test
|
||||
{ 5 } [ path [ char <mapped-array> length ] with-mapped-file-reader ] unit-test
|
||||
{ "22345" } [ path ascii file-contents ] unit-test
|
||||
|
|
|
@ -353,7 +353,7 @@ M: ssl-handle dispose*
|
|||
"*." ?head [
|
||||
{
|
||||
[ tail? ]
|
||||
[ [ [ CHAR: . = ] count ] bi@ - 1 <= ]
|
||||
[ [ [ char: . = ] count ] bi@ - 1 <= ]
|
||||
} 2&&
|
||||
] [
|
||||
=
|
||||
|
|
|
@ -13,7 +13,7 @@ IN: io.streams.limited.tests
|
|||
|
||||
{ } [ "data" get 24 <limited-stream> "limited" set ] unit-test
|
||||
|
||||
{ CHAR: h } [ "limited" get stream-read1 ] unit-test
|
||||
{ char: h } [ "limited" get stream-read1 ] unit-test
|
||||
|
||||
{ } [ "limited" get ascii <decoder> "decoded" set ] unit-test
|
||||
|
||||
|
@ -33,13 +33,13 @@ IN: io.streams.limited.tests
|
|||
|
||||
{ } [ "data" get 4 <limited-stream> "limited" set ] unit-test
|
||||
|
||||
{ "abc" CHAR: \n }
|
||||
{ "abc" char: \n }
|
||||
[ "\n" "limited" get stream-read-until [ >string ] dip ] unit-test
|
||||
|
||||
{ "" f } [ "\n" "limited" get stream-read-until [ >string ] dip ] unit-test
|
||||
|
||||
|
||||
{ CHAR: a }
|
||||
{ char: a }
|
||||
[ "a" <string-reader> 1 <limited-stream> stream-read1 ] unit-test
|
||||
|
||||
{ "abc" }
|
||||
|
|
|
@ -4,7 +4,7 @@ IN: io.streams.string.tests
|
|||
|
||||
{ "" } [ "" [ contents ] with-string-reader ] unit-test
|
||||
|
||||
{ "line 1" CHAR: l }
|
||||
{ "line 1" char: l }
|
||||
[
|
||||
"line 1\nline 2\nline 3" [ readln read1 ] with-string-reader
|
||||
]
|
||||
|
@ -29,8 +29,8 @@ unit-test
|
|||
{ "abc" f } [ "abc" [ 3 read read1 ] with-string-reader ] unit-test
|
||||
|
||||
{
|
||||
{ "It seems " CHAR: J }
|
||||
{ "obs has lost h" CHAR: i }
|
||||
{ "It seems " char: J }
|
||||
{ "obs has lost h" char: i }
|
||||
{ "s grasp on reality again.\n" f }
|
||||
} [
|
||||
"It seems Jobs has lost his grasp on reality again.\n" [
|
||||
|
@ -40,7 +40,7 @@ unit-test
|
|||
] with-string-reader
|
||||
] unit-test
|
||||
|
||||
{ "" CHAR: \r } [ "\r\n" [ "\r" read-until ] with-string-reader ] unit-test
|
||||
{ "" char: \r } [ "\r\n" [ "\r" read-until ] with-string-reader ] unit-test
|
||||
{ f f } [ "" [ "\r" read-until ] with-string-reader ] unit-test
|
||||
|
||||
{ "hello" "hi" } [
|
||||
|
|
|
@ -15,8 +15,8 @@ M: string-reader stream-read1 sequence-read1 ;
|
|||
M: string-reader stream-read-until sequence-read-until ;
|
||||
M: string-reader stream-readln
|
||||
dup >sequence-stream< bounds-check? [
|
||||
"\r\n" over sequence-read-until CHAR: \r eq? [
|
||||
over >sequence-stream< dupd ?nth CHAR: \n eq?
|
||||
"\r\n" over sequence-read-until char: \r eq? [
|
||||
over >sequence-stream< dupd ?nth char: \n eq?
|
||||
[ 1 + pick i<< ] [ drop ] if
|
||||
] when nip "" or
|
||||
] [ drop f ] if ;
|
||||
|
|
|
@ -52,7 +52,7 @@ IN: io.streams.throwing.tests
|
|||
] with-byte-reader
|
||||
] [ stream-exhausted? ] must-fail-with
|
||||
|
||||
{ "asd" CHAR: f } [
|
||||
{ "asd" char: f } [
|
||||
"asdf" [ [ "f" read-until ] throw-on-eof ] with-string-reader
|
||||
] unit-test
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ ERROR: more-than-8-components ;
|
|||
dup hex> [ ] [ bad-ipv6-component ] ?if ;
|
||||
|
||||
: split-ipv6 ( string -- seq )
|
||||
":" split CHAR: . over last member? [ unclip-last ] [ f ] if
|
||||
":" split char: . over last member? [ unclip-last ] [ f ] if
|
||||
[ [ ipv6-component ] map ]
|
||||
[ [ parse-ipv4 append ] unless-empty ] bi* ;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ GENERIC: pprint-json* ( obj -- )
|
|||
: write-spaces ( -- )
|
||||
indent-level get 0 > [
|
||||
indent-level get nspaces *
|
||||
CHAR: \s
|
||||
char: \s
|
||||
<string> write
|
||||
] when ;
|
||||
|
||||
|
|
|
@ -44,25 +44,25 @@ DEFER: (read-json-string)
|
|||
: (read-json-escape) ( stream accum -- accum )
|
||||
{ sbuf } declare
|
||||
over stream-read1 {
|
||||
{ CHAR: \" [ CHAR: \" ] }
|
||||
{ CHAR: \\ [ CHAR: \\ ] }
|
||||
{ CHAR: / [ CHAR: / ] }
|
||||
{ CHAR: b [ CHAR: \b ] }
|
||||
{ CHAR: f [ CHAR: \f ] }
|
||||
{ CHAR: n [ CHAR: \n ] }
|
||||
{ CHAR: r [ CHAR: \r ] }
|
||||
{ CHAR: t [ CHAR: \t ] }
|
||||
{ CHAR: u [ over read-json-escape-unicode ] }
|
||||
{ char: \" [ char: \" ] }
|
||||
{ char: \\ [ char: \\ ] }
|
||||
{ char: / [ char: / ] }
|
||||
{ char: b [ char: \b ] }
|
||||
{ char: f [ char: \f ] }
|
||||
{ char: n [ char: \n ] }
|
||||
{ char: r [ char: \r ] }
|
||||
{ char: t [ char: \t ] }
|
||||
{ char: u [ over read-json-escape-unicode ] }
|
||||
[ ]
|
||||
} case [ suffix! (read-json-string) ] [ json-error ] if* ;
|
||||
|
||||
: (read-json-string) ( stream accum -- accum )
|
||||
{ sbuf } declare
|
||||
"\\\"" pick stream-read-until [ append! ] dip
|
||||
CHAR: \" = [ nip ] [ (read-json-escape) ] if ;
|
||||
char: \" = [ nip ] [ (read-json-escape) ] if ;
|
||||
|
||||
: read-json-string ( stream -- str )
|
||||
"\\\"" over stream-read-until CHAR: \" =
|
||||
"\\\"" over stream-read-until char: \" =
|
||||
[ nip ] [ >sbuf (read-json-escape) { sbuf } declare "" like ] if ;
|
||||
|
||||
: second-last-unsafe ( seq -- second-last )
|
||||
|
@ -108,20 +108,20 @@ DEFER: (read-json-string)
|
|||
! 2dup 1string swap . . ! Great for debug...
|
||||
{ object vector object } declare
|
||||
{
|
||||
{ CHAR: \" [ over read-json-string suffix! ] }
|
||||
{ CHAR: [ [ json-open-array ] }
|
||||
{ CHAR: , [ v-over-push ] }
|
||||
{ CHAR: ] [ json-close-array ] }
|
||||
{ CHAR: { [ json-open-hash ] }
|
||||
{ CHAR: : [ v-pick-push ] }
|
||||
{ CHAR: } [ json-close-hash ] }
|
||||
{ CHAR: \s [ ] }
|
||||
{ CHAR: \t [ ] }
|
||||
{ CHAR: \r [ ] }
|
||||
{ CHAR: \n [ ] }
|
||||
{ CHAR: t [ "rue" pick json-expect t suffix! ] }
|
||||
{ CHAR: f [ "alse" pick json-expect f suffix! ] }
|
||||
{ CHAR: n [ "ull" pick json-expect json-null suffix! ] }
|
||||
{ char: \" [ over read-json-string suffix! ] }
|
||||
{ char: [ [ json-open-array ] }
|
||||
{ char: , [ v-over-push ] }
|
||||
{ char: ] [ json-close-array ] }
|
||||
{ char: { [ json-open-hash ] }
|
||||
{ char: : [ v-pick-push ] }
|
||||
{ char: } [ json-close-hash ] }
|
||||
{ char: \s [ ] }
|
||||
{ char: \t [ ] }
|
||||
{ char: \r [ ] }
|
||||
{ char: \n [ ] }
|
||||
{ char: t [ "rue" pick json-expect t suffix! ] }
|
||||
{ char: f [ "alse" pick json-expect f suffix! ] }
|
||||
{ char: n [ "ull" pick json-expect json-null suffix! ] }
|
||||
[ pick json-number [ suffix! ] dip [ scan ] when* ]
|
||||
} case ;
|
||||
|
||||
|
|
|
@ -59,20 +59,20 @@ M: json-null stream-json-print
|
|||
PRIVATE>
|
||||
|
||||
M: string stream-json-print
|
||||
CHAR: \" over stream-write1 swap [
|
||||
char: \" over stream-write1 swap [
|
||||
{
|
||||
{ CHAR: \" [ "\\\"" over stream-write ] }
|
||||
{ CHAR: \\ [ "\\\\" over stream-write ] }
|
||||
{ CHAR: / [
|
||||
{ char: \" [ "\\\"" over stream-write ] }
|
||||
{ char: \\ [ "\\\\" over stream-write ] }
|
||||
{ char: / [
|
||||
json-escape-slashes? get
|
||||
[ "\\/" over stream-write ]
|
||||
[ CHAR: / over stream-write1 ] if
|
||||
[ char: / over stream-write1 ] if
|
||||
] }
|
||||
{ CHAR: \b [ "\\b" over stream-write ] }
|
||||
{ CHAR: \f [ "\\f" over stream-write ] }
|
||||
{ CHAR: \n [ "\\n" over stream-write ] }
|
||||
{ CHAR: \r [ "\\r" over stream-write ] }
|
||||
{ CHAR: \t [ "\\t" over stream-write ] }
|
||||
{ char: \b [ "\\b" over stream-write ] }
|
||||
{ char: \f [ "\\f" over stream-write ] }
|
||||
{ char: \n [ "\\n" over stream-write ] }
|
||||
{ char: \r [ "\\r" over stream-write ] }
|
||||
{ char: \t [ "\\t" over stream-write ] }
|
||||
{ 0x2028 [ "\\u2028" over stream-write ] }
|
||||
{ 0x2029 [ "\\u2029" over stream-write ] }
|
||||
[
|
||||
|
@ -87,7 +87,7 @@ M: string stream-json-print
|
|||
] if
|
||||
]
|
||||
} case
|
||||
] each CHAR: \" swap stream-write1 ;
|
||||
] each char: \" swap stream-write1 ;
|
||||
|
||||
M: integer stream-json-print
|
||||
[ number>string ] [ stream-write ] bi* ;
|
||||
|
@ -111,10 +111,10 @@ M: real stream-json-print
|
|||
[ >float number>string ] [ stream-write ] bi* ;
|
||||
|
||||
M: sequence stream-json-print
|
||||
CHAR: [ over stream-write1 swap
|
||||
over '[ CHAR: , _ stream-write1 ]
|
||||
char: [ over stream-write1 swap
|
||||
over '[ char: , _ stream-write1 ]
|
||||
pick '[ _ stream-json-print ] interleave
|
||||
CHAR: ] swap stream-write1 ;
|
||||
char: ] swap stream-write1 ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
|
@ -130,8 +130,8 @@ M: float json-coerce float>json ;
|
|||
M: real json-coerce >float number>string ;
|
||||
|
||||
:: json-print-assoc ( obj stream -- )
|
||||
CHAR: { stream stream-write1 obj >alist
|
||||
[ CHAR: , stream stream-write1 ]
|
||||
char: { stream stream-write1 obj >alist
|
||||
[ char: , stream stream-write1 ]
|
||||
json-friendly-keys? get
|
||||
json-coerce-keys? get '[
|
||||
first2 [
|
||||
|
@ -140,11 +140,11 @@ M: real json-coerce >float number>string ;
|
|||
[ _ [ json-coerce ] when ] if
|
||||
stream stream-json-print
|
||||
] [
|
||||
CHAR: : stream stream-write1
|
||||
char: : stream stream-write1
|
||||
stream stream-json-print
|
||||
] bi*
|
||||
] interleave
|
||||
CHAR: } stream stream-write1 ;
|
||||
char: } stream stream-write1 ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ IN: lcs.diff2html
|
|||
GENERIC: diff-line ( obj -- xml )
|
||||
|
||||
: item-string ( item -- string )
|
||||
item>> [ CHAR: no-break-space 1string ] when-empty ;
|
||||
item>> [ char: no-break-space 1string ] when-empty ;
|
||||
|
||||
M: retain diff-line
|
||||
item-string
|
||||
|
|
|
@ -14,12 +14,12 @@ USING: tools.test lcs ;
|
|||
{ "abd" } [ "faxbcd" "abdef" lcs ] unit-test
|
||||
|
||||
{ {
|
||||
T{ delete f CHAR: f }
|
||||
T{ retain f CHAR: a }
|
||||
T{ delete f CHAR: x }
|
||||
T{ retain f CHAR: b }
|
||||
T{ delete f CHAR: c }
|
||||
T{ retain f CHAR: d }
|
||||
T{ insert f CHAR: e }
|
||||
T{ insert f CHAR: f }
|
||||
T{ delete f char: f }
|
||||
T{ retain f char: a }
|
||||
T{ delete f char: x }
|
||||
T{ retain f char: b }
|
||||
T{ delete f char: c }
|
||||
T{ retain f char: d }
|
||||
T{ insert f char: e }
|
||||
T{ insert f char: f }
|
||||
} } [ "faxbcd" "abdef" lcs-diff ] unit-test
|
||||
|
|
|
@ -108,14 +108,14 @@ GENERIC#: lambda-generic-1 1 ( a b -- c )
|
|||
M:: integer lambda-generic-1 ( a b -- c ) a b * ;
|
||||
|
||||
M:: string lambda-generic-1 ( a b -- c )
|
||||
a b CHAR: x <string> lambda-generic ;
|
||||
a b char: x <string> lambda-generic ;
|
||||
|
||||
M:: integer lambda-generic ( a b -- c ) a b lambda-generic-1 ;
|
||||
|
||||
GENERIC#: lambda-generic-2 1 ( a b -- c )
|
||||
|
||||
M:: integer lambda-generic-2 ( a b -- c )
|
||||
a CHAR: x <string> b lambda-generic ;
|
||||
a char: x <string> b lambda-generic ;
|
||||
|
||||
M:: string lambda-generic-2 ( a b -- c ) a b append ;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ SYMBOL: log-files
|
|||
: timestamp-header. ( -- )
|
||||
"[" write now (timestamp>rfc3339) "] " write ;
|
||||
|
||||
: multiline-header ( -- str ) 20 CHAR: - <string> ; foldable
|
||||
: multiline-header ( -- str ) 20 char: - <string> ; foldable
|
||||
|
||||
: multiline-header. ( -- )
|
||||
"[" write multiline-header write "] " write ;
|
||||
|
|
|
@ -71,7 +71,7 @@ SYMBOL: mime-test-server
|
|||
mime-test-server get insecure>> ;
|
||||
|
||||
: a-stream ( n -- stream )
|
||||
CHAR: a <string> <string-reader> ;
|
||||
char: a <string> <string-reader> ;
|
||||
|
||||
{ } [
|
||||
[
|
||||
|
|
|
@ -18,7 +18,7 @@ ERROR: bad-heredoc identifier ;
|
|||
dup next-line-text [
|
||||
dup ";" =
|
||||
[ drop next-line ]
|
||||
[ % CHAR: \n , (parse-here) ] if
|
||||
[ % char: \n , (parse-here) ] if
|
||||
] [ ";" throw-unexpected-eof ] if ;
|
||||
|
||||
PRIVATE>
|
||||
|
@ -45,7 +45,7 @@ SYNTAX: STRING:
|
|||
end text i subseq-start-from [| j |
|
||||
i j text subseq % j end length +
|
||||
] [
|
||||
text i short tail % CHAR: \n ,
|
||||
text i short tail % char: \n ,
|
||||
lexer next-line
|
||||
0 end lexer (scan-multiline-string)
|
||||
] if*
|
||||
|
@ -66,7 +66,7 @@ SYNTAX: STRING:
|
|||
lexer line-text>> begin-text sequence= [
|
||||
lexer begin-text advance-same-line
|
||||
] [
|
||||
lexer line-text>> % CHAR: \n ,
|
||||
lexer line-text>> % char: \n ,
|
||||
lexer next-line
|
||||
begin-text lexer (parse-til-line-begins)
|
||||
] if
|
||||
|
|
|
@ -33,62 +33,62 @@ M: object >n-byte-array ( n string -- byte-array ) heap-size >n-byte-array ;
|
|||
: expand-pack-format ( str -- str' )
|
||||
f swap [
|
||||
dup digit?
|
||||
[ [ 0 or 10 * ] [ CHAR: 0 - ] bi* + f ]
|
||||
[ [ 0 or 10 * ] [ char: 0 - ] bi* + f ]
|
||||
[ [ 1 or ] [ <string> ] bi* f swap ] if
|
||||
] { } map-as "" concat-as nip ; foldable
|
||||
|
||||
CONSTANT: pack-table
|
||||
H{
|
||||
{ CHAR: c s8>byte-array }
|
||||
{ CHAR: C u8>byte-array }
|
||||
{ CHAR: s s16>byte-array }
|
||||
{ CHAR: S u16>byte-array }
|
||||
{ CHAR: t s24>byte-array }
|
||||
{ CHAR: T u24>byte-array }
|
||||
{ CHAR: i s32>byte-array }
|
||||
{ CHAR: I u32>byte-array }
|
||||
{ CHAR: q s64>byte-array }
|
||||
{ CHAR: Q u64>byte-array }
|
||||
{ CHAR: f write-float }
|
||||
{ CHAR: F write-float }
|
||||
{ CHAR: d write-double }
|
||||
{ CHAR: D write-double }
|
||||
{ char: c s8>byte-array }
|
||||
{ char: C u8>byte-array }
|
||||
{ char: s s16>byte-array }
|
||||
{ char: S u16>byte-array }
|
||||
{ char: t s24>byte-array }
|
||||
{ char: T u24>byte-array }
|
||||
{ char: i s32>byte-array }
|
||||
{ char: I u32>byte-array }
|
||||
{ char: q s64>byte-array }
|
||||
{ char: Q u64>byte-array }
|
||||
{ char: f write-float }
|
||||
{ char: F write-float }
|
||||
{ char: d write-double }
|
||||
{ char: D write-double }
|
||||
}
|
||||
|
||||
CONSTANT: unpack-table
|
||||
H{
|
||||
{ CHAR: c [ 8 signed-endian> ] }
|
||||
{ CHAR: C [ unsigned-endian> ] }
|
||||
{ CHAR: s [ 16 signed-endian> ] }
|
||||
{ CHAR: S [ unsigned-endian> ] }
|
||||
{ CHAR: t [ 24 signed-endian> ] }
|
||||
{ CHAR: T [ unsigned-endian> ] }
|
||||
{ CHAR: i [ 32 signed-endian> ] }
|
||||
{ CHAR: I [ unsigned-endian> ] }
|
||||
{ CHAR: q [ 64 signed-endian> ] }
|
||||
{ CHAR: Q [ unsigned-endian> ] }
|
||||
{ CHAR: f [ unsigned-endian> bits>float ] }
|
||||
{ CHAR: F [ unsigned-endian> bits>float ] }
|
||||
{ CHAR: d [ unsigned-endian> bits>double ] }
|
||||
{ CHAR: D [ unsigned-endian> bits>double ] }
|
||||
{ char: c [ 8 signed-endian> ] }
|
||||
{ char: C [ unsigned-endian> ] }
|
||||
{ char: s [ 16 signed-endian> ] }
|
||||
{ char: S [ unsigned-endian> ] }
|
||||
{ char: t [ 24 signed-endian> ] }
|
||||
{ char: T [ unsigned-endian> ] }
|
||||
{ char: i [ 32 signed-endian> ] }
|
||||
{ char: I [ unsigned-endian> ] }
|
||||
{ char: q [ 64 signed-endian> ] }
|
||||
{ char: Q [ unsigned-endian> ] }
|
||||
{ char: f [ unsigned-endian> bits>float ] }
|
||||
{ char: F [ unsigned-endian> bits>float ] }
|
||||
{ char: d [ unsigned-endian> bits>double ] }
|
||||
{ char: D [ unsigned-endian> bits>double ] }
|
||||
}
|
||||
|
||||
CONSTANT: packed-length-table
|
||||
H{
|
||||
{ CHAR: c 1 }
|
||||
{ CHAR: C 1 }
|
||||
{ CHAR: s 2 }
|
||||
{ CHAR: S 2 }
|
||||
{ CHAR: t 3 }
|
||||
{ CHAR: T 3 }
|
||||
{ CHAR: i 4 }
|
||||
{ CHAR: I 4 }
|
||||
{ CHAR: q 8 }
|
||||
{ CHAR: Q 8 }
|
||||
{ CHAR: f 4 }
|
||||
{ CHAR: F 4 }
|
||||
{ CHAR: d 8 }
|
||||
{ CHAR: D 8 }
|
||||
{ char: c 1 }
|
||||
{ char: C 1 }
|
||||
{ char: s 2 }
|
||||
{ char: S 2 }
|
||||
{ char: t 3 }
|
||||
{ char: T 3 }
|
||||
{ char: i 4 }
|
||||
{ char: I 4 }
|
||||
{ char: q 8 }
|
||||
{ char: Q 8 }
|
||||
{ char: f 4 }
|
||||
{ char: F 4 }
|
||||
{ char: d 8 }
|
||||
{ char: D 8 }
|
||||
}
|
||||
|
||||
PRIVATE>
|
||||
|
|
|
@ -371,7 +371,7 @@ ARTICLE: "peg.ebnf.tokenizers" "EBNF Tokenizers"
|
|||
}
|
||||
}
|
||||
"This parser when run with the string \"++--\" or the array "
|
||||
"{ CHAR: + CHAR: + CHAR: - CHAR: - } will succeed with an AST of { \"++\" \"--\" }. "
|
||||
"{ char: + char: + char: - char: - } will succeed with an AST of { \"++\" \"--\" }. "
|
||||
"If you want to add whitespace handling to the grammar you need to put it "
|
||||
"between the terminals:"
|
||||
{ $examples
|
||||
|
|
|
@ -156,11 +156,11 @@ IN: peg.ebnf.tests
|
|||
"ab" [EBNF foo=('a') [[ drop 1 ]] ('b') [[ drop 2 ]] EBNF]
|
||||
] unit-test
|
||||
|
||||
{ CHAR: A } [
|
||||
{ char: A } [
|
||||
"A" [EBNF foo=[A-Z] EBNF]
|
||||
] unit-test
|
||||
|
||||
{ CHAR: Z } [
|
||||
{ char: Z } [
|
||||
"Z" [EBNF foo=[A-Z] EBNF]
|
||||
] unit-test
|
||||
|
||||
|
@ -168,7 +168,7 @@ IN: peg.ebnf.tests
|
|||
"0" [EBNF foo=[A-Z] EBNF]
|
||||
] must-fail
|
||||
|
||||
{ CHAR: 0 } [
|
||||
{ char: 0 } [
|
||||
"0" [EBNF foo=[^A-Z] EBNF]
|
||||
] unit-test
|
||||
|
||||
|
@ -498,7 +498,7 @@ foo=<foreign any-char> 'd'
|
|||
"ac" parser3
|
||||
] unit-test
|
||||
|
||||
{ V{ CHAR: a "d" } } [
|
||||
{ V{ char: a "d" } } [
|
||||
"ad" parser4
|
||||
] unit-test
|
||||
|
||||
|
@ -517,7 +517,7 @@ foo=<foreign any-char> 'd'
|
|||
] unit-test
|
||||
|
||||
! Tokenizer tests
|
||||
{ V{ "a" CHAR: b } } [
|
||||
{ V{ "a" char: b } } [
|
||||
"ab" [EBNF tokenizer=default foo="a" . EBNF]
|
||||
] unit-test
|
||||
|
||||
|
@ -541,7 +541,7 @@ Special = "(" | ")" | "{" | "}" | "[" | "]" | "," | "
|
|||
Tok = Spaces (Number | Special )
|
||||
;EBNF
|
||||
|
||||
{ V{ CHAR: 1 T{ ast-number f 23 } ";" CHAR: x } } [
|
||||
{ V{ char: 1 T{ ast-number f 23 } ";" char: x } } [
|
||||
"123;x" [EBNF bar = .
|
||||
tokenizer = <foreign a-tokenizer Tok> foo=.
|
||||
tokenizer=default baz=.
|
||||
|
@ -549,7 +549,7 @@ Tok = Spaces (Number | Special )
|
|||
EBNF]
|
||||
] unit-test
|
||||
|
||||
{ V{ CHAR: 5 "+" CHAR: 2 } } [
|
||||
{ V{ char: 5 "+" char: 2 } } [
|
||||
"5+2" [EBNF
|
||||
space=(" " | "\n")
|
||||
number=[0-9]
|
||||
|
@ -560,7 +560,7 @@ Tok = Spaces (Number | Special )
|
|||
EBNF]
|
||||
] unit-test
|
||||
|
||||
{ V{ CHAR: 5 "+" CHAR: 2 } } [
|
||||
{ V{ char: 5 "+" char: 2 } } [
|
||||
"5 + 2" [EBNF
|
||||
space=(" " | "\n")
|
||||
number=[0-9]
|
||||
|
|
|
@ -112,11 +112,11 @@ C: <ebnf> ebnf
|
|||
! between the quotes.
|
||||
[
|
||||
[
|
||||
[ CHAR: \ = ] satisfy
|
||||
[ char: \ = ] satisfy
|
||||
[ "\"\\" member? ] satisfy 2seq ,
|
||||
[ CHAR: \" = not ] satisfy ,
|
||||
[ char: \" = not ] satisfy ,
|
||||
] choice* repeat1 "\"" "\"" surrounded-by ,
|
||||
[ CHAR: ' = not ] satisfy repeat1 "'" "'" surrounded-by ,
|
||||
[ char: ' = not ] satisfy repeat1 "'" "'" surrounded-by ,
|
||||
] choice* [ "" flatten-as unescape-string ] action ;
|
||||
|
||||
: non-terminal-parser ( -- parser )
|
||||
|
@ -140,7 +140,7 @@ C: <ebnf> ebnf
|
|||
[
|
||||
{
|
||||
[ blank? ]
|
||||
[ CHAR: > = ]
|
||||
[ char: > = ]
|
||||
} 1|| not
|
||||
] satisfy repeat1 [ >string ] action ;
|
||||
|
||||
|
@ -155,13 +155,13 @@ C: <ebnf> ebnf
|
|||
|
||||
: any-character-parser ( -- parser )
|
||||
! A parser to match the symbol for any character match.
|
||||
[ CHAR: . = ] satisfy [ drop <ebnf-any-character> ] action ;
|
||||
[ char: . = ] satisfy [ drop <ebnf-any-character> ] action ;
|
||||
|
||||
: range-parser-parser ( -- parser )
|
||||
! Match the syntax for declaring character ranges
|
||||
[
|
||||
[ "[" syntax , "[" token ensure-not , ] seq* hide ,
|
||||
[ CHAR: ] = not ] satisfy repeat1 ,
|
||||
[ char: ] = not ] satisfy repeat1 ,
|
||||
"]" syntax ,
|
||||
] seq* [ first >string unescape-string <ebnf-range> ] action ;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ HELP: 1token
|
|||
} { $description
|
||||
"Calls 1string on a character and returns a parser that matches that character."
|
||||
} { $examples
|
||||
{ $example "USING: peg peg.parsers prettyprint ;" "\"a\" CHAR: a 1token parse ." "\"a\"" }
|
||||
{ $example "USING: peg peg.parsers prettyprint ;" "\"a\" char: a 1token parse ." "\"a\"" }
|
||||
} { $see-also string-parser } ;
|
||||
|
||||
HELP: (list-of)
|
||||
|
|
|
@ -74,9 +74,9 @@ PRIVATE>
|
|||
|
||||
: string-parser ( -- parser )
|
||||
[
|
||||
[ CHAR: \" = ] satisfy hide ,
|
||||
[ CHAR: \" = not ] satisfy repeat0 ,
|
||||
[ CHAR: \" = ] satisfy hide ,
|
||||
[ char: \" = ] satisfy hide ,
|
||||
[ char: \" = not ] satisfy repeat0 ,
|
||||
[ char: \" = ] satisfy hide ,
|
||||
] seq* [ first >string ] action ;
|
||||
|
||||
: (range-pattern) ( pattern -- string )
|
||||
|
@ -84,7 +84,7 @@ PRIVATE>
|
|||
! all characters within that range.
|
||||
[
|
||||
any-char ,
|
||||
[ CHAR: - = ] satisfy hide ,
|
||||
[ char: - = ] satisfy hide ,
|
||||
any-char ,
|
||||
] seq* [
|
||||
first2 [a,b] >string
|
||||
|
@ -100,7 +100,7 @@ PRIVATE>
|
|||
! characters separated with a dash (-) represents the
|
||||
! range of characters from the first to the second,
|
||||
! inclusive.
|
||||
dup first CHAR: ^ = [
|
||||
dup first char: ^ = [
|
||||
rest (range-pattern) [ member? not ] curry satisfy
|
||||
] [
|
||||
(range-pattern) [ member? ] curry satisfy
|
||||
|
|
|
@ -49,7 +49,7 @@ HELP: range
|
|||
}
|
||||
{ $description
|
||||
"Returns a parser that matches a single character that lies within the range of characters given, inclusive." }
|
||||
{ $examples { $code ": digit ( -- parser ) CHAR: 0 CHAR: 9 range ;" } } ;
|
||||
{ $examples { $code ": digit ( -- parser ) char: 0 char: 9 range ;" } } ;
|
||||
|
||||
HELP: seq
|
||||
{ $values
|
||||
|
@ -137,7 +137,7 @@ HELP: action
|
|||
"from that parse. The result of the quotation is then used as the final AST. This can be used "
|
||||
"for manipulating the parse tree to produce a AST better suited for the task at hand rather than "
|
||||
"the default AST. If the quotation returns " { $link fail } " then the parser fails." }
|
||||
{ $code "CHAR: 0 CHAR: 9 range [ to-digit ] action" } ;
|
||||
{ $code "char: 0 char: 9 range [ to-digit ] action" } ;
|
||||
|
||||
HELP: sp
|
||||
{ $values
|
||||
|
|
|
@ -18,19 +18,19 @@ IN: peg.tests
|
|||
] unit-test
|
||||
|
||||
[
|
||||
"" CHAR: a CHAR: z range parse
|
||||
"" char: a char: z range parse
|
||||
] must-fail
|
||||
|
||||
[
|
||||
"1bcd" CHAR: a CHAR: z range parse
|
||||
"1bcd" char: a char: z range parse
|
||||
] must-fail
|
||||
|
||||
{ CHAR: a } [
|
||||
"abcd" CHAR: a CHAR: z range parse
|
||||
{ char: a } [
|
||||
"abcd" char: a char: z range parse
|
||||
] unit-test
|
||||
|
||||
{ CHAR: z } [
|
||||
"zbcd" CHAR: a CHAR: z range parse
|
||||
{ char: z } [
|
||||
"zbcd" char: a char: z range parse
|
||||
] unit-test
|
||||
|
||||
[
|
||||
|
@ -93,12 +93,12 @@ IN: peg.tests
|
|||
"cb" "a" token optional "b" token 2array seq parse
|
||||
] must-fail
|
||||
|
||||
{ V{ CHAR: a CHAR: b } } [
|
||||
"ab" "a" token ensure CHAR: a CHAR: z range dup 3array seq parse
|
||||
{ V{ char: a char: b } } [
|
||||
"ab" "a" token ensure char: a char: z range dup 3array seq parse
|
||||
] unit-test
|
||||
|
||||
[
|
||||
"bb" "a" token ensure CHAR: a CHAR: z range 2array seq parse
|
||||
"bb" "a" token ensure char: a char: z range 2array seq parse
|
||||
] must-fail
|
||||
|
||||
{ t } [
|
||||
|
@ -138,11 +138,11 @@ IN: peg.tests
|
|||
] must-fail
|
||||
|
||||
[
|
||||
"b" [ CHAR: a = ] satisfy parse
|
||||
"b" [ char: a = ] satisfy parse
|
||||
] must-fail
|
||||
|
||||
{ CHAR: a } [
|
||||
"a" [ CHAR: a = ] satisfy parse
|
||||
{ char: a } [
|
||||
"a" [ char: a = ] satisfy parse
|
||||
] unit-test
|
||||
|
||||
{ "a" } [
|
||||
|
@ -191,7 +191,7 @@ IN: peg.tests
|
|||
"A" [ drop t ] satisfy [ 66 >= ] semantic parse
|
||||
] must-fail
|
||||
|
||||
{ CHAR: B } [
|
||||
{ char: B } [
|
||||
"B" [ drop t ] satisfy [ 66 >= ] semantic parse
|
||||
] unit-test
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ M: hash-0-b hashcode* 2drop 0 ;
|
|||
|
||||
: random-string ( -- str )
|
||||
1000000 random ;
|
||||
! [ CHAR: a CHAR: z [a,b] random ] "" replicate-as ;
|
||||
! [ char: a char: z [a,b] random ] "" replicate-as ;
|
||||
|
||||
: random-assocs ( n -- hash phash )
|
||||
[ random-string ] replicate
|
||||
|
|
|
@ -5,7 +5,7 @@ IN: porter-stemmer
|
|||
2dup nth dup "aeiou" member? [
|
||||
3drop f
|
||||
] [
|
||||
CHAR: y = [
|
||||
char: y = [
|
||||
over zero?
|
||||
[ 2drop t ] [ [ 1 - ] dip consonant? not ] if
|
||||
] [
|
||||
|
@ -67,7 +67,7 @@ IN: porter-stemmer
|
|||
pick consonant-seq 0 > [ nip ] [ drop ] if append ;
|
||||
|
||||
: step1a ( str -- newstr )
|
||||
dup last CHAR: s = [
|
||||
dup last char: s = [
|
||||
{
|
||||
{ [ "sses" ?tail ] [ "ss" append ] }
|
||||
{ [ "ies" ?tail ] [ "i" append ] }
|
||||
|
@ -199,13 +199,13 @@ IN: porter-stemmer
|
|||
[ 1 = [ but-last-slice cvc? not ] [ drop f ] if ] if ;
|
||||
|
||||
: remove-e ( str -- newstr )
|
||||
dup last CHAR: e = [
|
||||
dup last char: e = [
|
||||
dup remove-e? [ but-last-slice ] when
|
||||
] when ;
|
||||
|
||||
: ll->l ( str -- newstr )
|
||||
{
|
||||
{ [ dup last CHAR: l = not ] [ ] }
|
||||
{ [ dup last char: l = not ] [ ] }
|
||||
{ [ dup length 1 - over double-consonant? not ] [ ] }
|
||||
{ [ dup consonant-seq 1 > ] [ but-last-slice ] }
|
||||
[ ]
|
||||
|
|
|
@ -100,21 +100,21 @@ M: f pprint* drop \ f pprint-word ;
|
|||
! Strings
|
||||
: ch>ascii-escape ( ch -- ch' ? )
|
||||
H{
|
||||
{ CHAR: \a CHAR: a }
|
||||
{ CHAR: \b CHAR: b }
|
||||
{ CHAR: \e CHAR: e }
|
||||
{ CHAR: \f CHAR: f }
|
||||
{ CHAR: \n CHAR: n }
|
||||
{ CHAR: \r CHAR: r }
|
||||
{ CHAR: \t CHAR: t }
|
||||
{ CHAR: \v CHAR: v }
|
||||
{ CHAR: \0 CHAR: 0 }
|
||||
{ CHAR: \\ CHAR: \\ }
|
||||
{ CHAR: \" CHAR: \" }
|
||||
{ char: \a char: a }
|
||||
{ char: \b char: b }
|
||||
{ char: \e char: e }
|
||||
{ char: \f char: f }
|
||||
{ char: \n char: n }
|
||||
{ char: \r char: r }
|
||||
{ char: \t char: t }
|
||||
{ char: \v char: v }
|
||||
{ char: \0 char: 0 }
|
||||
{ char: \\ char: \\ }
|
||||
{ char: \" char: \" }
|
||||
} ?at ; inline
|
||||
|
||||
: unparse-ch ( ch -- )
|
||||
ch>ascii-escape [ CHAR: \\ , , ] [
|
||||
ch>ascii-escape [ char: \\ , , ] [
|
||||
dup 32 < [ dup 16 < "\\x0" "\\x" ? % >hex % ] [ , ] if
|
||||
] if ;
|
||||
|
||||
|
|
|
@ -468,7 +468,7 @@ TUPLE: fo { a intersection{ integer fixnum } initial: 0 } ;
|
|||
|
||||
: margin-test ( number-of-'a's -- str )
|
||||
[
|
||||
[ CHAR: a <string> text "b" text ] with-pprint
|
||||
[ char: a <string> text "b" text ] with-pprint
|
||||
] with-string-writer ;
|
||||
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ M: maybe vocabulary-name
|
|||
: line-limit? ( -- ? )
|
||||
line-limit get dup [ pprinter get line-count>> <= ] when ;
|
||||
|
||||
: do-indent ( -- ) pprinter get indent>> CHAR: \s <string> write ;
|
||||
: do-indent ( -- ) pprinter get indent>> char: \s <string> write ;
|
||||
|
||||
: fresh-line ( n -- )
|
||||
pprinter get 2dup last-newline>> = [
|
||||
|
|
|
@ -15,16 +15,16 @@ IN: quoted-printable
|
|||
|
||||
: printable? ( ch -- ? )
|
||||
{
|
||||
[ CHAR: \s CHAR: < between? ]
|
||||
[ CHAR: > CHAR: ~ between? ]
|
||||
[ CHAR: \t = ]
|
||||
[ char: \s char: < between? ]
|
||||
[ char: > char: ~ between? ]
|
||||
[ char: \t = ]
|
||||
} 1|| ;
|
||||
|
||||
: char>quoted ( ch -- str )
|
||||
dup printable? [ 1string ] [
|
||||
assure-small >hex >upper
|
||||
2 CHAR: 0 pad-head
|
||||
CHAR: = prefix
|
||||
2 char: 0 pad-head
|
||||
char: = prefix
|
||||
] if ;
|
||||
|
||||
: take-some ( seqs -- seqs seq )
|
||||
|
@ -46,8 +46,8 @@ PRIVATE>
|
|||
<PRIVATE
|
||||
|
||||
: read-char ( byte -- ch )
|
||||
dup CHAR: = = [
|
||||
drop read1 dup CHAR: \n =
|
||||
dup char: = = [
|
||||
drop read1 dup char: \n =
|
||||
[ drop read1 read-char ]
|
||||
[ read1 2array hex> ] if
|
||||
] when ;
|
||||
|
|
|
@ -10,11 +10,11 @@ CONSTANT: letters-count 26
|
|||
>>
|
||||
|
||||
: random-digit ( -- ch )
|
||||
digits-count random CHAR: 0 + ;
|
||||
digits-count random char: 0 + ;
|
||||
|
||||
: random-LETTER ( -- ch ) letters-count random CHAR: A + ;
|
||||
: random-LETTER ( -- ch ) letters-count random char: A + ;
|
||||
|
||||
: random-letter ( -- ch ) letters-count random CHAR: a + ;
|
||||
: random-letter ( -- ch ) letters-count random char: a + ;
|
||||
|
||||
: random-Letter ( -- ch )
|
||||
{ random-LETTER random-letter } execute-random ;
|
||||
|
|
|
@ -8,10 +8,10 @@ IN: regexp.classes.tests
|
|||
{ f } [ { 1 2 } <and-class> ] unit-test
|
||||
{ T{ or-class f { 1 2 } } } [ { 1 2 } <or-class> ] unit-test
|
||||
{ 3 } [ { 1 2 } <and-class> 3 2array <or-class> ] unit-test
|
||||
{ CHAR: A } [ CHAR: A LETTER-class <primitive-class> 2array <and-class> ] unit-test
|
||||
{ CHAR: A } [ LETTER-class <primitive-class> CHAR: A 2array <and-class> ] unit-test
|
||||
{ T{ primitive-class { class LETTER-class } } } [ CHAR: A LETTER-class <primitive-class> 2array <or-class> ] unit-test
|
||||
{ T{ primitive-class { class LETTER-class } } } [ LETTER-class <primitive-class> CHAR: A 2array <or-class> ] unit-test
|
||||
{ char: A } [ char: A LETTER-class <primitive-class> 2array <and-class> ] unit-test
|
||||
{ char: A } [ LETTER-class <primitive-class> char: A 2array <and-class> ] unit-test
|
||||
{ T{ primitive-class { class LETTER-class } } } [ char: A LETTER-class <primitive-class> 2array <or-class> ] unit-test
|
||||
{ T{ primitive-class { class LETTER-class } } } [ LETTER-class <primitive-class> char: A 2array <or-class> ] unit-test
|
||||
{ t } [ { t 1 } <or-class> ] unit-test
|
||||
{ t } [ { 1 t } <or-class> ] unit-test
|
||||
{ f } [ { f 1 } <and-class> ] unit-test
|
||||
|
|
|
@ -55,7 +55,7 @@ M: digit-class class-member? ( obj class -- ? )
|
|||
drop digit? ; inline
|
||||
|
||||
: c-identifier-char? ( ch -- ? )
|
||||
{ [ alpha? ] [ CHAR: _ = ] } 1|| ;
|
||||
{ [ alpha? ] [ char: _ = ] } 1|| ;
|
||||
|
||||
M: c-identifier-class class-member? ( obj class -- ? )
|
||||
drop c-identifier-char? ; inline
|
||||
|
@ -76,16 +76,16 @@ M: java-printable-class class-member? ( obj class -- ? )
|
|||
drop java-printable? ; inline
|
||||
|
||||
M: non-newline-blank-class class-member? ( obj class -- ? )
|
||||
drop { [ blank? ] [ CHAR: \n = not ] } 1&& ; inline
|
||||
drop { [ blank? ] [ char: \n = not ] } 1&& ; inline
|
||||
|
||||
M: control-character-class class-member? ( obj class -- ? )
|
||||
drop control? ; inline
|
||||
|
||||
: hex-digit? ( ch -- ? )
|
||||
{
|
||||
[ CHAR: A CHAR: F between? ]
|
||||
[ CHAR: a CHAR: f between? ]
|
||||
[ CHAR: 0 CHAR: 9 between? ]
|
||||
[ char: A char: F between? ]
|
||||
[ char: a char: f between? ]
|
||||
[ char: 0 char: 9 between? ]
|
||||
} 1|| ;
|
||||
|
||||
M: hex-digit-class class-member? ( obj class -- ? )
|
||||
|
@ -93,8 +93,8 @@ M: hex-digit-class class-member? ( obj class -- ? )
|
|||
|
||||
: java-blank? ( ch -- ? )
|
||||
{
|
||||
CHAR: \s CHAR: \t CHAR: \n
|
||||
0xb 0x7 CHAR: \r
|
||||
char: \s char: \t char: \n
|
||||
0xb 0x7 char: \r
|
||||
} member? ;
|
||||
|
||||
M: java-blank-class class-member? ( obj class -- ? )
|
||||
|
|
|
@ -37,10 +37,10 @@ M: ^ question>quot
|
|||
drop [ { [ drop zero? ] [ [ 1 - ] dip ?nth "\r\n" member? ] } 2|| ] ;
|
||||
|
||||
M: $unix question>quot
|
||||
drop [ { [ length = ] [ ?nth CHAR: \n = ] } 2|| ] ;
|
||||
drop [ { [ length = ] [ ?nth char: \n = ] } 2|| ] ;
|
||||
|
||||
M: ^unix question>quot
|
||||
drop [ { [ drop zero? ] [ [ 1 - ] dip ?nth CHAR: \n = ] } 2|| ] ;
|
||||
drop [ { [ drop zero? ] [ [ 1 - ] dip ?nth char: \n = ] } 2|| ] ;
|
||||
|
||||
M: word-break question>quot
|
||||
drop [ word-break-at? ] ;
|
||||
|
|
|
@ -26,9 +26,9 @@ IN: regexp.minimize.tests
|
|||
{
|
||||
T{ transition-table
|
||||
{ transitions H{
|
||||
{ 0 H{ { CHAR: a 1 } { CHAR: b 1 } } }
|
||||
{ 1 H{ { CHAR: a 2 } { CHAR: b 2 } } }
|
||||
{ 2 H{ { CHAR: c 3 } } }
|
||||
{ 0 H{ { char: a 1 } { char: b 1 } } }
|
||||
{ 1 H{ { char: a 2 } { char: b 2 } } }
|
||||
{ 2 H{ { char: c 3 } } }
|
||||
{ 3 H{ } }
|
||||
} }
|
||||
{ start-state 0 }
|
||||
|
@ -37,12 +37,12 @@ IN: regexp.minimize.tests
|
|||
} [
|
||||
T{ transition-table
|
||||
{ transitions H{
|
||||
{ 0 H{ { CHAR: a 1 } { CHAR: b 4 } } }
|
||||
{ 1 H{ { CHAR: a 2 } { CHAR: b 5 } } }
|
||||
{ 2 H{ { CHAR: c 3 } } }
|
||||
{ 0 H{ { char: a 1 } { char: b 4 } } }
|
||||
{ 1 H{ { char: a 2 } { char: b 5 } } }
|
||||
{ 2 H{ { char: c 3 } } }
|
||||
{ 3 H{ } }
|
||||
{ 4 H{ { CHAR: a 2 } { CHAR: b 5 } } }
|
||||
{ 5 H{ { CHAR: c 6 } } }
|
||||
{ 4 H{ { char: a 2 } { char: b 5 } } }
|
||||
{ 5 H{ { char: c 6 } } }
|
||||
{ 6 H{ } }
|
||||
} }
|
||||
{ start-state 0 }
|
||||
|
|
|
@ -7,7 +7,7 @@ IN: regexp.negation.tests
|
|||
! R/ |[^a]|.+/
|
||||
T{ transition-table
|
||||
{ transitions H{
|
||||
{ 0 H{ { CHAR: a 1 } { T{ not-class f CHAR: a } -1 } } }
|
||||
{ 0 H{ { char: a 1 } { T{ not-class f char: a } -1 } } }
|
||||
{ 1 H{ { t -1 } } }
|
||||
{ -1 H{ { t -1 } } }
|
||||
} }
|
||||
|
@ -18,7 +18,7 @@ IN: regexp.negation.tests
|
|||
! R/ a/
|
||||
T{ transition-table
|
||||
{ transitions H{
|
||||
{ 0 H{ { CHAR: a 1 } } }
|
||||
{ 0 H{ { char: a 1 } } }
|
||||
{ 1 H{ } }
|
||||
} }
|
||||
{ start-state 0 }
|
||||
|
|
|
@ -116,10 +116,10 @@ M: not-class modify-class
|
|||
class>> modify-class <not-class> ;
|
||||
|
||||
MEMO: unix-dot ( -- class )
|
||||
CHAR: \n <not-class> ;
|
||||
char: \n <not-class> ;
|
||||
|
||||
MEMO: nonl-dot ( -- class )
|
||||
{ CHAR: \n CHAR: \r } <or-class> <not-class> ;
|
||||
{ char: \n char: \r } <or-class> <not-class> ;
|
||||
|
||||
M: dot modify-class
|
||||
drop dotall option? [ t ] [
|
||||
|
|
|
@ -70,36 +70,36 @@ MEMO: simple-category-table ( -- table )
|
|||
|
||||
: lookup-escape ( char -- ast )
|
||||
{
|
||||
{ CHAR: t [ CHAR: \t ] }
|
||||
{ CHAR: n [ CHAR: \n ] }
|
||||
{ CHAR: r [ CHAR: \r ] }
|
||||
{ CHAR: f [ 0xc ] }
|
||||
{ CHAR: a [ 0x7 ] }
|
||||
{ CHAR: e [ 0x1b ] }
|
||||
{ CHAR: \\ [ CHAR: \\ ] }
|
||||
{ char: t [ char: \t ] }
|
||||
{ char: n [ char: \n ] }
|
||||
{ char: r [ char: \r ] }
|
||||
{ char: f [ 0xc ] }
|
||||
{ char: a [ 0x7 ] }
|
||||
{ char: e [ 0x1b ] }
|
||||
{ char: \\ [ char: \\ ] }
|
||||
|
||||
{ CHAR: w [ c-identifier-class <primitive-class> ] }
|
||||
{ CHAR: W [ c-identifier-class <primitive-class> <not-class> ] }
|
||||
{ CHAR: s [ java-blank-class <primitive-class> ] }
|
||||
{ CHAR: S [ java-blank-class <primitive-class> <not-class> ] }
|
||||
{ CHAR: d [ digit-class <primitive-class> ] }
|
||||
{ CHAR: D [ digit-class <primitive-class> <not-class> ] }
|
||||
{ char: w [ c-identifier-class <primitive-class> ] }
|
||||
{ char: W [ c-identifier-class <primitive-class> <not-class> ] }
|
||||
{ char: s [ java-blank-class <primitive-class> ] }
|
||||
{ char: S [ java-blank-class <primitive-class> <not-class> ] }
|
||||
{ char: d [ digit-class <primitive-class> ] }
|
||||
{ char: D [ digit-class <primitive-class> <not-class> ] }
|
||||
|
||||
{ CHAR: z [ end-of-input <tagged-epsilon> ] }
|
||||
{ CHAR: Z [ end-of-file <tagged-epsilon> ] }
|
||||
{ CHAR: A [ beginning-of-input <tagged-epsilon> ] }
|
||||
{ CHAR: b [ word-break <tagged-epsilon> ] }
|
||||
{ CHAR: B [ word-break <not-class> <tagged-epsilon> ] }
|
||||
{ char: z [ end-of-input <tagged-epsilon> ] }
|
||||
{ char: Z [ end-of-file <tagged-epsilon> ] }
|
||||
{ char: A [ beginning-of-input <tagged-epsilon> ] }
|
||||
{ char: b [ word-break <tagged-epsilon> ] }
|
||||
{ char: B [ word-break <not-class> <tagged-epsilon> ] }
|
||||
[ ]
|
||||
} case ;
|
||||
|
||||
: options-assoc ( -- assoc )
|
||||
H{
|
||||
{ CHAR: i case-insensitive }
|
||||
{ CHAR: d unix-lines }
|
||||
{ CHAR: m multiline }
|
||||
{ CHAR: r reversed-regexp }
|
||||
{ CHAR: s dotall }
|
||||
{ char: i case-insensitive }
|
||||
{ char: d unix-lines }
|
||||
{ char: m multiline }
|
||||
{ char: r reversed-regexp }
|
||||
{ char: s dotall }
|
||||
} ;
|
||||
|
||||
ERROR: nonexistent-option name ;
|
||||
|
|
|
@ -200,9 +200,9 @@ PRIVATE>
|
|||
: take-until ( lexer -- string )
|
||||
dup skip-blank [
|
||||
dupd [
|
||||
[ CHAR: / -rot index-from ] keep
|
||||
[ char: / -rot index-from ] keep
|
||||
over [ "Unterminated regexp" throw ] unless
|
||||
2dup [ 1 - ] dip nth CHAR: \\ =
|
||||
2dup [ 1 - ] dip nth char: \\ =
|
||||
[ [ [ 1 + ] dip ] when ] keep
|
||||
] loop over [ subseq ] dip 1 +
|
||||
] change-lexer-column ;
|
||||
|
|
|
@ -10,7 +10,7 @@ HELP: nsequence
|
|||
"that constructs a sequence from the top " { $snippet "n" } " elements of the stack."
|
||||
}
|
||||
{ $examples
|
||||
{ $example "USING: prettyprint sequences.generalizations ;" "CHAR: f CHAR: i CHAR: s CHAR: h 4 \"\" nsequence ." "\"fish\"" }
|
||||
{ $example "USING: prettyprint sequences.generalizations ;" "char: f char: i char: s char: h 4 \"\" nsequence ." "\"fish\"" }
|
||||
} ;
|
||||
|
||||
HELP: narray
|
||||
|
|
|
@ -13,7 +13,7 @@ IN: sequences.parser.tests
|
|||
{ "foo" ";bar" }
|
||||
[
|
||||
"foo;bar" [
|
||||
[ CHAR: ; take-until-object ] [ take-rest ] bi
|
||||
[ char: ; take-until-object ] [ take-rest ] bi
|
||||
] parse-sequence
|
||||
] unit-test
|
||||
|
||||
|
|
|
@ -62,22 +62,22 @@ SYMBOL: serialized
|
|||
: serialize-shared ( obj quot -- )
|
||||
[
|
||||
dup object-id
|
||||
[ CHAR: o write1 serialize-cell drop ]
|
||||
[ char: o write1 serialize-cell drop ]
|
||||
] dip if* ; inline
|
||||
|
||||
M: f (serialize) ( obj -- )
|
||||
drop CHAR: n write1 ;
|
||||
drop char: n write1 ;
|
||||
|
||||
M: integer (serialize) ( obj -- )
|
||||
[
|
||||
CHAR: z write1
|
||||
char: z write1
|
||||
] [
|
||||
dup 0 < [ neg CHAR: m ] [ CHAR: p ] if write1
|
||||
dup 0 < [ neg char: m ] [ char: p ] if write1
|
||||
serialize-cell
|
||||
] if-zero ;
|
||||
|
||||
M: float (serialize) ( obj -- )
|
||||
CHAR: F write1
|
||||
char: F write1
|
||||
double>bits serialize-cell ;
|
||||
|
||||
: serialize-seq ( obj code -- )
|
||||
|
@ -90,7 +90,7 @@ M: float (serialize) ( obj -- )
|
|||
|
||||
M: tuple (serialize) ( obj -- )
|
||||
[
|
||||
CHAR: T write1
|
||||
char: T write1
|
||||
[ class-of (serialize) ]
|
||||
[ add-object ]
|
||||
[ tuple-slots (serialize) ]
|
||||
|
@ -98,23 +98,23 @@ M: tuple (serialize) ( obj -- )
|
|||
] serialize-shared ;
|
||||
|
||||
M: array (serialize) ( obj -- )
|
||||
CHAR: a serialize-seq ;
|
||||
char: a serialize-seq ;
|
||||
|
||||
M: quotation (serialize) ( obj -- )
|
||||
[
|
||||
CHAR: q write1
|
||||
char: q write1
|
||||
[ >array (serialize) ] [ add-object ] bi
|
||||
] serialize-shared ;
|
||||
|
||||
M: hashtable (serialize) ( obj -- )
|
||||
[
|
||||
CHAR: h write1
|
||||
char: h write1
|
||||
[ add-object ] [ >alist (serialize) ] bi
|
||||
] serialize-shared ;
|
||||
|
||||
M: byte-array (serialize) ( obj -- )
|
||||
[
|
||||
CHAR: A write1
|
||||
char: A write1
|
||||
[ add-object ]
|
||||
[ length serialize-cell ]
|
||||
[ write ] tri
|
||||
|
@ -122,7 +122,7 @@ M: byte-array (serialize) ( obj -- )
|
|||
|
||||
M: string (serialize) ( obj -- )
|
||||
[
|
||||
CHAR: s write1
|
||||
char: s write1
|
||||
[ add-object ]
|
||||
[
|
||||
utf8 encode
|
||||
|
@ -132,11 +132,11 @@ M: string (serialize) ( obj -- )
|
|||
] serialize-shared ;
|
||||
|
||||
: serialize-true ( word -- )
|
||||
drop CHAR: t write1 ;
|
||||
drop char: t write1 ;
|
||||
|
||||
: serialize-gensym ( word -- )
|
||||
[
|
||||
CHAR: G write1
|
||||
char: G write1
|
||||
[ add-object ]
|
||||
[ def>> (serialize) ]
|
||||
[ props>> (serialize) ]
|
||||
|
@ -144,7 +144,7 @@ M: string (serialize) ( obj -- )
|
|||
] serialize-shared ;
|
||||
|
||||
: serialize-word ( word -- )
|
||||
CHAR: w write1
|
||||
char: w write1
|
||||
[ name>> (serialize) ]
|
||||
[ vocabulary>> (serialize) ]
|
||||
bi ;
|
||||
|
@ -157,7 +157,7 @@ M: word (serialize) ( obj -- )
|
|||
} cond ;
|
||||
|
||||
M: wrapper (serialize) ( obj -- )
|
||||
CHAR: W write1
|
||||
char: W write1
|
||||
wrapped>> (serialize) ;
|
||||
|
||||
DEFER: (deserialize)
|
||||
|
@ -246,22 +246,22 @@ SYMBOL: deserialized
|
|||
: deserialize* ( -- object ? )
|
||||
read1 [
|
||||
{
|
||||
{ CHAR: A [ deserialize-byte-array ] }
|
||||
{ CHAR: F [ deserialize-float ] }
|
||||
{ CHAR: T [ deserialize-tuple ] }
|
||||
{ CHAR: W [ deserialize-wrapper ] }
|
||||
{ CHAR: a [ deserialize-array ] }
|
||||
{ CHAR: h [ deserialize-hashtable ] }
|
||||
{ CHAR: m [ deserialize-negative-integer ] }
|
||||
{ CHAR: n [ deserialize-false ] }
|
||||
{ CHAR: t [ deserialize-true ] }
|
||||
{ CHAR: o [ deserialize-unknown ] }
|
||||
{ CHAR: p [ deserialize-positive-integer ] }
|
||||
{ CHAR: q [ deserialize-quotation ] }
|
||||
{ CHAR: s [ deserialize-string ] }
|
||||
{ CHAR: w [ deserialize-word ] }
|
||||
{ CHAR: G [ deserialize-word ] }
|
||||
{ CHAR: z [ deserialize-zero ] }
|
||||
{ char: A [ deserialize-byte-array ] }
|
||||
{ char: F [ deserialize-float ] }
|
||||
{ char: T [ deserialize-tuple ] }
|
||||
{ char: W [ deserialize-wrapper ] }
|
||||
{ char: a [ deserialize-array ] }
|
||||
{ char: h [ deserialize-hashtable ] }
|
||||
{ char: m [ deserialize-negative-integer ] }
|
||||
{ char: n [ deserialize-false ] }
|
||||
{ char: t [ deserialize-true ] }
|
||||
{ char: o [ deserialize-unknown ] }
|
||||
{ char: p [ deserialize-positive-integer ] }
|
||||
{ char: q [ deserialize-quotation ] }
|
||||
{ char: s [ deserialize-string ] }
|
||||
{ char: w [ deserialize-word ] }
|
||||
{ char: G [ deserialize-word ] }
|
||||
{ char: z [ deserialize-zero ] }
|
||||
} case t
|
||||
] [
|
||||
f f
|
||||
|
|
|
@ -94,7 +94,7 @@ ERROR: bad-email-address email ;
|
|||
LOG: smtp-response DEBUG
|
||||
|
||||
: multiline? ( response -- ? )
|
||||
3 swap ?nth CHAR: - = ;
|
||||
3 swap ?nth char: - = ;
|
||||
|
||||
: (receive-response) ( -- )
|
||||
read-crlf
|
||||
|
|
|
@ -9,7 +9,7 @@ IN: strings.tables
|
|||
dup longest length '[ _ "" pad-tail ] map! ;
|
||||
|
||||
: format-column ( seq -- seq )
|
||||
dup longest length '[ _ CHAR: \s pad-tail ] map! ;
|
||||
dup longest length '[ _ char: \s pad-tail ] map! ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
|
|
|
@ -28,6 +28,6 @@ IN: tools.completion
|
|||
{ f } [ { "USING:" "A" "B" "C" ";" } complete-vocab? ] unit-test
|
||||
{ t } [ { "X" ";" "USING:" "A" "B" "C" } complete-vocab? ] unit-test
|
||||
|
||||
{ f } [ { "CHAR:" } complete-char? ] unit-test
|
||||
{ t } [ { "CHAR:" "" } complete-char? ] unit-test
|
||||
{ t } [ { "CHAR:" "a" } complete-char? ] unit-test
|
||||
{ f } [ { "char:" } complete-char? ] unit-test
|
||||
{ t } [ { "char:" "" } complete-char? ] unit-test
|
||||
{ t } [ { "char:" "a" } complete-char? ] unit-test
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue