Updating XML and Unicode for recent changes
parent
0ea300ccfa
commit
1ad96ad319
|
@ -18,7 +18,7 @@ IN: assocs.lib
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
: set-hash-stack ( value key seq -- )
|
: set-hash-stack ( value key seq -- )
|
||||||
dupd [ key? ] curry* find-last nip set-at ;
|
dupd [ key? ] when find-last nip set-at ;
|
||||||
|
|
||||||
: at-default ( key assoc -- value/key )
|
: at-default ( key assoc -- value/key )
|
||||||
dupd at [ nip ] when* ;
|
dupd at [ nip ] when* ;
|
||||||
|
|
|
@ -2,7 +2,7 @@ USING: kernel parser words sequences ;
|
||||||
IN: const
|
IN: const
|
||||||
|
|
||||||
: define-const ( word value -- )
|
: define-const ( word value -- )
|
||||||
[ parsed ] curry dupd define-compound
|
[ parsed ] curry dupd define
|
||||||
t "parsing" set-word-prop ;
|
t "parsing" set-word-prop ;
|
||||||
|
|
||||||
: CONST:
|
: CONST:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
USING: delegate help.syntax help.markup ;
|
USING: help.syntax help.markup ;
|
||||||
|
IN: delegate
|
||||||
|
|
||||||
HELP: define-protocol
|
HELP: define-protocol
|
||||||
{ $values { "wordlist" "a sequence of words" } { "protocol" "a word for the new protocol" } }
|
{ $values { "wordlist" "a sequence of words" } { "protocol" "a word for the new protocol" } }
|
||||||
|
|
|
@ -30,10 +30,9 @@ CATEGORY: grapheme-control Zl Zp Cc Cf ;
|
||||||
concat >set ;
|
concat >set ;
|
||||||
|
|
||||||
: other-extend-lines ( -- lines )
|
: other-extend-lines ( -- lines )
|
||||||
"extra/unicode/PropList.txt" resource-path <file-reader> lines ;
|
"extra/unicode/PropList.txt" resource-path file-lines ;
|
||||||
|
|
||||||
DEFER: other-extend
|
DEFER: other-extend
|
||||||
<< other-extend-lines process-other-extend \ other-extend define-value >>
|
|
||||||
|
|
||||||
CATEGORY: (extend) Me Mn ;
|
CATEGORY: (extend) Me Mn ;
|
||||||
: extend? ( ch -- ? )
|
: extend? ( ch -- ? )
|
||||||
|
@ -79,11 +78,6 @@ SYMBOL: table
|
||||||
graphemes Extend connect-after ;
|
graphemes Extend connect-after ;
|
||||||
|
|
||||||
DEFER: grapheme-table
|
DEFER: grapheme-table
|
||||||
<<
|
|
||||||
init-grapheme-table table
|
|
||||||
[ make-grapheme-table finish-table ] with-variable
|
|
||||||
\ grapheme-table define-value
|
|
||||||
>>
|
|
||||||
|
|
||||||
: grapheme-break? ( class1 class2 -- ? )
|
: grapheme-break? ( class1 class2 -- ? )
|
||||||
grapheme-table nth nth not ;
|
grapheme-table nth nth not ;
|
||||||
|
@ -125,3 +119,11 @@ DEFER: grapheme-table
|
||||||
|
|
||||||
: prev-grapheme ( i str -- prev-i )
|
: prev-grapheme ( i str -- prev-i )
|
||||||
prev-grapheme-step (prev-grapheme) ;
|
prev-grapheme-step (prev-grapheme) ;
|
||||||
|
|
||||||
|
[
|
||||||
|
other-extend-lines process-other-extend \ other-extend define-value
|
||||||
|
|
||||||
|
init-grapheme-table table
|
||||||
|
[ make-grapheme-table finish-table ] with-variable
|
||||||
|
\ grapheme-table define-value
|
||||||
|
] with-compilation-unit
|
||||||
|
|
|
@ -3,5 +3,5 @@ USING: tools.test kernel unicode.categories words sequences unicode.syntax ;
|
||||||
[ { f f t t f t t f f t } ] [ CHAR: A {
|
[ { f f t t f t t f f t } ] [ CHAR: A {
|
||||||
blank? letter? LETTER? Letter? digit?
|
blank? letter? LETTER? Letter? digit?
|
||||||
printable? alpha? control? uncased? character?
|
printable? alpha? control? uncased? character?
|
||||||
} [ execute ] curry* map ] unit-test
|
} [ execute ] with map ] unit-test
|
||||||
[ "Nd" ] [ CHAR: 3 category ] unit-test
|
[ "Nd" ] [ CHAR: 3 category ] unit-test
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
USING: assocs math kernel sequences io.files hashtables quotations
|
USING: assocs math kernel sequences io.files hashtables
|
||||||
splitting arrays math.parser combinators.lib hash2 byte-arrays words
|
quotations splitting arrays math.parser combinators.lib hash2
|
||||||
namespaces words ;
|
byte-arrays words namespaces words compiler.units ;
|
||||||
IN: unicode.data
|
IN: unicode.data
|
||||||
|
|
||||||
! Convenience functions
|
! Convenience functions
|
||||||
|
@ -116,19 +116,7 @@ DEFER: class-map
|
||||||
DEFER: compat-map
|
DEFER: compat-map
|
||||||
DEFER: category-map
|
DEFER: category-map
|
||||||
DEFER: name-map
|
DEFER: name-map
|
||||||
|
DEFER: special-casing
|
||||||
<<
|
|
||||||
load-data
|
|
||||||
dup process-names \ name-map define-value
|
|
||||||
13 over process-data \ simple-lower define-value
|
|
||||||
12 over process-data tuck \ simple-upper define-value
|
|
||||||
14 over process-data swapd union \ simple-title define-value
|
|
||||||
dup process-combining \ class-map define-value
|
|
||||||
dup process-canonical \ canonical-map define-value
|
|
||||||
\ combine-map define-value
|
|
||||||
dup process-compat \ compat-map define-value
|
|
||||||
process-category \ category-map define-value
|
|
||||||
>>
|
|
||||||
|
|
||||||
: canonical-entry ( char -- seq ) canonical-map at ;
|
: canonical-entry ( char -- seq ) canonical-map at ;
|
||||||
: combine-chars ( a b -- char/f ) combine-map hash2 ;
|
: combine-chars ( a b -- char/f ) combine-map hash2 ;
|
||||||
|
@ -144,6 +132,16 @@ DEFER: name-map
|
||||||
[ length 5 = ] subset
|
[ length 5 = ] subset
|
||||||
[ [ set-code-point ] each ] H{ } make-assoc ;
|
[ [ set-code-point ] each ] H{ } make-assoc ;
|
||||||
|
|
||||||
DEFER: special-casing
|
[
|
||||||
|
load-data
|
||||||
<< load-special-casing \ special-casing define-value >>
|
dup process-names \ name-map define-value
|
||||||
|
13 over process-data \ simple-lower define-value
|
||||||
|
12 over process-data tuck \ simple-upper define-value
|
||||||
|
14 over process-data swapd union \ simple-title define-value
|
||||||
|
dup process-combining \ class-map define-value
|
||||||
|
dup process-canonical \ canonical-map define-value
|
||||||
|
\ combine-map define-value
|
||||||
|
dup process-compat \ compat-map define-value
|
||||||
|
process-category \ category-map define-value
|
||||||
|
load-special-casing \ special-casing define-value
|
||||||
|
] with-compilation-unit
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
USING: sequences namespaces unicode.data kernel combinators.lib math
|
USING: sequences namespaces unicode.data kernel combinators.lib
|
||||||
unicode arrays ;
|
math arrays ;
|
||||||
IN: unicode.normalize
|
IN: unicode.normalize
|
||||||
|
|
||||||
! Utility word
|
! Utility word
|
||||||
|
@ -89,7 +89,7 @@ IN: unicode.normalize
|
||||||
swap [ [
|
swap [ [
|
||||||
dup hangul? [ hangul>jamo % drop ]
|
dup hangul? [ hangul>jamo % drop ]
|
||||||
[ dup rot call [ % ] [ , ] ?if ] if
|
[ dup rot call [ % ] [ , ] ?if ] if
|
||||||
] curry* each ] "" make*
|
] with each ] "" make*
|
||||||
dup reorder
|
dup reorder
|
||||||
] if ; inline
|
] if ; inline
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,10 @@ IN: unicode.syntax
|
||||||
category# categories nth ;
|
category# categories nth ;
|
||||||
|
|
||||||
: >category-array ( categories -- bitarray )
|
: >category-array ( categories -- bitarray )
|
||||||
categories [ swap member? ] curry* map >bit-array ;
|
categories [ swap member? ] with map >bit-array ;
|
||||||
|
|
||||||
: as-string ( strings -- bit-array )
|
: as-string ( strings -- bit-array )
|
||||||
concat "\"" tuck 3append parse first ;
|
concat "\"" tuck 3append eval ;
|
||||||
|
|
||||||
: [category] ( categories -- quot )
|
: [category] ( categories -- quot )
|
||||||
[
|
[
|
||||||
|
|
|
@ -23,7 +23,7 @@ M: process-missing error.
|
||||||
: PROCESS:
|
: PROCESS:
|
||||||
CREATE
|
CREATE
|
||||||
dup H{ } clone "xtable" set-word-prop
|
dup H{ } clone "xtable" set-word-prop
|
||||||
dup [ run-process ] curry define-compound ; parsing
|
dup [ run-process ] curry define ; parsing
|
||||||
|
|
||||||
: TAG:
|
: TAG:
|
||||||
scan scan-word
|
scan scan-word
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
! Copyright (C) 2005, 2006 Daniel Ehrenberg
|
! Copyright (C) 2005, 2006 Daniel Ehrenberg
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: help.markup help.syntax kernel xml xml.data xml.errors
|
USING: help.markup help.syntax kernel xml.data xml.errors
|
||||||
xml.writer state-parser xml.tokenize xml.utilities xml.entities
|
xml.writer state-parser xml.tokenize xml.utilities xml.entities
|
||||||
strings sequences io ;
|
strings sequences io ;
|
||||||
|
IN: xml
|
||||||
|
|
||||||
HELP: string>xml
|
HELP: string>xml
|
||||||
{ $values { "string" "a string" } { "xml" "an xml document" } }
|
{ $values { "string" "a string" } { "xml" "an xml document" } }
|
||||||
|
|
Loading…
Reference in New Issue