From 8645b1db49c9937fe942dea25c5c8c5fddb4d0c4 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Mon, 19 May 2014 20:59:42 -0700 Subject: [PATCH] unicode.breaks: change to using constants instead of globals. --- basis/unicode/breaks/breaks.factor | 49 ++++++++++++++++-------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/basis/unicode/breaks/breaks.factor b/basis/unicode/breaks/breaks.factor index 686fdd7b02..ff1cf80934 100644 --- a/basis/unicode/breaks/breaks.factor +++ b/basis/unicode/breaks/breaks.factor @@ -3,16 +3,17 @@ USING: accessors alien.syntax arrays assocs combinators combinators.short-circuit compiler.units fry interval-maps io io.encodings.ascii io.files kernel literals locals make math -math.parser math.ranges memoize namespaces sequences +math.parser math.ranges memoize namespaces parser sequences sets simple-flat-file splitting unicode.categories unicode.categories.syntax unicode.data unicode.normalize -unicode.normalize.private words ; +unicode.normalize.private words words.constant ; FROM: sequences => change-nth ; IN: unicode.breaks > : grapheme-break? ( class1 class2 -- ? ) - grapheme-table get-global nth nth not ; + grapheme-table nth nth not ; PRIVATE> @@ -132,17 +137,8 @@ PRIVATE> > +[ 2 swap [ word-break-classes at ] change-nth ] each +define-constant +>> +: word-break-prop ( char -- word-break-prop ) + word-break-table interval-at wOther or ; + +<< SYMBOL: check-letter-before SYMBOL: check-letter-after SYMBOL: check-number-before @@ -189,19 +192,19 @@ SYMBOL: check-number-after { wALetter wNumeric wKatakana wExtendNumLet } { wExtendNumLet } [ connect ] [ swap connect ] 2bi ; -SYMBOL: word-table - : finish-word-table ( -- table ) table get [ [ { { 0 [ f ] } { 1 [ t ] } [ ] } case ] map ] map ; +"word-table" create-in words init-table table [ make-word-table finish-word-table ] with-variable -word-table set-global +define-constant +>> : word-table-nth ( class1 class2 -- ? ) - word-table get-global nth nth ; + word-table nth nth ; :: property-not= ( str i property -- ? ) i [