2008-10-05 19:36:56 -04:00
|
|
|
! Copyright (C) 2008 Daniel Ehrenberg.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2008-09-10 21:07:00 -04:00
|
|
|
USING: unicode.data kernel math sequences parser lexer
|
|
|
|
bit-arrays namespaces make sequences.private arrays quotations
|
2008-12-08 20:46:40 -05:00
|
|
|
assocs classes.predicate math.order strings.parser ;
|
2008-01-09 14:44:07 -05:00
|
|
|
IN: unicode.syntax
|
|
|
|
|
2009-03-17 20:39:04 -04:00
|
|
|
<PRIVATE
|
2008-01-09 14:44:07 -05:00
|
|
|
|
|
|
|
: >category-array ( categories -- bitarray )
|
2008-01-10 22:03:34 -05:00
|
|
|
categories [ swap member? ] with map >bit-array ;
|
2008-01-09 14:44:07 -05:00
|
|
|
|
|
|
|
: as-string ( strings -- bit-array )
|
2008-12-08 20:46:40 -05:00
|
|
|
concat unescape-string ;
|
2008-01-09 14:44:07 -05:00
|
|
|
|
|
|
|
: [category] ( categories -- quot )
|
|
|
|
[
|
2008-04-26 00:17:08 -04:00
|
|
|
[ [ categories member? not ] filter as-string ] keep
|
|
|
|
[ categories member? ] filter >category-array
|
2008-01-09 14:44:07 -05:00
|
|
|
[ dup category# ] % , [ nth-unsafe [ drop t ] ] %
|
|
|
|
\ member? 2array >quotation ,
|
|
|
|
\ if ,
|
|
|
|
] [ ] make ;
|
|
|
|
|
|
|
|
: define-category ( word categories -- )
|
2008-03-26 19:23:19 -04:00
|
|
|
[category] integer swap define-predicate-class ;
|
2008-01-09 14:44:07 -05:00
|
|
|
|
2009-03-17 20:39:04 -04:00
|
|
|
PRIVATE>
|
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: CATEGORY:
|
|
|
|
CREATE ";" parse-tokens define-category ;
|
2008-01-09 14:44:07 -05:00
|
|
|
|
|
|
|
: seq-minus ( seq1 seq2 -- diff )
|
2008-04-26 00:17:08 -04:00
|
|
|
[ member? not ] curry filter ;
|
2008-01-09 14:44:07 -05:00
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: CATEGORY-NOT:
|
2008-01-09 14:44:07 -05:00
|
|
|
CREATE ";" parse-tokens
|
2009-03-21 02:27:50 -04:00
|
|
|
categories swap seq-minus define-category ;
|