diff --git a/Factor.app/Contents/Info.plist b/Factor.app/Contents/Info.plist index ca0e6d5f8a..a8943d0d32 100644 --- a/Factor.app/Contents/Info.plist +++ b/Factor.app/Contents/Info.plist @@ -32,7 +32,7 @@ CFBundlePackageType APPL NSHumanReadableCopyright - Copyright © 2003-2007, Slava Pestov and friends + Copyright © 2003-2008, Slava Pestov and friends NSServices diff --git a/core/alien/alien-docs.factor b/core/alien/alien-docs.factor index 7d13080e3c..0caf0e9a9f 100755 --- a/core/alien/alien-docs.factor +++ b/core/alien/alien-docs.factor @@ -265,7 +265,7 @@ ARTICLE: "embedding-restrictions" "Embedding API restrictions" ARTICLE: "embedding-factor" "What embedding looks like from Factor" "Factor code will run inside an embedded instance in the same way it would run in a stand-alone instance." $nl -"One exception is the global " { $link stdio } " stream, which is by default not bound to the terminal where the process is running, to avoid conflicting with any I/O the host process might perform. To initialize the terminal stream, " { $link init-stdio } " must be called explicitly." +"One exception is that the global " { $link input-stream } " and " { $link output-stream } " streams are not bound by default, to avoid conflicting with any I/O the host process might perform. The " { $link init-stdio } " words must be called explicitly to initialize terminal streams." $nl "There is a word which can detect when Factor is embedded:" { $subsection embedded? } diff --git a/core/bootstrap/image/image.factor b/core/bootstrap/image/image.factor index cb73dc387e..1ff04bacc2 100755 --- a/core/bootstrap/image/image.factor +++ b/core/bootstrap/image/image.factor @@ -404,7 +404,7 @@ M: quotation ' [ { dictionary source-files builtins - update-map class<=-cache class<=>-cache + update-map class<=-cache class-not-cache classes-intersect-cache class-and-cache class-or-cache } [ dup get swap bootstrap-word set ] each @@ -475,7 +475,7 @@ M: quotation ' "Writing image to " write architecture get boot-image-name resource-path [ write "..." print flush ] - [ binary [ (write-image) ] with-stream ] bi ; + [ binary [ (write-image) ] with-file-writer ] bi ; PRIVATE> diff --git a/core/bootstrap/stage2.factor b/core/bootstrap/stage2.factor index 3247832d52..2e087ff5bd 100755 --- a/core/bootstrap/stage2.factor +++ b/core/bootstrap/stage2.factor @@ -87,7 +87,7 @@ f error-continuation set-global parse-command-line run-user-init "run" get run - stdio get [ stream-flush ] when* + output-stream get [ stream-flush ] when* ] [ print-error 1 exit ] recover ] set-boot-quot diff --git a/core/checksums/checksums-tests.factor b/core/checksums/checksums-tests.factor new file mode 100644 index 0000000000..1ec675b0cf --- /dev/null +++ b/core/checksums/checksums-tests.factor @@ -0,0 +1,7 @@ +IN: checksums.tests +USING: checksums tools.test ; + +\ checksum-bytes must-infer +\ checksum-stream must-infer +\ checksum-lines must-infer +\ checksum-file must-infer diff --git a/core/classes/algebra/algebra-docs.factor b/core/classes/algebra/algebra-docs.factor index 3903da1ebc..810bdbe10f 100755 --- a/core/classes/algebra/algebra-docs.factor +++ b/core/classes/algebra/algebra-docs.factor @@ -23,30 +23,19 @@ ARTICLE: "class-linearization" "Class linearization" "If a generic word defines a method on a mixin class A and another class B, and B is the only instance of A, there is an ambiguity because A and B are equal as sets; any object that is an instance of one is an instance of both." { "If a generic word defines methods on two union classes which are incomparable but not disjoint, for example " { $link sequence } " and " { $link number } ", there is an ambiguity because the generic word may be called on an object that is an instance of both unions." } } -"These difficulties are resolved by imposing a linear order on classes, computed as follows for two classes A and B:" +"The first ambiguity is resolved with a tie-breaker that compares metaclasses. The intrinsic meta-class order, from most-specific to least-specific:" { $list - "If A and B are the same class (not just equal as sets), then comparison stops." - "If A is a proper subset of B, or B is a proper subset of A, then comparison stops." - { "Next, the metaclasses of A and B are compared, with intrinsic meta-class order, from most-specific to least-specific:" - { $list - "Built-in classes and tuple classes" - "Predicate classes" - "Union classes" - "Mixin classes" - } - "If this yields an unambiguous answer, comparison stops." - } - "If the metaclasses of A and B occupy the same position in the order, then the vocabularies of A and B are compared lexicographically. If this yields an unambiguous answer, comparison stops." - "If A and B belong to the same vocabulary, their names are compared lexicographically. This must yield an unambiguous result, since if the names equal they must be the same class and this case was already handled in the first step." -} -"Some examples:" -{ $list - { { $link integer } " precedes " { $link number } " because it is a strict subset" } - { { $link number } " precedes " { $link sequence } " because the " { $vocab-link "math" } " vocabulary precedes the " { $vocab-link "sequences" } " vocabulary" } - { { $link crc32 } " precedes " { $link checksum } ", even if it were the only instance, because " { $link crc32 } " is a singleton class which is more specific than a mixin class" } + "Built-in classes and tuple classes" + "Predicate classes" + "Union classes" + "Mixin classes" } +"This means that in the above example, the generic word with methods on a mixin and its sole instance will always call the method for the sole instance, since it is more specific than a mixin class." +$nl +"The second problem is resolved with another tie-breaker. When performing the topological sort of classes, if there are multiple candidates at any given step of the sort, lexicographical order on the class name is used." +$nl "Operations:" -{ $subsection class<=> } +{ $subsection class< } { $subsection sort-classes } "Metaclass order:" { $subsection rank-class } ; @@ -72,8 +61,6 @@ HELP: sort-classes { $values { "seq" "a sequence of class" } { "newseq" "a new seqence of classes" } } { $description "Outputs a linear sort of a sequence of classes. Larger classes come before their subclasses." } ; -{ sort-classes class<=> } related-words - HELP: class-or { $values { "first" class } { "second" class } { "class" class } } { $description "Outputs the smallest anonymous class containing both " { $snippet "class1" } " and " { $snippet "class2" } "." } ; @@ -89,7 +76,3 @@ HELP: classes-intersect? HELP: min-class { $values { "class" class } { "seq" "a sequence of class words" } { "class/f" "a class word or " { $link f } } } { $description "If all classes in " { $snippet "seq" } " that intersect " { $snippet "class" } " are subtypes of " { $snippet "class" } ", outputs the last such element of " { $snippet "seq" } ". If any conditions fail to hold, outputs " { $link f } "." } ; - -HELP: class<=> -{ $values { "first" class } { "second" class } { "n" symbol } } -{ $description "Compares two classes with the class linearization order." } ; diff --git a/core/classes/algebra/algebra-tests.factor b/core/classes/algebra/algebra-tests.factor index 7387b8ae3a..dfe4a0fbc9 100755 --- a/core/classes/algebra/algebra-tests.factor +++ b/core/classes/algebra/algebra-tests.factor @@ -248,7 +248,16 @@ UNION: yyy xxx ; [ { yyy xxx } ] [ { xxx yyy } sort-classes ] unit-test [ { yyy xxx } ] [ { yyy xxx } sort-classes ] unit-test -[ { number integer ratio } ] [ { ratio number integer } sort-classes ] unit-test +[ { number ratio integer } ] [ { ratio number integer } sort-classes ] unit-test [ { sequence number ratio } ] [ { ratio number sequence } sort-classes ] unit-test -[ +lt+ ] [ \ real sequence class<=> ] unit-test +TUPLE: xa ; +TUPLE: xb ; +TUPLE: xc < xa ; +TUPLE: xd < xb ; +TUPLE: xe ; +TUPLE: xf < xb ; +TUPLE: xg < xb ; +TUPLE: xh < xb ; + +[ t ] [ { xa xb xc xd xe xf xg xh } sort-classes dup sort-classes = ] unit-test diff --git a/core/classes/algebra/algebra.factor b/core/classes/algebra/algebra.factor index 8c910a1f8c..4160f4e9d2 100755 --- a/core/classes/algebra/algebra.factor +++ b/core/classes/algebra/algebra.factor @@ -187,31 +187,15 @@ C: anonymous-complement [ [ rank-class ] bi@ < ] } cond ; -: class-tie-breaker ( first second -- n ) - 2dup [ rank-class ] compare { - { +lt+ [ 2drop +lt+ ] } - { +gt+ [ 2drop +gt+ ] } - { +eq+ [ <=> ] } - } case ; - -: (class<=>) ( first second -- n ) - { - { [ 2dup class<= ] [ - 2dup swap class<= - [ class-tie-breaker ] [ 2drop +lt+ ] if - ] } - { [ 2dup swap class<= ] [ - 2dup class<= - [ class-tie-breaker ] [ 2drop +gt+ ] if - ] } - [ class-tie-breaker ] - } cond ; - -: class<=> ( first second -- n ) - class<=>-cache get [ (class<=>) ] 2cache ; +: largest-class ( seq -- n elt ) + dup [ [ class< ] with contains? not ] curry find-last + [ "Topological sort failed" throw ] unless* ; : sort-classes ( seq -- newseq ) - [ class<=> invert-comparison ] sort ; + [ [ word-name ] compare ] sort >vector + [ dup empty? not ] + [ dup largest-class >r over delete-nth r> ] + [ ] unfold nip ; : min-class ( class seq -- class/f ) over [ classes-intersect? ] curry filter diff --git a/core/classes/classes.factor b/core/classes/classes.factor index 53840c0027..594b2005b8 100755 --- a/core/classes/classes.factor +++ b/core/classes/classes.factor @@ -6,7 +6,6 @@ quotations combinators sorting effects graphs vocabs ; IN: classes SYMBOL: class<=-cache -SYMBOL: class<=>-cache SYMBOL: class-not-cache SYMBOL: classes-intersect-cache SYMBOL: class-and-cache @@ -14,7 +13,6 @@ SYMBOL: class-or-cache : init-caches ( -- ) H{ } clone class<=-cache set - H{ } clone class<=>-cache set H{ } clone class-not-cache set H{ } clone classes-intersect-cache set H{ } clone class-and-cache set @@ -22,7 +20,6 @@ SYMBOL: class-or-cache : reset-caches ( -- ) class<=-cache get clear-assoc - class<=>-cache get clear-assoc class-not-cache get clear-assoc classes-intersect-cache get clear-assoc class-and-cache get clear-assoc diff --git a/core/classes/tuple/tuple-tests.factor b/core/classes/tuple/tuple-tests.factor index 0cde687f16..fb9530b1c5 100755 --- a/core/classes/tuple/tuple-tests.factor +++ b/core/classes/tuple/tuple-tests.factor @@ -542,3 +542,15 @@ TUPLE: another-forget-accessors-test ; ! Missing error check [ "IN: tuples.test USE: words TUPLE: wrong-superclass < word ;" eval ] must-fail + +TUPLE: subclass-forget-test ; + +TUPLE: subclass-forget-test-1 < subclass-forget-test ; +TUPLE: subclass-forget-test-2 < subclass-forget-test ; +TUPLE: subclass-forget-test-3 < subclass-forget-test-2 ; + +[ ] [ "IN: classes.tuple.tests FORGET: subclass-forget-test" eval ] unit-test + +[ f ] [ subclass-forget-test-1 tuple-class? ] unit-test +[ f ] [ subclass-forget-test-2 tuple-class? ] unit-test +[ subclass-forget-test-3 new ] must-fail diff --git a/core/classes/tuple/tuple.factor b/core/classes/tuple/tuple.factor index ee7ff8c608..5ebcc7a286 100755 --- a/core/classes/tuple/tuple.factor +++ b/core/classes/tuple/tuple.factor @@ -102,7 +102,7 @@ ERROR: bad-superclass class ; dup tuple-predicate-quot define-predicate ; : superclass-size ( class -- n ) - superclasses 1 head-slice* + superclasses but-last-slice [ slot-names length ] map sum ; : generate-tuple-slots ( class slots -- slot-specs ) diff --git a/core/compiler/compiler.factor b/core/compiler/compiler.factor index 806ea914bb..ef00e94dd5 100755 --- a/core/compiler/compiler.factor +++ b/core/compiler/compiler.factor @@ -4,38 +4,55 @@ USING: kernel namespaces arrays sequences io inference.backend inference.state generator debugger words compiler.units continuations vocabs assocs alien.compiler dlists optimizer definitions math compiler.errors threads graphs generic -inference ; +inference combinators ; IN: compiler : ripple-up ( word -- ) compiled-usage [ drop queue-compile ] assoc-each ; : save-effect ( word effect -- ) - over "compiled-uses" word-prop [ - 2dup swap "compiled-effect" word-prop = - [ over ripple-up ] unless - ] when - "compiled-effect" set-word-prop ; - -: finish-compile ( word effect dependencies -- ) - >r dupd save-effect r> - over compiled-unxref - over compiled-crossref? [ compiled-xref ] [ 2drop ] if ; - -: compile-succeeded ( word -- effect dependencies ) [ - [ word-dataflow optimize ] keep dup generate - ] computing-dependencies ; + over "compiled-effect" word-prop = [ + dup "compiled-uses" word-prop + [ dup ripple-up ] when + ] unless drop + ] + [ "compiled-effect" set-word-prop ] 2bi ; + +: compile-begins ( word -- ) + f swap compiler-error ; : compile-failed ( word error -- ) - f pick compiled get set-at - swap compiler-error ; + [ swap compiler-error ] + [ + drop + [ f swap compiled get set-at ] + [ f save-effect ] + bi + ] 2bi ; + +: compile-succeeded ( effect word -- ) + [ swap save-effect ] + [ compiled-unxref ] + [ + dup compiled-crossref? + [ dependencies get compiled-xref ] [ drop ] if + ] tri ; : (compile) ( word -- ) - f over compiler-error - [ dup compile-succeeded finish-compile ] - [ dupd compile-failed f save-effect ] - recover ; + [ + H{ } clone dependencies set + + { + [ compile-begins ] + [ + [ word-dataflow ] [ compile-failed return ] recover + optimize + ] + [ dup generate ] + [ compile-succeeded ] + } cleave + ] curry with-return ; : compile-loop ( assoc -- ) dup assoc-empty? [ drop ] [ diff --git a/core/compiler/errors/errors-docs.factor b/core/compiler/errors/errors-docs.factor index dd71eb704f..d86587662b 100755 --- a/core/compiler/errors/errors-docs.factor +++ b/core/compiler/errors/errors-docs.factor @@ -21,19 +21,19 @@ HELP: compiler-error HELP: compiler-error. { $values { "error" "an error" } { "word" word } } -{ $description "Prints a compiler error to the " { $link stdio } " stream." } ; +{ $description "Prints a compiler error to " { $link output-stream } "." } ; HELP: compiler-errors. { $values { "type" symbol } } -{ $description "Prints compiler errors to the " { $link stdio } " stream. The type parameter is one of " { $link +error+ } ", " { $link +warning+ } ", or " { $link +linkage+ } "." } ; +{ $description "Prints compiler errors to " { $link output-stream } ". The type parameter is one of " { $link +error+ } ", " { $link +warning+ } ", or " { $link +linkage+ } "." } ; HELP: :errors -{ $description "Prints all serious compiler errors from the most recent compile to the " { $link stdio } " stream." } ; +{ $description "Prints all serious compiler errors from the most recent compile to " { $link output-stream } "." } ; HELP: :warnings -{ $description "Prints all ignorable compiler warnings from the most recent compile to the " { $link stdio } " stream." } ; +{ $description "Prints all ignorable compiler warnings from the most recent compile to " { $link output-stream } "." } ; HELP: :linkage -{ $description "Prints all C library interface linkage errors from the most recent compile to the " { $link stdio } " stream." } ; +{ $description "Prints all C library interface linkage errors from the most recent compile to " { $link output-stream } "." } ; { :errors :warnings } related-words diff --git a/core/continuations/continuations-docs.factor b/core/continuations/continuations-docs.factor index b1db09b6bc..472136da8e 100755 --- a/core/continuations/continuations-docs.factor +++ b/core/continuations/continuations-docs.factor @@ -34,7 +34,7 @@ $nl { $code " ... do stuff ... dispose" } -"The reason being that if " { $snippet "do stuff" } " throws an error, the resource will not be disposed of. The most important case where this can occur is with I/O streams, and the correct solution is to always use " { $link with-stream } "; see " { $link "stdio" } " for details." ; +"The reason being that if " { $snippet "do stuff" } " throws an error, the resource will not be disposed of. The most important case where this can occur is with I/O streams, and the correct solution is to always use " { $link with-input-stream } " and " { $link with-output-stream } "; see " { $link "stdio" } " for details." ; ARTICLE: "errors" "Error handling" "Support for handling exceptional situations such as bad user input, implementation bugs, and input/output errors is provided by a set of words built using continuations." diff --git a/core/continuations/continuations-tests.factor b/core/continuations/continuations-tests.factor index b0c216e82f..28581820fd 100755 --- a/core/continuations/continuations-tests.factor +++ b/core/continuations/continuations-tests.factor @@ -39,7 +39,7 @@ IN: continuations.tests "!!! The following error is part of the test" print -[ ] [ [ [ "2 car" ] eval ] [ print-error ] recover ] unit-test +[ ] [ [ [ "2 car" ] eval ] try ] unit-test [ f throw ] must-fail @@ -117,3 +117,5 @@ T{ dispose-dummy } "b" set [ { "a" "b" } [ get ] map dispose-each ] [ 3 = ] must-fail-with [ t ] [ "b" get disposed?>> ] unit-test + +[ ] [ [ return ] with-return ] unit-test diff --git a/core/continuations/continuations.factor b/core/continuations/continuations.factor index 3e675b1f0f..78effb043a 100755 --- a/core/continuations/continuations.factor +++ b/core/continuations/continuations.factor @@ -101,6 +101,14 @@ PRIVATE> : continue ( continuation -- ) f swap continue-with ; +SYMBOL: return-continuation + +: with-return ( quot -- ) + [ [ return-continuation set ] prepose callcc0 ] with-scope ; inline + +: return ( -- ) + return-continuation get continue ; + GENERIC: compute-restarts ( error -- seq ) > error-help ; M: assert summary drop "Assertion failed" ; +M: assert error. + "Assertion failed" print + standard-table-style [ + 15 length-limit set + 5 line-limit set + [ expect>> [ [ "Expect:" write ] with-cell pprint-cell ] with-row ] + [ got>> [ [ "Got:" write ] with-cell pprint-cell ] with-row ] bi + ] tabular-output ; + M: immutable summary drop "Sequence is immutable" ; M: redefine-error error. @@ -267,8 +270,7 @@ M: double-free summary M: realloc-error summary drop "Memory reallocation failed" ; -: error-in-thread. ( -- ) - error-thread get-global +: error-in-thread. ( thread -- ) "Error in thread " write [ dup thread-id # @@ -282,7 +284,7 @@ M: thread error-in-thread ( error thread -- ) die drop ] [ global [ - error-in-thread. print-error flush + error-thread get-global error-in-thread. print-error flush ] bind ] if ; diff --git a/core/generic/standard/engines/tuple/tuple.factor b/core/generic/standard/engines/tuple/tuple.factor index 7639d1d499..51ea4f8225 100644 --- a/core/generic/standard/engines/tuple/tuple.factor +++ b/core/generic/standard/engines/tuple/tuple.factor @@ -127,8 +127,6 @@ M: echelon-dispatch-engine engine>quot 1 slot { tuple-layout } declare 5 slot ; inline -: unclip-last [ 1 head* ] [ peek ] bi ; - M: tuple-dispatch-engine engine>quot [ picker % diff --git a/core/inference/inference-docs.factor b/core/inference/inference-docs.factor index e32c94ed37..d79c82ed65 100755 --- a/core/inference/inference-docs.factor +++ b/core/inference/inference-docs.factor @@ -135,7 +135,7 @@ HELP: infer HELP: infer. { $values { "quot" "a quotation" } } -{ $description "Attempts to infer the quotation's stack effect, and prints this data to the " { $link stdio } " stream." } +{ $description "Attempts to infer the quotation's stack effect, and prints this data to " { $link output-stream } "." } { $errors "Throws an " { $link inference-error } " if stack effect inference fails." } ; { infer infer. } related-words diff --git a/core/inference/state/state-tests.factor b/core/inference/state/state-tests.factor index 84d72bdd9b..fe1f51a5e7 100644 --- a/core/inference/state/state-tests.factor +++ b/core/inference/state/state-tests.factor @@ -1,6 +1,10 @@ IN: inference.state.tests USING: tools.test inference.state words ; +: computing-dependencies ( quot -- dependencies ) + H{ } clone [ dependencies rot with-variable ] keep ; + inline + SYMBOL: a SYMBOL: b diff --git a/core/inference/state/state.factor b/core/inference/state/state.factor index a426f410e2..6f0eecf2d9 100755 --- a/core/inference/state/state.factor +++ b/core/inference/state/state.factor @@ -36,10 +36,6 @@ SYMBOL: dependencies 2dup at +inlined+ eq? [ 3drop ] [ set-at ] if ] [ 3drop ] if ; -: computing-dependencies ( quot -- dependencies ) - H{ } clone [ dependencies rot with-variable ] keep ; - inline - ! Did the current control-flow path throw an error? SYMBOL: terminated? diff --git a/core/inference/transforms/transforms.factor b/core/inference/transforms/transforms.factor index 624dcbbf98..0040629edd 100755 --- a/core/inference/transforms/transforms.factor +++ b/core/inference/transforms/transforms.factor @@ -32,7 +32,7 @@ IN: inference.transforms drop [ no-case ] ] [ dup peek quotation? [ - dup peek swap 1 head* + dup peek swap but-last ] [ [ no-case ] swap ] if case>quot diff --git a/core/inspector/inspector-docs.factor b/core/inspector/inspector-docs.factor index 84ae34480d..ab1c38b0b7 100644 --- a/core/inspector/inspector-docs.factor +++ b/core/inspector/inspector-docs.factor @@ -108,4 +108,4 @@ HELP: me HELP: inspector-hook { $var-description "A quotation with stack effect " { $snippet "( obj -- )" } ", called by the inspector to display an overview of an object." $nl -"The default implementation calls " { $link describe } " which outputs on the " { $link stdio } " stream, but the graphical listener sets this variable so that calling " { $link inspect } " in the UI opens the graphical inspector." } ; +"The default implementation calls " { $link describe } " which outputs on " { $link output-stream } ", but the graphical listener sets this variable so that calling " { $link inspect } " in the UI opens the graphical inspector." } ; diff --git a/core/io/backend/backend-docs.factor b/core/io/backend/backend-docs.factor index 8bf761e2a6..48b49ed32b 100644 --- a/core/io/backend/backend-docs.factor +++ b/core/io/backend/backend-docs.factor @@ -9,4 +9,4 @@ HELP: init-io { $contract "Initializes the I/O system. Called on startup." } ; HELP: init-stdio -{ $contract "Initializes the global " { $link stdio } " stream. Called on startup." } ; +{ $contract "Initializes the global " { $link input-stream } " and " { $link output-stream } ". Called on startup." } ; diff --git a/core/io/backend/backend.factor b/core/io/backend/backend.factor index 44b1eea349..0760063f0d 100755 --- a/core/io/backend/backend.factor +++ b/core/io/backend/backend.factor @@ -11,8 +11,10 @@ HOOK: init-io io-backend ( -- ) HOOK: (init-stdio) io-backend ( -- stdin stdout stderr ) : init-stdio ( -- ) - (init-stdio) utf8 stderr set-global - utf8 stdio set-global ; + (init-stdio) + [ utf8 input-stream set-global ] + [ utf8 output-stream set-global ] + [ utf8 error-stream set-global ] tri* ; HOOK: io-multiplex io-backend ( ms -- ) diff --git a/core/io/encodings/encodings-docs.factor b/core/io/encodings/encodings-docs.factor index 8a176ce4ec..92471acb5d 100644 --- a/core/io/encodings/encodings-docs.factor +++ b/core/io/encodings/encodings-docs.factor @@ -12,8 +12,7 @@ ARTICLE: "io.encodings" "I/O encodings" ARTICLE: "encodings-constructors" "Manually constructing an encoded stream" "The following words can be used to construct encoded streams. Note that they are usually not used directly, but rather by the stream constructors themselves. Most stream constructors take an encoding descriptor as a parameter and internally call these constructors." { $subsection } -{ $subsection } -{ $subsection } ; +{ $subsection } ; HELP: { $values { "stream" "an output stream" } @@ -29,16 +28,6 @@ HELP: { $description "Wraps the given stream in a new stream using the given encoding for all input. The encoding descriptor can either be a class or an instance of something conforming to the " { $link "encodings-protocol" } "." } $low-level-note ; -HELP: -{ $values { "stream-in" "an input stream" } - { "stream-out" "an output stream" } - { "encoding" "an encoding descriptor" } - { "duplex" "an encoded duplex stream" } } -{ $description "Wraps the given streams in an encoder or decoder stream, and puts them together in a duplex stream for input and output. If either input stream is already encoded, that encoding is stripped off before it is reencoded. The encoding descriptor must conform to the " { $link "encodings-protocol" } "." } -$low-level-note ; - -{ } related-words - ARTICLE: "encodings-descriptors" "Encoding descriptors" "An encoding descriptor is something which can be used for input or output streams to encode or decode files. It must conform to the " { $link "encodings-protocol" } ". Encodings which you can use are defined in the following vocabularies:" { $subsection "io.encodings.binary" } diff --git a/core/io/encodings/encodings-tests.factor b/core/io/encodings/encodings-tests.factor index 397d1ea89c..e6b180fde2 100755 --- a/core/io/encodings/encodings-tests.factor +++ b/core/io/encodings/encodings-tests.factor @@ -2,35 +2,35 @@ USING: io.files io.streams.string io tools.test kernel io.encodings.ascii ; IN: io.streams.encodings.tests -: ( resource -- stream ) - resource-path ascii ; - [ { } ] -[ "core/io/test/empty-file.txt" lines ] +[ "resource:core/io/test/empty-file.txt" ascii lines ] unit-test : lines-test ( stream -- line1 line2 ) - [ readln readln ] with-stream ; + [ readln readln ] with-input-stream ; [ "This is a line." "This is another line." ] [ - "core/io/test/windows-eol.txt" lines-test + "resource:core/io/test/windows-eol.txt" + ascii lines-test ] unit-test [ "This is a line." "This is another line." ] [ - "core/io/test/mac-os-eol.txt" lines-test + "resource:core/io/test/mac-os-eol.txt" + ascii lines-test ] unit-test [ "This is a line." "This is another line." ] [ - "core/io/test/unix-eol.txt" lines-test + "resource:core/io/test/unix-eol.txt" + ascii lines-test ] unit-test [ diff --git a/core/io/encodings/encodings.factor b/core/io/encodings/encodings.factor index 4559cec666..0f6e58bdc9 100755 --- a/core/io/encodings/encodings.factor +++ b/core/io/encodings/encodings.factor @@ -2,8 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: math kernel sequences sbufs vectors namespaces growable strings io classes continuations combinators io.styles -io.streams.plain splitting io.streams.duplex byte-arrays -sequences.private accessors ; +io.streams.plain splitting byte-arrays sequences.private +accessors ; IN: io.encodings ! The encoding descriptor protocol @@ -131,6 +131,3 @@ INSTANCE: encoder plain-writer over decoder? [ >r decoder-stream r> ] when ; PRIVATE> - -: ( stream-in stream-out encoding -- duplex ) - tuck reencode >r redecode r> ; diff --git a/core/io/files/files-docs.factor b/core/io/files/files-docs.factor index ba17223a29..d18babf31b 100755 --- a/core/io/files/files-docs.factor +++ b/core/io/files/files-docs.factor @@ -184,8 +184,12 @@ HELP: +unknown+ { $description "A unknown file type." } ; HELP: -{ $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" { "stream" "an input stream" } } - { "stream" "an input stream" } } +{ + $values + { "path" "a pathname string" } + { "encoding" "an encoding descriptor" } + { "stream" "an input stream" } +} { $description "Outputs an input stream for reading from the specified pathname using the given encoding." } { $errors "Throws an error if the file is unreadable." } ; @@ -201,17 +205,17 @@ HELP: HELP: with-file-reader { $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" } { "quot" "a quotation" } } -{ $description "Opens a file for reading and calls the quotation using " { $link with-stream } "." } +{ $description "Opens a file for reading and calls the quotation using " { $link with-input-stream } "." } { $errors "Throws an error if the file is unreadable." } ; HELP: with-file-writer { $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" } { "quot" "a quotation" } } -{ $description "Opens a file for writing using the given encoding and calls the quotation using " { $link with-stream } "." } +{ $description "Opens a file for writing using the given encoding and calls the quotation using " { $link with-output-stream } "." } { $errors "Throws an error if the file cannot be opened for writing." } ; HELP: with-file-appender { $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" } { "quot" "a quotation" } } -{ $description "Opens a file for appending using the given encoding and calls the quotation using " { $link with-stream } "." } +{ $description "Opens a file for appending using the given encoding and calls the quotation using " { $link with-output-stream } "." } { $errors "Throws an error if the file cannot be opened for writing." } ; HELP: set-file-lines diff --git a/core/io/files/files.factor b/core/io/files/files.factor index 576307b589..76c7b144d0 100755 --- a/core/io/files/files.factor +++ b/core/io/files/files.factor @@ -25,13 +25,13 @@ HOOK: (file-appender) io-backend ( path -- stream ) lines ; : with-file-reader ( path encoding quot -- ) - >r r> with-stream ; inline + >r r> with-input-stream ; inline : file-contents ( path encoding -- str ) contents ; : with-file-writer ( path encoding quot -- ) - >r r> with-stream ; inline + >r r> with-output-stream ; inline : set-file-lines ( seq path encoding -- ) [ [ print ] each ] with-file-writer ; @@ -40,7 +40,7 @@ HOOK: (file-appender) io-backend ( path -- stream ) [ write ] with-file-writer ; : with-file-appender ( path encoding quot -- ) - >r r> with-stream ; inline + >r r> with-output-stream ; inline ! Pathnames : path-separator? ( ch -- ? ) os windows? "/\\" "/" ? member? ; diff --git a/core/io/io-docs.factor b/core/io/io-docs.factor index fd40950e62..ddea4da556 100755 --- a/core/io/io-docs.factor +++ b/core/io/io-docs.factor @@ -5,7 +5,7 @@ IN: io ARTICLE: "stream-protocol" "Stream protocol" "The stream protocol consists of a large number of generic words, many of which are optional." $nl -"Stream protocol words are rarely called directly, since code which only works with one stream at a time should be written use " { $link "stdio" } " instead, wrapping I/O operations such as " { $link read } " and " { $link write } " in a " { $link with-stream } ". This leads more simpler, more reusable and more robust code." +"Stream protocol words are rarely called directly, since code which only works with one stream at a time should be written use " { $link "stdio" } " instead, wrapping I/O operations such as " { $link read } " and " { $link write } " in " { $link with-input-stream } " and " { $link with-output-stream } "." $nl "All streams must implement the " { $link dispose } " word in addition to the stream protocol." $nl @@ -26,24 +26,24 @@ $nl { $subsection stream-write-table } { $see-also "io.timeouts" } ; -ARTICLE: "stdio" "The default stream" -"Most I/O code only operates on one stream at a time. The " { $emphasis "default stream" } " is an implicit parameter used by many I/O words designed for this particular use-case. Using this idiom improves code in three ways:" +ARTICLE: "stdio" "Default input and output streams" +"Most I/O code only operates on one stream at a time. The " { $link input-stream } " and " { $link output-stream } " variables are implicit parameters used by many I/O words. Using this idiom improves code in three ways:" { $list { "Code becomes simpler because there is no need to keep a stream around on the stack." } - { "Code becomes more robust because " { $link with-stream } " automatically closes the stream if there is an error." } - { "Code becomes more reusable because it can be written to not worry about which stream is being used, and instead the caller can use " { $link with-stream } " to specify the source or destination for I/O operations." } + { "Code becomes more robust because " { $link with-input-stream } " and " { $link with-output-stream } " automatically close the streams if there is an error." } + { "Code becomes more reusable because it can be written to not worry about which stream is being used, and instead the caller can use " { $link with-input-stream } " or " { $link with-output-stream } " to specify the source or destination for I/O operations." } } "For example, here is a program which reads the first line of a file, converts it to an integer, then reads that many characters, and splits them into groups of 16:" { $code "USING: continuations kernel io io.files math.parser splitting ;" - "\"data.txt\" " + "\"data.txt\" utf8 " "dup stream-readln number>string over stream-read 16 group" "swap dispose" } "This code has two problems: it has some unnecessary stack shuffling, and if either " { $link stream-readln } " or " { $link stream-read } " throws an I/O error, the stream is not closed because " { $link dispose } " is never reached. So we can add a call to " { $link with-disposal } " to ensure the stream is always closed:" { $code "USING: continuations kernel io io.files math.parser splitting ;" - "\"data.txt\" [" + "\"data.txt\" utf8 [" " dup stream-readln number>string over stream-read" " 16 group" "] with-disposal" @@ -51,17 +51,34 @@ ARTICLE: "stdio" "The default stream" "This code is robust however it is more complex than it needs to be since. This is where the default stream words come in; using them, the above can be rewritten as follows:" { $code "USING: continuations kernel io io.files math.parser splitting ;" - "\"data.txt\" [" + "\"data.txt\" utf8 [" " readln number>string read 16 group" - "] with-stream" + "] with-input-stream" } -"The default stream is stored in a dynamically-scoped variable:" -{ $subsection stdio } -"Unless rebound in a child namespace, this variable will be set to a console stream for interacting with the user." +"An even better implementation that takes advantage of a utility word:" +{ $code + "USING: continuations kernel io io.files math.parser splitting ;" + "\"data.txt\" utf8 [" + " readln number>string read 16 group" + "] with-file-reader" +} +"The default input stream is stored in a dynamically-scoped variable:" +{ $subsection input-stream } +"Unless rebound in a child namespace, this variable will be set to a console stream for reading input from the user." +$nl +"Words reading from the default input stream:" { $subsection read1 } { $subsection read } { $subsection read-until } { $subsection readln } +"A pair of combinators for rebinding the " { $link input-stream } " variable:" +{ $subsection with-input-stream } +{ $subsection with-input-stream* } +"The default output stream is stored in a dynamically-scoped variable:" +{ $subsection output-stream } +"Unless rebound in a child namespace, this variable will be set to a console stream for showing output to the user." +$nl +"Words writing to the default input stream:" { $subsection flush } { $subsection write1 } { $subsection write } @@ -78,9 +95,12 @@ ARTICLE: "stdio" "The default stream" { $subsection with-row } { $subsection with-cell } { $subsection write-cell } -"A pair of combinators support rebinding the " { $link stdio } " variable:" -{ $subsection with-stream } -{ $subsection with-stream* } ; +"A pair of combinators for rebinding the " { $link output-stream } " variable:" +{ $subsection with-output-stream } +{ $subsection with-output-stream* } +"A pair of combinators for rebinding both default streams at once:" +{ $subsection with-streams } +{ $subsection with-streams* } ; ARTICLE: "stream-utils" "Stream utilities" "There are a few useful stream-related words which are not generic, but merely built up from the stream protocol." @@ -204,62 +224,65 @@ HELP: stream-copy { $description "Copies the contents of one stream into another, closing both streams when done." } $io-error ; -HELP: stdio -{ $var-description "Holds a stream, used for various implicit stream operations. Rebound using " { $link with-stream } " and " { $link with-stream* } "." } ; +HELP: input-stream +{ $var-description "Holds an input stream for various implicit stream operations. Rebound using " { $link with-input-stream } " and " { $link with-input-stream* } "." } ; + +HELP: output-stream +{ $var-description "Holds an output stream for various implicit stream operations. Rebound using " { $link with-output-stream } " and " { $link with-output-stream* } "." } ; HELP: readln { $values { "str/f" "a string or " { $link f } } } -{ $description "Reads a line of input from the " { $link stdio } " stream. Outputs " { $link f } " on stream exhaustion." } +{ $description "Reads a line of input from " { $link input-stream } ". Outputs " { $link f } " on stream exhaustion." } $io-error ; HELP: read1 { $values { "ch/f" "a character or " { $link f } } } -{ $description "Reads a character of input from the " { $link stdio } " stream. Outputs " { $link f } " on stream exhaustion." } +{ $description "Reads a character of input from " { $link input-stream } ". Outputs " { $link f } " on stream exhaustion." } $io-error ; HELP: read { $values { "n" "a non-negative integer" } { "str/f" "a string or " { $link f } } } -{ $description "Reads " { $snippet "n" } " characters of input from the " { $link stdio } " stream. Outputs a truncated string or " { $link f } " on stream exhaustion." } +{ $description "Reads " { $snippet "n" } " characters of input from " { $link input-stream } ". Outputs a truncated string or " { $link f } " on stream exhaustion." } $io-error ; HELP: read-until { $values { "seps" string } { "str/f" "a string or " { $link f } } { "sep/f" "a character or " { $link f } } } -{ $contract "Reads characters from the " { $link stdio } " stream. until the first occurrence of a separator character, or stream exhaustion. In the former case, the separator character is pushed on the stack, and is not part of the output string. In the latter case, the entire stream contents are output, along with " { $link f } "." } +{ $contract "Reads characters from " { $link input-stream } ". until the first occurrence of a separator character, or stream exhaustion. In the former case, the separator character is pushed on the stack, and is not part of the output string. In the latter case, the entire stream contents are output, along with " { $link f } "." } $io-error ; HELP: write1 { $values { "ch" "a character" } } -{ $contract "Writes a character of output to the " { $link stdio } " stream. If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." } +{ $contract "Writes a character of output to " { $link output-stream } ". If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." } $io-error ; HELP: write { $values { "str" string } } -{ $description "Writes a string of output to the " { $link stdio } " stream. If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." } +{ $description "Writes a string of output to " { $link output-stream } ". If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." } $io-error ; HELP: flush -{ $description "Waits for any pending output to the " { $link stdio } " stream to complete." } +{ $description "Waits for any pending output on " { $link output-stream } " to complete." } $io-error ; HELP: nl -{ $description "Writes a line terminator to the " { $link stdio } " stream. If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." } +{ $description "Writes a line terminator to " { $link output-stream } ". If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." } $io-error ; HELP: format { $values { "str" string } { "style" "a hashtable" } } -{ $description "Writes formatted text to the " { $link stdio } " stream. If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." } +{ $description "Writes formatted text to " { $link output-stream } ". If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." } { $notes "Details are in the documentation for " { $link stream-format } "." } $io-error ; HELP: with-nesting -{ $values { "style" "a hashtable" } { "quot" "a quotation" } } -{ $description "Calls the quotation in a new dynamic scope with the " { $link stdio } " stream rebound to a nested paragraph stream, with formatting information applied." } +{ $values { "style" "a hashtable" } { "quot" quotation } } +{ $description "Calls the quotation in a new dynamic scope with " { $link output-stream } " rebound to a nested paragraph stream, with formatting information applied." } { $notes "Details are in the documentation for " { $link make-block-stream } "." } $io-error ; HELP: tabular-output { $values { "style" "a hashtable" } { "quot" quotation } } -{ $description "Calls a quotation which emits a series of equal-length table rows using " { $link with-row } ". The results are laid out in a tabular fashion on the " { $link stdio } " stream." +{ $description "Calls a quotation which emits a series of equal-length table rows using " { $link with-row } ". The results are laid out in a tabular fashion on " { $link output-stream } "." $nl "The " { $snippet "style" } " hashtable holds table style information. See " { $link "table-styles" } "." } { $examples @@ -279,7 +302,7 @@ $io-error ; HELP: with-cell { $values { "quot" quotation } } -{ $description "Calls a quotation in a new scope with the " { $link stdio } " stream rebound. Output performed by the quotation is displayed in a table cell. This word can only be called inside the quotation given to " { $link with-row } "." } +{ $description "Calls a quotation in a new scope with " { $link output-stream } " rebound. Output performed by the quotation is displayed in a table cell. This word can only be called inside the quotation given to " { $link with-row } "." } $io-error ; HELP: write-cell @@ -288,34 +311,54 @@ HELP: write-cell $io-error ; HELP: with-style -{ $values { "style" "a hashtable" } { "quot" "a quotation" } } +{ $values { "style" "a hashtable" } { "quot" quotation } } { $description "Calls the quotation in a new dynamic scope where calls to " { $link write } ", " { $link format } " and other stream output words automatically inherit style settings from " { $snippet "style" } "." } { $notes "Details are in the documentation for " { $link make-span-stream } "." } $io-error ; HELP: print { $values { "string" string } } -{ $description "Writes a newline-terminated string to the " { $link stdio } " stream." } +{ $description "Writes a newline-terminated string to " { $link output-stream } "." } $io-error ; -HELP: with-stream -{ $values { "stream" "an input or output stream" } { "quot" "a quotation" } } -{ $description "Calls the quotation in a new dynamic scope, with the " { $link stdio } " variable rebound to " { $snippet "stream" } ". The stream is closed if the quotation returns or throws an error." } ; +HELP: with-input-stream +{ $values { "stream" "an input stream" } { "quot" quotation } } +{ $description "Calls the quotation in a new dynamic scope, with " { $link input-stream } " rebound to " { $snippet "stream" } ". The stream is closed if the quotation returns or throws an error." } ; -{ with-stream with-stream* } related-words +HELP: with-output-stream +{ $values { "stream" "an output stream" } { "quot" quotation } } +{ $description "Calls the quotation in a new dynamic scope, with " { $link output-stream } " rebound to " { $snippet "stream" } ". The stream is closed if the quotation returns or throws an error." } ; -HELP: with-stream* -{ $values { "stream" "an input or output stream" } { "quot" "a quotation" } } -{ $description "Calls the quotation in a new dynamic scope, with the " { $link stdio } " variable rebound to " { $snippet "stream" } "." } -{ $notes "This word does not close the stream. Compare with " { $link with-stream } "." } ; +HELP: with-streams +{ $values { "input" "an input stream" } { "output" "an output stream" } { "quot" quotation } } +{ $description "Calls the quotation in a new dynamic scope, with " { $link input-stream } " rebound to " { $snippet "input" } " and " { $link output-stream } " rebound to " { $snippet "output" } ". The stream is closed if the quotation returns or throws an error." } ; + +HELP: with-streams* +{ $values { "input" "an input stream" } { "output" "an output stream" } { "quot" quotation } } +{ $description "Calls the quotation in a new dynamic scope, with " { $link input-stream } " rebound to " { $snippet "input" } " and " { $link output-stream } " rebound to " { $snippet "output" } "." } +{ $notes "This word does not close the stream. Compare with " { $link with-streams } "." } ; + +{ with-input-stream with-input-stream* } related-words + +{ with-output-stream with-output-stream* } related-words + +HELP: with-input-stream* +{ $values { "stream" "an input stream" } { "quot" quotation } } +{ $description "Calls the quotation in a new dynamic scope, with " { $link input-stream } " rebound to " { $snippet "stream" } "." } +{ $notes "This word does not close the stream. Compare with " { $link with-input-stream } "." } ; + +HELP: with-output-stream* +{ $values { "stream" "an output stream" } { "quot" quotation } } +{ $description "Calls the quotation in a new dynamic scope, with " { $link output-stream } " rebound to " { $snippet "stream" } "." } +{ $notes "This word does not close the stream. Compare with " { $link with-output-stream } "." } ; HELP: bl -{ $description "Outputs a space character (" { $snippet "\" \"" } ")." } +{ $description "Outputs a space character (" { $snippet "\" \"" } ") to " { $link output-stream } "." } $io-error ; HELP: write-object { $values { "str" string } { "obj" "an object" } } -{ $description "Writes a string to the " { $link stdio } " stream, associating it with the object. If formatted output is supported, the string will become a clickable presentation of the object, otherwise this word behaves like a call to " { $link write } "." } +{ $description "Writes a string to " { $link output-stream } ", associating it with the object. If formatted output is supported, the string will become a clickable presentation of the object, otherwise this word behaves like a call to " { $link write } "." } $io-error ; HELP: lines diff --git a/core/io/io-tests.factor b/core/io/io-tests.factor index b7d1cf81c8..50a798d290 100755 --- a/core/io/io-tests.factor +++ b/core/io/io-tests.factor @@ -8,21 +8,18 @@ IN: io.tests "foo" "io.tests" lookup ] unit-test -: ( resource -- stream ) - resource-path latin1 ; - [ "This is a line.\rThis is another line.\r" ] [ - "core/io/test/mac-os-eol.txt" - [ 500 read ] with-stream + "resource:core/io/test/mac-os-eol.txt" latin1 + [ 500 read ] with-input-stream ] unit-test [ 255 ] [ - "core/io/test/binary.txt" - [ read1 ] with-stream >fixnum + "resource:core/io/test/binary.txt" latin1 + [ read1 ] with-input-stream >fixnum ] unit-test ! Make sure we use correct to_c_string form when writing @@ -36,11 +33,12 @@ IN: io.tests } ] [ [ - "core/io/test/separator-test.txt" [ + "resource:core/io/test/separator-test.txt" + latin1 [ "J" read-until 2array , "i" read-until 2array , "X" read-until 2array , - ] with-stream + ] with-input-stream ] { } make ] unit-test @@ -49,12 +47,3 @@ IN: io.tests 10 [ 65536 read drop ] times ] with-file-reader ] unit-test - -! [ "" ] [ 0 read ] unit-test - -! [ ] [ "123" write 9000 CHAR: x write flush ] unit-test - -! [ -! "/core/io/test/binary.txt" -! [ 0.2 read ] with-stream -! ] must-fail diff --git a/core/io/io.factor b/core/io/io.factor index ef9eae7902..e28fd28fb3 100755 --- a/core/io/io.factor +++ b/core/io/io.factor @@ -30,39 +30,52 @@ GENERIC: stream-write-table ( table-cells style stream -- ) [ 2dup (stream-copy) ] [ dispose dispose ] [ ] cleanup ; -! Default stream -SYMBOL: stdio +! Default streams +SYMBOL: input-stream +SYMBOL: output-stream +SYMBOL: error-stream -! Default error stream -SYMBOL: stderr +: readln ( -- str/f ) input-stream get stream-readln ; +: read1 ( -- ch/f ) input-stream get stream-read1 ; +: read ( n -- str/f ) input-stream get stream-read ; +: read-until ( seps -- str/f sep/f ) input-stream get stream-read-until ; -: readln ( -- str/f ) stdio get stream-readln ; -: read1 ( -- ch/f ) stdio get stream-read1 ; -: read ( n -- str/f ) stdio get stream-read ; -: read-until ( seps -- str/f sep/f ) stdio get stream-read-until ; +: write1 ( ch -- ) output-stream get stream-write1 ; +: write ( str -- ) output-stream get stream-write ; +: flush ( -- ) output-stream get stream-flush ; -: write1 ( ch -- ) stdio get stream-write1 ; -: write ( str -- ) stdio get stream-write ; -: flush ( -- ) stdio get stream-flush ; +: nl ( -- ) output-stream get stream-nl ; +: format ( str style -- ) output-stream get stream-format ; -: nl ( -- ) stdio get stream-nl ; -: format ( str style -- ) stdio get stream-format ; +: with-input-stream* ( stream quot -- ) + input-stream swap with-variable ; inline -: with-stream* ( stream quot -- ) - stdio swap with-variable ; inline +: with-input-stream ( stream quot -- ) + [ with-input-stream* ] curry with-disposal ; inline -: with-stream ( stream quot -- ) - [ with-stream* ] curry with-disposal ; inline +: with-output-stream* ( stream quot -- ) + output-stream swap with-variable ; inline + +: with-output-stream ( stream quot -- ) + [ with-output-stream* ] curry with-disposal ; inline + +: with-streams* ( input output quot -- ) + [ output-stream set input-stream set ] prepose with-scope ; inline + +: with-streams ( input output quot -- ) + [ [ with-streams* ] 3curry ] + [ [ drop dispose dispose ] 3curry ] 3bi + [ ] cleanup ; inline : tabular-output ( style quot -- ) - swap >r { } make r> stdio get stream-write-table ; inline + swap >r { } make r> output-stream get stream-write-table ; inline : with-row ( quot -- ) { } make , ; inline : with-cell ( quot -- ) - H{ } stdio get make-cell-stream - [ swap with-stream ] keep , ; inline + H{ } output-stream get make-cell-stream + [ swap with-output-stream ] keep , ; inline : write-cell ( str -- ) [ write ] with-cell ; inline @@ -71,13 +84,14 @@ SYMBOL: stderr swap dup assoc-empty? [ drop call ] [ - stdio get make-span-stream swap with-stream + output-stream get make-span-stream swap with-output-stream ] if ; inline : with-nesting ( style quot -- ) - >r stdio get make-block-stream r> with-stream ; inline + >r output-stream get make-block-stream + r> with-output-stream ; inline -: print ( string -- ) stdio get stream-print ; +: print ( string -- ) output-stream get stream-print ; : bl ( -- ) " " write ; @@ -85,9 +99,9 @@ SYMBOL: stderr presented associate format ; : lines ( stream -- seq ) - [ [ readln dup ] [ ] [ drop ] unfold ] with-stream ; + [ [ readln dup ] [ ] [ drop ] unfold ] with-input-stream ; : contents ( stream -- str ) [ [ 65536 read dup ] [ ] [ drop ] unfold concat f like - ] with-stream ; + ] with-input-stream ; diff --git a/core/io/streams/byte-array/byte-array-docs.factor b/core/io/streams/byte-array/byte-array-docs.factor index 741725af41..7b27621343 100644 --- a/core/io/streams/byte-array/byte-array-docs.factor +++ b/core/io/streams/byte-array/byte-array-docs.factor @@ -25,10 +25,10 @@ HELP: HELP: with-byte-reader { $values { "encoding" "an encoding descriptor" } { "quot" quotation } { "byte-array" byte-array } } -{ $description "Calls the quotation in a new dynamic scope with " { $link stdio } " rebound to an input stream for reading from a byte array using an encoding." } ; +{ $description "Calls the quotation in a new dynamic scope with " { $link input-stream } " rebound to an input stream for reading from a byte array using an encoding." } ; HELP: with-byte-writer { $values { "encoding" "an encoding descriptor" } { "quot" quotation } { "byte-array" byte-array } } -{ $description "Calls the quotation in a new dynamic scope with " { $link stdio } " rebound to an output stream writing data to a byte array using an encoding." } ; +{ $description "Calls the quotation in a new dynamic scope with " { $link output-stream } " rebound to an output stream writing data to a byte array using an encoding." } ; diff --git a/core/io/streams/byte-array/byte-array.factor b/core/io/streams/byte-array/byte-array.factor index 2a8441ff23..28d789d66f 100644 --- a/core/io/streams/byte-array/byte-array.factor +++ b/core/io/streams/byte-array/byte-array.factor @@ -1,16 +1,16 @@ USING: byte-arrays byte-vectors kernel io.encodings io.streams.string -sequences io namespaces io.encodings.private ; +sequences io namespaces io.encodings.private accessors ; IN: io.streams.byte-array : ( encoding -- stream ) 512 swap ; : with-byte-writer ( encoding quot -- byte-array ) - >r r> [ stdio get ] compose with-stream* - dup encoder? [ encoder-stream ] when >byte-array ; inline + >r r> [ output-stream get ] compose with-output-stream* + dup encoder? [ stream>> ] when >byte-array ; inline : ( byte-array encoding -- stream ) >r >byte-vector dup reverse-here r> ; : with-byte-reader ( byte-array encoding quot -- ) - >r r> with-stream ; inline + >r r> with-input-stream* ; inline diff --git a/core/io/streams/c/c.factor b/core/io/streams/c/c.factor index 372acbe0c1..91732f3211 100755 --- a/core/io/streams/c/c.factor +++ b/core/io/streams/c/c.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel kernel.private namespaces io io.encodings sequences math generic threads.private classes io.backend -io.streams.duplex io.files continuations byte-arrays ; +io.files continuations byte-arrays ; IN: io.streams.c TUPLE: c-writer handle ; diff --git a/core/io/streams/duplex/duplex-docs.factor b/core/io/streams/duplex/duplex-docs.factor deleted file mode 100755 index c9691af5ba..0000000000 --- a/core/io/streams/duplex/duplex-docs.factor +++ /dev/null @@ -1,19 +0,0 @@ -USING: help.markup help.syntax io continuations ; -IN: io.streams.duplex - -ARTICLE: "io.streams.duplex" "Duplex streams" -"Duplex streams combine an input stream and an output stream into a bidirectional stream." -{ $subsection duplex-stream } -{ $subsection } ; - -ABOUT: "io.streams.duplex" - -HELP: duplex-stream -{ $class-description "A bidirectional stream wrapping an input and output stream." } ; - -HELP: -{ $values { "in" "an input stream" } { "out" "an output stream" } { "stream" " a duplex stream" } } -{ $description "Creates a duplex stream. Writing to a duplex stream will write to " { $snippet "out" } ", and reading from a duplex stream will read from " { $snippet "in" } ". Closing a duplex stream closes both the input and output streams." } ; - -HELP: stream-closed-twice -{ $error-description "This error is thrown when performing an I/O operation on a " { $link duplex-stream } " which has been closed with " { $link dispose } "." } ; diff --git a/core/io/streams/string/string-docs.factor b/core/io/streams/string/string-docs.factor index 5b09baa56d..b87e5ca591 100644 --- a/core/io/streams/string/string-docs.factor +++ b/core/io/streams/string/string-docs.factor @@ -17,7 +17,7 @@ HELP: HELP: with-string-writer { $values { "quot" quotation } { "str" string } } -{ $description "Calls the quotation in a new dynamic scope with " { $link stdio } " rebound to a new string writer. The accumulated string is output when the quotation returns." } ; +{ $description "Calls the quotation in a new dynamic scope with " { $link output-stream } " rebound to a new string writer. The accumulated string is output when the quotation returns." } ; HELP: { $values { "str" string } { "stream" "an input stream" } } @@ -26,4 +26,4 @@ HELP: HELP: with-string-reader { $values { "str" string } { "quot" quotation } } -{ $description "Calls the quotation in a new dynamic scope with " { $link stdio } " rebound to an input stream reading " { $snippet "str" } " from beginning to end." } ; +{ $description "Calls the quotation in a new dynamic scope with " { $link input-stream } " rebound to an input stream reading " { $snippet "str" } " from beginning to end." } ; diff --git a/core/io/streams/string/string-tests.factor b/core/io/streams/string/string-tests.factor index ca117534da..3512ac871d 100644 --- a/core/io/streams/string/string-tests.factor +++ b/core/io/streams/string/string-tests.factor @@ -35,7 +35,7 @@ unit-test "J" read-until 2array , "i" read-until 2array , "X" read-until 2array , - ] with-stream + ] with-input-stream ] { } make ] unit-test diff --git a/core/io/streams/string/string.factor b/core/io/streams/string/string.factor index 531d0401b2..d43599776b 100755 --- a/core/io/streams/string/string.factor +++ b/core/io/streams/string/string.factor @@ -15,7 +15,7 @@ M: growable stream-flush drop ; 512 ; : with-string-writer ( quot -- str ) - swap [ stdio get ] compose with-stream* + swap [ output-stream get ] compose with-output-stream* >string ; inline M: growable stream-read1 dup empty? [ drop f ] [ pop ] if ; @@ -56,7 +56,7 @@ M: null decode-char drop stream-read1 ; >sbuf dup reverse-here null ; : with-string-reader ( str quot -- ) - >r r> with-stream ; inline + >r r> with-input-stream ; inline INSTANCE: growable plain-writer @@ -67,15 +67,14 @@ INSTANCE: growable plain-writer ] unless ; : map-last ( seq quot -- seq ) - swap dup length - [ zero? rot [ call ] keep swap ] 2map nip ; inline + >r dup length [ zero? ] r> compose 2map ; inline : format-table ( table -- seq ) flip [ format-column ] map-last flip [ " " join ] map ; M: plain-writer stream-write-table - [ drop format-table [ print ] each ] with-stream* ; + [ drop format-table [ print ] each ] with-output-stream* ; M: plain-writer make-cell-stream 2drop ; diff --git a/core/listener/listener-docs.factor b/core/listener/listener-docs.factor index 755c79ac68..beea9005b4 100755 --- a/core/listener/listener-docs.factor +++ b/core/listener/listener-docs.factor @@ -32,14 +32,14 @@ HELP: listener-hook HELP: read-quot { $values { "quot/f" "a parsed quotation, or " { $link f } " indicating end of file" } } -{ $description "Reads a Factor expression which possibly spans more than one line from " { $link stdio } " stream. Additional lines of input are read while the parser stack height is greater than one. Since structural parsing words push partial quotations on the stack, this will keep on reading input until all delimited parsing words are terminated." } ; +{ $description "Reads a Factor expression which possibly spans more than one line from " { $link input-stream } ". Additional lines of input are read while the parser stack height is greater than one. Since structural parsing words push partial quotations on the stack, this will keep on reading input until all delimited parsing words are terminated." } ; HELP: listen -{ $description "Prompts for an expression on the " { $link stdio } " stream and evaluates it. On end of file, " { $link quit-flag } " is set to terminate the listener loop." } -{ $errors "If the expression input by the user throws an error, the error is printed to the " { $link stdio } " stream and the word returns normally." } ; +{ $description "Prompts for an expression on " { $link input-stream } " and evaluates it. On end of file, " { $link quit-flag } " is set to terminate the listener loop." } +{ $errors "If the expression input by the user throws an error, the error is printed to " { $link output-stream } " and the word returns normally." } ; HELP: listener -{ $description "Prompts for expressions on the " { $link stdio } " stream and evaluates them until end of file is reached." } ; +{ $description "Prompts for expressions on " { $link input-stream } " and evaluates them until end of file is reached." } ; HELP: bye { $description "Exits the current listener." } diff --git a/core/listener/listener-tests.factor b/core/listener/listener-tests.factor index 2c05c049a7..24449049e0 100755 --- a/core/listener/listener-tests.factor +++ b/core/listener/listener-tests.factor @@ -51,6 +51,6 @@ IN: listener.tests [ [ ] [ "IN: listener.tests : hello\n\"world\" ;" parse-interactive - drop + drop ] unit-test ] with-file-vocabs diff --git a/core/listener/listener.factor b/core/listener/listener.factor index ddb29bb768..e00e64f4bc 100755 --- a/core/listener/listener.factor +++ b/core/listener/listener.factor @@ -2,8 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays hashtables io kernel math math.parser memory namespaces parser sequences strings io.styles -io.streams.duplex vectors words generic system combinators -continuations debugger definitions compiler.units accessors ; +vectors words generic system combinators continuations debugger +definitions compiler.units accessors ; IN: listener SYMBOL: quit-flag @@ -35,10 +35,7 @@ GENERIC: stream-read-quot ( stream -- quot/f ) M: object stream-read-quot V{ } clone read-quot-loop ; -M: duplex-stream stream-read-quot - duplex-stream-in stream-read-quot ; - -: read-quot ( -- quot/f ) stdio get stream-read-quot ; +: read-quot ( -- quot/f ) input-stream get stream-read-quot ; : bye ( -- ) quit-flag on ; @@ -46,9 +43,13 @@ M: duplex-stream stream-read-quot "( " in get " )" 3append H{ { background { 1 0.7 0.7 1 } } } format bl flush ; +SYMBOL: error-hook + +[ print-error-and-restarts ] error-hook set-global + : listen ( -- ) listener-hook get call prompt. - [ read-quot [ try ] [ bye ] if* ] + [ read-quot [ [ error-hook get call ] recover ] [ bye ] if* ] [ dup parse-error? [ error-hook get call diff --git a/core/math/order/order-docs.factor b/core/math/order/order-docs.factor index 98ff1920fa..23ea1058ad 100644 --- a/core/math/order/order-docs.factor +++ b/core/math/order/order-docs.factor @@ -25,8 +25,8 @@ HELP: +gt+ { $description "Returned by " { $link <=> } " when the first object is strictly greater than the second object." } ; HELP: invert-comparison -{ $values { "symbol" "a comparison symbol, +lt+, +eq+, or +gt+" } - { "new-symbol" "a comparison symbol, +lt+, +eq+, or +gt+" } } +{ $values { "symbol" symbol } + { "new-symbol" symbol } } { $description "Invert the comparison symbol returned by " { $link <=> } ". The output for the symbol " { $snippet "+eq+" } " is itself." } { $examples { $example "USING: math.order prettyprint ;" "+lt+ invert-comparison ." "+gt+" } } ; diff --git a/core/math/parser/parser-tests.factor b/core/math/parser/parser-tests.factor index baa6634a9f..15234ee310 100755 --- a/core/math/parser/parser-tests.factor +++ b/core/math/parser/parser-tests.factor @@ -98,3 +98,9 @@ unit-test [ 1 1 >base ] must-fail [ 1 0 >base ] must-fail [ 1 -1 >base ] must-fail + +[ "0.0/0.0" ] [ 0.0 0.0 / number>string ] unit-test + +[ "1.0/0.0" ] [ 1.0 0.0 / number>string ] unit-test + +[ "-1.0/0.0" ] [ -1.0 0.0 / number>string ] unit-test diff --git a/core/math/parser/parser.factor b/core/math/parser/parser.factor index 1a1a080564..d1b8e6fd37 100755 --- a/core/math/parser/parser.factor +++ b/core/math/parser/parser.factor @@ -140,9 +140,9 @@ M: ratio >base M: float >base drop { + { [ dup fp-nan? ] [ drop "0.0/0.0" ] } { [ dup 1.0/0.0 = ] [ drop "1.0/0.0" ] } { [ dup -1.0/0.0 = ] [ drop "-1.0/0.0" ] } - { [ dup fp-nan? ] [ drop "0.0/0.0" ] } [ float>string fix-float ] } cond ; diff --git a/core/optimizer/def-use/def-use-tests.factor b/core/optimizer/def-use/def-use-tests.factor index ef829da9f2..f49ab7fcba 100755 --- a/core/optimizer/def-use/def-use-tests.factor +++ b/core/optimizer/def-use/def-use-tests.factor @@ -1,6 +1,6 @@ IN: optimizer.def-use.tests USING: inference inference.dataflow optimizer optimizer.def-use -namespaces assocs kernel sequences math tools.test words ; +namespaces assocs kernel sequences math tools.test words sets ; [ 3 { 1 1 1 } ] [ [ 1 2 3 ] dataflow compute-def-use drop diff --git a/core/parser/parser-docs.factor b/core/parser/parser-docs.factor index b69985fb1d..418278baee 100755 --- a/core/parser/parser-docs.factor +++ b/core/parser/parser-docs.factor @@ -5,7 +5,7 @@ quotations namespaces compiler.units assocs ; IN: parser ARTICLE: "vocabulary-search-shadow" "Shadowing word names" -"If adding a vocabulary to the search path results in a word in another vocabulary becoming inaccessible due to the new vocabulary defining a word with the same name, a message is printed to the " { $link stdio } " stream. Except when debugging suspected name clashes, these messages can be ignored." +"If adding a vocabulary to the search path results in a word in another vocabulary becoming inaccessible due to the new vocabulary defining a word with the same name, we say that the old word has been " { $emphasis "shadowed" } "." $nl "Here is an example where shadowing occurs:" { $code @@ -13,18 +13,18 @@ $nl "USING: sequences io ;" "" ": append" - " \"foe::append calls sequences::append\" print append ;" + " \"foe::append calls sequences:append\" print append ;" "" "IN: fee" "" ": append" - " \"fee::append calls fee::append\" print append ;" + " \"fee::append calls fee:append\" print append ;" "" "IN: fox" "USE: foe" "" ": append" - " \"fox::append calls foe::append\" print append ;" + " \"fox::append calls foe:append\" print append ;" "" "\"1234\" \"5678\" append print" "" @@ -33,12 +33,13 @@ $nl } "When placed in a source file and run, the above code produces the following output:" { $code - "foe::append calls sequences::append" + "foe:append calls sequences:append" "12345678" - "fee::append calls foe::append" - "foe::append calls sequences::append" + "fee:append calls foe:append" + "foe:append calls sequences:append" "12345678" -} ; +} +"The " { $vocab-link "qualified" } " vocabulary contains some tools for helping with shadowing." ; ARTICLE: "vocabulary-search-errors" "Word lookup errors" "If the parser cannot not find a word in the current vocabulary search path, it attempts to look for the word in all loaded vocabularies. Then, one of three things happen:" @@ -215,7 +216,7 @@ HELP: save-location { $description "Saves the location of a definition and associates this definition with the current source file." } ; HELP: parser-notes -{ $var-description "A boolean controlling whether the parser will print various notes and warnings. Switched on by default. If a source file is being run for its effect on the " { $link stdio } " stream, this variable should be switched off, to prevent parser notes from polluting the output." } ; +{ $var-description "A boolean controlling whether the parser will print various notes and warnings. Switched on by default. If a source file is being run for its effect on " { $link output-stream } ", this variable should be switched off, to prevent parser notes from polluting the output." } ; HELP: parser-notes? { $values { "?" "a boolean" } } @@ -506,7 +507,7 @@ HELP: bootstrap-file HELP: eval>string { $values { "str" string } { "output" string } } -{ $description "Evaluates the Factor code in " { $snippet "str" } " with the " { $link stdio } " stream rebound to a string output stream, then outputs the resulting string." } ; +{ $description "Evaluates the Factor code in " { $snippet "str" } " with " { $link output-stream } " rebound to a string output stream, then outputs the resulting string." } ; HELP: staging-violation { $values { "word" word } } diff --git a/core/prettyprint/prettyprint-docs.factor b/core/prettyprint/prettyprint-docs.factor index 2933c8ee6f..f7f0f7ee44 100755 --- a/core/prettyprint/prettyprint-docs.factor +++ b/core/prettyprint/prettyprint-docs.factor @@ -135,7 +135,7 @@ ARTICLE: "prettyprint" "The prettyprinter" $nl "Prettyprinter words are found in the " { $vocab-link "prettyprint" } " vocabulary." $nl -"The key words to print an object to the " { $link stdio } " stream; the first two emit a trailing newline, the second two do not:" +"The key words to print an object to " { $link output-stream } "; the first two emit a trailing newline, the second two do not:" { $subsection . } { $subsection short. } { $subsection pprint } @@ -161,17 +161,17 @@ ABOUT: "prettyprint" HELP: with-pprint { $values { "obj" object } { "quot" quotation } } -{ $description "Sets up the prettyprinter and calls the quotation in a new scope. The quotation should add sections to the top-level block. When the quotation returns, the top-level block is printed to the " { $link stdio } " stream." } ; +{ $description "Sets up the prettyprinter and calls the quotation in a new scope. The quotation should add sections to the top-level block. When the quotation returns, the top-level block is printed to " { $link output-stream } "." } ; HELP: pprint { $values { "obj" object } } -{ $description "Prettyprints an object to the " { $link stdio } " stream. Output is influenced by many variables; see " { $link "prettyprint-variables" } "." } ; +{ $description "Prettyprints an object to " { $link output-stream } ". Output is influenced by many variables; see " { $link "prettyprint-variables" } "." } ; { pprint pprint* with-pprint } related-words HELP: . { $values { "obj" object } } -{ $description "Prettyprints an object to the " { $link stdio } " stream with a trailing line break. Output is influenced by many variables; see " { $link "prettyprint-variables" } "." } ; +{ $description "Prettyprints an object to " { $link output-stream } " with a trailing line break. Output is influenced by many variables; see " { $link "prettyprint-variables" } "." } ; HELP: unparse { $values { "obj" object } { "str" "Factor source string" } } @@ -179,11 +179,11 @@ HELP: unparse HELP: pprint-short { $values { "obj" object } } -{ $description "Prettyprints an object to the " { $link stdio } " stream. This word rebinds printer control variables to enforce ``shorter'' output. See " { $link "prettyprint-variables" } "." } ; +{ $description "Prettyprints an object to " { $link output-stream } ". This word rebinds printer control variables to enforce ``shorter'' output. See " { $link "prettyprint-variables" } "." } ; HELP: short. { $values { "obj" object } } -{ $description "Prettyprints an object to the " { $link stdio } " stream with a trailing line break. This word rebinds printer control variables to enforce ``shorter'' output." } ; +{ $description "Prettyprints an object to " { $link output-stream } " with a trailing line break. This word rebinds printer control variables to enforce ``shorter'' output." } ; HELP: .b { $values { "n" "an integer" } } diff --git a/core/prettyprint/prettyprint-tests.factor b/core/prettyprint/prettyprint-tests.factor index e94670992c..0faae398e9 100755 --- a/core/prettyprint/prettyprint-tests.factor +++ b/core/prettyprint/prettyprint-tests.factor @@ -114,7 +114,7 @@ unit-test [ parse-fresh drop ] with-compilation-unit [ "prettyprint.tests" lookup see - ] with-string-writer "\n" split 1 head* + ] with-string-writer "\n" split but-last ] keep = ] with-scope ; diff --git a/core/prettyprint/sections/sections-docs.factor b/core/prettyprint/sections/sections-docs.factor index ceb37c2fe4..842a36a13b 100755 --- a/core/prettyprint/sections/sections-docs.factor +++ b/core/prettyprint/sections/sections-docs.factor @@ -15,7 +15,7 @@ HELP: line-limit? HELP: do-indent -{ $description "Outputs the current indent nesting to the " { $link stdio } " stream." } ; +{ $description "Outputs the current indent nesting to " { $link output-stream } "." } ; HELP: fresh-line { $values { "n" "the current column position" } } diff --git a/core/prettyprint/sections/sections.factor b/core/prettyprint/sections/sections.factor index 5f32539115..11fa4da28e 100644 --- a/core/prettyprint/sections/sections.factor +++ b/core/prettyprint/sections/sections.factor @@ -15,9 +15,9 @@ SYMBOL: pprinter-stack SYMBOL: pprinter-in SYMBOL: pprinter-use -TUPLE: pprinter last-newline line-count end-printing indent ; +TUPLE: pprinter last-newline line-count indent ; -: ( -- pprinter ) 0 1 f 0 pprinter boa ; +: ( -- pprinter ) 0 1 0 pprinter boa ; : record-vocab ( word -- ) word-vocabulary [ dup pprinter-use get set-at ] when* ; @@ -34,7 +34,7 @@ TUPLE: pprinter last-newline line-count end-printing indent ; ] [ pprinter get (>>last-newline) line-limit? [ - "..." write pprinter get end-printing>> continue + "..." write pprinter get return ] when pprinter get [ 1+ ] change-line-count drop nl do-indent @@ -275,16 +275,15 @@ M: colon unindent-first-line? drop t ; [ dup style>> [ [ - >r pprinter get (>>end-printing) r> short-section - ] curry callcc0 + ] curry with-return ] with-nesting ] if-nonempty ] with-variable ; ! Long section layout algorithm : chop-break ( seq -- seq ) - dup peek line-break? [ 1 head-slice* chop-break ] when ; + dup peek line-break? [ but-last-slice chop-break ] when ; SYMBOL: prev SYMBOL: next diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 2a2fcf29cd..8b15f5b980 100755 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -92,9 +92,11 @@ ARTICLE: "sequences-slices" "Subsequences and slices" { $subsection subseq } { $subsection head } { $subsection tail } -{ $subsection rest } { $subsection head* } { $subsection tail* } +"Removing the first or last element:" +{ $subsection rest } +{ $subsection but-last } "Taking a sequence apart into a head and a tail:" { $subsection unclip } { $subsection cut } @@ -106,6 +108,7 @@ ARTICLE: "sequences-slices" "Subsequences and slices" { $subsection } { $subsection head-slice } { $subsection tail-slice } +{ $subsection but-last-slice } { $subsection rest-slice } { $subsection head-slice* } { $subsection tail-slice* } @@ -836,11 +839,16 @@ HELP: tail-slice { $description "Outputs a virtual sequence sharing storage with all elements from the " { $snippet "n" } "th index until the end of the input sequence." } { $errors "Throws an error if the index is out of bounds." } ; +HELP: but-last-slice +{ $values { "seq" sequence } { "slice" "a slice" } } +{ $description "Outputs a virtual sequence sharing storage with all but the last element of the input sequence." } +{ $errors "Throws an error on an empty sequence." } ; + HELP: rest-slice { $values { "seq" sequence } { "slice" "a slice" } } { $description "Outputs a virtual sequence sharing storage with all elements from the 1st index until the end of the input sequence." } { $notes "Equivalent to " { $snippet "1 tail" } } -{ $errors "Throws an error if the index is out of bounds." } ; +{ $errors "Throws an error on an empty sequence." } ; HELP: head-slice* { $values { "seq" sequence } { "n" "a non-negative integer" } { "slice" "a slice" } } @@ -862,6 +870,11 @@ HELP: tail { $description "Outputs a new sequence consisting of the input sequence with the first n items removed." } { $errors "Throws an error if the index is out of bounds." } ; +HELP: but-last +{ $values { "seq" sequence } { "headseq" "a new sequence" } } +{ $description "Outputs a new sequence consisting of the input sequence with the last item removed." } +{ $errors "Throws an error on an empty sequence." } ; + HELP: rest { $values { "seq" sequence } { "tailseq" "a new sequence" } } { $description "Outputs a new sequence consisting of the input sequence with the first item removed." } diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index a63e6d2835..8d0e3eec18 100755 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -216,6 +216,8 @@ M: slice length dup slice-to swap slice-from - ; : tail-slice* ( seq n -- slice ) from-end tail-slice ; +: but-last-slice ( seq -- slice ) 1 head-slice* ; + INSTANCE: slice virtual-sequence ! One element repeated many times @@ -263,6 +265,8 @@ PRIVATE> : tail* ( seq n -- tailseq ) from-end tail ; +: but-last ( seq -- headseq ) 1 head* ; + : copy ( src i dst -- ) pick length >r 3dup check-copy spin 0 r> (copy) drop ; inline @@ -670,9 +674,15 @@ PRIVATE> : unclip ( seq -- rest first ) [ rest ] [ first ] bi ; +: unclip-last ( seq -- butfirst last ) + [ but-last ] [ peek ] bi ; + : unclip-slice ( seq -- rest first ) [ rest-slice ] [ first ] bi ; +: unclip-last-slice ( seq -- butfirst last ) + [ but-last-slice ] [ peek ] bi ; + : ( seq -- slice ) dup slice? [ { } like ] when 0 over length rot ; inline diff --git a/core/splitting/splitting.factor b/core/splitting/splitting.factor index eb10b9fe4a..9f6ae75d32 100755 --- a/core/splitting/splitting.factor +++ b/core/splitting/splitting.factor @@ -1,42 +1,72 @@ -! Copyright (C) 2005, 2007 Slava Pestov. +! Copyright (C) 2005, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel math namespaces strings arrays vectors sequences -sets math.order ; +sets math.order accessors ; IN: splitting -TUPLE: groups seq n sliced? ; +TUPLE: abstract-groups seq n ; -: check-groups 0 <= [ "Invalid group count" throw ] when ; +: check-groups dup 0 <= [ "Invalid group count" throw ] when ; inline + +: construct-groups ( seq n class -- groups ) + >r check-groups r> boa ; inline + +GENERIC: group@ ( n groups -- from to seq ) + +M: abstract-groups nth group@ subseq ; + +M: abstract-groups set-nth group@ 0 swap copy ; + +M: abstract-groups like drop { } like ; + +INSTANCE: abstract-groups sequence + +TUPLE: groups < abstract-groups ; : ( seq n -- groups ) - dup check-groups f groups boa ; inline - -: ( seq n -- groups ) - t over set-groups-sliced? ; + groups construct-groups ; inline M: groups length - dup groups-seq length swap groups-n [ + 1- ] keep /i ; + [ seq>> length ] [ n>> ] bi [ + 1- ] keep /i ; M: groups set-length - [ groups-n * ] keep groups-seq set-length ; + [ n>> * ] [ seq>> ] bi set-length ; -: group@ ( n groups -- from to seq ) - [ groups-n [ * dup ] keep + ] keep - groups-seq [ length min ] keep ; +M: groups group@ + [ n>> [ * dup ] keep + ] [ seq>> ] bi [ length min ] keep ; -M: groups nth - [ group@ ] keep - groups-sliced? [ ] [ subseq ] if ; +TUPLE: sliced-groups < groups ; -M: groups set-nth - group@ 0 swap copy ; +: ( seq n -- groups ) + sliced-groups construct-groups ; inline -M: groups like drop { } like ; +M: sliced-groups nth group@ ; -INSTANCE: groups sequence +TUPLE: clumps < abstract-groups ; + +: ( seq n -- groups ) + clumps construct-groups ; inline + +M: clumps length + [ seq>> length ] [ n>> ] bi - 1+ ; + +M: clumps set-length + [ n>> + 1- ] [ seq>> ] bi set-length ; + +M: clumps group@ + [ n>> over + ] [ seq>> ] bi ; + +TUPLE: sliced-clumps < groups ; + +: ( seq n -- groups ) + sliced-clumps construct-groups ; inline + +M: sliced-clumps nth group@ ; : group ( seq n -- array ) { } like ; +: clump ( seq n -- array ) { } like ; + : ?head ( seq begin -- newseq ? ) 2dup head? [ length tail t ] [ drop f ] if ; @@ -74,7 +104,7 @@ INSTANCE: groups sequence 1array ] [ "\n" split [ - 1 head-slice* [ + but-last-slice [ "\r" ?tail drop "\r" split ] map ] keep peek "\r" split suffix concat diff --git a/core/threads/threads-docs.factor b/core/threads/threads-docs.factor index 3f9ff54ac8..7d8791d493 100755 --- a/core/threads/threads-docs.factor +++ b/core/threads/threads-docs.factor @@ -116,10 +116,13 @@ $nl "Other threads may interrupt the sleep by calling " { $link interrupt } "." } ; HELP: sleep -{ $values { "ms" "a non-negative integer" } } -{ $description "Suspends the current thread for " { $snippet "ms" } " milliseconds." +{ $values { "dt" "a duration" } } +{ $description "Suspends the current thread for the given duration." $nl -"Other threads may interrupt the sleep by calling " { $link interrupt } "." } ; +"Other threads may interrupt the sleep by calling " { $link interrupt } "." } +{ $examples + { $code "USING: threads calendar ;" "10 seconds sleep" } +} ; HELP: interrupt { $values { "thread" thread } } diff --git a/core/threads/threads-tests.factor b/core/threads/threads-tests.factor index 0ac607f0ed..0e33ccd94c 100755 --- a/core/threads/threads-tests.factor +++ b/core/threads/threads-tests.factor @@ -1,5 +1,6 @@ USING: namespaces io tools.test threads kernel -concurrency.combinators math ; +concurrency.combinators concurrency.promises locals math +words ; IN: threads.tests 3 "x" set @@ -27,3 +28,16 @@ yield "i" tget ] parallel-map ] unit-test + +[ [ 3 throw ] "A" suspend ] [ 3 = ] must-fail-with + +:: spawn-namespace-test ( -- ) + [let | p [ ] g [ gensym ] | + [ + g "x" set + [ "x" get p fulfill ] "B" spawn drop + ] with-scope + p ?promise g eq? + ] ; + +[ t ] [ spawn-namespace-test ] unit-test diff --git a/core/threads/threads.factor b/core/threads/threads.factor index 8b89cd5732..a1c7e208dc 100755 --- a/core/threads/threads.factor +++ b/core/threads/threads.factor @@ -12,7 +12,7 @@ SYMBOL: initial-thread TUPLE: thread name quot exit-handler id -continuation state +continuation state runnable mailbox variables sleep-entry ; : self ( -- thread ) 40 getenv ; inline @@ -91,9 +91,11 @@ PRIVATE> [ sleep-queue heap-peek nip millis [-] ] } cond ; +DEFER: stop + r check-registered dup r> sleep-queue heap-push* >>sleep-entry drop ; @@ -111,36 +113,57 @@ PRIVATE> [ ] while drop ; +: start ( namestack thread -- ) + [ + set-self + set-namestack + V{ } set-catchstack + { } set-retainstack + { } set-datastack + self quot>> [ call stop ] call-clear + ] 2 (throw) ; + +DEFER: next + +: no-runnable-threads ( -- * ) + ! We should never be in a state where the only threads + ! are sleeping; the I/O wait thread is always runnable. + ! However, if it dies, we handle this case + ! semi-gracefully. + ! + ! And if sleep-time outputs f, there are no sleeping + ! threads either... so WTF. + sleep-time [ die 0 ] unless* (sleep) next ; + +: (next) ( arg thread -- * ) + f >>state + dup set-self + dup runnable>> [ + continuation>> box> continue-with + ] [ + t >>runnable start + ] if ; + : next ( -- * ) expire-sleep-loop run-queue dup dlist-empty? [ - ! We should never be in a state where the only threads - ! are sleeping; the I/O wait thread is always runnable. - ! However, if it dies, we handle this case - ! semi-gracefully. - ! - ! And if sleep-time outputs f, there are no sleeping - ! threads either... so WTF. - drop sleep-time [ die 0 ] unless* (sleep) next + drop no-runnable-threads ] [ - pop-back - dup array? [ first2 ] [ f swap ] if dup set-self - f >>state - continuation>> box> - continue-with + pop-back dup array? [ first2 ] [ f swap ] if (next) ] if ; PRIVATE> : stop ( -- ) - self dup exit-handler>> call - unregister-thread next ; + self [ exit-handler>> call ] [ unregister-thread ] bi next ; : suspend ( quot state -- obj ) [ - self continuation>> >box - self (>>state) - self swap call next + >r + >r self swap call + r> self (>>state) + r> self continuation>> >box + next ] callcc1 2nip ; inline : yield ( -- ) [ resume ] f suspend drop ; @@ -153,7 +176,7 @@ M: integer sleep-until M: f sleep-until drop [ drop ] "interrupt" suspend drop ; -GENERIC: sleep ( ms -- ) +GENERIC: sleep ( dt -- ) M: real sleep millis + >integer sleep-until ; @@ -166,16 +189,7 @@ M: real sleep ] when drop ; : (spawn) ( thread -- ) - [ - resume-now [ - dup set-self - dup register-thread - V{ } set-catchstack - { } set-retainstack - >r { } set-datastack r> - quot>> [ call stop ] call-clear - ] 1 (throw) - ] "spawn" suspend 2drop ; + [ register-thread ] [ namestack swap resume-with ] bi ; : spawn ( quot name -- thread ) [ (spawn) ] keep ; @@ -184,8 +198,8 @@ M: real sleep >r [ [ ] [ ] while ] curry r> spawn ; : in-thread ( quot -- ) - >r datastack namestack r> - [ >r set-namestack set-datastack r> call ] 3curry + >r datastack r> + [ >r set-datastack r> call ] 2curry "Thread" spawn drop ; GENERIC: error-in-thread ( error thread -- ) @@ -199,6 +213,7 @@ GENERIC: error-in-thread ( error thread -- ) initial-thread global [ drop f "Initial" ] cache >>continuation + t >>runnable f >>state dup register-thread set-self ; diff --git a/extra/asn1/asn1-tests.factor b/extra/asn1/asn1-tests.factor index 329ba8256d..1908e28d39 100755 --- a/extra/asn1/asn1-tests.factor +++ b/extra/asn1/asn1-tests.factor @@ -1,16 +1,16 @@ USING: asn1 asn1.ldap io io.streams.string tools.test ; [ 6 ] [ - "\u000002\u000001\u000006" [ asn-syntax read-ber ] with-stream + "\u000002\u000001\u000006" [ asn-syntax read-ber ] with-input-stream ] unit-test [ "testing" ] [ - "\u000004\u000007testing" [ asn-syntax read-ber ] with-stream + "\u000004\u000007testing" [ asn-syntax read-ber ] with-input-stream ] unit-test [ { 1 { 3 "Administrator" "ad_is_bogus" } } ] [ "0$\u000002\u000001\u000001`\u00001f\u000002\u000001\u000003\u000004\rAdministrator\u000080\u00000bad_is_bogus" - [ asn-syntax read-ber ] with-stream + [ asn-syntax read-ber ] with-input-stream ] unit-test [ diff --git a/extra/asn1/asn1.factor b/extra/asn1/asn1.factor index 32e3602f8f..50102d1929 100644 --- a/extra/asn1/asn1.factor +++ b/extra/asn1/asn1.factor @@ -98,7 +98,7 @@ DEFER: read-ber SYMBOL: end -: (read-array) ( stream -- ) +: (read-array) ( -- ) elements get element-id [ elements get element-syntax read-ber dup end = [ drop ] [ , (read-array) ] if @@ -106,7 +106,7 @@ SYMBOL: end : read-array ( -- array ) [ (read-array) ] { } make ; -: set-case ( -- ) +: set-case ( -- object ) elements get element-newobj elements get element-objtype { { "boolean" [ "\0" = not ] } diff --git a/extra/bank/bank.factor b/extra/bank/bank.factor index 35d1337afc..abe3250ecf 100644 --- a/extra/bank/bank.factor +++ b/extra/bank/bank.factor @@ -26,8 +26,6 @@ C: transaction : daily-rate>> ( account date -- rate ) [ interest-rate>> ] dip daily-rate ; -: before? ( date date -- ? ) <=> 0 < ; - : transactions-on-date ( account date -- transactions ) [ before? ] curry filter ; diff --git a/extra/benchmark/fasta/fasta.factor b/extra/benchmark/fasta/fasta.factor index 215b677e16..d449c0fc5b 100755 --- a/extra/benchmark/fasta/fasta.factor +++ b/extra/benchmark/fasta/fasta.factor @@ -81,7 +81,7 @@ HINTS: random fixnum ; write-description [let | k! [ 0 ] alu [ ] | [| len | k len alu make-repeat-fasta k! ] split-lines - ] with-locals ; inline + ] ; inline : fasta ( n out -- ) homo-sapiens make-cumulative @@ -103,7 +103,7 @@ HINTS: random fixnum ; drop ] with-file-writer - ] with-locals ; + ] ; : run-fasta 2500000 reverse-complement-in fasta ; diff --git a/extra/benchmark/knucleotide/knucleotide.factor b/extra/benchmark/knucleotide/knucleotide.factor index e06b81f6de..6bd2d69cfa 100644 --- a/extra/benchmark/knucleotide/knucleotide.factor +++ b/extra/benchmark/knucleotide/knucleotide.factor @@ -56,7 +56,7 @@ IN: benchmark.knucleotide drop ; : knucleotide ( -- ) - "extra/benchmark/knucleotide/knucleotide-input.txt" resource-path + "resource:extra/benchmark/knucleotide/knucleotide-input.txt" ascii [ read-input ] with-file-reader process-input ; diff --git a/extra/benchmark/reverse-complement/reverse-complement.factor b/extra/benchmark/reverse-complement/reverse-complement.factor index d83b720187..5fdaf49d8f 100755 --- a/extra/benchmark/reverse-complement/reverse-complement.factor +++ b/extra/benchmark/reverse-complement/reverse-complement.factor @@ -32,13 +32,11 @@ HINTS: do-line vector string ; readln [ do-line (reverse-complement) ] [ show-seq ] if* ; : reverse-complement ( infile outfile -- ) - ascii [ - swap ascii [ - swap [ - 500000 (reverse-complement) - ] with-stream - ] with-disposal - ] with-disposal ; + ascii [ + ascii [ + 500000 (reverse-complement) + ] with-file-reader + ] with-file-writer ; : reverse-complement-in "reverse-complement-in.txt" temp-file ; diff --git a/extra/benchmark/sockets/sockets.factor b/extra/benchmark/sockets/sockets.factor index 25212c7264..6defd94290 100755 --- a/extra/benchmark/sockets/sockets.factor +++ b/extra/benchmark/sockets/sockets.factor @@ -1,6 +1,6 @@ USING: io.sockets io kernel math threads io.encodings.ascii -debugger tools.time prettyprint concurrency.count-downs -namespaces arrays continuations ; +io.streams.duplex debugger tools.time prettyprint +concurrency.count-downs namespaces arrays continuations ; IN: benchmark.sockets SYMBOL: counter @@ -10,7 +10,7 @@ SYMBOL: counter : server-addr "127.0.0.1" 7777 ; : server-loop ( server -- ) - dup accept [ + dup accept drop [ [ read1 CHAR: x = [ "server" get dispose @@ -30,17 +30,17 @@ SYMBOL: counter ] ignore-errors ; : simple-client ( -- ) - server-addr ascii [ + server-addr ascii [ CHAR: b write1 flush number-of-requests [ CHAR: a dup write1 flush read1 assert= ] times counter get count-down - ] with-stream ; + ] with-client ; : stop-server ( -- ) - server-addr ascii [ + server-addr ascii [ CHAR: x write1 - ] with-stream ; + ] with-client ; : clients ( n -- ) dup pprint " clients: " write [ diff --git a/extra/builder/util/util.factor b/extra/builder/util/util.factor index 3b0834b190..c40efaaa04 100644 --- a/extra/builder/util/util.factor +++ b/extra/builder/util/util.factor @@ -16,7 +16,7 @@ IN: builder.util : minutes>ms ( min -- ms ) 60 * 1000 * ; -: file>string ( file -- string ) utf8 [ stdio get contents ] with-file-reader ; +: file>string ( file -- string ) utf8 file-contents ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -107,5 +107,5 @@ USE: prettyprint ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! : git-id ( -- id ) - { "git" "show" } utf8 [ readln ] with-stream + { "git" "show" } utf8 [ readln ] with-input-stream " " split second ; diff --git a/extra/cairo/png/png.factor b/extra/cairo/png/png.factor index 1bbad29835..a3b13c9691 100755 --- a/extra/cairo/png/png.factor +++ b/extra/cairo/png/png.factor @@ -21,7 +21,7 @@ ERROR: cairo-error string ; { CAIRO_STATUS_FILE_NOT_FOUND [ "Cairo: file not found" cairo-error ] } { CAIRO_STATUS_READ_ERROR [ "Cairo: read error" cairo-error ] } [ drop ] - } cond ; + } case ; : ( path -- png ) normalize-path diff --git a/extra/checksums/md5/md5.factor b/extra/checksums/md5/md5.factor index 78494a40c0..a385f6d04f 100755 --- a/extra/checksums/md5/md5.factor +++ b/extra/checksums/md5/md5.factor @@ -180,4 +180,4 @@ SINGLETON: md5 INSTANCE: md5 checksum M: md5 checksum-stream ( stream -- byte-array ) - drop [ initialize-md5 stream>md5 get-md5 ] with-stream ; + drop [ initialize-md5 stream>md5 get-md5 ] with-input-stream ; diff --git a/extra/checksums/null/null.factor b/extra/checksums/null/null.factor index d2dc305ac2..d3ab878a12 100644 --- a/extra/checksums/null/null.factor +++ b/extra/checksums/null/null.factor @@ -1,8 +1,8 @@ -USING: checksums ; +USING: checksums kernel ; IN: checksums.null SINGLETON: null INSTANCE: null checksum -M: null checksum-bytes ; +M: null checksum-bytes drop ; diff --git a/extra/checksums/sha1/sha1.factor b/extra/checksums/sha1/sha1.factor index 2efab873bc..6427e0e8eb 100755 --- a/extra/checksums/sha1/sha1.factor +++ b/extra/checksums/sha1/sha1.factor @@ -111,7 +111,7 @@ SINGLETON: sha1 INSTANCE: sha1 checksum M: sha1 checksum-stream ( stream -- sha1 ) - drop [ initialize-sha1 stream>sha1 get-sha1 ] with-stream ; + drop [ initialize-sha1 stream>sha1 get-sha1 ] with-input-stream ; : sha1-interleave ( string -- seq ) [ zero? ] left-trim diff --git a/extra/combinators/lib/lib.factor b/extra/combinators/lib/lib.factor index 84b41a91ff..5dfe8527c1 100755 --- a/extra/combinators/lib/lib.factor +++ b/extra/combinators/lib/lib.factor @@ -169,3 +169,8 @@ MACRO: multikeep ( word out-indexes -- ... ) : generate ( generator predicate -- obj ) [ dup ] swap [ dup [ nip ] unless not ] 3compose swap [ ] do-while ; + +MACRO: predicates ( seq -- quot/f ) + dup [ 1quotation [ drop ] prepend ] map + >r [ [ dup ] prepend ] map r> zip [ drop f ] suffix + [ cond ] curry ; diff --git a/extra/concurrency/combinators/combinators-docs.factor b/extra/concurrency/combinators/combinators-docs.factor index bbf8fb0f5f..a23301c1e2 100755 --- a/extra/concurrency/combinators/combinators-docs.factor +++ b/extra/concurrency/combinators/combinators-docs.factor @@ -6,11 +6,21 @@ HELP: parallel-map { $description "Spawns a new thread for applying " { $snippet "quot" } " to every element of " { $snippet "seq" } ", collecting the results at the end." } { $errors "Throws an error if one of the iterations throws an error." } ; +HELP: 2parallel-map +{ $values { "seq1" sequence } { "seq2" sequence } { "quot" "a quotation with stack effect " { $snippet "( elt -- newelt )" } } { "newseq" sequence } } +{ $description "Spawns a new thread for applying " { $snippet "quot" } " to pairwise elements of " { $snippet "seq1" } " and " { $snippet "seq2" } ", collecting the results at the end." } +{ $errors "Throws an error if one of the iterations throws an error." } ; + HELP: parallel-each { $values { "seq" sequence } { "quot" "a quotation with stack effect " { $snippet "( elt -- )" } } } { $description "Spawns a new thread for applying " { $snippet "quot" } " to every element of " { $snippet "seq" } ", blocking until all quotations complete." } { $errors "Throws an error if one of the iterations throws an error." } ; +HELP: 2parallel-each +{ $values { "seq1" sequence } { "seq2" sequence } { "quot" "a quotation with stack effect " { $snippet "( elt -- )" } } } +{ $description "Spawns a new thread for applying " { $snippet "quot" } " to pairwise elements of " { $snippet "seq1" } " and " { $snippet "seq2" } ", blocking until all quotations complete." } +{ $errors "Throws an error if one of the iterations throws an error." } ; + HELP: parallel-filter { $values { "seq" sequence } { "quot" "a quotation with stack effect " { $snippet "( elt -- ? )" } } { "newseq" sequence } } { $description "Spawns a new thread for applying " { $snippet "quot" } " to every element of " { $snippet "seq" } ", collecting the elements for which the quotation yielded a true value." } @@ -19,7 +29,9 @@ HELP: parallel-filter ARTICLE: "concurrency.combinators" "Concurrent combinators" "The " { $vocab-link "concurrency.combinators" } " vocabulary provides concurrent variants of " { $link each } ", " { $link map } " and " { $link filter } ":" { $subsection parallel-each } +{ $subsection 2parallel-each } { $subsection parallel-map } +{ $subsection 2parallel-map } { $subsection parallel-filter } ; ABOUT: "concurrency.combinators" diff --git a/extra/concurrency/combinators/combinators-tests.factor b/extra/concurrency/combinators/combinators-tests.factor index 3381cba5e8..562111242d 100755 --- a/extra/concurrency/combinators/combinators-tests.factor +++ b/extra/concurrency/combinators/combinators-tests.factor @@ -1,9 +1,11 @@ IN: concurrency.combinators.tests USING: concurrency.combinators tools.test random kernel math -concurrency.mailboxes threads sequences accessors ; +concurrency.mailboxes threads sequences accessors arrays ; [ [ drop ] parallel-each ] must-infer +{ 2 0 } [ [ 2drop ] 2parallel-each ] must-infer-as [ [ ] parallel-map ] must-infer +{ 2 1 } [ [ 2array ] 2parallel-map ] must-infer-as [ [ ] parallel-filter ] must-infer [ { 1 4 9 } ] [ { 1 2 3 } [ sq ] parallel-map ] unit-test @@ -22,3 +24,24 @@ concurrency.mailboxes threads sequences accessors ; 10 over [ push ] curry parallel-each length ] unit-test + +[ { 10 20 30 } ] [ + { 1 4 3 } { 10 5 10 } [ * ] 2parallel-map +] unit-test + +[ { -9 -1 -7 } ] [ + { 1 4 3 } { 10 5 10 } [ - ] 2parallel-map +] unit-test + +[ + { 1 4 3 } { 1 0 1 } [ / drop ] 2parallel-each +] must-fail + +[ 20 ] +[ + V{ } clone + 10 10 pick [ [ push ] [ push ] bi ] curry 2parallel-each + length +] unit-test + +[ { f } [ "OOPS" throw ] parallel-each ] must-fail diff --git a/extra/concurrency/combinators/combinators.factor b/extra/concurrency/combinators/combinators.factor index 3c4101e381..eab0ed4cb4 100755 --- a/extra/concurrency/combinators/combinators.factor +++ b/extra/concurrency/combinators/combinators.factor @@ -4,14 +4,27 @@ USING: concurrency.futures concurrency.count-downs sequences kernel ; IN: concurrency.combinators -: parallel-map ( seq quot -- newseq ) - [ curry future ] curry map dup [ ?future ] change-each ; - inline +: (parallel-each) ( n quot -- ) + >r r> keep await ; inline : parallel-each ( seq quot -- ) - over length - [ [ >r curry r> spawn-stage ] 2curry each ] keep await ; - inline + over length [ + [ >r curry r> spawn-stage ] 2curry each + ] (parallel-each) ; inline + +: 2parallel-each ( seq1 seq2 quot -- ) + 2over min-length [ + [ >r 2curry r> spawn-stage ] 2curry 2each + ] (parallel-each) ; inline : parallel-filter ( seq quot -- newseq ) over >r pusher >r each r> r> like ; inline + +: future-values dup [ ?future ] change-each ; inline + +: parallel-map ( seq quot -- newseq ) + [ curry future ] curry map future-values ; + inline + +: 2parallel-map ( seq1 seq2 quot -- newseq ) + [ 2curry future ] curry 2map future-values ; diff --git a/extra/concurrency/count-downs/count-downs.factor b/extra/concurrency/count-downs/count-downs.factor index 6a75f7206c..93cef250a1 100755 --- a/extra/concurrency/count-downs/count-downs.factor +++ b/extra/concurrency/count-downs/count-downs.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: dlists kernel math concurrency.promises -concurrency.mailboxes ; +concurrency.mailboxes debugger accessors ; IN: concurrency.count-downs ! http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/CountDownLatch.html @@ -9,9 +9,7 @@ IN: concurrency.count-downs TUPLE: count-down n promise ; : count-down-check ( count-down -- ) - dup count-down-n zero? [ - t swap count-down-promise fulfill - ] [ drop ] if ; + dup n>> zero? [ t swap promise>> fulfill ] [ drop ] if ; : ( n -- count-down ) dup 0 < [ "Invalid count for count down" throw ] when @@ -19,15 +17,12 @@ TUPLE: count-down n promise ; dup count-down-check ; : count-down ( count-down -- ) - dup count-down-n dup zero? [ - "Count down already done" throw - ] [ - 1- over set-count-down-n - count-down-check - ] if ; + dup n>> dup zero? + [ "Count down already done" throw ] + [ 1- >>n count-down-check ] if ; : await-timeout ( count-down timeout -- ) - >r count-down-promise r> ?promise-timeout drop ; + >r promise>> r> ?promise-timeout ?linked t assert= ; : await ( count-down -- ) f await-timeout ; @@ -35,5 +30,4 @@ TUPLE: count-down n promise ; : spawn-stage ( quot count-down -- ) [ [ count-down ] curry compose ] keep "Count down stage" - swap count-down-promise - promise-mailbox spawn-linked-to drop ; + swap promise>> mailbox>> spawn-linked-to drop ; diff --git a/extra/concurrency/distributed/distributed.factor b/extra/concurrency/distributed/distributed.factor index 6704272305..c637f4baa3 100755 --- a/extra/concurrency/distributed/distributed.factor +++ b/extra/concurrency/distributed/distributed.factor @@ -3,7 +3,7 @@ USING: serialize sequences concurrency.messaging threads io io.server qualified arrays namespaces kernel io.encodings.binary accessors ; -QUALIFIED: io.sockets +FROM: io.sockets => host-name with-client ; IN: concurrency.distributed SYMBOL: local-node @@ -23,7 +23,7 @@ SYMBOL: local-node : start-node ( port -- ) [ internet-server ] - [ io.sockets:host-name swap io.sockets: ] bi + [ host-name swap ] bi (start-node) ; TUPLE: remote-process id node ; @@ -31,8 +31,7 @@ TUPLE: remote-process id node ; C: remote-process : send-remote-message ( message node -- ) - binary io.sockets: - [ serialize ] with-stream ; + binary [ serialize ] with-client ; M: remote-process send ( message thread -- ) [ id>> 2array ] [ node>> ] bi diff --git a/extra/concurrency/flags/flags-tests.factor b/extra/concurrency/flags/flags-tests.factor index f23ea95167..9d3f6de98c 100755 --- a/extra/concurrency/flags/flags-tests.factor +++ b/extra/concurrency/flags/flags-tests.factor @@ -1,11 +1,12 @@ IN: concurrency.flags.tests -USING: tools.test concurrency.flags kernel threads locals ; +USING: tools.test concurrency.flags concurrency.combinators +kernel threads locals accessors ; :: flag-test-1 ( -- ) [let | f [ ] | [ f raise-flag ] "Flag test" spawn drop f lower-flag - f flag-value? + f value>> ] ; [ f ] [ flag-test-1 ] unit-test @@ -14,7 +15,7 @@ USING: tools.test concurrency.flags kernel threads locals ; [let | f [ ] | [ 1000 sleep f raise-flag ] "Flag test" spawn drop f lower-flag - f flag-value? + f value>> ] ; [ f ] [ flag-test-2 ] unit-test @@ -22,7 +23,7 @@ USING: tools.test concurrency.flags kernel threads locals ; :: flag-test-3 ( -- ) [let | f [ ] | f raise-flag - f flag-value? + f value>> ] ; [ t ] [ flag-test-3 ] unit-test @@ -31,7 +32,7 @@ USING: tools.test concurrency.flags kernel threads locals ; [let | f [ ] | [ f raise-flag ] "Flag test" spawn drop f wait-for-flag - f flag-value? + f value>> ] ; [ t ] [ flag-test-4 ] unit-test @@ -40,7 +41,13 @@ USING: tools.test concurrency.flags kernel threads locals ; [let | f [ ] | [ 1000 sleep f raise-flag ] "Flag test" spawn drop f wait-for-flag - f flag-value? + f value>> ] ; [ t ] [ flag-test-5 ] unit-test + +[ ] [ + { 1 2 } + [ [ 1000 sleep raise-flag ] curry "Flag test" spawn drop ] + [ [ wait-for-flag drop ] curry parallel-each ] bi +] unit-test diff --git a/extra/concurrency/flags/flags.factor b/extra/concurrency/flags/flags.factor index b3c76a7a01..ec260961d0 100755 --- a/extra/concurrency/flags/flags.factor +++ b/extra/concurrency/flags/flags.factor @@ -1,22 +1,20 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: boxes kernel threads ; +USING: dlists kernel threads concurrency.conditions accessors ; IN: concurrency.flags -TUPLE: flag value? thread ; +TUPLE: flag value threads ; -: ( -- flag ) f flag boa ; +: ( -- flag ) f flag boa ; : raise-flag ( flag -- ) - dup flag-value? [ - t over set-flag-value? - dup flag-thread [ resume ] if-box? - ] unless drop ; + dup value>> [ drop ] [ t >>value threads>> notify-all ] if ; + +: wait-for-flag-timeout ( flag timeout -- ) + over value>> [ 2drop ] [ >r threads>> r> "flag" wait ] if ; : wait-for-flag ( flag -- ) - dup flag-value? [ drop ] [ - [ flag-thread >box ] curry "flag" suspend drop - ] if ; + f wait-for-flag-timeout ; : lower-flag ( flag -- ) - dup wait-for-flag f swap set-flag-value? ; + [ wait-for-flag ] [ f >>value drop ] bi ; diff --git a/extra/concurrency/mailboxes/mailboxes.factor b/extra/concurrency/mailboxes/mailboxes.factor index ac03197708..aa4dc2df3d 100755 --- a/extra/concurrency/mailboxes/mailboxes.factor +++ b/extra/concurrency/mailboxes/mailboxes.factor @@ -3,7 +3,7 @@ IN: concurrency.mailboxes USING: dlists threads sequences continuations namespaces random math quotations words kernel arrays assocs -init system concurrency.conditions accessors ; +init system concurrency.conditions accessors debugger ; TUPLE: mailbox threads data closed ; @@ -83,6 +83,9 @@ M: mailbox dispose TUPLE: linked-error error thread ; +M: linked-error error. + [ thread>> error-in-thread. ] [ error>> error. ] bi ; + C: linked-error : ?linked dup linked-error? [ rethrow ] when ; diff --git a/extra/contributors/contributors-tests.factor b/extra/contributors/contributors-tests.factor new file mode 100644 index 0000000000..1476715588 --- /dev/null +++ b/extra/contributors/contributors-tests.factor @@ -0,0 +1,5 @@ +IN: contributors.tests +USING: contributors tools.test ; + +\ contributors must-infer +[ ] [ contributors ] unit-test diff --git a/extra/contributors/contributors.factor b/extra/contributors/contributors.factor index 868e968169..9f2d5a55fa 100755 --- a/extra/contributors/contributors.factor +++ b/extra/contributors/contributors.factor @@ -1,13 +1,13 @@ ! Copyright (C) 2007 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io.files io.launcher io.styles io hashtables kernel -sequences sequences.lib assocs system sorting math.parser -sets ; +USING: io.files io.launcher io.styles io.encodings.ascii io +hashtables kernel sequences sequences.lib assocs system sorting +math.parser sets ; IN: contributors : changelog ( -- authors ) image parent-directory [ - "git-log --pretty=format:%an" lines + "git-log --pretty=format:%an" ascii lines ] with-directory ; : patch-counts ( authors -- assoc ) diff --git a/extra/cpu/8080/test/test.factor b/extra/cpu/8080/test/test.factor index 85f27d7e40..f88db2935f 100755 --- a/extra/cpu/8080/test/test.factor +++ b/extra/cpu/8080/test/test.factor @@ -1,5 +1,5 @@ USING: kernel cpu.8080 cpu.8080.emulator math math io -tools.time combinators sequences io.files ; +tools.time combinators sequences io.files io.encodings.ascii ; IN: cpu.8080.test : step ( cpu -- ) @@ -29,7 +29,7 @@ IN: cpu.8080.test : >ppm ( cpu filename -- cpu ) #! Dump the current screen image to a ppm image file with the given name. - [ + ascii [ "P3" print "256 224" print "1" print @@ -45,7 +45,7 @@ IN: cpu.8080.test ] each-8bit drop ] each drop nl ] each - ] with-stream ; + ] with-file-writer ; : time-test ( -- ) test-cpu [ 1000000 run-n drop ] time ; diff --git a/extra/crypto/hmac/hmac.factor b/extra/crypto/hmac/hmac.factor index fe77aa8969..6e30f19775 100755 --- a/extra/crypto/hmac/hmac.factor +++ b/extra/crypto/hmac/hmac.factor @@ -30,7 +30,7 @@ MEMO: opad ( -- seq ) 64 HEX: 5c ; ipad seq-bitxor ; : stream>sha1-hmac ( K stream -- hmac ) - [ init-hmac sha1-hmac ] with-stream ; + [ init-hmac sha1-hmac ] with-input-stream ; : file>sha1-hmac ( K path -- hmac ) binary stream>sha1-hmac ; @@ -39,7 +39,7 @@ MEMO: opad ( -- seq ) 64 HEX: 5c ; binary stream>sha1-hmac ; : stream>md5-hmac ( K stream -- hmac ) - [ init-hmac md5-hmac ] with-stream ; + [ init-hmac md5-hmac ] with-input-stream ; : file>md5-hmac ( K path -- hmac ) binary stream>md5-hmac ; diff --git a/extra/csv/csv.factor b/extra/csv/csv.factor index b1953f5b57..8ba0832b29 100644 --- a/extra/csv/csv.factor +++ b/extra/csv/csv.factor @@ -61,11 +61,11 @@ VAR: delimiter : csv-row ( stream -- row ) init-vars - [ row nip ] with-stream ; + [ row nip ] with-input-stream ; : csv ( stream -- rows ) init-vars - [ [ (csv) ] { } make ] with-stream ; + [ [ (csv) ] { } make ] with-input-stream ; : with-delimiter ( char quot -- ) delimiter swap with-variable ; inline diff --git a/extra/delegate/protocols/protocols.factor b/extra/delegate/protocols/protocols.factor index f1ad068fe2..c1d7e1e4ab 100755 --- a/extra/delegate/protocols/protocols.factor +++ b/extra/delegate/protocols/protocols.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. USING: delegate sequences.private sequences assocs prettyprint.sections -io definitions kernel continuations ; +io definitions kernel continuations listener ; IN: delegate.protocols PROTOCOL: sequence-protocol @@ -12,8 +12,10 @@ PROTOCOL: assoc-protocol at* assoc-size >alist set-at assoc-clone-like { assoc-find 1 } delete-at clear-assoc new-assoc assoc-like ; -PROTOCOL: stream-protocol - stream-read1 stream-read stream-read-until dispose +PROTOCOL: input-stream-protocol + stream-read1 stream-read stream-read-until stream-read-quot ; + +PROTOCOL: output-stream-protocol stream-flush stream-write1 stream-write stream-format stream-nl make-span-stream make-block-stream stream-readln make-cell-stream stream-write-table ; diff --git a/extra/destructors/destructors.factor b/extra/destructors/destructors.factor index c3914e9c93..6fc7ab249f 100755 --- a/extra/destructors/destructors.factor +++ b/extra/destructors/destructors.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: continuations io.backend libc kernel namespaces -sequences system vectors ; +USING: continuations io.backend io.nonblocking libc kernel +namespaces sequences system vectors ; IN: destructors SYMBOL: error-destructors @@ -59,10 +59,8 @@ TUPLE: handle-destructor alien ; C: handle-destructor -HOOK: destruct-handle io-backend ( obj -- ) - M: handle-destructor dispose ( obj -- ) - handle-destructor-alien destruct-handle ; + handle-destructor-alien close-handle ; : close-always ( handle -- ) add-always-destructor ; diff --git a/extra/editors/jedit/jedit.factor b/extra/editors/jedit/jedit.factor index e4f19781ef..fe9abc0e76 100755 --- a/extra/editors/jedit/jedit.factor +++ b/extra/editors/jedit/jedit.factor @@ -25,11 +25,11 @@ IN: editors.jedit ] with-byte-writer ; : send-jedit-request ( request -- ) - jedit-server-info "localhost" rot binary [ + jedit-server-info "localhost" rot binary [ 4 >be write dup length 2 >be write write - ] with-stream ; + ] with-client ; : jedit-location ( file line -- ) number>string "+line:" prepend 2array diff --git a/extra/fry/fry-docs.factor b/extra/fry/fry-docs.factor index 84d02d529d..7a444fecbc 100755 --- a/extra/fry/fry-docs.factor +++ b/extra/fry/fry-docs.factor @@ -87,7 +87,7 @@ $nl } ; ARTICLE: "fry.limitations" "Fried quotation limitations" -"As with " { $link "locals" } ", fried quotations cannot contain " { $link >r } " and " { $link r> } ". Unlike " { $link "locals" } ", using " { $link dip } " is not a suitable workaround since unlike closure conversion, fry conversion is not recursive, and so the quotation passed to " { $link dip } " cannot contain fry specifiers." ; +"As with " { $vocab-link "locals" } ", fried quotations cannot contain " { $link >r } " and " { $link r> } "." ; ARTICLE: "fry" "Fried quotations" "A " { $emphasis "fried quotation" } " differs from a literal quotation in that when it is evaluated, instead of just pushing itself on the stack, it consumes zero or more stack values and inserts them into the quotation." diff --git a/extra/fry/fry-tests.factor b/extra/fry/fry-tests.factor index 7586e254b2..eb59ffae4e 100755 --- a/extra/fry/fry-tests.factor +++ b/extra/fry/fry-tests.factor @@ -48,3 +48,7 @@ sequences ; [ { 1 2 3 } ] [ 3 1 '[ , [ , + ] map ] call ] unit-test + +[ { 1 { 2 { 3 } } } ] [ + 1 2 3 '[ , [ , [ , 1array ] call 2array ] call 2array ] call +] unit-test diff --git a/extra/fry/fry.factor b/extra/fry/fry.factor index 1b9e2dc82b..27a321ed92 100755 --- a/extra/fry/fry.factor +++ b/extra/fry/fry.factor @@ -54,7 +54,7 @@ DEFER: (shallow-fry) [ { , namespaces:, @ } member? ] filter length \ , % ] - [ deep-fry % ] bi + [ fry % ] bi ] [ namespaces:, ] if ] each ] [ ] make deep-fry ; diff --git a/extra/gap-buffer/tags.txt b/extra/gap-buffer/tags.txt index fd3a2d285a..b5e4471134 100644 --- a/extra/gap-buffer/tags.txt +++ b/extra/gap-buffer/tags.txt @@ -1,2 +1,2 @@ collections -collections sequences +sequences diff --git a/core/io/streams/duplex/authors.txt b/extra/geo-ip/authors.txt similarity index 100% rename from core/io/streams/duplex/authors.txt rename to extra/geo-ip/authors.txt diff --git a/extra/geo-ip/geo-ip.factor b/extra/geo-ip/geo-ip.factor new file mode 100644 index 0000000000..5926dd596d --- /dev/null +++ b/extra/geo-ip/geo-ip.factor @@ -0,0 +1,46 @@ +USING: kernel sequences io.files io.launcher io.encodings.ascii +io.streams.string http.client sequences.lib combinators +math.parser math.vectors math.intervals interval-maps memoize +csv accessors assocs strings math splitting ; +IN: geo-ip + +: db-path "IpToCountry.csv" temp-file ; + +: db-url "http://software77.net/cgi-bin/ip-country/geo-ip.pl?action=download" ; + +: download-db ( -- path ) + db-path dup exists? [ + db-url over ".gz" append download-to + { "gunzip" } over ".gz" append (normalize-path) suffix try-process + ] unless ; + +TUPLE: ip-entry from to registry assigned city cntry country ; + +: parse-ip-entry ( row -- ip-entry ) + 7 firstn { + [ string>number ] + [ string>number ] + [ ] + [ ] + [ ] + [ ] + [ ] + } spread ip-entry boa ; + +MEMO: ip-db ( -- seq ) + download-db ascii file-lines + [ "#" head? not ] filter "\n" join csv + [ parse-ip-entry ] map ; + +MEMO: ip-intervals ( -- interval-map ) + ip-db [ [ [ from>> ] [ to>> ] bi [a,b] ] keep ] { } map>assoc + ; + +GENERIC: lookup-ip ( ip -- ip-entry ) + +M: string lookup-ip + "." split [ string>number ] map + { HEX: 1000000 HEX: 10000 HEX: 100 1 } v. + lookup-ip ; + +M: integer lookup-ip ip-intervals interval-at ; diff --git a/extra/geo-ip/summary.txt b/extra/geo-ip/summary.txt new file mode 100644 index 0000000000..402d3230f1 --- /dev/null +++ b/extra/geo-ip/summary.txt @@ -0,0 +1 @@ +IP address geolocation using database from http://software77.net/cgi-bin/ip-country/ diff --git a/extra/geo-ip/tags.txt b/extra/geo-ip/tags.txt new file mode 100644 index 0000000000..0aef4feca8 --- /dev/null +++ b/extra/geo-ip/tags.txt @@ -0,0 +1 @@ +enterprise diff --git a/extra/gesture-logger/gesture-logger.factor b/extra/gesture-logger/gesture-logger.factor index 1977efd3f9..b9de7c1b74 100644 --- a/extra/gesture-logger/gesture-logger.factor +++ b/extra/gesture-logger/gesture-logger.factor @@ -15,13 +15,13 @@ TUPLE: gesture-logger stream ; M: gesture-logger handle-gesture* drop dup T{ button-down } = [ over request-focus ] when - swap gesture-logger-stream [ . ] with-stream* + swap gesture-logger-stream [ . ] with-output-stream* t ; M: gesture-logger user-input* gesture-logger-stream [ "User input: " write print - ] with-stream* t ; + ] with-output-stream* t ; : gesture-logger ( -- ) [ diff --git a/extra/help/cookbook/cookbook.factor b/extra/help/cookbook/cookbook.factor index 995b8540f5..c2e12469c5 100755 --- a/extra/help/cookbook/cookbook.factor +++ b/extra/help/cookbook/cookbook.factor @@ -205,8 +205,8 @@ ARTICLE: "cookbook-io" "Input and output cookbook" } "Send some bytes to a remote host:" { $code - "\"myhost\" 1033 " - "[ { 12 17 102 } >string write ] with-stream" + "\"myhost\" 1033 " + "[ { 12 17 102 } >string write ] with-client" } { $references { } diff --git a/extra/help/handbook/handbook.factor b/extra/help/handbook/handbook.factor index a9e94466c4..a8271a0e3b 100755 --- a/extra/help/handbook/handbook.factor +++ b/extra/help/handbook/handbook.factor @@ -31,7 +31,7 @@ $nl { { $snippet "set-" { $emphasis "foo" } } { "sets " { $snippet "foo" } " to a new value" } { $links set-length } } { { $snippet { $emphasis "foo" } "-" { $emphasis "bar" } } { "(tuple accessors) outputs the value of the " { $snippet "bar" } " slot of the " { $snippet "foo" } " at the top of the stack" } { } } { { $snippet "set-" { $emphasis "foo" } "-" { $emphasis "bar" } } { "(tuple mutators) sets the value of the " { $snippet "bar" } " slot of the " { $snippet "foo" } " at the top of the stack" } { } } - { { $snippet "with-" { $emphasis "foo" } } { "performs some kind of initialization and cleanup related to " { $snippet "foo" } ", usually in a new dynamic scope" } { $links with-scope with-stream } } + { { $snippet "with-" { $emphasis "foo" } } { "performs some kind of initialization and cleanup related to " { $snippet "foo" } ", usually in a new dynamic scope" } { $links with-scope with-input-stream with-output-stream } } { { $snippet "$" { $emphasis "foo" } } { "help markup" } { $links $heading $emphasis } } } { $heading "Stack effect conventions" } @@ -193,17 +193,19 @@ ARTICLE: "io" "Input and output" "Utilities:" { $subsection "stream-binary" } { $subsection "styles" } -{ $heading "Files" } -{ $subsection "io.files" } -{ $subsection "io.mmap" } -{ $subsection "io.monitors" } { $heading "Encodings" } { $subsection "encodings-introduction" } { $subsection "io.encodings" } { $subsection "io.encodings.string" } -{ $heading "Other features" } +{ $heading "Files" } +{ $subsection "io.files" } +{ $subsection "io.mmap" } +{ $subsection "io.monitors" } +{ $heading "Communications" } { $subsection "network-streams" } { $subsection "io.launcher" } +{ $subsection "io.pipes" } +{ $heading "Other features" } { $subsection "io.timeouts" } { $subsection "checksums" } ; diff --git a/extra/help/help-docs.factor b/extra/help/help-docs.factor index d4981751e2..f20ce89263 100755 --- a/extra/help/help-docs.factor +++ b/extra/help/help-docs.factor @@ -126,7 +126,7 @@ HELP: $title HELP: help { $values { "topic" "an article name or a word" } } { $description - "Displays a help article or documentation associated to a word on the " { $link stdio } " stream." + "Displays a help article or documentation associated to a word on " { $link output-stream } "." } ; HELP: about @@ -151,7 +151,7 @@ HELP: $index HELP: ($index) { $values { "articles" "a sequence of help articles" } } -{ $description "Writes a list of " { $link $subsection } " elements to the " { $link stdio } " stream." } ; +{ $description "Writes a list of " { $link $subsection } " elements to " { $link output-stream } "." } ; HELP: xref-help { $description "Update help cross-referencing. Usually this is done automatically." } ; @@ -168,11 +168,11 @@ HELP: $predicate HELP: print-element { $values { "element" "a markup element" } } -{ $description "Prints a markup element to the " { $link stdio } " stream." } ; +{ $description "Prints a markup element to " { $link output-stream } "." } ; HELP: print-content { $values { "element" "a markup element" } } -{ $description "Prints a top-level markup element to the " { $link stdio } " stream." } ; +{ $description "Prints a top-level markup element to " { $link output-stream } "." } ; HELP: simple-element { $class-description "Class of simple elements, which are just arrays of elements." } ; diff --git a/extra/help/lint/lint.factor b/extra/help/lint/lint.factor index fc4b7f6f25..a9ec7f9267 100755 --- a/extra/help/lint/lint.factor +++ b/extra/help/lint/lint.factor @@ -10,7 +10,7 @@ IN: help.lint : check-example ( element -- ) rest [ - 1 head* "\n" join 1vector + but-last "\n" join 1vector [ use [ clone ] change [ eval>string ] with-datastack diff --git a/extra/help/tutorial/tutorial.factor b/extra/help/tutorial/tutorial.factor index fffcda69b6..cafa758c7e 100755 --- a/extra/help/tutorial/tutorial.factor +++ b/extra/help/tutorial/tutorial.factor @@ -135,7 +135,7 @@ $nl { $code "[ Letter? ] filter >lower" } "This code starts with a string on the stack, removes non-alphabetical characters, and converts the result to lower case, leaving a new string on the stack. We put this code in a new word, and add the new word to " { $snippet "palindrome.factor" } ":" { $code ": normalize ( str -- newstr ) [ Letter? ] filter >lower ;" } -"You will need to add " { $vocab-link "unicode.categories" } " to the vocabulary search path, so that " { $link Letter? } " can be used in the source file." +"You will need to add " { $vocab-link "unicode.case" } " and " { $vocab-link "unicode.categories" } " to the vocabulary search path, so that " { $link Letter? } " can be used in the source file." $nl "We modify " { $snippet "palindrome?" } " to first apply " { $snippet "normalize" } " to its input:" { $code ": palindrome? ( str -- ? ) normalize dup reverse = ;" } diff --git a/extra/html/html-tests.factor b/extra/html/html-tests.factor index ce320ca75b..9f1ce6b689 100644 --- a/extra/html/html-tests.factor +++ b/extra/html/html-tests.factor @@ -24,7 +24,7 @@ IN: html.tests ] unit-test [ "<" ] [ - [ "<" H{ } stdio get format-html-span ] make-html-string + [ "<" H{ } output-stream get format-html-span ] make-html-string ] unit-test TUPLE: funky town ; diff --git a/extra/html/html.factor b/extra/html/html.factor index f0ae424760..c154c35223 100755 --- a/extra/html/html.factor +++ b/extra/html/html.factor @@ -44,7 +44,7 @@ TUPLE: html-sub-stream style stream ; rot html-sub-stream-stream ; : delegate-write ( string -- ) - stdio get delegate stream-write ; + output-stream get delegate stream-write ; : object-link-tag ( style quot -- ) presented pick at [ @@ -101,7 +101,7 @@ TUPLE: html-sub-stream style stream ; : format-html-span ( string style stream -- ) [ [ [ drop delegate-write ] span-tag ] object-link-tag - ] with-stream* ; + ] with-output-stream* ; TUPLE: html-span-stream ; @@ -134,7 +134,7 @@ M: html-span-stream dispose : format-html-div ( string style stream -- ) [ [ [ delegate-write ] div-tag ] object-link-tag - ] with-stream* ; + ] with-output-stream* ; TUPLE: html-block-stream ; @@ -184,17 +184,17 @@ M: html-stream stream-write-table ( grid style stream -- ) ] with each ] with each - ] with-stream* ; + ] with-output-stream* ; M: html-stream make-cell-stream ( style stream -- stream' ) (html-sub-stream) ; M: html-stream stream-nl ( stream -- ) - dup test-last-div? [ drop ] [ [
] with-stream* ] if ; + dup test-last-div? [ drop ] [ [
] with-output-stream* ] if ; ! Utilities : with-html-stream ( quot -- ) - stdio get swap with-stream* ; inline + output-stream get swap with-output-stream* ; inline : xhtml-preamble "" write-html @@ -225,13 +225,13 @@ M: html-stream stream-nl ( stream -- ) : vertical-layout ( list -- ) #! Given a list of HTML components, arrange them vertically. - +
[ ] each
call
; : horizontal-layout ( list -- ) #! Given a list of HTML components, arrange them horizontally. - +
[ ] each
call
; @@ -246,8 +246,8 @@ M: html-stream stream-nl ( stream -- ) : simple-page ( title quot -- ) #! Call the quotation, with all output going to the #! body of an html page with the given title. - - swap write + + swap write call ; @@ -255,10 +255,13 @@ M: html-stream stream-nl ( stream -- ) #! Call the quotation, with all output going to the #! body of an html page with the given title. stylesheet-quot #! is called to generate the required stylesheet. - - - rot write - swap call - + + + rot write + swap call + call ; + +: render-error ( message -- ) + escape-string write ; diff --git a/extra/html/parser/analyzer/analyzer.factor b/extra/html/parser/analyzer/analyzer.factor index 160b95ab1d..e9906f3f2a 100755 --- a/extra/html/parser/analyzer/analyzer.factor +++ b/extra/html/parser/analyzer/analyzer.factor @@ -99,7 +99,7 @@ IN: html.parser.analyzer : find-between ( i/f tag/f vector -- vector ) find-between* dup length 3 >= [ - [ rest-slice 1 head-slice* ] keep like + [ rest-slice but-last-slice ] keep like ] when ; : find-between-first ( string vector -- vector' ) diff --git a/extra/html/parser/utils/utils.factor b/extra/html/parser/utils/utils.factor index 0ae75e41fd..5083b1cec2 100644 --- a/extra/html/parser/utils/utils.factor +++ b/extra/html/parser/utils/utils.factor @@ -36,7 +36,7 @@ IN: html.parser.utils dup quoted? [ quote ] unless ; : unquote ( str -- newstr ) - dup quoted? [ 1 head-slice* rest-slice >string ] when ; + dup quoted? [ but-last-slice rest-slice >string ] when ; : quote? ( ch -- ? ) "'\"" member? ; diff --git a/extra/http/client/client.factor b/extra/http/client/client.factor index 7762b01843..17882277a3 100755 --- a/extra/http/client/client.factor +++ b/extra/http/client/client.factor @@ -3,7 +3,8 @@ USING: assocs http kernel math math.parser namespaces sequences io io.sockets io.streams.string io.files io.timeouts strings splitting calendar continuations accessors vectors math.order -io.encodings.8-bit io.encodings.binary fry debugger inspector ; +io.encodings.8-bit io.encodings.binary io.streams.duplex +fry debugger inspector ; IN: http.client : max-redirects 10 ; @@ -26,73 +27,56 @@ DEFER: http-request : store-path ( request path -- request ) "?" split1 >r >>path r> dup [ query>assoc ] when >>query ; -: request-with-url ( url request -- request ) - swap parse-url >r >r store-path r> >>host r> >>port ; - -! This is all pretty complex because it needs to handle -! HTTP redirects, which might be absolute or relative -: absolute-redirect ( url -- request ) - request get request-with-url ; - -: relative-redirect ( path -- request ) - request get swap store-path ; +: request-with-url ( request url -- request ) + parse-url >r >r store-path r> >>host r> >>port ; SYMBOL: redirects : absolute-url? ( url -- ? ) [ "http://" head? ] [ "https://" head? ] bi or ; -: do-redirect ( response -- response stream ) - dup response-code 300 399 between? [ - stdio get dispose +: do-redirect ( response data -- response data ) + over code>> 300 399 between? [ + drop redirects inc redirects get max-redirects < [ - header>> "location" swap at - dup absolute-url? [ - absolute-redirect - ] [ - relative-redirect - ] if "GET" >>method http-request + request get + swap "location" header dup absolute-url? + [ request-with-url ] [ store-path ] if + "GET" >>method http-request ] [ too-many-redirects ] if - ] [ - stdio get - ] if ; - -: close-on-error ( stream quot -- ) - '[ , with-stream* ] [ ] pick '[ , dispose ] cleanup ; inline + ] when ; PRIVATE> -: http-request ( request -- response stream ) - dup request [ - dup request-addr latin1 - 1 minutes over set-timeout - [ - write-request flush - read-response - do-redirect - ] close-on-error - ] with-variable ; - : read-chunks ( -- ) read-crlf ";" split1 drop hex> dup { f 0 } member? [ drop ] [ read % read-crlf "" assert= read-chunks ] if ; -: do-chunked-encoding ( response stream -- response stream/string ) - over "transfer-encoding" header "chunked" = [ - [ [ read-chunks ] "" make ] with-stream - ] when ; +: read-response-body ( response -- response data ) + dup "transfer-encoding" header "chunked" = + [ [ read-chunks ] "" make ] [ input-stream get contents ] if ; + +: http-request ( request -- response data ) + dup request [ + dup request-addr latin1 [ + 1 minutes timeouts + write-request + read-response + read-response-body + ] with-client + do-redirect + ] with-variable ; : ( url -- request ) - request-with-url "GET" >>method ; + + swap request-with-url + "GET" >>method ; -: string-or-contents ( stream/string -- string ) - dup string? [ contents ] unless ; - -: http-get-stream ( url -- response stream/string ) - http-request do-chunked-encoding ; +: http-get* ( url -- response data ) + http-request ; : success? ( code -- ? ) 200 = ; @@ -112,29 +96,24 @@ M: download-failed error. over code>> success? [ nip ] [ download-failed ] if ; : http-get ( url -- string ) - http-get-stream string-or-contents check-response ; + http-get* check-response ; : download-name ( url -- name ) file-name "?" split1 drop "/" ?tail drop ; : download-to ( url file -- ) #! Downloads the contents of a URL to a file. - swap http-get-stream check-response - dup string? [ - latin1 [ write ] with-file-writer - ] [ - [ swap latin1 stream-copy ] with-disposal - ] if ; + >r http-get r> latin1 [ write ] with-file-writer ; : download ( url -- ) dup download-name download-to ; : ( content-type content url -- request ) - request-with-url - "POST" >>method - swap >>post-data - swap >>post-data-type ; + "POST" >>method + swap request-with-url + swap >>post-data + swap >>post-data-type ; -: http-post ( content-type content url -- response string ) - http-request do-chunked-encoding string-or-contents ; +: http-post ( content-type content url -- response data ) + http-request ; diff --git a/extra/http/http-tests.factor b/extra/http/http-tests.factor index 831becd264..21eb241b84 100755 --- a/extra/http/http-tests.factor +++ b/extra/http/http-tests.factor @@ -30,6 +30,8 @@ IN: http.tests [ H{ { "a" { "b" "c" } } } ] [ "a=b&a=c" query>assoc ] unit-test +[ "a=3" ] [ { { "a" 3 } } assoc>query ] unit-test + : lf>crlf "\n" split "\r\n" join ; STRING: read-request-test-1 @@ -164,7 +166,7 @@ test-db [ add-quit-action - "extra/http/test" resource-path >>default + "resource:extra/http/test" >>default "nested" add-responder [ "redirect-loop" f ] >>display @@ -176,18 +178,18 @@ test-db [ ] unit-test [ t ] [ - "extra/http/test/foo.html" resource-path ascii file-contents + "resource:extra/http/test/foo.html" ascii file-contents "http://localhost:1237/nested/foo.html" http-get = ] unit-test ! Try with a slightly malformed request [ t ] [ - "localhost" 1237 ascii [ + "localhost" 1237 ascii [ "GET nested HTTP/1.0\r\n" write flush "\r\n" write flush read-crlf drop read-header - ] with-stream "location" swap at "/" head? + ] with-client "location" swap at "/" head? ] unit-test [ "http://localhost:1237/redirect-loop" http-get ] diff --git a/extra/http/http.factor b/extra/http/http.factor index 315250692b..786210123d 100755 --- a/extra/http/http.factor +++ b/extra/http/http.factor @@ -143,7 +143,7 @@ IN: http : assoc>query ( hash -- str ) [ { - { [ dup number? ] [ number>string ] } + { [ dup number? ] [ number>string 1array ] } { [ dup string? ] [ 1array ] } { [ dup sequence? ] [ ] } } cond @@ -472,7 +472,7 @@ M: string write-response-body* write ; M: callable write-response-body* call ; -M: object write-response-body* stdio get stream-copy ; +M: object write-response-body* output-stream get stream-copy ; : write-response-body ( response -- response ) dup body>> write-response-body* ; diff --git a/extra/http/server/actions/actions.factor b/extra/http/server/actions/actions.factor index 6e1aac9627..2d73cb46a7 100755 --- a/extra/http/server/actions/actions.factor +++ b/extra/http/server/actions/actions.factor @@ -2,13 +2,20 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors sequences kernel assocs combinators http.server http.server.validators http hashtables namespaces -fry continuations locals ; +fry continuations locals boxes xml.entities html.elements io ; IN: http.server.actions -SYMBOL: +path+ - SYMBOL: params +SYMBOL: validation-message + +: render-validation-message ( -- ) + validation-message get value>> [ + + escape-string write + + ] when* ; + TUPLE: action init display submit get-params post-params ; : @@ -37,11 +44,16 @@ TUPLE: action init display submit get-params post-params ; : validation-failed ( -- * ) action get display>> call exit-with ; +: validation-failed-with ( string -- * ) + validation-message get >box + validation-failed ; + M: action call-responder* ( path action -- response ) '[ , [ CHAR: / = ] right-trim empty? [ , action set request get + validation-message set [ request-params params set ] [ method>> { diff --git a/extra/http/server/auth/admin/admin.factor b/extra/http/server/auth/admin/admin.factor index e762103d7b..21e1a6181b 100644 --- a/extra/http/server/auth/admin/admin.factor +++ b/extra/http/server/auth/admin/admin.factor @@ -82,10 +82,8 @@ IN: http.server.auth.admin same-password-twice - user new "username" value >>username select-tuple [ - user-exists? on - validation-failed - ] when + user new "username" value >>username select-tuple + [ user-exists ] when "username" value "realname" value >>realname diff --git a/extra/http/server/auth/admin/admin.xml b/extra/http/server/auth/admin/admin.xml index 1864c3c4bf..05817565ed 100644 --- a/extra/http/server/auth/admin/admin.xml +++ b/extra/http/server/auth/admin/admin.xml @@ -2,8 +2,6 @@ - -

diff --git a/extra/http/server/auth/admin/edit-user.xml b/extra/http/server/auth/admin/edit-user.xml index b8c235532b..9c0fe702bb 100644 --- a/extra/http/server/auth/admin/edit-user.xml +++ b/extra/http/server/auth/admin/edit-user.xml @@ -4,9 +4,7 @@ Edit User - - - + @@ -49,17 +47,10 @@

- - - passwords do not match - +

- - - - - + Delete diff --git a/extra/http/server/auth/admin/new-user.xml b/extra/http/server/auth/admin/new-user.xml index 072e0c95bd..2d67639985 100644 --- a/extra/http/server/auth/admin/new-user.xml +++ b/extra/http/server/auth/admin/new-user.xml @@ -42,14 +42,7 @@

- - - username taken - - - - passwords do not match - +

diff --git a/extra/http/server/auth/login/edit-profile.xml b/extra/http/server/auth/login/edit-profile.xml index 107dbba2b8..1eaf65fa07 100644 --- a/extra/http/server/auth/login/edit-profile.xml +++ b/extra/http/server/auth/login/edit-profile.xml @@ -62,14 +62,7 @@

- - - invalid password - - - - passwords do not match - +

diff --git a/extra/http/server/auth/login/login.factor b/extra/http/server/auth/login/login.factor index 28486f3362..9f1fe6fe77 100755 --- a/extra/http/server/auth/login/login.factor +++ b/extra/http/server/auth/login/login.factor @@ -30,8 +30,6 @@ http.server.validators ; IN: http.server.auth.login QUALIFIED: smtp -SYMBOL: login-failed? - TUPLE: login < dispatcher users checksum ; : users ( -- provider ) @@ -82,6 +80,8 @@ M: user-saver dispose username>> set-uid "$login" end-flow ; +: login-failed "invalid username or password" validation-failed-with ; + :: ( -- action ) [let | form [ ] | @@ -94,12 +94,8 @@ M: user-saver dispose form validate-form - "password" value "username" value check-login [ - successful-login - ] [ - login-failed? on - validation-failed - ] if* + "password" value "username" value check-login + [ successful-login ] [ login-failed ] if* ] >>submit ] ; @@ -121,14 +117,13 @@ M: user-saver dispose "email" add-field "captcha" add-field ; -SYMBOL: password-mismatch? -SYMBOL: user-exists? +: password-mismatch "passwords do not match" validation-failed-with ; + +: user-exists "username taken" validation-failed-with ; : same-password-twice ( -- ) - "new-password" value "verify-password" value = [ - password-mismatch? on - validation-failed - ] unless ; + "new-password" value "verify-password" value = + [ password-mismatch ] unless ; :: ( -- action ) [let | form [ ] | @@ -150,10 +145,7 @@ SYMBOL: user-exists? "email" value >>email H{ } clone >>profile - users new-user [ - user-exists? on - validation-failed - ] unless* + users new-user [ user-exists ] unless* successful-login @@ -201,7 +193,7 @@ SYMBOL: user-exists? same-password-twice "password" value uid check-login - [ login-failed? on validation-failed ] unless + [ login-failed ] unless "new-password" value >>encoded-password ] unless diff --git a/extra/http/server/auth/login/login.xml b/extra/http/server/auth/login/login.xml index 0524d0889f..d0a73a4d8b 100644 --- a/extra/http/server/auth/login/login.xml +++ b/extra/http/server/auth/login/login.xml @@ -23,10 +23,8 @@

+ - - invalid username or password -

diff --git a/extra/http/server/auth/login/recover-3.xml b/extra/http/server/auth/login/recover-3.xml index 61ef0aef86..6c60b257a8 100644 --- a/extra/http/server/auth/login/recover-3.xml +++ b/extra/http/server/auth/login/recover-3.xml @@ -32,10 +32,7 @@

- - - passwords do not match - +

diff --git a/extra/http/server/auth/login/register.xml b/extra/http/server/auth/login/register.xml index 19917002b5..9b45a7f087 100644 --- a/extra/http/server/auth/login/register.xml +++ b/extra/http/server/auth/login/register.xml @@ -63,14 +63,7 @@

- - - username taken - - - - passwords do not match - +

diff --git a/extra/http/server/cgi/cgi.factor b/extra/http/server/cgi/cgi.factor index 509943faa8..20eb7318d0 100755 --- a/extra/http/server/cgi/cgi.factor +++ b/extra/http/server/cgi/cgi.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: namespaces kernel assocs io.files combinators -arrays io.launcher io http.server.static http.server +USING: namespaces kernel assocs io.files io.streams.duplex +combinators arrays io.launcher io http.server.static http.server http accessors sequences strings math.parser fry ; IN: http.server.cgi @@ -51,9 +51,9 @@ IN: http.server.cgi 200 >>code "CGI output follows" >>message swap '[ - , stdio get swap [ + , output-stream get swap [ post? [ request get post-data>> write flush ] when - stdio get swap (stream-copy) + input-stream get swap (stream-copy) ] with-stream ] >>body ; diff --git a/extra/http/server/components/code/code.factor b/extra/http/server/components/code/code.factor index 8bf07700e8..19fc8c5ca8 100644 --- a/extra/http/server/components/code/code.factor +++ b/extra/http/server/components/code/code.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. USING: splitting kernel io sequences xmode.code2html accessors -http.server.components xml.entities ; +http.server.components html xml.entities ; IN: http.server.components.code TUPLE: code-renderer < text-renderer mode ; @@ -11,7 +11,9 @@ TUPLE: code-renderer < text-renderer mode ; swap >>mode ; M: code-renderer render-view* - [ string-lines ] [ mode>> value ] bi* htmlize-lines ; + [ + [ string-lines ] [ mode>> value ] bi* htmlize-lines + ] with-html-stream ; : ( id mode -- component ) swap diff --git a/extra/http/server/components/components.factor b/extra/http/server/components/components.factor index c0bac1fb99..7f2a5a9ce1 100755 --- a/extra/http/server/components/components.factor +++ b/extra/http/server/components/components.factor @@ -3,7 +3,7 @@ USING: accessors namespaces kernel io math.parser assocs classes words classes.tuple arrays sequences splitting mirrors hashtables fry locals combinators continuations math -calendar.format html.elements xml.entities +calendar.format html html.elements xml.entities http.server.validators ; IN: http.server.components @@ -24,9 +24,6 @@ M: field render-view* M: field render-edit* > =type =name =value input/> ; -: render-error ( message -- ) - escape-string write ; - TUPLE: hidden < field ; : hidden ( -- renderer ) T{ hidden f "hidden" } ; inline diff --git a/extra/http/server/server.factor b/extra/http/server/server.factor index f6dd6c57bb..70c1e9a1f5 100755 --- a/extra/http/server/server.factor +++ b/extra/http/server/server.factor @@ -260,15 +260,13 @@ SYMBOL: exit-continuation bi ] recover ; -: default-timeout 1 minutes stdio get set-timeout ; - : ?refresh-all ( -- ) development-mode get-global [ global [ refresh-all ] bind ] when ; : handle-client ( -- ) [ - default-timeout + 1 minutes timeouts ?refresh-all read-request do-request diff --git a/extra/http/server/static/static.factor b/extra/http/server/static/static.factor index 2ecc347d76..b9a8e9d46e 100755 --- a/extra/http/server/static/static.factor +++ b/extra/http/server/static/static.factor @@ -36,7 +36,7 @@ TUPLE: file-responder root hook special allow-listings ; [ size>> "content-length" set-header ] [ modified>> "last-modified" set-header ] bi ] - [ '[ , binary stdio get stream-copy ] >>body ] bi + [ '[ , binary output-stream get stream-copy ] >>body ] bi ] ; : serve-static ( filename mime-type -- response ) diff --git a/extra/http/server/templating/chloe/chloe.factor b/extra/http/server/templating/chloe/chloe.factor index a8a456cdb2..c3d93f5909 100644 --- a/extra/http/server/templating/chloe/chloe.factor +++ b/extra/http/server/templating/chloe/chloe.factor @@ -1,10 +1,14 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel sequences combinators kernel namespaces classes.tuple assocs splitting words arrays memoize -io io.files io.encodings.utf8 html.elements unicode.case -tuple-syntax xml xml.data xml.writer xml.utilities +io io.files io.encodings.utf8 io.streams.string +unicode.case tuple-syntax html html.elements +multiline xml xml.data xml.writer xml.utilities http.server http.server.auth http.server.flows +http.server.actions http.server.components http.server.sessions http.server.templating @@ -21,7 +25,10 @@ DEFER: process-template : chloe-ns "http://factorcode.org/chloe/1.0" ; inline -: filter-chloe-attrs ( assoc -- assoc' ) +: chloe-attrs-only ( assoc -- assoc' ) + [ drop name-url chloe-ns = ] assoc-filter ; + +: non-chloe-attrs-only ( assoc -- assoc' ) [ drop name-url chloe-ns = not ] assoc-filter ; : chloe-tag? ( tag -- ? ) @@ -45,6 +52,12 @@ MEMO: chloe-name ( string -- name ) : optional-attr ( tag name -- value ) chloe-name swap at ; +: children>string ( tag -- string ) + [ [ process-template ] each ] with-string-writer ; + +: title-tag ( tag -- ) + children>string set-title ; + : write-title-tag ( tag -- ) drop "head" tags get member? "title" tags get member? not and @@ -131,16 +144,20 @@ MEMO: chloe-name ( string -- name ) : form-start-tag ( tag -- ) [ -
- hidden-form-field + [ + + ] [ + hidden-form-field + "for" optional-attr [ component render-edit ] when* + ] bi ] with-scope ; : form-tag ( tag -- ) @@ -149,6 +166,26 @@ MEMO: chloe-name ( string -- name ) [ drop ] tri ; +DEFER: process-chloe-tag + +STRING: button-tag-markup + + + +; + +: add-tag-attrs ( attrs tag -- ) + tag-attrs swap update ; + +: button-tag ( tag -- ) + button-tag-markup string>xml delegate + { + [ >r tag-attrs chloe-attrs-only r> add-tag-attrs ] + [ >r tag-attrs non-chloe-attrs-only r> "button" tag-named add-tag-attrs ] + [ >r children>string 1array r> "button" tag-named set-tag-children ] + [ nip ] + } 2cleave process-chloe-tag ; + : attr>word ( value -- word/f ) dup ":" split1 swap lookup [ ] [ "No such word: " swap append throw ] ?if ; @@ -159,23 +196,25 @@ MEMO: chloe-name ( string -- name ) ] unless ; : if-satisfied? ( tag -- ? ) + t swap { - [ "code" optional-attr [ attr>word execute ] [ t ] if* ] - [ "var" optional-attr [ attr>var get ] [ t ] if* ] - [ "svar" optional-attr [ attr>var sget ] [ t ] if* ] - [ "uvar" optional-attr [ attr>var uget ] [ t ] if* ] - } cleave 4array [ ] all? ; + [ "code" optional-attr [ attr>word execute and ] when* ] + [ "var" optional-attr [ attr>var get and ] when* ] + [ "svar" optional-attr [ attr>var sget and ] when* ] + [ "uvar" optional-attr [ attr>var uget and ] when* ] + [ "value" optional-attr [ value and ] when* ] + } cleave ; : if-tag ( tag -- ) dup if-satisfied? [ process-tag-children ] [ drop ] if ; -: error-tag ( tag -- ) +: error-message-tag ( tag -- ) children>string render-error ; : process-chloe-tag ( tag -- ) dup name-tag { { "chloe" [ [ process-template ] each ] } - { "title" [ children>string set-title ] } + { "title" [ title-tag ] } { "write-title" [ write-title-tag ] } { "style" [ style-tag ] } { "write-style" [ write-style-tag ] } @@ -186,7 +225,9 @@ MEMO: chloe-name ( string -- name ) { "summary" [ summary-tag ] } { "a" [ a-tag ] } { "form" [ form-tag ] } - { "error" [ error-tag ] } + { "button" [ button-tag ] } + { "error-message" [ error-message-tag ] } + { "validation-message" [ drop render-validation-message ] } { "if" [ if-tag ] } { "comment" [ drop ] } { "call-next-template" [ drop call-next-template ] } diff --git a/extra/icfp/2006/2006.factor b/extra/icfp/2006/2006.factor index e88301c7f8..ca6f9d5905 100755 --- a/extra/icfp/2006/2006.factor +++ b/extra/icfp/2006/2006.factor @@ -148,4 +148,4 @@ SYMBOL: open-arrays init f exec-loop ; : run-sand ( -- ) - "extra/icfp/2006/sandmark.umz" resource-path run-prog ; + "resource:extra/icfp/2006/sandmark.umz" run-prog ; diff --git a/extra/interval-maps/authors.txt b/extra/interval-maps/authors.txt new file mode 100755 index 0000000000..504363d316 --- /dev/null +++ b/extra/interval-maps/authors.txt @@ -0,0 +1 @@ +Daniel Ehrenberg diff --git a/extra/interval-maps/interval-maps-docs.factor b/extra/interval-maps/interval-maps-docs.factor new file mode 100755 index 0000000000..1a862fbe2d --- /dev/null +++ b/extra/interval-maps/interval-maps-docs.factor @@ -0,0 +1,29 @@ +USING: help.markup help.syntax ; +IN: interval-maps + +HELP: interval-at* +{ $values { "key" "an object" } { "map" "an interval map" } { "value" "the value for the key, or f" } { "?" "whether the key is present" } } +{ $description "Looks up a key in an interval map, returning the corresponding value if the item is in an interval in the map, and a boolean flag. The operation takes O(log n) time." } ; + +HELP: interval-at +{ $values { "key" "an object" } { "map" "an interval map" } { "value" "the value for the key, or f" } } +{ $description "Looks up a key in an interval map, returning the value of the corresponding interval, or f if the interval is not present in the map." } ; + +HELP: interval-key? +{ $values { "key" "an object" } { "map" "an interval map" } { "?" "a boolean" } } +{ $description "Tests whether an object is in an interval in the interval map, returning t if the object is present." } ; + +HELP: +{ $values { "specification" "an assoc" } { "map" "an interval map" } } +{ $description "From a specification, produce an interval tree. The specification is an assoc where the keys are intervals, or pairs of numbers to represent intervals, or individual numbers to represent singleton intervals. The values are the values int he interval map. Construction time is O(n log n)." } ; + +ARTICLE: "interval-maps" "Interval maps" +"Interval maps are a mechanism, similar to assocs, where a set of closed intervals of keys are associated with values. As such, interval maps do not conform to the assoc protocol, because intervals of floats, for example, can be used, and it is impossible to get a list of keys in between." +"The following operations are used to query interval maps:" +{ $subsection interval-at* } +{ $subsection interval-at } +{ $subsection interval-key? } +"Use the following to construct interval maps" +{ $subsection } ; + +ABOUT: "interval-maps" diff --git a/extra/interval-maps/interval-maps-tests.factor b/extra/interval-maps/interval-maps-tests.factor new file mode 100755 index 0000000000..5a4b508939 --- /dev/null +++ b/extra/interval-maps/interval-maps-tests.factor @@ -0,0 +1,18 @@ +USING: kernel namespaces interval-maps tools.test ; +IN: interval-maps.test + +SYMBOL: test + +[ ] [ { { { 4 8 } 3 } { 1 2 } } test set ] unit-test +[ 3 ] [ 5 test get interval-at ] unit-test +[ 3 ] [ 8 test get interval-at ] unit-test +[ 3 ] [ 4 test get interval-at ] unit-test +[ f ] [ 9 test get interval-at ] unit-test +[ 2 ] [ 1 test get interval-at ] unit-test +[ f ] [ 2 test get interval-at ] unit-test +[ f ] [ 0 test get interval-at ] unit-test + +[ { { { 1 4 } 3 } { { 4 8 } 6 } } ] must-fail + +[ { { { 1 3 } 2 } { { 4 5 } 4 } { { 7 8 } 4 } } ] +[ { { 1 2 } { 2 2 } { 3 2 } { 4 4 } { 5 4 } { 7 4 } { 8 4 } } coalesce ] unit-test diff --git a/extra/interval-maps/interval-maps.factor b/extra/interval-maps/interval-maps.factor new file mode 100755 index 0000000000..7dcb9466cc --- /dev/null +++ b/extra/interval-maps/interval-maps.factor @@ -0,0 +1,56 @@ +USING: kernel sequences arrays math.intervals accessors +math.order sorting math assocs locals namespaces ; +IN: interval-maps + +TUPLE: interval-map array ; + +> from>> first <=> ] binsearch ; + +GENERIC: >interval ( object -- interval ) +M: number >interval [a,a] ; +M: sequence >interval first2 [a,b] ; +M: interval >interval ; + +: all-intervals ( sequence -- intervals ) + [ >r >interval r> ] assoc-map ; + +: ensure-disjoint ( intervals -- intervals ) + dup keys [ interval-intersect not ] monotonic? + [ "Intervals are not disjoint" throw ] unless ; + + +PRIVATE> + +: interval-at* ( key map -- value ? ) + array>> [ find-interval ] 2keep swapd nth + [ nip value>> ] [ interval>> interval-contains? ] 2bi + fixup-value ; + +: interval-at ( key map -- value ) interval-at* drop ; +: interval-key? ( key map -- ? ) interval-at* nip ; + +: ( specification -- map ) + all-intervals { } assoc-like + [ [ first to>> ] compare ] sort ensure-disjoint + [ interval-node boa ] { } assoc>map + interval-map boa ; + +:: coalesce ( alist -- specification ) + ! Only works with integer keys, because they're discrete + ! Makes 2array keys + [ + alist sort-keys unclip first2 dupd roll + [| oldkey oldval key val | ! Underneath is start + oldkey 1+ key = + oldval val = and + [ oldkey 2array oldval 2array , key ] unless + key val + ] assoc-each [ 2array ] bi@ , + ] { } make ; diff --git a/extra/interval-maps/summary.txt b/extra/interval-maps/summary.txt new file mode 100755 index 0000000000..d25263260e --- /dev/null +++ b/extra/interval-maps/summary.txt @@ -0,0 +1 @@ +Interval maps for disjoint closed ranges diff --git a/extra/interval-maps/tags.txt b/extra/interval-maps/tags.txt new file mode 100755 index 0000000000..5e9549f425 --- /dev/null +++ b/extra/interval-maps/tags.txt @@ -0,0 +1 @@ +collections diff --git a/extra/inverse/inverse.factor b/extra/inverse/inverse.factor index 265675f8df..705c2d070b 100755 --- a/extra/inverse/inverse.factor +++ b/extra/inverse/inverse.factor @@ -197,7 +197,7 @@ DEFER: _ \ prefix [ unclip ] define-inverse \ unclip [ prefix ] define-inverse -\ suffix [ dup 1 head* swap peek ] define-inverse +\ suffix [ dup but-last swap peek ] define-inverse ! Constructor inverse : deconstruct-pred ( class -- quot ) diff --git a/extra/io/encodings/8-bit/8-bit.factor b/extra/io/encodings/8-bit/8-bit.factor index 3fbb3908e2..88414efd16 100755 --- a/extra/io/encodings/8-bit/8-bit.factor +++ b/extra/io/encodings/8-bit/8-bit.factor @@ -30,9 +30,8 @@ IN: io.encodings.8-bit } ; : encoding-file ( file-name -- stream ) - "extra/io/encodings/8-bit/" ".TXT" - swapd 3append resource-path - ascii ; + "resource:extra/io/encodings/8-bit/" ".TXT" + swapd 3append ascii ; : tail-if ( seq n -- newseq ) 2dup swap length <= [ tail ] [ drop ] if ; diff --git a/extra/io/launcher/launcher-docs.factor b/extra/io/launcher/launcher-docs.factor index dadb627fc0..45bbec20e3 100755 --- a/extra/io/launcher/launcher-docs.factor +++ b/extra/io/launcher/launcher-docs.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: help.markup help.syntax quotations kernel io math -calendar ; +USING: help.markup help.syntax quotations kernel io io.files +math calendar ; IN: io.launcher ARTICLE: "io.launcher.command" "Specifying a command" @@ -26,10 +26,10 @@ $nl "To specify redirection, set the " { $snippet "stdin" } ", " { $snippet "stdout" } " and " { $snippet "stderr" } " slots of a " { $link process } " to one of the following values:" { $list { { $link f } " - default value; the stream is either inherited from the current process, or is a " { $link } " pipe" } - { { $link +inherit+ } " - the stream is inherited from the current process, overriding a " { $link } " pipe" } { { $link +closed+ } " - the stream is closed; reads will return end of file and writes will fails" } { { $link +stdout+ } " - a special value for the " { $snippet "stderr" } " slot only, indicating that the standard output and standard error streams should be merged" } { "a path name - the stream is sent to the given file, which must exist for input and is created automatically on output" } + { "an " { $link appender } " wrapping a path name - output is sent to the end given file, as with " { $link } } { "a file stream or a socket - the stream is connected to the given Factor stream, which cannot be used again from within Factor and must be closed after the process has been started" } } ; @@ -47,12 +47,16 @@ ARTICLE: "io.launcher.priority" "Setting process priority" HELP: +closed+ { $description "Possible value for the " { $snippet "stdin" } ", " { $snippet "stdout" } ", and " { $snippet "stderr" } " slots of a " { $link process } "." } ; -HELP: +inherit+ -{ $description "Possible value for the " { $snippet "stdin" } ", " { $snippet "stdout" } ", and " { $snippet "stderr" } " slots of a " { $link process } "." } ; - HELP: +stdout+ { $description "Possible value for the " { $snippet "stderr" } " slot of a " { $link process } "." } ; +HELP: appender +{ $class-description "An object representing a file to append to. Instances are created with " { $link } "." } ; + +HELP: +{ $values { "path" "a pathname string" } { "appender" appender } } +{ $description "Creates an object which may be stored in the " { $snippet "stdout" } " or " { $snippet "stderr" } " slot of a " { $link process } " instance." } ; + HELP: +prepend-environment+ { $description "Possible value of " { $snippet "environment-mode" } " slot of a " { $link process } "." $nl @@ -138,13 +142,6 @@ HELP: { "stream" "a bidirectional stream" } } { $description "Launches a process and redirects its input and output via a pair of pipes which may be read and written as a stream of the given encoding." } ; -HELP: with-process-stream -{ $values - { "desc" "a launch descriptor" } - { "quot" quotation } - { "status" "an exit code" } } -{ $description "Calls " { $snippet "quot" } " in a dynamic scope where " { $link stdio } " is rebound to a process stream. After the quotation returns, waits for the process to end and outputs the exit code." } ; - HELP: wait-for-process { $values { "process" process } { "status" integer } } { $description "If the process is still running, waits for it to exit, otherwise outputs the exit code immediately. Can be called multiple times on the same process." } ; @@ -175,8 +172,9 @@ ARTICLE: "io.launcher.launch" "Launching processes" { $subsection try-process } { $subsection run-detached } "Redirecting standard input and output to a pipe:" -{ $subsection } -{ $subsection with-process-stream } ; +{ $subsection } +{ $subsection } +{ $subsection } ; ARTICLE: "io.launcher.examples" "Launcher examples" "Starting a command and waiting for it to finish:" @@ -212,7 +210,7 @@ ARTICLE: "io.launcher.examples" "Launcher examples" " " " swap >>stderr" " \"report\" >>command" - " ascii lines sort reverse [ print ] each" + " ascii lines sort reverse [ print ] each" "] with-disposal" } ; diff --git a/extra/io/launcher/launcher-tests.factor b/extra/io/launcher/launcher-tests.factor index bacb8eb5a9..003f382020 100755 --- a/extra/io/launcher/launcher-tests.factor +++ b/extra/io/launcher/launcher-tests.factor @@ -2,3 +2,5 @@ IN: io.launcher.tests USING: tools.test io.launcher ; \ must-infer +\ must-infer +\ must-infer diff --git a/extra/io/launcher/launcher.factor b/extra/io/launcher/launcher.factor index 6ee8660528..e9fbdaea62 100755 --- a/extra/io/launcher/launcher.factor +++ b/extra/io/launcher/launcher.factor @@ -1,9 +1,10 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io io.backend io.timeouts system kernel namespaces -strings hashtables sequences assocs combinators vocabs.loader -init threads continuations math io.encodings io.streams.duplex -io.nonblocking accessors concurrency.flags ; +USING: system kernel namespaces strings hashtables sequences +assocs combinators vocabs.loader init threads continuations +math accessors concurrency.flags destructors +io io.backend io.timeouts io.pipes io.pipes.private io.encodings +io.streams.duplex io.nonblocking ; IN: io.launcher TUPLE: process < identity-tuple @@ -26,9 +27,12 @@ handle status killed ; SYMBOL: +closed+ -SYMBOL: +inherit+ SYMBOL: +stdout+ +TUPLE: appender path ; + +: ( path -- appender ) appender boa ; + SYMBOL: +prepend-environment+ SYMBOL: +replace-environment+ SYMBOL: +append-environment+ @@ -145,20 +149,63 @@ M: process set-timeout set-process-timeout ; M: process timed-out kill-process ; -HOOK: (process-stream) io-backend ( process -- handle in out ) +M: object run-pipeline-element + [ >process swap >>stdout swap >>stdin run-detached ] + [ drop [ [ close-handle ] when* ] bi@ ] + 3bi + wait-for-process ; -: ( desc encoding -- stream process ) - >r >process dup dup (process-stream) - r> -roll - process-started ; +: ( process encoding -- process stream ) + [ + >r (pipe) { + [ add-error-destructor ] + [ + swap >process + [ swap out>> or ] change-stdout + run-detached + ] + [ out>> close-handle ] + [ in>> ] + } cleave r> + ] with-destructors ; + +: ( desc encoding -- stream ) + nip ; inline + +: ( process encoding -- process stream ) + [ + >r (pipe) { + [ add-error-destructor ] + [ + swap >process + [ swap in>> or ] change-stdout + run-detached + ] + [ in>> close-handle ] + [ out>> ] + } cleave r> + ] with-destructors ; + +: ( desc encoding -- stream ) + nip ; inline + +: ( process encoding -- process stream ) + [ + >r (pipe) (pipe) { + [ [ add-error-destructor ] bi@ ] + [ + rot >process + [ swap out>> or ] change-stdout + [ swap in>> or ] change-stdin + run-detached + ] + [ [ in>> close-handle ] [ out>> close-handle ] bi* ] + [ [ in>> ] [ out>> ] bi* ] + } 2cleave r> + ] with-destructors ; : ( desc encoding -- stream ) - drop ; inline - -: with-process-stream ( desc quot -- status ) - swap >r - [ swap with-stream ] keep - r> wait-for-process ; inline + nip ; inline : notify-exit ( process status -- ) >>status @@ -168,9 +215,9 @@ HOOK: (process-stream) io-backend ( process -- handle in out ) GENERIC: underlying-handle ( stream -- handle ) -M: port underlying-handle port-handle ; +M: port underlying-handle handle>> ; M: duplex-stream underlying-handle - dup duplex-stream-in underlying-handle - swap duplex-stream-out underlying-handle tuck = - [ "Invalid duplex stream" throw ] when ; + [ in>> underlying-handle ] + [ out>> underlying-handle ] bi + [ = [ "Invalid duplex stream" throw ] when ] keep ; diff --git a/extra/io/nonblocking/nonblocking.factor b/extra/io/nonblocking/nonblocking.factor index fc8ade5758..d25d4b7050 100755 --- a/extra/io/nonblocking/nonblocking.factor +++ b/extra/io/nonblocking/nonblocking.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2005, 2008 Slava Pestov, Doug Coleman ! See http://factorcode.org/license.txt for BSD license. USING: math kernel io sequences io.buffers io.timeouts generic -byte-vectors system io.streams.duplex io.encodings math.order -io.backend continuations debugger classes byte-arrays namespaces -splitting dlists assocs io.encodings.binary inspector accessors ; +byte-vectors system io.encodings math.order io.backend +continuations debugger classes byte-arrays namespaces splitting +dlists assocs io.encodings.binary inspector accessors ; IN: io.nonblocking SYMBOL: default-buffer-size diff --git a/extra/io/pipes/pipes-docs.factor b/extra/io/pipes/pipes-docs.factor new file mode 100644 index 0000000000..d51ae94bc7 --- /dev/null +++ b/extra/io/pipes/pipes-docs.factor @@ -0,0 +1,47 @@ +USING: help.markup help.syntax continuations io ; +IN: io.pipes + +HELP: pipe +{ $class-description "A low-level pipe. Instances are created by calling " { $link (pipe) } " and closed by calling " { $link dispose } "." } ; + +HELP: (pipe) +{ $values { "pipe" pipe } } +{ $description "Opens a new pipe. This is a low-level word; the " { $link } " and " { $link run-pipeline } " words can be used in most cases instead." } ; + +HELP: +{ $values { "encoding" "an encoding specifier" } { "stream" "a bidirectional stream" } } +{ $description "Opens a new pipe and wraps it in a stream. Data written from the stream can be read back from the same stream instance." } +{ $notes "Pipe streams must be disposed by calling " { $link dispose } " or " { $link with-disposal } " to avoid resource leaks." } ; + +HELP: run-pipeline +{ $values { "seq" "a sequence of pipeline components" } { "results" "a sequence of pipeline results" } } +{ $description + "Creates a pipe between each pipeline component, with the output of each component becoming the input of the next." + $nl + "The first component reads input from " { $link input-stream } " and the last component writes output to " { $link output-stream } "." + $nl + "Each component runs in its own thread, and the word returns when all components finish executing. Each component outputs a result value." + $nl + "Pipeline components must be one of the following:" + { $list + { "A quotation. The quotation is called with both " { $link input-stream } " and " { $link output-stream } " rebound, except for the first and last pipeline components, and it must output a single value." } + { "A process launch descriptor. See " { $link "io.launcher.descriptors" } "." } + } +} +{ $examples + "Print the lines of a log file which contain the string ``error'', sort them and filter out duplicates, using Unix shell commands only:" + { $code "{ \"cat log.txt\" \"grep error\" \"sort\" \"uniq\" } run-pipeline" } +} ; + +ARTICLE: "io.pipes" "Pipes" +"A " { $emphasis "pipe" } " is a unidirectional channel for transfer of bytes. Data written to one end of the pipe can be read from the other. Pipes can be used to pass data between processes; they can also be used within a single process to implement communication between coroutines." +$nl +"Low-level pipes:" +{ $subsection pipe } +{ $subsection (pipe) } +"High-level pipe streams:" +{ $subsection } +"Pipelines of coroutines and processes:" +{ $subsection run-pipeline } ; + +ABOUT: "io.pipes" diff --git a/extra/io/pipes/pipes-tests.factor b/extra/io/pipes/pipes-tests.factor new file mode 100755 index 0000000000..c1b37f6efc --- /dev/null +++ b/extra/io/pipes/pipes-tests.factor @@ -0,0 +1,26 @@ +USING: io io.pipes io.streams.string io.encodings.utf8 +io.streams.duplex io.encodings namespaces continuations +tools.test kernel ; +IN: io.pipes.tests + +[ "Hello" ] [ + utf8 [ + "Hello" print flush + readln + ] with-stream +] unit-test + +[ { } ] [ { } run-pipeline ] unit-test +[ { f } ] [ { [ f ] } run-pipeline ] unit-test +[ { "Hello" } ] [ + "Hello" [ + { [ input-stream [ utf8 ] change readln ] } run-pipeline + ] with-string-reader +] unit-test + +[ { f "Hello" } ] [ + { + [ output-stream [ utf8 ] change "Hello" print flush f ] + [ input-stream [ utf8 ] change readln ] + } run-pipeline +] unit-test diff --git a/extra/io/pipes/pipes.factor b/extra/io/pipes/pipes.factor new file mode 100644 index 0000000000..72d27372f3 --- /dev/null +++ b/extra/io/pipes/pipes.factor @@ -0,0 +1,53 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: io.encodings io.backend io.nonblocking io.streams.duplex +io splitting sequences sequences.lib namespaces kernel +destructors math concurrency.combinators accessors +arrays continuations quotations ; +IN: io.pipes + +TUPLE: pipe in out ; + +M: pipe dispose ( pipe -- ) + [ in>> close-handle ] [ out>> close-handle ] bi ; + +HOOK: (pipe) io-backend ( -- pipe ) + +: ( encoding -- stream ) + [ + >r (pipe) + [ add-error-destructor ] + [ in>> ] + [ out>> ] + tri + r> + ] with-destructors ; + + dup add-always-destructor ] [ input-stream get ] if* ; +: ?writer [ dup add-always-destructor ] [ output-stream get ] if* ; + +GENERIC: run-pipeline-element ( input-fd output-fd obj -- quot ) + +M: callable run-pipeline-element + [ + >r [ ?reader ] [ ?writer ] bi* + r> with-streams* + ] with-destructors ; + +: ( n -- pipes ) + [ + [ (pipe) dup add-error-destructor ] replicate + T{ pipe } [ prefix ] [ suffix ] bi + 2 + ] with-destructors ; + +PRIVATE> + +: run-pipeline ( seq -- results ) + [ length dup zero? [ drop { } ] [ 1- ] if ] keep + [ + >r [ first in>> ] [ second out>> ] bi + r> run-pipeline-element + ] 2parallel-map ; diff --git a/extra/io/server/server-docs.factor b/extra/io/server/server-docs.factor index 7eda48f747..50f38cb146 100755 --- a/extra/io/server/server-docs.factor +++ b/extra/io/server/server-docs.factor @@ -3,8 +3,8 @@ IN: io.server HELP: with-server { $values { "seq" "a sequence of address specifiers" } { "service" "a string or " { $link f } } { "encoding" "an encoding to use for client connections" } { "quot" "a quotation" } } -{ $description "Starts a TCP/IP server. The quotation is called in a new thread for each client connection, with the client connection being the " { $link stdio } " stream. Client connections are logged to the " { $link stdio } " stream at the time the server was started." } ; +{ $description "Starts a TCP/IP server. The quotation is called in a new thread for each client connection, with the client connection being both the " { $link input-stream } " and " { $link output-stream } "." } ; HELP: with-datagrams { $values { "seq" "a sequence of address specifiers" } { "service" "a string or " { $link f } } { "quot" "a quotation" } } -{ $description "Starts a UDP/IP server. The quotation is called for each datagram packet received. Datagram packets are logged to the " { $link stdio } " stream at the time the server was started." } ; +{ $description "Starts a UDP/IP server. The quotation is called for each datagram packet received." } ; diff --git a/extra/io/server/server.factor b/extra/io/server/server.factor index 45e3b1de66..1d626a9e15 100755 --- a/extra/io/server/server.factor +++ b/extra/io/server/server.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2003, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io io.sockets io.files logging continuations kernel -math math.parser namespaces parser sequences strings -prettyprint debugger quotations calendar +USING: io io.sockets io.files io.streams.duplex logging +continuations kernel math math.parser namespaces parser +sequences strings prettyprint debugger quotations calendar threads concurrency.combinators assocs ; IN: io.server diff --git a/extra/io/sockets/sockets-docs.factor b/extra/io/sockets/sockets-docs.factor index ad78b4631c..ee3cb3aa7b 100755 --- a/extra/io/sockets/sockets-docs.factor +++ b/extra/io/sockets/sockets-docs.factor @@ -14,6 +14,7 @@ ARTICLE: "network-addressing" "Address specifiers" ARTICLE: "network-connection" "Connection-oriented networking" "Network connections can be established with this word:" { $subsection } +{ $subsection with-client } "Connection-oriented network servers are implemented by first opening a server socket, then waiting for connections:" { $subsection } { $subsection accept } diff --git a/extra/io/sockets/sockets.factor b/extra/io/sockets/sockets.factor index 859dcb4cdc..f835f0beb2 100755 --- a/extra/io/sockets/sockets.factor +++ b/extra/io/sockets/sockets.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2007, 2008 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. USING: generic kernel io.backend namespaces continuations -sequences arrays io.encodings io.nonblocking accessors ; +sequences arrays io.encodings io.nonblocking io.streams.duplex +accessors ; IN: io.sockets TUPLE: local path ; @@ -30,6 +31,9 @@ M: object (client) ((client)) ; : ( addrspec encoding -- stream ) >r (client) r> ; +: with-client ( addrspec encoding quot -- ) + >r r> with-stream ; inline + HOOK: (server) io-backend ( addrspec -- handle ) : ( addrspec encoding -- server ) diff --git a/extra/levenshtein/authors.txt b/extra/io/streams/duplex/authors.txt similarity index 100% rename from extra/levenshtein/authors.txt rename to extra/io/streams/duplex/authors.txt diff --git a/extra/io/streams/duplex/duplex-docs.factor b/extra/io/streams/duplex/duplex-docs.factor new file mode 100755 index 0000000000..15d401ad68 --- /dev/null +++ b/extra/io/streams/duplex/duplex-docs.factor @@ -0,0 +1,39 @@ +USING: help.markup help.syntax io continuations quotations ; +IN: io.streams.duplex + +ARTICLE: "io.streams.duplex" "Duplex streams" +"Duplex streams combine an input stream and an output stream into a bidirectional stream." +{ $subsection duplex-stream } +{ $subsection } +"A pair of combinators for rebinding both default streams at once:" +{ $subsection with-stream } +{ $subsection with-stream* } ; + +ABOUT: "io.streams.duplex" + +HELP: duplex-stream +{ $class-description "A bidirectional stream wrapping an input and output stream." } ; + +HELP: +{ $values { "in" "an input stream" } { "out" "an output stream" } { "stream" " a duplex stream" } } +{ $description "Creates a duplex stream. Writing to a duplex stream will write to " { $snippet "out" } ", and reading from a duplex stream will read from " { $snippet "in" } ". Closing a duplex stream closes both the input and output streams." } ; + +HELP: stream-closed-twice +{ $error-description "This error is thrown when performing an I/O operation on a " { $link duplex-stream } " which has been closed with " { $link dispose } "." } ; + +HELP: with-stream +{ $values { "stream" duplex-stream } { "quot" quotation } } +{ $description "Calls the quotation in a new dynamic scope, with both " { $link input-stream } " and " { $link output-stream } " rebound to " { $snippet "stream" } ". The stream is closed if the quotation returns or throws an error." } ; + +HELP: with-stream* +{ $values { "stream" duplex-stream } { "quot" quotation } } +{ $description "Calls the quotation in a new dynamic scope, with both " { $link input-stream } " and " { $link output-stream } " rebound to " { $snippet "stream" } "." } +{ $notes "This word does not close the stream. Compare with " { $link with-stream } "." } ; + +HELP: +{ $values { "stream-in" "an input stream" } + { "stream-out" "an output stream" } + { "encoding" "an encoding descriptor" } + { "duplex" "an encoded duplex stream" } } +{ $description "Wraps the given streams in an encoder or decoder stream, and puts them together in a duplex stream for input and output. If either input stream is already encoded, that encoding is stripped off before it is reencoded. The encoding descriptor must conform to the " { $link "encodings-protocol" } "." } +$low-level-note ; diff --git a/core/io/streams/duplex/duplex-tests.factor b/extra/io/streams/duplex/duplex-tests.factor similarity index 100% rename from core/io/streams/duplex/duplex-tests.factor rename to extra/io/streams/duplex/duplex-tests.factor diff --git a/core/io/streams/duplex/duplex.factor b/extra/io/streams/duplex/duplex.factor similarity index 51% rename from core/io/streams/duplex/duplex.factor rename to extra/io/streams/duplex/duplex.factor index 40f0cb6e73..cb96d8017a 100755 --- a/core/io/streams/duplex/duplex.factor +++ b/extra/io/streams/duplex/duplex.factor @@ -1,6 +1,8 @@ ! Copyright (C) 2005, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel continuations io accessors ; +USING: kernel continuations io io.encodings io.encodings.private +io.timeouts debugger inspector listener accessors delegate +delegate.protocols ; IN: io.streams.duplex ! We ensure that the stream can only be closed once, to preserve @@ -13,6 +15,9 @@ TUPLE: duplex-stream in out closed ; ERROR: stream-closed-twice ; +M: stream-closed-twice summary + drop "Attempt to perform I/O on closed stream" ; + -M: duplex-stream stream-flush - out stream-flush ; +CONSULT: input-stream-protocol duplex-stream in ; -M: duplex-stream stream-readln - in stream-readln ; +CONSULT: output-stream-protocol duplex-stream out ; -M: duplex-stream stream-read1 - in stream-read1 ; - -M: duplex-stream stream-read-until - in stream-read-until ; - -M: duplex-stream stream-read-partial - in stream-read-partial ; - -M: duplex-stream stream-read - in stream-read ; - -M: duplex-stream stream-write1 - out stream-write1 ; - -M: duplex-stream stream-write - out stream-write ; - -M: duplex-stream stream-nl - out stream-nl ; - -M: duplex-stream stream-format - out stream-format ; - -M: duplex-stream make-span-stream - out make-span-stream ; - -M: duplex-stream make-block-stream - out make-block-stream ; - -M: duplex-stream make-cell-stream - out make-cell-stream ; - -M: duplex-stream stream-write-table - out stream-write-table ; +M: duplex-stream set-timeout + [ in set-timeout ] [ out set-timeout ] 2bi ; M: duplex-stream dispose #! The output stream is closed first, in case both streams @@ -75,3 +45,12 @@ M: duplex-stream dispose [ dup out>> dispose ] [ dup in>> dispose ] [ ] cleanup ] unless drop ; + +: ( stream-in stream-out encoding -- duplex ) + tuck reencode >r redecode r> ; + +: with-stream* ( stream quot -- ) + >r [ in>> ] [ out>> ] bi r> with-streams* ; inline + +: with-stream ( stream quot -- ) + >r [ in>> ] [ out>> ] bi r> with-streams ; inline diff --git a/core/io/streams/duplex/summary.txt b/extra/io/streams/duplex/summary.txt similarity index 100% rename from core/io/streams/duplex/summary.txt rename to extra/io/streams/duplex/summary.txt diff --git a/extra/io/streams/null/null.factor b/extra/io/streams/null/null.factor index eee66239be..384a3806b8 100755 --- a/extra/io/streams/null/null.factor +++ b/extra/io/streams/null/null.factor @@ -1,25 +1,38 @@ ! Copyright (C) 2007 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. IN: io.streams.null -USING: kernel io io.timeouts continuations ; +USING: kernel io io.timeouts io.streams.duplex continuations ; TUPLE: null-stream ; M: null-stream dispose drop ; M: null-stream set-timeout 2drop ; -M: null-stream stream-readln drop f ; -M: null-stream stream-read1 drop f ; -M: null-stream stream-read-until 2drop f f ; -M: null-stream stream-read 2drop f ; -M: null-stream stream-write1 2drop ; -M: null-stream stream-write 2drop ; -M: null-stream stream-nl drop ; -M: null-stream stream-flush drop ; -M: null-stream stream-format 3drop ; -M: null-stream make-span-stream nip ; -M: null-stream make-block-stream nip ; -M: null-stream make-cell-stream nip ; -M: null-stream stream-write-table 3drop ; + +TUPLE: null-reader < null-stream ; + +M: null-reader stream-readln drop f ; +M: null-reader stream-read1 drop f ; +M: null-reader stream-read-until 2drop f f ; +M: null-reader stream-read 2drop f ; + +TUPLE: null-writer < null-stream ; + +M: null-writer stream-write1 2drop ; +M: null-writer stream-write 2drop ; +M: null-writer stream-nl drop ; +M: null-writer stream-flush drop ; +M: null-writer stream-format 3drop ; +M: null-writer make-span-stream nip ; +M: null-writer make-block-stream nip ; +M: null-writer make-cell-stream nip ; +M: null-writer stream-write-table 3drop ; + +: with-null-reader ( quot -- ) + T{ null-reader } swap with-input-stream* ; inline + +: with-null-writer ( quot -- ) + T{ null-writer } swap with-output-stream* ; inline : with-null-stream ( quot -- ) - T{ null-stream } swap with-stream* ; inline + T{ duplex-stream f T{ null-reader } T{ null-writer } } + swap with-stream* ; inline diff --git a/extra/io/timeouts/timeouts.factor b/extra/io/timeouts/timeouts.factor index f1031e98e2..f9ffd5e98f 100755 --- a/extra/io/timeouts/timeouts.factor +++ b/extra/io/timeouts/timeouts.factor @@ -1,20 +1,16 @@ ! Copyright (C) 2008 Slava Pestov, Doug Coleman ! See http://factorcode.org/license.txt for BSD license. -USING: kernel calendar alarms io.streams.duplex io.encodings ; +USING: kernel calendar alarms io io.encodings accessors +namespaces ; IN: io.timeouts ! Won't need this with new slot accessors GENERIC: timeout ( obj -- dt/f ) GENERIC: set-timeout ( dt/f obj -- ) -M: duplex-stream set-timeout - 2dup - duplex-stream-in set-timeout - duplex-stream-out set-timeout ; +M: decoder set-timeout stream>> set-timeout ; -M: decoder set-timeout decoder-stream set-timeout ; - -M: encoder set-timeout encoder-stream set-timeout ; +M: encoder set-timeout stream>> set-timeout ; GENERIC: timed-out ( obj -- ) @@ -29,3 +25,7 @@ M: object timed-out drop ; ] [ 2drop call ] if ; inline + +: timeouts ( dt -- ) + [ input-stream get set-timeout ] + [ output-stream get set-timeout ] bi ; diff --git a/extra/io/unix/backend/backend.factor b/extra/io/unix/backend/backend.factor index ba4e587d13..08ff526f14 100644 --- a/extra/io/unix/backend/backend.factor +++ b/extra/io/unix/backend/backend.factor @@ -1,10 +1,10 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: alien generic assocs kernel kernel.private math -io.nonblocking sequences strings structs sbufs -threads unix vectors io.buffers io.backend io.encodings -io.streams.duplex math.parser continuations system libc -qualified namespaces io.timeouts io.encodings.utf8 accessors ; +io.nonblocking sequences strings structs sbufs threads unix +vectors io.buffers io.backend io.encodings math.parser +continuations system libc qualified namespaces io.timeouts +io.encodings.utf8 accessors ; QUALIFIED: io IN: io.unix.backend @@ -78,7 +78,8 @@ M: integer init-handle ( fd -- ) #! since on OS X 10.3, this operation fails from init-io #! when running the Factor.app (presumably because fd 0 and #! 1 are closed). - F_SETFL O_NONBLOCK fcntl drop ; + [ F_SETFL O_NONBLOCK fcntl drop ] + [ F_SETFD FD_CLOEXEC fcntl drop ] bi ; M: integer close-handle ( fd -- ) close ; diff --git a/extra/io/unix/launcher/launcher-tests.factor b/extra/io/unix/launcher/launcher-tests.factor index 7e527196be..177c5775dc 100755 --- a/extra/io/unix/launcher/launcher-tests.factor +++ b/extra/io/unix/launcher/launcher-tests.factor @@ -31,16 +31,7 @@ accessors kernel sequences io.encodings.utf8 ; "cat" "launcher-test-1" temp-file 2array - ascii contents -] unit-test - -[ f ] [ - - "cat" - "launcher-test-1" temp-file - 2array >>command - +inherit+ >>stdout - ascii contents + ascii contents ] unit-test [ ] [ @@ -59,7 +50,7 @@ accessors kernel sequences io.encodings.utf8 ; "cat" "launcher-test-1" temp-file 2array - ascii contents + ascii contents ] unit-test [ ] [ @@ -77,14 +68,14 @@ accessors kernel sequences io.encodings.utf8 ; "cat" "launcher-test-1" temp-file 2array - ascii contents + ascii contents ] unit-test [ t ] [ "env" >>command { { "A" "B" } } >>environment - ascii lines + ascii lines "A=B" swap member? ] unit-test @@ -93,7 +84,7 @@ accessors kernel sequences io.encodings.utf8 ; "env" >>command { { "A" "B" } } >>environment +replace-environment+ >>environment-mode - ascii lines + ascii lines ] unit-test [ "hi\n" ] [ @@ -107,3 +98,15 @@ accessors kernel sequences io.encodings.utf8 ; temp-directory "aloha" append-path utf8 file-contents ] unit-test + +[ "append-test" temp-file delete-file ] ignore-errors + +[ "hi\nhi\n" ] [ + 2 [ + + "echo hi" >>command + "append-test" temp-file >>stdout + try-process + ] times + "append-test" temp-file utf8 file-contents +] unit-test diff --git a/extra/io/unix/launcher/launcher.factor b/extra/io/unix/launcher/launcher.factor index 2c1e6261c0..043b2bd73e 100755 --- a/extra/io/unix/launcher/launcher.factor +++ b/extra/io/unix/launcher/launcher.factor @@ -1,10 +1,12 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io io.backend io.launcher io.nonblocking io.unix.backend -io.unix.files io.nonblocking sequences kernel namespaces math -system alien.c-types debugger continuations arrays assocs -combinators unix.process strings threads unix -io.unix.launcher.parser accessors io.files io.files.private ; +USING: kernel namespaces math system sequences debugger +continuations arrays assocs combinators alien.c-types strings +threads accessors +io io.backend io.launcher io.nonblocking io.files +io.files.private io.unix.files io.unix.backend +io.unix.launcher.parser +unix unix.process ; IN: io.unix.launcher ! Search unix first @@ -34,7 +36,8 @@ USE: unix : reset-fd ( fd -- ) #! We drop the error code because on *BSD, fcntl of #! /dev/null fails. - F_SETFL 0 fcntl drop ; + [ F_SETFL 0 fcntl drop ] + [ F_SETFD 0 fcntl drop ] bi ; : redirect-inherit ( obj mode fd -- ) 2nip reset-fd ; @@ -43,19 +46,20 @@ USE: unix >r >r normalize-path r> file-mode open dup io-error r> redirect-fd ; +: redirect-file-append ( obj mode fd -- ) + >r drop path>> normalize-path open-append r> redirect-fd ; + : redirect-closed ( obj mode fd -- ) >r >r drop "/dev/null" r> r> redirect-file ; -: redirect-stream ( obj mode fd -- ) - >r drop underlying-handle dup reset-fd r> redirect-fd ; - : redirect ( obj mode fd -- ) { { [ pick not ] [ redirect-inherit ] } { [ pick string? ] [ redirect-file ] } + { [ pick appender? ] [ redirect-file-append ] } { [ pick +closed+ eq? ] [ redirect-closed ] } - { [ pick +inherit+ eq? ] [ redirect-closed ] } - [ redirect-stream ] + { [ pick integer? ] [ >r drop dup reset-fd r> redirect-fd ] } + [ >r >r underlying-handle r> r> redirect ] } cond ; : ?closed dup +closed+ eq? [ drop "/dev/null" ] when ; @@ -90,27 +94,10 @@ M: unix run-process* ( process -- pid ) M: unix kill-process* ( pid -- ) SIGTERM kill io-error ; -: open-pipe ( -- pair ) - 2 "int" dup pipe zero? - [ 2 c-int-array> ] [ drop f ] if ; - -: setup-stdio-pipe ( stdin stdout -- ) - 2dup first close second close - >r first 0 dup2 drop r> second 1 dup2 drop ; - -M: unix (process-stream) - >r open-pipe open-pipe r> - [ >r setup-stdio-pipe r> spawn-process ] curry - [ -rot 2dup second close first close ] - with-fork - first swap second ; - : find-process ( handle -- process ) processes get swap [ nip swap handle>> = ] curry assoc-find 2drop ; -! Inefficient process wait polling, used on Linux and Solaris. -! On BSD and Mac OS X, we use kqueue() which scales better. M: unix wait-for-processes ( -- ? ) -1 0 tuck WNOHANG waitpid dup 0 <= [ diff --git a/extra/io/unix/macosx/macosx.factor b/extra/io/unix/macosx/macosx.factor index 0a0aec6ab6..8a5d0c490f 100644 --- a/extra/io/unix/macosx/macosx.factor +++ b/extra/io/unix/macosx/macosx.factor @@ -13,9 +13,11 @@ TUPLE: macosx-monitor < monitor handle ; ] curry each ; M:: macosx (monitor) ( path recursive? mailbox -- monitor ) - path mailbox macosx-monitor new-monitor - dup [ enqueue-notifications ] curry - path 1array 0 0 >>handle ; + [let | path [ path normalize-path ] | + path mailbox macosx-monitor new-monitor + dup [ enqueue-notifications ] curry + path 1array 0 0 >>handle + ] ; M: macosx-monitor dispose handle>> dispose ; diff --git a/extra/io/unix/pipes/pipes-tests.factor b/extra/io/unix/pipes/pipes-tests.factor new file mode 100644 index 0000000000..27a490d801 --- /dev/null +++ b/extra/io/unix/pipes/pipes-tests.factor @@ -0,0 +1,17 @@ +USING: tools.test io.pipes io.unix.pipes io.encodings.utf8 +io.encodings io namespaces sequences ; +IN: io.unix.pipes.tests + +[ { 0 0 } ] [ { "ls" "grep x" } run-pipeline ] unit-test + +[ { 0 f 0 } ] [ + { + "ls" + [ + input-stream [ utf8 ] change + output-stream [ utf8 ] change + input-stream get lines reverse [ print ] each f + ] + "grep x" + } run-pipeline +] unit-test diff --git a/extra/io/unix/pipes/pipes.factor b/extra/io/unix/pipes/pipes.factor new file mode 100644 index 0000000000..4fc5acf634 --- /dev/null +++ b/extra/io/unix/pipes/pipes.factor @@ -0,0 +1,12 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: system alien.c-types kernel unix math sequences +qualified io.unix.backend io.nonblocking ; +IN: io.unix.pipes +QUALIFIED: io.pipes + +M: unix io.pipes:(pipe) ( -- pair ) + 2 "int" + dup pipe io-error + 2 c-int-array> first2 + [ [ init-handle ] bi@ ] [ io.pipes:pipe boa ] 2bi ; diff --git a/extra/io/unix/unix-tests.factor b/extra/io/unix/unix-tests.factor index ff315bc529..61a667b70f 100755 --- a/extra/io/unix/unix-tests.factor +++ b/extra/io/unix/unix-tests.factor @@ -1,6 +1,7 @@ USING: io.files io.sockets io kernel threads namespaces tools.test continuations strings byte-arrays -sequences prettyprint system io.encodings.binary io.encodings.ascii ; +sequences prettyprint system io.encodings.binary io.encodings.ascii +io.streams.duplex ; IN: io.unix.tests ! Unix domain stream sockets @@ -24,12 +25,11 @@ yield [ { "Hello world" "FOO" } ] [ [ - socket-server ascii - [ + socket-server ascii [ readln , "XYZ" print flush readln , - ] with-stream + ] with-client ] { } make ] unit-test @@ -125,16 +125,16 @@ datagram-client delete-file ! Invalid parameter tests [ - image binary [ stdio get accept ] with-file-reader + image binary [ input-stream get accept ] with-file-reader ] must-fail [ - image binary [ stdio get receive ] with-file-reader + image binary [ input-stream get receive ] with-file-reader ] must-fail [ image binary [ B{ 1 2 } datagram-server - stdio get send + input-stream get send ] with-file-reader ] must-fail diff --git a/extra/io/unix/unix.factor b/extra/io/unix/unix.factor index 1e5638fb4a..e8e7135e1a 100755 --- a/extra/io/unix/unix.factor +++ b/extra/io/unix/unix.factor @@ -1,5 +1,6 @@ -USING: io.unix.backend io.unix.files io.unix.sockets io.timeouts -io.unix.launcher io.unix.mmap io.backend combinators namespaces -system vocabs.loader sequences words init ; +USING: io.unix.backend io.unix.files io.unix.sockets +io.unix.launcher io.unix.mmap io.unix.pipes io.timeouts +io.backend combinators namespaces system vocabs.loader +sequences words init ; "io.unix." os word-name append require diff --git a/extra/io/windows/launcher/launcher.factor b/extra/io/windows/launcher/launcher.factor index 670ea18f5e..a5d7338cd6 100755 --- a/extra/io/windows/launcher/launcher.factor +++ b/extra/io/windows/launcher/launcher.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types arrays continuations io io.windows io.windows.nt.pipes libc io.nonblocking -io.streams.duplex windows.types math windows.kernel32 +windows.types math windows.kernel32 namespaces io.launcher kernel sequences windows.errors splitting system threads init strings combinators io.backend accessors concurrency.flags io.files assocs diff --git a/extra/io/windows/nt/files/files.factor b/extra/io/windows/nt/files/files.factor index c9f17147d3..8839410d91 100755 --- a/extra/io/windows/nt/files/files.factor +++ b/extra/io/windows/nt/files/files.factor @@ -52,6 +52,10 @@ M: winnt CreateFile-flags ( DWORD -- DWORD ) M: winnt FileArgs-overlapped ( port -- overlapped ) make-overlapped ; +M: winnt open-append + [ dup file-info size>> ] [ drop 0 ] recover + >r (open-append) r> ; + : update-file-ptr ( n port -- ) port-handle dup win32-file-ptr [ diff --git a/extra/io/windows/nt/launcher/launcher-tests.factor b/extra/io/windows/nt/launcher/launcher-tests.factor index 8b13b9b3b9..254f845c48 100755 --- a/extra/io/windows/nt/launcher/launcher-tests.factor +++ b/extra/io/windows/nt/launcher/launcher-tests.factor @@ -1,7 +1,7 @@ IN: io.windows.launcher.nt.tests USING: io.launcher tools.test calendar accessors namespaces kernel system arrays io io.files io.encodings.ascii -sequences parser assocs hashtables math ; +sequences parser assocs hashtables math continuations ; [ ] [ @@ -41,7 +41,7 @@ sequences parser assocs hashtables math ; ] unit-test [ ] [ - "extra/io/windows/nt/launcher/test" resource-path [ + "resource:extra/io/windows/nt/launcher/test" [ vm "-script" "stderr.factor" 3array >>command "out.txt" temp-file >>stdout @@ -59,7 +59,7 @@ sequences parser assocs hashtables math ; ] unit-test [ ] [ - "extra/io/windows/nt/launcher/test" resource-path [ + "resource:extra/io/windows/nt/launcher/test" [ vm "-script" "stderr.factor" 3array >>command "out.txt" temp-file >>stdout @@ -73,11 +73,11 @@ sequences parser assocs hashtables math ; ] unit-test [ "output" ] [ - "extra/io/windows/nt/launcher/test" resource-path [ + "resource:extra/io/windows/nt/launcher/test" [ vm "-script" "stderr.factor" 3array >>command "err2.txt" temp-file >>stderr - ascii lines first + ascii lines first ] with-directory ] unit-test @@ -86,45 +86,45 @@ sequences parser assocs hashtables math ; ] unit-test [ t ] [ - "extra/io/windows/nt/launcher/test" resource-path [ + "resource:extra/io/windows/nt/launcher/test" [ vm "-script" "env.factor" 3array >>command - ascii contents + ascii contents ] with-directory eval os-envs = ] unit-test [ t ] [ - "extra/io/windows/nt/launcher/test" resource-path [ + "resource:extra/io/windows/nt/launcher/test" [ vm "-script" "env.factor" 3array >>command +replace-environment+ >>environment-mode os-envs >>environment - ascii contents + ascii contents ] with-directory eval os-envs = ] unit-test [ "B" ] [ - "extra/io/windows/nt/launcher/test" resource-path [ + "resource:extra/io/windows/nt/launcher/test" [ vm "-script" "env.factor" 3array >>command { { "A" "B" } } >>environment - ascii contents + ascii contents ] with-directory eval "A" swap at ] unit-test [ f ] [ - "extra/io/windows/nt/launcher/test" resource-path [ + "resource:extra/io/windows/nt/launcher/test" [ vm "-script" "env.factor" 3array >>command { { "HOME" "XXX" } } >>environment +prepend-environment+ >>environment-mode - ascii contents + ascii contents ] with-directory eval "HOME" swap at "XXX" = @@ -140,3 +140,18 @@ sequences parser assocs hashtables math ; [ ] [ "dir.txt" temp-file delete-file ] unit-test ] times + +[ "append-test" temp-file delete-file ] ignore-errors + +[ "Hello appender\r\nHello appender\r\n" ] [ + 2 [ + "resource:extra/io/windows/nt/launcher/test" [ + + vm "-script" "append.factor" 3array >>command + "append-test" temp-file >>stdout + try-process + ] with-directory + ] times + + "append-test" temp-file ascii file-contents +] unit-test diff --git a/extra/io/windows/nt/launcher/launcher.factor b/extra/io/windows/nt/launcher/launcher.factor index f57902608f..39edd931b1 100755 --- a/extra/io/windows/nt/launcher/launcher.factor +++ b/extra/io/windows/nt/launcher/launcher.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types arrays continuations destructors io -io.windows libc io.nonblocking io.streams.duplex windows.types +io.windows libc io.nonblocking io.pipes windows.types math windows.kernel32 windows namespaces io.launcher kernel sequences windows.errors assocs splitting system strings io.windows.launcher io.windows.nt.pipes io.backend io.files @@ -19,15 +19,25 @@ IN: io.windows.nt.launcher DuplicateHandle win32-error=0/f ] keep *void* ; +! /dev/null simulation +: null-input ( -- pipe ) + (pipe) [ in>> handle>> ] [ out>> close-handle ] bi ; + +: null-output ( -- pipe ) + (pipe) [ in>> close-handle ] [ out>> handle>> ] bi ; + +: null-pipe ( mode -- pipe ) + { + { GENERIC_READ [ null-input ] } + { GENERIC_WRITE [ null-output ] } + } case ; + ! The below code is based on the example given in ! http://msdn2.microsoft.com/en-us/library/ms682499.aspx : redirect-default ( default obj access-mode create-mode -- handle ) 3drop ; -: redirect-inherit ( default obj access-mode create-mode -- handle ) - 4drop f ; - : redirect-closed ( default obj access-mode create-mode -- handle ) drop 2nip null-pipe ; @@ -41,25 +51,34 @@ IN: io.windows.nt.launcher f ! template file CreateFile dup invalid-handle? dup close-always ; +: redirect-append ( default path access-mode create-mode -- handle ) + >r >r path>> r> r> + drop OPEN_ALWAYS + redirect-file + dup 0 FILE_END set-file-pointer ; + : set-inherit ( handle ? -- ) >r HANDLE_FLAG_INHERIT r> >BOOLEAN SetHandleInformation win32-error=0/f ; -: redirect-stream ( default stream access-mode create-mode -- handle ) +: redirect-handle ( default handle access-mode create-mode -- handle ) 2drop nip - underlying-handle win32-file-handle - duplicate-handle dup t set-inherit ; + handle>> duplicate-handle dup t set-inherit ; + +: redirect-stream ( default stream access-mode create-mode -- handle ) + >r >r underlying-handle r> r> redirect-handle ; : redirect ( default obj access-mode create-mode -- handle ) { { [ pick not ] [ redirect-default ] } - { [ pick +inherit+ eq? ] [ redirect-inherit ] } { [ pick +closed+ eq? ] [ redirect-closed ] } { [ pick string? ] [ redirect-file ] } + { [ pick appender? ] [ redirect-append ] } + { [ pick win32-file? ] [ redirect-handle ] } [ redirect-stream ] } cond ; : default-stdout ( args -- handle ) - stdout-pipe>> dup [ pipe-out ] when ; + stdout-pipe>> dup [ out>> ] when ; : redirect-stdout ( process args -- handle ) default-stdout @@ -85,7 +104,7 @@ IN: io.windows.nt.launcher ] if ; : default-stdin ( args -- handle ) - stdin-pipe>> dup [ pipe-in ] when ; + stdin-pipe>> dup [ in>> ] when ; : redirect-stdin ( process args -- handle ) default-stdin @@ -95,46 +114,8 @@ IN: io.windows.nt.launcher redirect STD_INPUT_HANDLE GetStdHandle or ; -: add-pipe-dtors ( pipe -- ) - dup - in>> close-later - out>> close-later ; - -: fill-stdout-pipe ( args -- args ) - - dup add-pipe-dtors - dup pipe-in f set-inherit - >>stdout-pipe ; - -: fill-stdin-pipe ( args -- args ) - - dup add-pipe-dtors - dup pipe-out f set-inherit - >>stdin-pipe ; - M: winnt fill-redirection ( process args -- ) [ 2dup redirect-stdout ] keep lpStartupInfo>> set-STARTUPINFO-hStdOutput [ 2dup redirect-stderr ] keep lpStartupInfo>> set-STARTUPINFO-hStdError [ 2dup redirect-stdin ] keep lpStartupInfo>> set-STARTUPINFO-hStdInput 2drop ; - -M: winnt (process-stream) - [ - current-directory get (normalize-path) cd - - dup make-CreateProcess-args - - fill-stdout-pipe - fill-stdin-pipe - - tuck fill-redirection - - dup call-CreateProcess - - dup stdin-pipe>> pipe-in CloseHandle drop - dup stdout-pipe>> pipe-out CloseHandle drop - - dup lpProcessInformation>> - over stdout-pipe>> in>> f - rot stdin-pipe>> out>> f - ] with-destructors ; diff --git a/extra/io/windows/nt/launcher/test/append.factor b/extra/io/windows/nt/launcher/test/append.factor new file mode 100755 index 0000000000..4c1de0c5f9 --- /dev/null +++ b/extra/io/windows/nt/launcher/test/append.factor @@ -0,0 +1,2 @@ +USE: io +"Hello appender" print diff --git a/extra/io/windows/nt/launcher/test/stderr.factor b/extra/io/windows/nt/launcher/test/stderr.factor index 0b97387cf7..f22f50e406 100755 --- a/extra/io/windows/nt/launcher/test/stderr.factor +++ b/extra/io/windows/nt/launcher/test/stderr.factor @@ -2,4 +2,4 @@ USE: io USE: namespaces "output" write flush -"error" stderr get stream-write stderr get stream-flush +"error" error-stream get stream-write error-stream get stream-flush diff --git a/extra/io/windows/nt/monitors/monitors.factor b/extra/io/windows/nt/monitors/monitors.factor index 2397d207b9..37784c673c 100755 --- a/extra/io/windows/nt/monitors/monitors.factor +++ b/extra/io/windows/nt/monitors/monitors.factor @@ -3,9 +3,9 @@ USING: alien alien.c-types libc destructors locals kernel math assocs namespaces continuations sequences hashtables sorting arrays combinators math.bitfields strings system -accessors threads -io.backend io.windows io.windows.nt.backend io.monitors -io.nonblocking io.buffers io.files io.timeouts io +accessors threads splitting +io.backend io.windows io.windows.nt.backend io.windows.nt.files +io.monitors io.nonblocking io.buffers io.files io.timeouts io windows windows.kernel32 windows.types ; IN: io.windows.nt.monitors @@ -79,9 +79,12 @@ TUPLE: win32-monitor < monitor port ; : file-notify-records ( buffer -- seq ) [ (file-notify-records) drop ] { } make ; -: parse-notify-records ( monitor buffer -- ) - file-notify-records - [ parse-notify-record rot queue-change ] with each ; +:: parse-notify-records ( monitor buffer -- ) + buffer file-notify-records [ + parse-notify-record + [ monitor path>> prepend-path normalize-path ] dip + monitor queue-change + ] each ; : fill-queue ( monitor -- ) dup port>> check-closed diff --git a/extra/io/windows/nt/pipes/pipes.factor b/extra/io/windows/nt/pipes/pipes.factor index b164d5872b..aa565b52e8 100755 --- a/extra/io/windows/nt/pipes/pipes.factor +++ b/extra/io/windows/nt/pipes/pipes.factor @@ -1,16 +1,16 @@ ! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types arrays destructors io io.windows libc -windows.types math windows.kernel32 windows namespaces kernel -sequences windows.errors assocs math.parser system random -combinators accessors ; +windows.types math.bitfields windows.kernel32 windows namespaces +kernel sequences windows.errors assocs math.parser system random +combinators accessors io.pipes io.nonblocking ; IN: io.windows.nt.pipes ! This code is based on ! http://twistedmatrix.com/trac/browser/trunk/twisted/internet/iocpreactor/process.py -: create-named-pipe ( name mode -- handle ) - FILE_FLAG_OVERLAPPED bitor +: create-named-pipe ( name -- handle ) + { PIPE_ACCESS_INBOUND FILE_FLAG_OVERLAPPED } flags PIPE_TYPE_BYTE 1 4096 @@ -19,37 +19,20 @@ IN: io.windows.nt.pipes security-attributes-inherit CreateNamedPipe dup win32-error=0/f - dup add-completion ; + dup add-completion + f ; -: open-other-end ( name mode -- handle ) - FILE_SHARE_READ FILE_SHARE_WRITE bitor +: open-other-end ( name -- handle ) + GENERIC_WRITE + { FILE_SHARE_READ FILE_SHARE_WRITE } flags security-attributes-inherit OPEN_EXISTING FILE_FLAG_OVERLAPPED f CreateFile dup win32-error=0/f - dup add-completion ; - -TUPLE: pipe in out ; - -: ( name in-mode out-mode -- pipe ) - [ - >r over >r create-named-pipe dup close-later - r> r> open-other-end dup close-later - pipe boa - ] with-destructors ; - -: close-pipe ( pipe -- ) - dup - in>> CloseHandle drop - out>> CloseHandle drop ; - -: ( name -- pipe ) - PIPE_ACCESS_INBOUND GENERIC_WRITE ; - -: ( name -- pipe ) - PIPE_ACCESS_DUPLEX GENERIC_READ ; + dup add-completion + f ; : unique-pipe-name ( -- string ) [ @@ -61,25 +44,10 @@ TUPLE: pipe in out ; millis # ] "" make ; -: ( -- pipe ) - unique-pipe-name ; - -: ( -- pipe ) - unique-pipe-name ; - -! /dev/null simulation -: null-input ( -- pipe ) - - dup out>> CloseHandle drop - in>> ; - -: null-output ( -- pipe ) - - dup in>> CloseHandle drop - out>> ; - -: null-pipe ( mode -- pipe ) - { - { [ dup GENERIC_READ = ] [ drop null-input ] } - { [ dup GENERIC_WRITE = ] [ drop null-output ] } - } cond ; +M: winnt (pipe) ( -- pipe ) + [ + unique-pipe-name + [ create-named-pipe dup close-later ] + [ open-other-end dup close-later ] + bi pipe boa + ] with-destructors ; diff --git a/extra/io/windows/windows.factor b/extra/io/windows/windows.factor index 772ad9124f..85c448bdbd 100755 --- a/extra/io/windows/windows.factor +++ b/extra/io/windows/windows.factor @@ -2,14 +2,12 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types arrays destructors io io.backend io.buffers io.files io.nonblocking io.sockets io.binary -io.sockets.impl windows.errors strings io.streams.duplex +io.sockets.impl windows.errors strings kernel math namespaces sequences windows windows.kernel32 windows.shell32 windows.types windows.winsock splitting continuations math.bitfields system accessors ; IN: io.windows -M: windows destruct-handle CloseHandle drop ; - M: windows destruct-socket closesocket drop ; TUPLE: win32-file handle ptr ; @@ -43,7 +41,10 @@ M: win32-file init-handle ( handle -- ) drop ; M: win32-file close-handle ( handle -- ) - win32-file-handle CloseHandle drop ; + win32-file-handle close-handle ; + +M: alien close-handle ( handle -- ) + CloseHandle drop ; ! Clean up resources (open handle) if add-completion fails : open-file ( path access-mode create-mode flags -- handle ) @@ -85,15 +86,13 @@ M: win32-file close-handle ( handle -- ) f CreateFileW dup win32-error=0/f GetLastError ERROR_ALREADY_EXISTS = not ; -: set-file-pointer ( handle length -- ) - dupd d>w/w FILE_BEGIN SetFilePointer +: set-file-pointer ( handle length method -- ) + >r dupd d>w/w r> SetFilePointer INVALID_SET_FILE_POINTER = [ CloseHandle "SetFilePointer failed" throw ] when drop ; -: open-append ( path -- handle length ) - [ dup file-info size>> ] [ drop 0 ] recover - >r (open-append) r> 2dup set-file-pointer ; +HOOK: open-append os ( path -- handle length ) TUPLE: FileArgs hFile lpBuffer nNumberOfBytesToRead diff --git a/extra/koszul/koszul.factor b/extra/koszul/koszul.factor index e9de82ebb6..aecae1cf88 100755 --- a/extra/koszul/koszul.factor +++ b/extra/koszul/koszul.factor @@ -184,7 +184,7 @@ DEFER: (d) [ length ] keep [ (graded-ker/im-d) ] curry map ; : graded-betti ( generators -- seq ) - basis graded graded-ker/im-d flip first2 1 head* 0 prefix v- ; + basis graded graded-ker/im-d flip first2 but-last 0 prefix v- ; ! Bi-graded for two-step complexes : (bigraded-ker/im-d) ( u-deg z-deg bigraded-basis -- null/rank ) diff --git a/extra/lcs/authors.txt b/extra/lcs/authors.txt new file mode 100755 index 0000000000..504363d316 --- /dev/null +++ b/extra/lcs/authors.txt @@ -0,0 +1 @@ +Daniel Ehrenberg diff --git a/extra/lcs/lcs-docs.factor b/extra/lcs/lcs-docs.factor new file mode 100755 index 0000000000..49e46c7641 --- /dev/null +++ b/extra/lcs/lcs-docs.factor @@ -0,0 +1,35 @@ +USING: help.syntax help.markup ; +IN: lcs + +HELP: levenshtein +{ $values { "old" "a sequence" } { "new" "a sequence" } { "n" "the Levenshtein distance" } } +{ $description "Calculates the Levenshtein distance between old and new, that is, the minimal number of changes from the old sequence to the new one, in terms of deleting, inserting and replacing characters." } ; + +HELP: lcs +{ $values { "seq1" "a sequence" } { "seq2" "a sequence" } { "lcs" "a longest common subsequence" } } +{ $description "Given two sequences, calculates a longest common subsequence between them. Note two things: this is only one of the many possible LCSs, and the LCS may not be contiguous." } ; + +HELP: diff +{ $values { "old" "a sequence" } { "new" "a sequence" } { "diff" "an edit script" } } +{ $description "Given two sequences, find a minimal edit script from the old to the new. There may be more than one minimal edit script, and this chooses one arbitrarily. This script is in the form of an array of the tuples of the classes " { $link retain } ", " { $link delete } " and " { $link insert } " which have their information stored in the 'item' slot." } ; + +HELP: retain +{ $class-description "Represents an action in an edit script where an item is kept, going from the initial sequence to the final sequence. This has one slot, called item, containing the thing which is retained" } ; + +HELP: delete +{ $class-description "Represents an action in an edit script where an item is deleted, going from the initial sequence to the final sequence. This has one slot, called item, containing the thing which is deleted" } ; + +HELP: insert +{ $class-description "Represents an action in an edit script where an item is added, going from the initial sequence to the final sequence. This has one slot, called item, containing the thing which is inserted" } ; + +ARTICLE: "lcs" "LCS, Diffing and Distance" +"This vocabulary provides words for three apparently unrelated but in fact very similar problems: finding a longest common subsequence between two sequences, getting a minimal edit script (diff) between two sequences, and calculating the Levenshtein distance between two sequences. The implementations of these algorithms are very closely related, and all running times are O(nm), where n and m are the lengths of the input sequences." +{ $subsection lcs } +{ $subsection diff } +{ $subsection levenshtein } +"The " { $link diff } " word returns a sequence of tuples of the following classes. They all hold their contents in the 'item' slot." +{ $subsection insert } +{ $subsection delete } +{ $subsection retain } ; + +ABOUT: "lcs" diff --git a/extra/lcs/lcs-tests.factor b/extra/lcs/lcs-tests.factor new file mode 100755 index 0000000000..3aa10a0687 --- /dev/null +++ b/extra/lcs/lcs-tests.factor @@ -0,0 +1,25 @@ +! Copyright (C) 2006 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: tools.test lcs ; + +[ 3 ] [ "sitting" "kitten" levenshtein ] unit-test +[ 3 ] [ "kitten" "sitting" levenshtein ] unit-test +[ 1 ] [ "freshpak" "freshpack" levenshtein ] unit-test +[ 1 ] [ "freshpack" "freshpak" levenshtein ] unit-test + +[ "hell" ] [ "hello" "hell" lcs ] unit-test +[ "hell" ] [ "hell" "hello" lcs ] unit-test +[ "ell" ] [ "ell" "hell" lcs ] unit-test +[ "ell" ] [ "hell" "ell" lcs ] unit-test +[ "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 } +} ] [ "faxbcd" "abdef" diff ] unit-test diff --git a/extra/lcs/lcs.factor b/extra/lcs/lcs.factor new file mode 100755 index 0000000000..cdebfc4325 --- /dev/null +++ b/extra/lcs/lcs.factor @@ -0,0 +1,97 @@ +USING: sequences kernel math locals math.order math.ranges +accessors combinators.lib arrays namespaces combinators ; +IN: lcs + +r [ 1+ ] bi@ r> min min ; + +: lcs-step ( insert delete change same? -- next ) + 1 -9999 ? + max max ; ! Replace -9999 with -inf when added + +:: loop-step ( i j matrix old new step -- ) + i j 1+ matrix nth nth ! insertion + i 1+ j matrix nth nth ! deletion + i j matrix nth nth ! replace/retain + i old nth j new nth = ! same? + step call + i 1+ j 1+ matrix nth set-nth ; inline + +: lcs-initialize ( |str1| |str2| -- matrix ) + [ drop 0 ] with map ; + +: levenshtein-initialize ( |str1| |str2| -- matrix ) + [ [ + ] curry map ] with map ; + +:: run-lcs ( old new init step -- matrix ) + [let | matrix [ old length 1+ new length 1+ init call ] | + old length [0,b) [| i | + new length [0,b) + [| j | i j matrix old new step loop-step ] + each + ] each matrix ] ; inline +PRIVATE> + +: levenshtein ( old new -- n ) + [ levenshtein-initialize ] [ levenshtein-step ] + run-lcs peek peek ; + +TUPLE: retain item ; +TUPLE: delete item ; +TUPLE: insert item ; + +> 1- ] [ old>> ] bi nth ; + +: new-nth ( state -- elt ) + [ j>> 1- ] [ new>> ] bi nth ; + +: top-beats-side? ( state -- ? ) + [ [ i>> ] [ j>> 1- ] [ table>> ] tri nth nth ] + [ [ i>> 1- ] [ j>> ] [ table>> ] tri nth nth ] bi > ; + +: retained? ( state -- ? ) + { + [ i>> 0 > ] [ j>> 0 > ] + [ [ old-nth ] [ new-nth ] bi = ] + } <-&& ; + +: do-retain ( state -- state ) + dup old-nth retain boa , + [ 1- ] change-i [ 1- ] change-j ; + +: inserted? ( state -- ? ) + [ j>> 0 > ] + [ [ i>> zero? ] [ top-beats-side? ] or? ] and? ; + +: do-insert ( state -- state ) + dup new-nth insert boa , [ 1- ] change-j ; + +: deleted? ( state -- ? ) + [ i>> 0 > ] + [ [ j>> zero? ] [ top-beats-side? not ] or? ] and? ; + +: do-delete ( state -- state ) + dup old-nth delete boa , [ 1- ] change-i ; + +: (trace-diff) ( state -- ) + { + { [ dup retained? ] [ do-retain (trace-diff) ] } + { [ dup inserted? ] [ do-insert (trace-diff) ] } + { [ dup deleted? ] [ do-delete (trace-diff) ] } + [ drop ] ! i=j=0 + } cond ; + +: trace-diff ( old new table -- diff ) + [ ] [ first length 1- ] [ length 1- ] tri trace-state boa + [ (trace-diff) ] { } make reverse ; +PRIVATE> + +: diff ( old new -- diff ) + 2dup [ lcs-initialize ] [ lcs-step ] run-lcs trace-diff ; + +: lcs ( seq1 seq2 -- lcs ) + [ diff [ retain? ] filter ] keep [ item>> ] swap map-as ; diff --git a/extra/lcs/summary.txt b/extra/lcs/summary.txt new file mode 100755 index 0000000000..9e70fd7e63 --- /dev/null +++ b/extra/lcs/summary.txt @@ -0,0 +1 @@ +Levenshtein distance and diff between sequences diff --git a/extra/lcs/tags.txt b/extra/lcs/tags.txt new file mode 100755 index 0000000000..4d914f4c46 --- /dev/null +++ b/extra/lcs/tags.txt @@ -0,0 +1 @@ +algorithms diff --git a/extra/levenshtein/levenshtein-tests.factor b/extra/levenshtein/levenshtein-tests.factor deleted file mode 100644 index 722ccb86ca..0000000000 --- a/extra/levenshtein/levenshtein-tests.factor +++ /dev/null @@ -1,9 +0,0 @@ -! Copyright (C) 2006 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -IN: levenshtein.tests -USING: tools.test levenshtein ; - -[ 3 ] [ "sitting" "kitten" levenshtein ] unit-test -[ 3 ] [ "kitten" "sitting" levenshtein ] unit-test -[ 1 ] [ "freshpak" "freshpack" levenshtein ] unit-test -[ 1 ] [ "freshpack" "freshpak" levenshtein ] unit-test diff --git a/extra/levenshtein/levenshtein.factor b/extra/levenshtein/levenshtein.factor deleted file mode 100644 index 07731bfb84..0000000000 --- a/extra/levenshtein/levenshtein.factor +++ /dev/null @@ -1,47 +0,0 @@ -! Copyright (C) 2006 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: arrays help io kernel math namespaces sequences -math.order ; -IN: levenshtein - -: ( m n -- matrix ) - [ drop 0 ] with map ; inline - -: matrix-> nth nth ; inline -: ->matrix nth set-nth ; inline - -SYMBOL: d - -: ->d ( n i j -- ) d get ->matrix ; inline -: d-> ( i j -- n ) d get matrix-> ; inline - -SYMBOL: costs - -: init-d ( str1 str2 -- ) - [ length 1+ ] bi@ 2dup d set - [ 0 over ->d ] each - [ dup 0 ->d ] each ; inline - -: compute-costs ( str1 str2 -- ) - swap [ - [ = 0 1 ? ] with { } map-as - ] curry { } map-as costs set ; inline - -: levenshtein-step ( i j -- ) - [ 1+ d-> 1+ ] 2keep - [ >r 1+ r> d-> 1+ ] 2keep - [ d-> ] 2keep - [ costs get matrix-> + min min ] 2keep - >r 1+ r> 1+ ->d ; inline - -: levenshtein-result ( -- n ) d get peek peek ; inline - -: levenshtein ( str1 str2 -- n ) - [ - 2dup init-d - 2dup compute-costs - [ length ] bi@ [ - [ levenshtein-step ] curry each - ] with each - levenshtein-result - ] with-scope ; diff --git a/extra/levenshtein/summary.txt b/extra/levenshtein/summary.txt deleted file mode 100644 index 583669a8b0..0000000000 --- a/extra/levenshtein/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Levenshtein edit distance algorithm diff --git a/extra/locals/locals-docs.factor b/extra/locals/locals-docs.factor index 96485825ff..961017f39e 100644 --- a/extra/locals/locals-docs.factor +++ b/extra/locals/locals-docs.factor @@ -2,15 +2,6 @@ USING: help.syntax help.markup kernel macros prettyprint memoize ; IN: locals - - HELP: [| { $syntax "[| bindings... | body... ]" } { $description "A lambda abstraction. When called, reads stack values into the bindings from left to right; the body may then refer to these bindings." } @@ -22,8 +13,7 @@ HELP: [| "3 5 adder call ." "8" } -} -$with-locals-note ; +} ; HELP: [let { $syntax "[let | binding1 [ value1... ]\n binding2 [ value2... ]\n ... |\n body... ]" } @@ -38,8 +28,7 @@ HELP: [let "6 { 36 14 } frobnicate ." "{ 36 2 }" } -} -$with-locals-note ; +} ; HELP: [let* { $syntax "[let* | binding1 [ value1... ]\n binding2 [ value2... ]\n ... |\n body... ]" } @@ -55,8 +44,7 @@ HELP: [let* "1 { 32 48 } frobnicate ." "{ 2 3 }" } -} -$with-locals-note ; +} ; { POSTPONE: [let POSTPONE: [let* } related-words @@ -75,10 +63,6 @@ HELP: [wlet } } ; -HELP: with-locals -{ $values { "form" "a quotation, lambda, let or wlet form" } { "quot" "a quotation" } } -{ $description "Performs closure conversion of a lexically-scoped form. All nested sub-forms are converted. This word must be applied to a " { $link POSTPONE: [| } ", " { $link POSTPONE: [let } " or " { $link POSTPONE: [wlet } " used in an ordinary definition, however forms in " { $link POSTPONE: :: } " and " { $link POSTPONE: MACRO:: } " definitions are automatically closure-converted and there is no need to use this word." } ; - HELP: :: { $syntax ":: word ( bindings... -- outputs... ) body... ;" } { $description "Defines a word with named inputs; it reads stack values into bindings from left to right, then executes the body with those bindings in lexical scope. Any " { $link POSTPONE: [| } ", " { $link POSTPONE: [let } " or " { $link POSTPONE: [wlet } " forms used in the body of the word definition are automatically closure-converted." } @@ -136,8 +120,6 @@ $nl { $subsection POSTPONE: :: } { $subsection POSTPONE: MEMO:: } { $subsection POSTPONE: MACRO:: } -"Explicit closure conversion outside of applicative word definitions:" -{ $subsection with-locals } "Lexical binding forms:" { $subsection POSTPONE: [let } { $subsection POSTPONE: [let* } diff --git a/extra/locals/locals-tests.factor b/extra/locals/locals-tests.factor index bb2fd9893c..5c3d2005a8 100755 --- a/extra/locals/locals-tests.factor +++ b/extra/locals/locals-tests.factor @@ -1,6 +1,6 @@ USING: locals math sequences tools.test hashtables words kernel namespaces arrays strings prettyprint io.streams.string parser -; +accessors ; IN: locals.tests :: foo ( a b -- a a ) a a ; @@ -55,7 +55,6 @@ IN: locals.tests [ 5 ] [ [let | a [ 3 ] | [wlet | func [ a + ] | 2 func ] ] - with-locals ] unit-test :: wlet-test-2 ( a b -- seq ) @@ -108,7 +107,7 @@ write-test-2 "q" set [ 10 20 ] [ - 20 10 [| a! | [| b! | a b ] ] with-locals call call + 20 10 [| a! | [| b! | a b ] ] call call ] unit-test :: write-test-3 ( a! -- q ) [| b | b a! ] ; @@ -170,16 +169,22 @@ M:: string lambda-generic ( a b -- c ) a b lambda-generic-2 ; [ ] [ \ lambda-generic see ] unit-test +:: unparse-test-1 ( a -- ) [let | a! [ ] | ] ; + [ "[let | a! [ ] | ]" ] [ - [let | a! [ ] | ] unparse + \ unparse-test-1 "lambda" word-prop body>> first unparse ] unit-test +:: unparse-test-2 ( -- ) [wlet | a! [ ] | ] ; + [ "[wlet | a! [ ] | ]" ] [ - [wlet | a! [ ] | ] unparse + \ unparse-test-2 "lambda" word-prop body>> first unparse ] unit-test +:: unparse-test-3 ( -- b ) [| a! | ] ; + [ "[| a! | ]" ] [ - [| a! | ] unparse + \ unparse-test-3 "lambda" word-prop body>> first unparse ] unit-test DEFER: xyzzy @@ -237,3 +242,7 @@ M: integer next-method-test 3 + ; M:: fixnum next-method-test ( a -- b ) a call-next-method 1 + ; [ 5 ] [ 1 next-method-test ] unit-test + +: no-with-locals-test { 1 2 3 } [| x | x 3 + ] map ; + +[ { 4 5 6 } ] [ no-with-locals-test ] unit-test diff --git a/extra/locals/locals.factor b/extra/locals/locals.factor index d18017f69b..4b7ab8cdad 100755 --- a/extra/locals/locals.factor +++ b/extra/locals/locals.factor @@ -101,7 +101,7 @@ UNION: special local quote local-word local-reader local-writer ; ] if ; : point-free-body ( quot args -- newquot ) - >r 1 head-slice* r> [ localize ] curry map concat ; + >r but-last-slice r> [ localize ] curry map concat ; : point-free-end ( quot args -- newquot ) over peek special? @@ -201,8 +201,11 @@ M: object local-rewrite* , ; : pop-locals ( assoc -- ) use get delete ; +SYMBOL: in-lambda? + : (parse-lambda) ( assoc end -- quot ) - parse-until >quotation swap pop-locals ; + t in-lambda? [ parse-until ] with-variable + >quotation swap pop-locals ; : parse-lambda ( -- lambda ) "|" parse-tokens make-locals dup push-locals @@ -283,24 +286,24 @@ M: wlet local-rewrite* CREATE-METHOD [ parse-locals-definition ] with-method-definition ; +: parsed-lambda ( form -- ) + in-lambda? get [ parsed ] [ lambda-rewrite over push-all ] if ; + PRIVATE> -: [| parse-lambda parsed ; parsing +: [| parse-lambda parsed-lambda ; parsing : [let scan "|" assert= parse-bindings -\ ] (parse-lambda) parsed ; parsing + \ ] (parse-lambda) parsed-lambda ; parsing : [let* scan "|" assert= parse-bindings* - >r \ ] parse-until >quotation parsed r> pop-locals ; - parsing + \ ] (parse-lambda) parsed-lambda ; parsing : [wlet scan "|" assert= parse-wbindings - \ ] (parse-lambda) parsed ; parsing - -MACRO: with-locals ( form -- quot ) lambda-rewrite ; + \ ] (parse-lambda) parsed-lambda ; parsing : :: (::) define ; parsing diff --git a/extra/logging/server/server.factor b/extra/logging/server/server.factor index 7601d1cc2e..3bc8637f90 100755 --- a/extra/logging/server/server.factor +++ b/extra/logging/server/server.factor @@ -48,7 +48,7 @@ SYMBOL: log-files : (log-message) ( msg -- ) #! msg: { msg word-name level service } - first4 log-stream [ write-message flush ] with-stream* ; + first4 log-stream [ write-message flush ] with-output-stream* ; : try-dispose ( stream -- ) [ dispose ] curry [ error. ] recover ; diff --git a/extra/monads/authors.txt b/extra/monads/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/extra/monads/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/extra/monads/monads-tests.factor b/extra/monads/monads-tests.factor new file mode 100644 index 0000000000..52cdc47ac6 --- /dev/null +++ b/extra/monads/monads-tests.factor @@ -0,0 +1,128 @@ +USING: tools.test monads math kernel sequences lazy-lists promises ; +IN: monads.tests + +[ 5 ] [ 1 identity-monad return [ 4 + ] fmap run-identity ] unit-test +[ "OH HAI" identity-monad fail ] must-fail + +[ 666 ] [ + 111 just [ 6 * ] fmap [ ] [ "OOPS" throw ] if-maybe +] unit-test + +[ nothing ] [ + 111 just [ maybe-monad fail ] bind +] unit-test + +[ 100 ] [ + 5 either-monad return [ 10 * ] [ 20 * ] if-either +] unit-test + +[ T{ left f "OOPS" } ] [ + 5 either-monad return >>= [ drop "OOPS" either-monad fail ] swap call +] unit-test + +[ { 10 20 30 } ] [ + { 1 2 3 } [ 10 * ] fmap +] unit-test + +[ { } ] [ + { 1 2 3 } [ drop "OOPS" array-monad fail ] bind +] unit-test + +[ 5 ] [ + 5 state-monad return "initial state" run-st +] unit-test + +[ 8 ] [ + 5 state-monad return [ 3 + state-monad return ] bind + "initial state" run-st +] unit-test + +[ 8 ] [ + 5 state-monad return >>= + [ 3 + state-monad return ] swap call + "initial state" run-st +] unit-test + +[ 11 ] [ + f state-monad return >>= + [ drop get-st ] swap call + 11 run-st +] unit-test + +[ 15 ] [ + f state-monad return + [ drop get-st ] bind + [ 4 + put-st ] bind + [ drop get-st ] bind + 11 run-st +] unit-test + +[ 15 ] [ + { + [ f return-st ] + [ drop get-st ] + [ 4 + put-st ] + [ drop get-st ] + } do + 11 run-st +] unit-test + +[ nothing ] [ + { + [ "hi" just ] + [ " bye" append just ] + [ drop nothing ] + [ reverse just ] + } do +] unit-test + +LAZY: nats-from ( n -- list ) + dup 1+ nats-from cons ; + +: nats 0 nats-from ; + +[ 3 ] [ + { + [ nats ] + [ dup 3 = [ list-monad return ] [ list-monad fail ] if ] + } do car +] unit-test + +[ 9/11 ] [ + { + [ ask ] + } do 9/11 run-reader +] unit-test + +[ 8 ] [ + { + [ ask ] + [ 3 + reader-monad return ] + } do + 5 run-reader +] unit-test + +[ 6 ] [ + f reader-monad return [ drop ask ] bind [ 1 + ] local 5 run-reader +] unit-test + +[ f { 1 2 3 } ] [ + 5 writer-monad return + [ drop { 1 2 3 } tell ] bind + run-writer +] unit-test + +[ T{ identity f 7 } ] +[ + 4 identity-monad return + [ 3 + ] identity-monad return + identity-monad apply +] unit-test + +[ nothing ] [ + 5 just nothing maybe-monad apply +] unit-test + +[ T{ just f 15 } ] [ + 5 just [ 10 + ] just maybe-monad apply +] unit-test diff --git a/extra/monads/monads.factor b/extra/monads/monads.factor new file mode 100644 index 0000000000..0f4138c985 --- /dev/null +++ b/extra/monads/monads.factor @@ -0,0 +1,192 @@ +! Copyright (C) 2008 Slava Pestov +! See http://factorcode.org/license.txt for BSD license. +USING: arrays kernel sequences sequences.deep splitting +accessors fry locals combinators namespaces lazy-lists +shuffle ; +IN: monads + +! Functors +GENERIC# fmap 1 ( functor quot -- functor' ) inline + +! Monads + +! Mixin type for monad singleton classes, used for return/fail only +MIXIN: monad + +GENERIC: monad-of ( mvalue -- singleton ) +GENERIC: return ( string singleton -- mvalue ) +GENERIC: fail ( value singleton -- mvalue ) +GENERIC: >>= ( mvalue -- quot ) + +M: monad return monad-of return ; +M: monad fail monad-of fail ; + +: bind ( mvalue quot -- mvalue' ) swap >>= call ; +: >> ( mvalue k -- mvalue' ) '[ drop , ] bind ; + +:: lift-m2 ( m1 m2 f monad -- m3 ) + m1 [| x1 | m2 [| x2 | x1 x2 f monad return ] bind ] bind ; + +:: apply ( mvalue mquot monad -- result ) + mvalue [| value | + mquot [| quot | + value quot call monad return + ] bind + ] bind ; + +M: monad fmap over '[ @ , return ] bind ; + +! 'do' notation +: do ( quots -- result ) unclip dip [ bind ] each ; + +! Identity +SINGLETON: identity-monad +INSTANCE: identity-monad monad + +TUPLE: identity value ; +INSTANCE: identity monad + +M: identity monad-of drop identity-monad ; + +M: identity-monad return drop identity boa ; +M: identity-monad fail "Fail" throw ; + +M: identity >>= value>> '[ , _ call ] ; + +: run-identity ( identity -- value ) value>> ; + +! Maybe +SINGLETON: maybe-monad +INSTANCE: maybe-monad monad + +SINGLETON: nothing + +TUPLE: just value ; +: just \ just boa ; + +UNION: maybe just nothing ; +INSTANCE: maybe monad + +M: maybe monad-of drop maybe-monad ; + +M: maybe-monad return drop just ; +M: maybe-monad fail 2drop nothing ; + +M: nothing >>= '[ drop , ] ; +M: just >>= value>> '[ , _ call ] ; + +: if-maybe ( maybe just-quot nothing-quot -- ) + pick nothing? [ 2nip call ] [ drop [ value>> ] dip call ] if ; inline + +! Either +SINGLETON: either-monad +INSTANCE: either-monad monad + +TUPLE: left value ; +: left \ left boa ; + +TUPLE: right value ; +: right \ right boa ; + +UNION: either left right ; +INSTANCE: either monad + +M: either monad-of drop either-monad ; + +M: either-monad return drop right ; +M: either-monad fail drop left ; + +M: left >>= '[ drop , ] ; +M: right >>= value>> '[ , _ call ] ; + +: if-either ( value left-quot right-quot -- ) + [ [ value>> ] [ left? ] bi ] 2dip if ; inline + +! Arrays +SINGLETON: array-monad +INSTANCE: array-monad monad +INSTANCE: array monad + +M: array-monad return drop 1array ; +M: array-monad fail 2drop { } ; + +M: array monad-of drop array-monad ; + +M: array >>= '[ , _ map concat ] ; + +! List +SINGLETON: list-monad +INSTANCE: list-monad monad +INSTANCE: list monad + +M: list-monad return drop 1list ; +M: list-monad fail 2drop nil ; + +M: list monad-of drop list-monad ; + +M: list >>= '[ , _ lmap lconcat ] ; + +! State +SINGLETON: state-monad +INSTANCE: state-monad monad + +TUPLE: state quot ; +: state \ state boa ; + +INSTANCE: state monad + +M: state monad-of drop state-monad ; + +M: state-monad return drop '[ , 2array ] state ; +M: state-monad fail "Fail" throw ; + +: mcall quot>> call ; + +M: state >>= '[ , _ '[ , mcall first2 @ mcall ] state ] ; + +: get-st ( -- state ) [ dup 2array ] state ; +: put-st ( value -- state ) '[ drop , f 2array ] state ; + +: run-st ( state initial -- ) swap mcall second ; + +: return-st state-monad return ; + +! Reader +SINGLETON: reader-monad +INSTANCE: reader-monad monad + +TUPLE: reader quot ; +: reader \ reader boa ; +INSTANCE: reader monad + +M: reader monad-of drop reader-monad ; + +M: reader-monad return drop '[ drop , ] reader ; +M: reader-monad fail "Fail" throw ; + +M: reader >>= '[ , _ '[ dup , mcall @ mcall ] reader ] ; + +: run-reader ( reader env -- ) swap mcall ; + +: ask ( -- reader ) [ ] reader ; +: local ( reader quot -- reader' ) swap '[ @ , mcall ] reader ; + +! Writer +SINGLETON: writer-monad +INSTANCE: writer-monad monad + +TUPLE: writer value log ; +: writer \ writer boa ; + +M: writer monad-of drop writer-monad ; + +M: writer-monad return drop { } writer ; +M: writer-monad fail "Fail" throw ; + +: run-writer ( writer -- value log ) [ value>> ] [ log>> ] bi ; + +M: writer >>= '[ , run-writer _ '[ @ run-writer ] dip append writer ] ; + +: pass ( writer -- writer' ) run-writer [ first2 ] dip swap call writer ; +: listen ( writer -- writer' ) run-writer [ 2array ] keep writer ; +: tell ( seq -- writer ) f swap writer ; diff --git a/extra/monads/summary.txt b/extra/monads/summary.txt new file mode 100644 index 0000000000..359722ce04 --- /dev/null +++ b/extra/monads/summary.txt @@ -0,0 +1 @@ +Haskell-style monads diff --git a/extra/monads/tags.txt b/extra/monads/tags.txt new file mode 100644 index 0000000000..f4274299b1 --- /dev/null +++ b/extra/monads/tags.txt @@ -0,0 +1 @@ +extensions diff --git a/extra/morse/morse-docs.factor b/extra/morse/morse-docs.factor index f31b741c85..e35967d3e9 100644 --- a/extra/morse/morse-docs.factor +++ b/extra/morse/morse-docs.factor @@ -24,6 +24,10 @@ HELP: morse> { $description "Translates morse code into ASCII text" } { $see-also >morse morse>ch } ; -HELP: play-as-morse +HELP: play-as-morse* { $values { "str" "A string of ascii characters which can be translated into morse code" } { "unit-length" "The length of a dot" } } { $description "Plays a string as morse code" } ; + +HELP: play-as-morse +{ $values { "str" "A string of ascii characters which can be translated into morse code" } } +{ $description "Plays a string as morse code" } ; diff --git a/extra/morse/morse-tests.factor b/extra/morse/morse-tests.factor index dabb93579d..9bfdc6b50c 100644 --- a/extra/morse/morse-tests.factor +++ b/extra/morse/morse-tests.factor @@ -9,5 +9,5 @@ USING: arrays morse strings tools.test ; [ "-- --- .-. ... . / -.-. --- -.. ." ] [ "morse code" >morse ] unit-test [ "morse code" ] [ "-- --- .-. ... . / -.-. --- -.. ." morse> ] unit-test [ "hello, world!" ] [ "Hello, World!" >morse morse> ] unit-test -[ ] [ "sos" 0.075 play-as-morse ] unit-test +[ ] [ "sos" 0.075 play-as-morse* ] unit-test [ ] [ "Factor rocks!" play-as-morse ] unit-test diff --git a/extra/mortar/mortar.factor b/extra/mortar/mortar.factor index b7862af7ac..6173669ad0 100644 --- a/extra/mortar/mortar.factor +++ b/extra/mortar/mortar.factor @@ -122,7 +122,7 @@ over class-class-methods assoc-stack call ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! : send-message-next ( object message -- ) -over object-class class-methods 1 head* assoc-stack call ; +over object-class class-methods but-last assoc-stack call ; : <-~ scan parsed \ send-message-next parsed ; parsing diff --git a/extra/multiline/multiline.factor b/extra/multiline/multiline.factor index e140c5227c..ce79bdaf5f 100755 --- a/extra/multiline/multiline.factor +++ b/extra/multiline/multiline.factor @@ -14,7 +14,7 @@ IN: multiline ] [ ";" unexpected-eof ] if* ; : parse-here ( -- str ) - [ (parse-here) ] "" make 1 head* + [ (parse-here) ] "" make but-last lexer get next-line ; : STRING: @@ -34,7 +34,7 @@ IN: multiline [ lexer get lexer-column swap (parse-multiline-string) lexer get set-lexer-column - ] "" make rest 1 head* ; + ] "" make rest but-last ; : <" "\">" parse-multiline-string parsed ; parsing diff --git a/extra/opengl/opengl-docs.factor b/extra/opengl/opengl-docs.factor index 2788ebdfc2..b168f4cad1 100644 --- a/extra/opengl/opengl-docs.factor +++ b/extra/opengl/opengl-docs.factor @@ -7,7 +7,7 @@ HELP: gl-color { $description "Wrapper for " { $link glColor4d } " taking a color specifier." } ; HELP: gl-error -{ $description "If the most recent OpenGL call resulted in an error, print the error to the " { $link stdio } " stream." } ; +{ $description "If the most recent OpenGL call resulted in an error, print the error to " { $link output-stream } "." } ; HELP: do-state { diff --git a/extra/pack/pack-tests.factor b/extra/pack/pack-tests.factor index 510e44d34e..d58ccbd0f2 100755 --- a/extra/pack/pack-tests.factor +++ b/extra/pack/pack-tests.factor @@ -38,7 +38,7 @@ USING: io io.streams.string kernel namespaces pack strings tools.test ; [ 2 ] [ [ 2 "int" b, ] B{ } make - [ "int" read-native ] with-stream + [ "int" read-native ] with-input-stream ] unit-test [ "FRAM" ] [ "FRAM\0" [ read-c-string ] with-string-reader ] unit-test diff --git a/extra/pack/pack.factor b/extra/pack/pack.factor index 65912244dd..5320583df0 100755 --- a/extra/pack/pack.factor +++ b/extra/pack/pack.factor @@ -154,13 +154,12 @@ MACRO: (pack) ( seq str -- quot ) MACRO: (unpack) ( str -- quot ) [ - \ , [ [ unpack-table at , \ , , ] each ] [ ] make 1quotation [ { } make ] append 1quotation % - \ with-stream , + \ with-string-reader , ] [ ] make ; : unpack-native ( seq str -- seq ) diff --git a/extra/peg/ebnf/ebnf.factor b/extra/peg/ebnf/ebnf.factor index 0ee7bf515f..c3252de500 100644 --- a/extra/peg/ebnf/ebnf.factor +++ b/extra/peg/ebnf/ebnf.factor @@ -324,7 +324,7 @@ M: ebnf-sequence build-locals ( code ast -- code ) ] 2each " | " % % - " ] with-locals" % + " ]" % ] "" make ] if ; @@ -334,7 +334,7 @@ M: ebnf-var build-locals ( code ast -- ) name>> % " [ dup ] " % " | " % % - " ] with-locals" % + " ]" % ] "" make ; M: object build-locals ( code ast -- ) diff --git a/extra/porter-stemmer/porter-stemmer-tests.factor b/extra/porter-stemmer/porter-stemmer-tests.factor index 32386fed2b..42c358646b 100644 --- a/extra/porter-stemmer/porter-stemmer-tests.factor +++ b/extra/porter-stemmer/porter-stemmer-tests.factor @@ -56,11 +56,9 @@ io.files io.encodings.utf8 ; [ "hell" ] [ "hell" step5 "" like ] unit-test [ "mate" ] [ "mate" step5 "" like ] unit-test -: resource-lines resource-path utf8 file-lines ; - [ { } ] [ - "extra/porter-stemmer/test/voc.txt" resource-lines + "resource:extra/porter-stemmer/test/voc.txt" utf8 file-lines [ stem ] map - "extra/porter-stemmer/test/output.txt" resource-lines + "resource:extra/porter-stemmer/test/output.txt" utf8 file-lines [ 2array ] 2map [ first2 = not ] filter ] unit-test diff --git a/extra/porter-stemmer/porter-stemmer.factor b/extra/porter-stemmer/porter-stemmer.factor index 81820e0152..9a2a08bcbe 100644 --- a/extra/porter-stemmer/porter-stemmer.factor +++ b/extra/porter-stemmer/porter-stemmer.factor @@ -66,8 +66,6 @@ USING: kernel math parser sequences combinators splitting ; : r ( str oldsuffix newsuffix -- str ) pick consonant-seq 0 > [ nip ] [ drop ] if append ; -: butlast ( seq -- seq ) 1 head-slice* ; - : step1a ( str -- newstr ) dup peek CHAR: s = [ { @@ -95,7 +93,7 @@ USING: kernel math parser sequences combinators splitting ; { [ "iz" ?tail ] [ "ize" append ] } { [ dup length 1- over double-consonant? ] - [ dup "lsz" last-is? [ butlast ] unless ] + [ dup "lsz" last-is? [ but-last-slice ] unless ] } { [ t ] @@ -122,7 +120,7 @@ USING: kernel math parser sequences combinators splitting ; } cond ; : step1c ( str -- newstr ) - dup butlast stem-vowel? [ + dup but-last-slice stem-vowel? [ "y" ?tail [ "i" append ] when ] when ; @@ -198,18 +196,18 @@ USING: kernel math parser sequences combinators splitting ; : remove-e? ( str -- ? ) dup consonant-seq dup 1 > [ 2drop t ] - [ 1 = [ butlast cvc? not ] [ drop f ] if ] if ; + [ 1 = [ but-last-slice cvc? not ] [ drop f ] if ] if ; : remove-e ( str -- newstr ) dup peek CHAR: e = [ - dup remove-e? [ butlast ] when + dup remove-e? [ but-last-slice ] when ] when ; : ll->l ( str -- newstr ) { { [ dup peek CHAR: l = not ] [ ] } { [ dup length 1- over double-consonant? not ] [ ] } - { [ dup consonant-seq 1 > ] [ butlast ] } + { [ dup consonant-seq 1 > ] [ but-last-slice ] } [ ] } cond ; diff --git a/extra/project-euler/002/002.factor b/extra/project-euler/002/002.factor index c2def03ace..108f5c1e94 100644 --- a/extra/project-euler/002/002.factor +++ b/extra/project-euler/002/002.factor @@ -41,7 +41,7 @@ PRIVATE> : fib-upto* ( n -- seq ) 0 1 [ pick over >= ] [ tuck + dup ] [ ] unfold 3nip - 1 head-slice* { 0 1 } prepend ; + but-last-slice { 0 1 } prepend ; : euler002a ( -- answer ) 1000000 fib-upto* [ even? ] filter sum ; diff --git a/extra/project-euler/022/022.factor b/extra/project-euler/022/022.factor index 452d2ec637..82054ce014 100644 --- a/extra/project-euler/022/022.factor +++ b/extra/project-euler/022/022.factor @@ -28,7 +28,7 @@ IN: project-euler.022 number ] map ; @@ -78,7 +78,7 @@ INSTANCE: rollover immutable-sequence frequency-analysis sort-values keys peek ; : crack-key ( seq key-length -- key ) - [ " " decrypt ] dip group 1 head-slice* + [ " " decrypt ] dip group but-last-slice flip [ most-frequent ] map ; PRIVATE> diff --git a/extra/project-euler/067/067.factor b/extra/project-euler/067/067.factor index 436ccde776..3e16996e04 100644 --- a/extra/project-euler/067/067.factor +++ b/extra/project-euler/067/067.factor @@ -38,7 +38,7 @@ IN: project-euler.067 number ] map ] map ; PRIVATE> diff --git a/extra/project-euler/079/079.factor b/extra/project-euler/079/079.factor index 3674804b0c..cde4dc079b 100644 --- a/extra/project-euler/079/079.factor +++ b/extra/project-euler/079/079.factor @@ -27,7 +27,7 @@ IN: project-euler.079 edges ( seq -- seq ) [ diff --git a/extra/random/unix/unix.factor b/extra/random/unix/unix.factor index 6016a6e9cb..7fda7c5d1d 100644 --- a/extra/random/unix/unix.factor +++ b/extra/random/unix/unix.factor @@ -9,7 +9,7 @@ C: unix-random : file-read-unbuffered ( n path -- bytes ) over default-buffer-size [ - binary [ read ] with-stream + binary [ read ] with-file-reader ] with-variable ; M: unix-random random-bytes* ( n tuple -- byte-array ) diff --git a/extra/rss/rss-tests.factor b/extra/rss/rss-tests.factor index 252defe99b..0e6bb0b9c1 100755 --- a/extra/rss/rss-tests.factor +++ b/extra/rss/rss-tests.factor @@ -22,7 +22,7 @@ IN: rss.tests f } } -} ] [ "extra/rss/rss1.xml" resource-path load-news-file ] unit-test +} ] [ "resource:extra/rss/rss1.xml" load-news-file ] unit-test [ T{ feed f @@ -39,4 +39,4 @@ IN: rss.tests T{ timestamp f 2003 12 13 8 29 29 T{ duration f 0 0 0 -4 0 0 } } } } -} ] [ "extra/rss/atom.xml" resource-path load-news-file ] unit-test +} ] [ "resource:extra/rss/atom.xml" load-news-file ] unit-test diff --git a/extra/shuffle/shuffle.factor b/extra/shuffle/shuffle.factor index 33587bb7fa..89522d1f76 100644 --- a/extra/shuffle/shuffle.factor +++ b/extra/shuffle/shuffle.factor @@ -5,6 +5,8 @@ USING: kernel sequences namespaces math inference.transforms IN: shuffle +: 2dip -rot 2slip ; inline + MACRO: npick ( n -- ) 1- dup saver [ dup ] rot [ r> swap ] n*quot 3append ; MACRO: ndup ( n -- ) dup [ npick ] curry n*quot ; diff --git a/extra/size-of/size-of.factor b/extra/size-of/size-of.factor index 5b6f26acea..a2b47fc0aa 100644 --- a/extra/size-of/size-of.factor +++ b/extra/size-of/size-of.factor @@ -36,4 +36,4 @@ VAR: headers { "gcc" c-file "-o" exe } to-strings [ "Error compiling generated C program" print ] run-or-bail - exe ascii contents string>number ; \ No newline at end of file + exe ascii contents string>number ; \ No newline at end of file diff --git a/extra/smtp/server/server.factor b/extra/smtp/server/server.factor index 737a887f9f..f23ee138d5 100755 --- a/extra/smtp/server/server.factor +++ b/extra/smtp/server/server.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2007 Elie CHAFTARI ! See http://factorcode.org/license.txt for BSD license. USING: combinators kernel prettyprint io io.timeouts io.server -sequences namespaces io.sockets continuations calendar io.encodings.ascii ; +sequences namespaces io.sockets continuations calendar +io.encodings.ascii io.streams.duplex ; IN: smtp.server ! Mock SMTP server for testing purposes. @@ -65,7 +66,7 @@ SYMBOL: data-mode "Starting SMTP server on port " write dup . flush "127.0.0.1" swap ascii [ accept drop [ - 1 minutes stdio get set-timeout + 1 minutes timeouts "220 hello\r\n" write flush process global [ flush ] bind diff --git a/extra/smtp/smtp.factor b/extra/smtp/smtp.factor index 4d548738d2..8fdc0e07a4 100755 --- a/extra/smtp/smtp.factor +++ b/extra/smtp/smtp.factor @@ -17,11 +17,11 @@ LOG: log-smtp-connection NOTICE ( addrspec -- ) : with-smtp-connection ( quot -- ) smtp-server get dup log-smtp-connection - ascii [ + ascii [ smtp-domain [ host-name or ] change - read-timeout get stdio get set-timeout + read-timeout get timeouts call - ] with-stream ; inline + ] with-client ; inline : crlf "\r\n" write ; diff --git a/extra/space-invaders/space-invaders.factor b/extra/space-invaders/space-invaders.factor index 200257b31c..f773d331b1 100755 --- a/extra/space-invaders/space-invaders.factor +++ b/extra/space-invaders/space-invaders.factor @@ -45,21 +45,21 @@ TUPLE: space-invaders port1 port2i port2o port3o port4lo port4hi port5o bitmap s : init-sound ( index cpu filename -- ) swapd >r space-invaders-sounds nth AL_BUFFER r> - resource-path create-buffer-from-wav set-source-param ; + create-buffer-from-wav set-source-param ; : init-sounds ( cpu -- ) init-openal [ 9 gen-sources swap set-space-invaders-sounds ] keep - [ SOUND-SHOT "extra/space-invaders/resources/Shot.wav" init-sound ] keep - [ SOUND-UFO "extra/space-invaders/resources/Ufo.wav" init-sound ] keep + [ SOUND-SHOT "resource:extra/space-invaders/resources/Shot.wav" init-sound ] keep + [ SOUND-UFO "resource:extra/space-invaders/resources/Ufo.wav" init-sound ] keep [ space-invaders-sounds SOUND-UFO swap nth AL_LOOPING AL_TRUE set-source-param ] keep - [ SOUND-BASE-HIT "extra/space-invaders/resources/BaseHit.wav" init-sound ] keep - [ SOUND-INVADER-HIT "extra/space-invaders/resources/InvHit.wav" init-sound ] keep - [ SOUND-WALK1 "extra/space-invaders/resources/Walk1.wav" init-sound ] keep - [ SOUND-WALK2 "extra/space-invaders/resources/Walk2.wav" init-sound ] keep - [ SOUND-WALK3 "extra/space-invaders/resources/Walk3.wav" init-sound ] keep - [ SOUND-WALK4 "extra/space-invaders/resources/Walk4.wav" init-sound ] keep - [ SOUND-UFO-HIT "extra/space-invaders/resources/UfoHit.wav" init-sound ] keep + [ SOUND-BASE-HIT "resource:extra/space-invaders/resources/BaseHit.wav" init-sound ] keep + [ SOUND-INVADER-HIT "resource:extra/space-invaders/resources/InvHit.wav" init-sound ] keep + [ SOUND-WALK1 "resource:extra/space-invaders/resources/Walk1.wav" init-sound ] keep + [ SOUND-WALK2 "resource:extra/space-invaders/resources/Walk2.wav" init-sound ] keep + [ SOUND-WALK3 "resource:extra/space-invaders/resources/Walk3.wav" init-sound ] keep + [ SOUND-WALK4 "resource:extra/space-invaders/resources/Walk4.wav" init-sound ] keep + [ SOUND-UFO-HIT "resource:extra/space-invaders/resources/UfoHit.wav" init-sound ] keep f swap set-space-invaders-looping? ; : ( -- cpu ) diff --git a/extra/state-parser/state-parser-docs.factor b/extra/state-parser/state-parser-docs.factor index cac0e30175..3027c01c19 100644 --- a/extra/state-parser/state-parser-docs.factor +++ b/extra/state-parser/state-parser-docs.factor @@ -69,4 +69,4 @@ HELP: next { $description "originally written as " { $code "spot inc" } ", code that would no longer run, this word moves the state of the XML parser to the next place in the source file, keeping track of appropriate debugging information." } ; HELP: parsing-error -{ $class-description "class to which parsing errors delegate, containing information about which line and column the error occured on, and what the line was. Contains three slots, line, an integer, column, another integer, and line-str, a string" } ; +{ $class-description "class from which parsing errors inherit, containing information about which line and column the error occured on, and what the line was. Contains three slots, line, an integer, column, another integer, and line-str, a string" } ; diff --git a/extra/state-parser/state-parser.factor b/extra/state-parser/state-parser.factor index 96ad4ca0b4..b41d7f5023 100644 --- a/extra/state-parser/state-parser.factor +++ b/extra/state-parser/state-parser.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2005, 2006 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. USING: io io.streams.string kernel math namespaces sequences -strings circular prettyprint debugger ascii ; +strings circular prettyprint debugger ascii sbufs fry inspector +accessors sequences.lib ; IN: state-parser ! * Basic underlying words @@ -11,50 +12,56 @@ TUPLE: spot char line column next ; C: spot -: get-char ( -- char ) spot get spot-char ; -: set-char ( char -- ) spot get set-spot-char ; -: get-line ( -- line ) spot get spot-line ; -: set-line ( line -- ) spot get set-spot-line ; -: get-column ( -- column ) spot get spot-column ; -: set-column ( column -- ) spot get set-spot-column ; -: get-next ( -- char ) spot get spot-next ; -: set-next ( char -- ) spot get set-spot-next ; +: get-char ( -- char ) spot get char>> ; +: set-char ( char -- ) spot get swap >>char drop ; +: get-line ( -- line ) spot get line>> ; +: set-line ( line -- ) spot get swap >>line drop ; +: get-column ( -- column ) spot get column>> ; +: set-column ( column -- ) spot get swap >>column drop ; +: get-next ( -- char ) spot get next>> ; +: set-next ( char -- ) spot get swap >>next drop ; ! * Errors TUPLE: parsing-error line column ; -: ( -- parsing-error ) - get-line get-column parsing-error boa ; -: construct-parsing-error ( ... slots class -- error ) - construct over set-delegate ; inline +: parsing-error ( class -- obj ) + new + get-line >>line + get-column >>column ; +M: parsing-error summary ( obj -- str ) + [ + "Parsing error" print + "Line: " write dup line>> . + "Column: " write column>> . + ] with-string-writer ; -: parsing-error. ( parsing-error -- ) - "Parsing error" print - "Line: " write dup parsing-error-line . - "Column: " write parsing-error-column . ; +TUPLE: expected < parsing-error should-be was ; +: expected ( should-be was -- * ) + \ expected parsing-error + swap >>was + swap >>should-be throw ; +M: expected summary ( obj -- str ) + [ + dup call-next-method write + "Token expected: " write dup should-be>> print + "Token present: " write was>> print + ] with-string-writer ; -TUPLE: expected should-be was ; -: ( should-be was -- error ) - { set-expected-should-be set-expected-was } - expected construct-parsing-error ; -M: expected error. - dup parsing-error. - "Token expected: " write dup expected-should-be print - "Token present: " write expected-was print ; +TUPLE: unexpected-end < parsing-error ; +: unexpected-end \ unexpected-end parsing-error throw ; +M: unexpected-end summary ( obj -- str ) + [ + call-next-method write + "File unexpectedly ended." print + ] with-string-writer ; -TUPLE: unexpected-end ; -: ( -- unexpected-end ) - { } unexpected-end construct-parsing-error ; -M: unexpected-end error. - parsing-error. - "File unexpectedly ended." print ; - -TUPLE: missing-close ; -: ( -- missing-close ) - { } missing-close construct-parsing-error ; -M: missing-close error. - parsing-error. - "Missing closing token." print ; +TUPLE: missing-close < parsing-error ; +: missing-close \ missing-close parsing-error throw ; +M: missing-close summary ( obj -- str ) + [ + call-next-method write + "Missing closing token." print + ] with-string-writer ; SYMBOL: prolog-data @@ -65,7 +72,8 @@ SYMBOL: prolog-data [ 0 get-line 1+ set-line ] [ get-column 1+ ] if set-column ; -: (next) ( -- char ) ! this normalizes \r\n and \r +! (next) normalizes \r\n and \r +: (next) ( -- char ) get-next read1 2dup swap CHAR: \r = [ CHAR: \n = @@ -75,10 +83,7 @@ SYMBOL: prolog-data : next ( -- ) #! Increment spot. - get-char [ - throw - ] unless - (next) record ; + get-char [ unexpected-end ] unless (next) record ; : next* ( -- ) get-char [ (next) record ] when ; @@ -95,9 +100,9 @@ SYMBOL: prolog-data #! Take the substring of a string starting at spot #! from code until the quotation given is true and #! advance spot to after the substring. - [ [ - dup slip swap dup [ get-char , ] unless - ] skip-until ] "" make nip ; inline + 10 [ + '[ @ [ t ] [ get-char , push f ] if ] skip-until + ] keep >string ; inline : take-rest ( -- string ) [ f ] take-until ; @@ -105,6 +110,20 @@ SYMBOL: prolog-data : take-char ( ch -- string ) [ dup get-char = ] take-until nip ; +TUPLE: not-enough-characters < parsing-error ; +: not-enough-characters + \ not-enough-characters parsing-error throw ; +M: not-enough-characters summary ( obj -- str ) + [ + call-next-method write + "Not enough characters" print + ] with-string-writer ; + +: take ( n -- string ) + [ 1- ] [ ] bi [ + '[ drop get-char [ next , push f ] [ t ] if* ] attempt-each drop + ] keep get-char [ over push ] when* >string ; + : pass-blank ( -- ) #! Advance code past any whitespace, including newlines [ get-char blank? not ] skip-until ; @@ -117,24 +136,24 @@ SYMBOL: prolog-data dup length [ 2dup string-matches? ] take-until nip dup length rot length 1- - head - get-char [ throw ] unless next ; + get-char [ missing-close ] unless next ; : expect ( ch -- ) get-char 2dup = [ 2drop ] [ - >r 1string r> 1string throw + >r 1string r> 1string expected ] if next ; : expect-string ( string -- ) dup [ drop get-char next ] map 2dup = - [ 2drop ] [ throw ] if ; + [ 2drop ] [ expected ] if ; : init-parser ( -- ) 0 1 0 f spot set read1 set-next next ; : state-parse ( stream quot -- ) - ! with-stream implicitly creates a new scope which we use - swap [ init-parser call ] with-stream ; inline + ! with-input-stream implicitly creates a new scope which we use + swap [ init-parser call ] with-input-stream ; inline : string-parse ( input quot -- ) >r r> state-parse ; inline diff --git a/extra/tangle/tangle.factor b/extra/tangle/tangle.factor index afaf3da3cd..52c454f97f 100644 --- a/extra/tangle/tangle.factor +++ b/extra/tangle/tangle.factor @@ -65,7 +65,7 @@ TUPLE: tangle-dispatcher < dispatcher tangle ; : ( tangle -- dispatcher ) tangle-dispatcher new-dispatcher swap >>tangle >>default - "extra/tangle/resources" resource-path "resources" add-responder + "resource:extra/tangle/resources" "resources" add-responder "node" add-responder [ all-node-ids ] >>display "all" add-responder ; diff --git a/extra/tar/tar.factor b/extra/tar/tar.factor index 9b3d2ae79f..b5d01b6ed2 100755 --- a/extra/tar/tar.factor +++ b/extra/tar/tar.factor @@ -1,7 +1,6 @@ -USING: combinators io io.files io.streams.duplex -io.streams.string kernel math math.parser continuations -namespaces pack prettyprint sequences strings system -hexdump io.encodings.binary inspector accessors ; +USING: combinators io io.files io.streams.string kernel math +math.parser continuations namespaces pack prettyprint sequences +strings system hexdump io.encodings.binary inspector accessors ; IN: tar : zero-checksum 256 ; @@ -61,9 +60,7 @@ SYMBOL: filename ] if* ; : read-data-blocks ( tar-header out -- ) - >r stdio get r> [ - (read-data-blocks) - ] with-stream* ; + [ (read-data-blocks) ] with-output-stream* ; : parse-tar-header ( seq -- obj ) [ header-checksum ] keep over zero-checksum = [ diff --git a/extra/taxes/taxes-tests.factor b/extra/taxes/taxes-tests.factor index 6aeb5aa098..32dbd0d625 100644 --- a/extra/taxes/taxes-tests.factor +++ b/extra/taxes/taxes-tests.factor @@ -96,3 +96,21 @@ IN: taxes.tests 1000000 2008 3 t net dollars/cents ] unit-test + + +[ 30 97 ] [ + 24000 2008 2 f withholding biweekly dollars/cents +] unit-test + +[ 173 66 ] [ + 78250 2008 2 f withholding biweekly dollars/cents +] unit-test + + +[ 138 69 ] [ + 24000 2008 2 f withholding biweekly dollars/cents +] unit-test + +[ 754 22 ] [ + 78250 2008 2 f withholding biweekly dollars/cents +] unit-test diff --git a/extra/tools/deploy/backend/backend.factor b/extra/tools/deploy/backend/backend.factor index d4fbf1de78..6dff511238 100755 --- a/extra/tools/deploy/backend/backend.factor +++ b/extra/tools/deploy/backend/backend.factor @@ -4,7 +4,7 @@ USING: namespaces continuations.private kernel.private init assocs kernel vocabs words sequences memory io system arrays continuations math definitions mirrors splitting parser classes inspector layouts vocabs.loader prettyprint.config prettyprint -debugger io.streams.c io.streams.duplex io.files io.backend +debugger io.streams.c io.files io.backend quotations io.launcher words.private tools.deploy.config bootstrap.image io.encodings.utf8 accessors ; IN: tools.deploy.backend @@ -31,10 +31,9 @@ IN: tools.deploy.backend +stdout+ >>stderr +closed+ >>stdin +low-priority+ >>priority - utf8 - >r copy-lines r> wait-for-process zero? [ - "Deployment failed" throw - ] unless ; + utf8 + copy-lines + wait-for-process zero? [ "Deployment failed" throw ] unless ; : make-boot-image ( -- ) #! If stage1 image doesn't exist, create one. @@ -64,11 +63,11 @@ DEFER: ?make-staging-image dup empty? [ "-i=" my-boot-image-name append , ] [ - dup 1 head* ?make-staging-image + dup but-last ?make-staging-image "-resource-path=" "" resource-path append , - "-i=" over 1 head* staging-image-name append , + "-i=" over but-last staging-image-name append , "-run=tools.deploy.restage" , ] if diff --git a/extra/tools/deploy/shaker/shaker.factor b/extra/tools/deploy/shaker/shaker.factor index 1ad9957cc9..1374254612 100755 --- a/extra/tools/deploy/shaker/shaker.factor +++ b/extra/tools/deploy/shaker/shaker.factor @@ -114,14 +114,15 @@ IN: tools.deploy.shaker continuations:error-continuation continuations:error-thread continuations:restarts - error-hook + listener:error-hook init:init-hooks inspector:inspector-hook io.thread:io-thread libc.private:mallocs source-files:source-files - stderr - stdio + input-stream + output-stream + error-stream } % deploy-threads? [ @@ -145,7 +146,6 @@ IN: tools.deploy.shaker classes:class-not-cache classes:class-or-cache classes:class<=-cache - classes:class<=>-cache classes:classes-intersect-cache classes:update-map command-line:main-vocab-hook diff --git a/extra/tools/profiler/profiler-docs.factor b/extra/tools/profiler/profiler-docs.factor index 89e84bbc86..50bbc527d1 100755 --- a/extra/tools/profiler/profiler-docs.factor +++ b/extra/tools/profiler/profiler-docs.factor @@ -27,7 +27,7 @@ HELP: counters HELP: counters. { $values { "assoc" "an association list mapping words to integers" } } -{ $description "Prints an association list of call counts to the " { $link stdio } " stream." } ; +{ $description "Prints an association list of call counts to " { $link output-stream } "." } ; HELP: profile { $values { "quot" quotation } } diff --git a/extra/tools/test/test-docs.factor b/extra/tools/test/test-docs.factor index a605543bda..4b2521d19c 100755 --- a/extra/tools/test/test-docs.factor +++ b/extra/tools/test/test-docs.factor @@ -91,4 +91,4 @@ HELP: run-all-tests HELP: test-failures. { $values { "assoc" "an association list of unit test failures" } } -{ $description "Prints unit test failures output by " { $link run-tests } " or " { $link run-all-tests } " to the " { $link stdio } " stream." } ; +{ $description "Prints unit test failures output by " { $link run-tests } " or " { $link run-all-tests } " to " { $link output-stream } "." } ; diff --git a/extra/tools/test/ui/ui.factor b/extra/tools/test/ui/ui.factor index 9b32bc9e10..8825cffa4d 100755 --- a/extra/tools/test/ui/ui.factor +++ b/extra/tools/test/ui/ui.factor @@ -2,7 +2,7 @@ USING: dlists ui.gadgets kernel ui namespaces io.streams.string io ; IN: tools.test.ui -! We can't print to stdio here because that might be a pane +! We can't print to output-stream here because that might be a pane ! stream, and our graft-queue rebinding here would be captured ! by code adding children to the pane... : with-grafted-gadget ( gadget quot -- ) diff --git a/extra/tools/vocabs/monitor/monitor.factor b/extra/tools/vocabs/monitor/monitor.factor index 563cd04e3e..ee5198a8f4 100755 --- a/extra/tools/vocabs/monitor/monitor.factor +++ b/extra/tools/vocabs/monitor/monitor.factor @@ -13,9 +13,9 @@ IN: tools.vocabs.monitor dup ".factor" tail? [ parent-directory ] when ; : chop-vocab-root ( path -- path' ) - "resource:" prepend-path (normalize-path) + "resource:" prepend-path normalize-path dup vocab-roots get - [ (normalize-path) ] map + [ normalize-path ] map [ head? ] with find nip ?head drop ; @@ -29,17 +29,17 @@ IN: tools.vocabs.monitor reset-cache monitor-loop ; -: add-monitor-for-path ( path -- ) - normalize-path dup exists? [ t my-mailbox (monitor) ] when drop ; - +: add-monitor-for-path ( path -- ) + dup exists? [ t my-mailbox (monitor) ] when drop ; + : monitor-thread ( -- ) [ [ vocab-roots get prune [ add-monitor-for-path ] each - + H{ } clone changed-vocabs set-global vocabs [ changed-vocab ] each - + monitor-loop ] with-monitors ] ignore-errors ; diff --git a/extra/trees/avl/avl-tests.factor b/extra/trees/avl/avl-tests.factor old mode 100644 new mode 100755 index 570125cb45..5cb6606ce4 --- a/extra/trees/avl/avl-tests.factor +++ b/extra/trees/avl/avl-tests.factor @@ -2,85 +2,79 @@ USING: kernel tools.test trees trees.avl math random sequences assocs ; IN: trees.avl.tests [ "key1" 0 "key2" 0 ] [ - T{ avl-node T{ node f "key1" f f T{ avl-node T{ node f "key2" } 1 } } 2 } + T{ avl-node f "key1" f f T{ avl-node f "key2" f f 1 } 2 } [ single-rotate ] go-left [ node-left dup node-key swap avl-node-balance ] keep dup node-key swap avl-node-balance ] unit-test [ "key1" 0 "key2" 0 ] [ - T{ avl-node T{ node f "key1" f f T{ avl-node T{ node f "key2" } 1 } } 2 } + T{ avl-node f "key1" f f T{ avl-node f "key2" f f f 1 } 2 } [ select-rotate ] go-left [ node-left dup node-key swap avl-node-balance ] keep dup node-key swap avl-node-balance ] unit-test [ "key1" 0 "key2" 0 ] [ - T{ avl-node T{ node f "key1" f T{ avl-node T{ node f "key2" } -1 } } -2 } + T{ avl-node f "key1" f T{ avl-node f "key2" f f f -1 } f -2 } [ single-rotate ] go-right [ node-right dup node-key swap avl-node-balance ] keep dup node-key swap avl-node-balance ] unit-test [ "key1" 0 "key2" 0 ] [ - T{ avl-node T{ node f "key1" f T{ avl-node T{ node f "key2" } -1 } } -2 } + T{ avl-node f "key1" f T{ avl-node f "key2" f f f -1 } f -2 } [ select-rotate ] go-right [ node-right dup node-key swap avl-node-balance ] keep dup node-key swap avl-node-balance ] unit-test [ "key1" -1 "key2" 0 "key3" 0 ] -[ T{ avl-node T{ node f "key1" f f - T{ avl-node T{ node f "key2" f - T{ avl-node T{ node f "key3" } 1 } } - -1 } } - 2 } [ double-rotate ] go-left +[ T{ avl-node f "key1" f f + T{ avl-node f "key2" f + T{ avl-node f "key3" f f f 1 } f -1 } 2 } + [ double-rotate ] go-left [ node-left dup node-key swap avl-node-balance ] keep [ node-right dup node-key swap avl-node-balance ] keep dup node-key swap avl-node-balance ] unit-test [ "key1" 0 "key2" 0 "key3" 0 ] -[ T{ avl-node T{ node f "key1" f f - T{ avl-node T{ node f "key2" f - T{ avl-node T{ node f "key3" } 0 } } - -1 } } - 2 } [ double-rotate ] go-left +[ T{ avl-node f "key1" f f + T{ avl-node f "key2" f + T{ avl-node f "key3" f f f 0 } f -1 } 2 } + [ double-rotate ] go-left [ node-left dup node-key swap avl-node-balance ] keep [ node-right dup node-key swap avl-node-balance ] keep dup node-key swap avl-node-balance ] unit-test [ "key1" 0 "key2" 1 "key3" 0 ] -[ T{ avl-node T{ node f "key1" f f - T{ avl-node T{ node f "key2" f - T{ avl-node T{ node f "key3" } -1 } } - -1 } } - 2 } [ double-rotate ] go-left +[ T{ avl-node f "key1" f f + T{ avl-node f "key2" f + T{ avl-node f "key3" f f f -1 } f -1 } 2 } + [ double-rotate ] go-left [ node-left dup node-key swap avl-node-balance ] keep [ node-right dup node-key swap avl-node-balance ] keep dup node-key swap avl-node-balance ] unit-test [ "key1" 1 "key2" 0 "key3" 0 ] -[ T{ avl-node T{ node f "key1" f - T{ avl-node T{ node f "key2" f f - T{ avl-node T{ node f "key3" } -1 } } - 1 } } - -2 } [ double-rotate ] go-right +[ T{ avl-node f "key1" f + T{ avl-node f "key2" f f + T{ avl-node f "key3" f f f -1 } 1 } f -2 } + [ double-rotate ] go-right [ node-right dup node-key swap avl-node-balance ] keep [ node-left dup node-key swap avl-node-balance ] keep dup node-key swap avl-node-balance ] unit-test [ "key1" 0 "key2" 0 "key3" 0 ] -[ T{ avl-node T{ node f "key1" f - T{ avl-node T{ node f "key2" f f - T{ avl-node T{ node f "key3" } 0 } } - 1 } } - -2 } [ double-rotate ] go-right +[ T{ avl-node f "key1" f + T{ avl-node f "key2" f f + T{ avl-node f "key3" f f f 0 } 1 } f -2 } + [ double-rotate ] go-right [ node-right dup node-key swap avl-node-balance ] keep [ node-left dup node-key swap avl-node-balance ] keep dup node-key swap avl-node-balance ] unit-test [ "key1" 0 "key2" -1 "key3" 0 ] -[ T{ avl-node T{ node f "key1" f - T{ avl-node T{ node f "key2" f f - T{ avl-node T{ node f "key3" } 1 } } - 1 } } - -2 } [ double-rotate ] go-right +[ T{ avl-node f "key1" f + T{ avl-node f "key2" f f + T{ avl-node f "key3" f f f 1 } 1 } f -2 } + [ double-rotate ] go-right [ node-right dup node-key swap avl-node-balance ] keep [ node-left dup node-key swap avl-node-balance ] keep dup node-key swap avl-node-balance ] unit-test diff --git a/extra/trees/avl/avl.factor b/extra/trees/avl/avl.factor index 3a37ec5fc7..866e035a21 100755 --- a/extra/trees/avl/avl.factor +++ b/extra/trees/avl/avl.factor @@ -1,33 +1,34 @@ ! Copyright (C) 2007 Alex Chapman ! See http://factorcode.org/license.txt for BSD license. -USING: combinators kernel generic math math.functions math.parser -namespaces io prettyprint.backend sequences trees assocs parser -math.order ; +USING: combinators kernel generic math math.functions +math.parser namespaces io prettyprint.backend sequences trees +assocs parser accessors math.order ; IN: trees.avl -TUPLE: avl ; - -INSTANCE: avl tree-mixin +TUPLE: avl < tree ; : ( -- tree ) - avl construct-tree ; + avl new-tree ; -TUPLE: avl-node balance ; +TUPLE: avl-node < node balance ; : ( key value -- node ) - swap 0 avl-node boa tuck set-delegate ; + avl-node new-node + 0 >>balance ; -: change-balance ( node amount -- ) - over avl-node-balance + swap set-avl-node-balance ; +: increase-balance ( node amount -- ) + swap [ + ] change-balance drop ; : rotate ( node -- node ) - dup node+link dup node-link pick set-node+link tuck set-node-link ; + dup node+link dup node-link pick set-node+link + tuck set-node-link ; : single-rotate ( node -- node ) - 0 over set-avl-node-balance 0 over node+link set-avl-node-balance rotate ; + 0 over (>>balance) 0 over node+link + (>>balance) rotate ; : pick-balances ( a node -- balance balance ) - avl-node-balance { + balance>> { { [ dup zero? ] [ 2drop 0 0 ] } { [ over = ] [ neg 0 ] } [ 0 swap ] @@ -36,18 +37,22 @@ TUPLE: avl-node balance ; : double-rotate ( node -- node ) [ node+link [ - node-link current-side get neg over pick-balances rot 0 swap set-avl-node-balance - ] keep set-avl-node-balance - ] keep tuck set-avl-node-balance - dup node+link [ rotate ] with-other-side over set-node+link rotate ; + node-link current-side get neg + over pick-balances rot 0 swap (>>balance) + ] keep (>>balance) + ] keep swap >>balance + dup node+link [ rotate ] with-other-side + over set-node+link rotate ; : select-rotate ( node -- node ) - dup node+link avl-node-balance current-side get = [ double-rotate ] [ single-rotate ] if ; + dup node+link balance>> current-side get = + [ double-rotate ] [ single-rotate ] if ; : balance-insert ( node -- node taller? ) dup avl-node-balance { { [ dup zero? ] [ drop f ] } - { [ dup abs 2 = ] [ sgn neg [ select-rotate ] with-side f ] } + { [ dup abs 2 = ] + [ sgn neg [ select-rotate ] with-side f ] } { [ drop t ] [ t ] } ! balance is -1 or 1, tree is taller } cond ; @@ -57,7 +62,8 @@ DEFER: avl-set 2dup node-key before? left right ? [ [ node-link avl-set ] keep swap >r tuck set-node-link r> - [ dup current-side get change-balance balance-insert ] [ f ] if + [ dup current-side get increase-balance balance-insert ] + [ f ] if ] with-side ; : (avl-set) ( value key node -- node taller? ) @@ -66,10 +72,10 @@ DEFER: avl-set ] [ avl-insert ] if ; : avl-set ( value key node -- node taller? ) - [ (avl-set) ] [ t ] if* ; + [ (avl-set) ] [ swap t ] if* ; M: avl set-at ( value key node -- node ) - [ avl-set drop ] change-root ; + [ avl-set drop ] change-root drop ; : delete-select-rotate ( node -- node shorter? ) dup node+link avl-node-balance zero? [ @@ -87,10 +93,10 @@ M: avl set-at ( value key node -- node ) } cond ; : balance-delete ( node -- node shorter? ) - current-side get over avl-node-balance { + current-side get over balance>> { { [ dup zero? ] [ drop neg over set-avl-node-balance f ] } - { [ dupd = ] [ drop 0 over set-avl-node-balance t ] } - [ dupd neg change-balance rebalance-delete ] + { [ dupd = ] [ drop 0 >>balance t ] } + [ dupd neg increase-balance rebalance-delete ] } cond ; : avl-replace-with-extremity ( to-replace node -- node shorter? ) @@ -135,12 +141,12 @@ M: avl-node avl-delete ( key node -- node shorter? deleted? ) ] if ; M: avl delete-at ( key node -- ) - [ avl-delete 2drop ] change-root ; + [ avl-delete 2drop ] change-root drop ; M: avl new-assoc 2drop ; : >avl ( assoc -- avl ) - T{ avl T{ tree f f 0 } } assoc-clone-like ; + T{ avl f f 0 } assoc-clone-like ; M: avl assoc-like drop dup avl? [ >avl ] unless ; diff --git a/extra/trees/splay/splay.factor b/extra/trees/splay/splay.factor old mode 100644 new mode 100755 index 8931db3a10..ef5fcf8ca6 --- a/extra/trees/splay/splay.factor +++ b/extra/trees/splay/splay.factor @@ -4,12 +4,10 @@ USING: arrays kernel math namespaces sequences assocs parser prettyprint.backend trees generic math.order ; IN: trees.splay -TUPLE: splay ; +TUPLE: splay < tree ; : ( -- tree ) - \ splay construct-tree ; - -INSTANCE: splay tree-mixin + \ splay new-tree ; : rotate-right ( node -- node ) dup node-left @@ -131,7 +129,7 @@ M: splay new-assoc 2drop ; : >splay ( assoc -- tree ) - T{ splay T{ tree f f 0 } } assoc-clone-like ; + T{ splay f f 0 } assoc-clone-like ; : SPLAY{ \ } [ >splay ] parse-literal ; parsing diff --git a/extra/trees/trees.factor b/extra/trees/trees.factor index 3cad81e447..3b0ab01666 100755 --- a/extra/trees/trees.factor +++ b/extra/trees/trees.factor @@ -5,23 +5,25 @@ prettyprint.private kernel.private assocs random combinators parser prettyprint.backend math.order accessors ; IN: trees -MIXIN: tree-mixin - TUPLE: tree root count ; +: new-tree ( class -- tree ) + new + f >>root + 0 >>count ; inline + : ( -- tree ) - f 0 tree boa ; + tree new-tree ; -: construct-tree ( class -- tree ) - new over set-delegate ; inline - -INSTANCE: tree tree-mixin - -INSTANCE: tree-mixin assoc +INSTANCE: tree assoc TUPLE: node key value left right ; + +: new-node ( key value class -- node ) + new swap >>value swap >>key ; + : ( key value -- node ) - f f node boa ; + node new-node ; SYMBOL: current-side @@ -57,9 +59,6 @@ SYMBOL: current-side : go-left ( quot -- ) left swap with-side ; inline : go-right ( quot -- ) right swap with-side ; inline -: change-root ( tree quot -- ) - swap [ root>> swap call ] keep set-tree-root ; inline - : leaf? ( node -- ? ) [ left>> ] [ right>> ] bi or not ; @@ -91,7 +90,7 @@ M: tree at* ( key tree -- value ? ) ] if ; M: tree set-at ( value key tree -- ) - [ [ node-set ] [ swap ] if* ] change-root ; + [ [ node-set ] [ swap ] if* ] change-root drop ; : valid-node? ( node -- ? ) [ @@ -117,10 +116,10 @@ M: tree set-at ( value key tree -- ) [ >r right>> r> find-node ] } cond ; inline -M: tree-mixin assoc-find ( tree quot -- key value ? ) +M: tree assoc-find ( tree quot -- key value ? ) >r root>> r> find-node ; -M: tree-mixin clear-assoc +M: tree clear-assoc 0 >>count f >>root drop ; @@ -182,7 +181,7 @@ DEFER: delete-node ] if ; M: tree delete-at - [ delete-bst-node ] change-root ; + [ delete-bst-node ] change-root drop ; M: tree new-assoc 2drop ; @@ -192,14 +191,12 @@ M: tree clone dup assoc-clone-like ; : >tree ( assoc -- tree ) T{ tree f f 0 } assoc-clone-like ; -M: tree-mixin assoc-like drop dup tree? [ >tree ] unless ; +M: tree assoc-like drop dup tree? [ >tree ] unless ; : TREE{ \ } [ >tree ] parse-literal ; parsing - + M: tree pprint-delims drop \ TREE{ \ } ; - -M: tree-mixin assoc-size count>> ; -M: tree-mixin clone dup assoc-clone-like ; -M: tree-mixin >pprint-sequence >alist ; -M: tree-mixin pprint-narrow? drop t ; +M: tree assoc-size count>> ; +M: tree >pprint-sequence >alist ; +M: tree pprint-narrow? drop t ; diff --git a/extra/tuple-syntax/tuple-syntax.factor b/extra/tuple-syntax/tuple-syntax.factor index 219df5197c..cf439f6407 100755 --- a/extra/tuple-syntax/tuple-syntax.factor +++ b/extra/tuple-syntax/tuple-syntax.factor @@ -7,7 +7,7 @@ IN: tuple-syntax : parse-slot-writer ( tuple -- slot# ) scan dup "}" = [ 2drop f ] [ - 1 head* swap object-slots slot-named slot-spec-offset + but-last swap object-slots slot-named slot-spec-offset ] if ; : parse-slots ( accum tuple -- accum tuple ) diff --git a/extra/ui/gadgets/gadgets-tests.factor b/extra/ui/gadgets/gadgets-tests.factor index dbe06ec8cd..f88b207603 100755 --- a/extra/ui/gadgets/gadgets-tests.factor +++ b/extra/ui/gadgets/gadgets-tests.factor @@ -124,7 +124,7 @@ M: mock-gadget ungraft* dup mock-gadget-ungraft-called 1+ swap set-mock-gadget-ungraft-called ; -! We can't print to stdio here because that might be a pane +! We can't print to output-stream here because that might be a pane ! stream, and our graft-queue rebinding here would be captured ! by code adding children to the pane... [ diff --git a/extra/ui/gadgets/panes/panes-docs.factor b/extra/ui/gadgets/panes/panes-docs.factor index a684153b98..99f8b2e82a 100755 --- a/extra/ui/gadgets/panes/panes-docs.factor +++ b/extra/ui/gadgets/panes/panes-docs.factor @@ -23,7 +23,7 @@ HELP: print-gadget HELP: gadget. { $values { "gadget" gadget } } -{ $description "Writes a gadget followed by a newline to the " { $link stdio } " stream." } +{ $description "Writes a gadget followed by a newline to " { $link output-stream } "." } { $notes "Not all streams support this operation." } ; HELP: ?nl @@ -32,11 +32,11 @@ HELP: ?nl HELP: with-pane { $values { "pane" pane } { "quot" quotation } } -{ $description "Clears the pane and calls the quotation in a new scope where " { $link stdio } " is rebound to a " { $link pane-stream } " writing to the pane." } ; +{ $description "Clears the pane and calls the quotation in a new scope where " { $link output-stream } " is rebound to a " { $link pane-stream } " writing to the pane." } ; HELP: make-pane { $values { "quot" quotation } { "gadget" "a new " { $link gadget } } } -{ $description "Calls the quotation in a new scope where " { $link stdio } " is rebound to a " { $link pane-stream } " writing to a new pane. The output area of the new pane is output on the stack after the quotation returns. The pane itself is not output." } ; +{ $description "Calls the quotation in a new scope where " { $link output-stream } " is rebound to a " { $link pane-stream } " writing to a new pane. The output area of the new pane is output on the stack after the quotation returns. The pane itself is not output." } ; HELP: { $values { "pane" "a new " { $link pane } } } diff --git a/extra/ui/gadgets/panes/panes-tests.factor b/extra/ui/gadgets/panes/panes-tests.factor index 0263b15d71..31bb4233bf 100755 --- a/extra/ui/gadgets/panes/panes-tests.factor +++ b/extra/ui/gadgets/panes/panes-tests.factor @@ -11,7 +11,7 @@ help.stylesheet splitting tools.test.ui models math inspector ; [ ] [ #children "num-children" set ] unit-test [ ] [ - "pane" get [ 10000 [ . ] each ] with-stream* + "pane" get [ 10000 [ . ] each ] with-output-stream* ] unit-test [ t ] [ #children "num-children" get = ] unit-test diff --git a/extra/ui/gadgets/panes/panes.factor b/extra/ui/gadgets/panes/panes.factor index bff0ca10ad..533a6c42b7 100755 --- a/extra/ui/gadgets/panes/panes.factor +++ b/extra/ui/gadgets/panes/panes.factor @@ -6,7 +6,7 @@ ui.gadgets.paragraphs ui.gadgets.incremental ui.gadgets.packs ui.gadgets.theme ui.clipboards ui.gestures ui.traverse ui.render hashtables io kernel namespaces sequences io.styles strings quotations math opengl combinators math.vectors -io.streams.duplex sorting splitting io.streams.nested assocs +sorting splitting io.streams.nested assocs ui.gadgets.presentations ui.gadgets.slots ui.gadgets.grids ui.gadgets.grid-lines classes.tuple models continuations ; IN: ui.gadgets.panes @@ -113,14 +113,11 @@ GENERIC: write-gadget ( gadget stream -- ) M: pane-stream write-gadget pane-stream-pane pane-current add-gadget ; -M: duplex-stream write-gadget - duplex-stream-out write-gadget ; - : print-gadget ( gadget stream -- ) tuck write-gadget stream-nl ; : gadget. ( gadget -- ) - stdio get print-gadget ; + output-stream get print-gadget ; : ?nl ( stream -- ) dup pane-stream-pane pane-current gadget-children empty? @@ -129,7 +126,7 @@ M: duplex-stream write-gadget : with-pane ( pane quot -- ) over scroll>top over pane-clear >r r> - over >r with-stream* r> ?nl ; inline + over >r with-output-stream* r> ?nl ; inline : make-pane ( quot -- gadget ) [ swap with-pane ] keep smash-pane ; inline diff --git a/extra/ui/gestures/gestures.factor b/extra/ui/gestures/gestures.factor index 0970bd6027..5bba095253 100755 --- a/extra/ui/gestures/gestures.factor +++ b/extra/ui/gestures/gestures.factor @@ -54,7 +54,7 @@ TUPLE: zoom-in-action ; C: zoom-in-action TUPLE: zoom-out-action ; C: zoom-out-action : generalize-gesture ( gesture -- newgesture ) - tuple>array 1 head* >tuple ; + tuple>array but-last >tuple ; ! Modifiers SYMBOLS: C+ A+ M+ S+ ; @@ -111,7 +111,8 @@ SYMBOL: double-click-timeout ] if ; : drag-gesture ( -- ) - hand-buttons get-global first button-gesture ; + hand-buttons get-global + dup empty? [ drop ] [ first button-gesture ] if ; SYMBOL: drag-timer diff --git a/extra/ui/tools/interactor/interactor-tests.factor b/extra/ui/tools/interactor/interactor-tests.factor index 99c005451d..f8d5e33df9 100755 --- a/extra/ui/tools/interactor/interactor-tests.factor +++ b/extra/ui/tools/interactor/interactor-tests.factor @@ -1,18 +1,21 @@ IN: ui.tools.interactor.tests USING: ui.tools.interactor ui.gadgets.panes namespaces ui.gadgets.editors concurrency.promises threads listener -tools.test kernel calendar parser ; +tools.test kernel calendar parser accessors ; + +\ must-infer [ - \ must-infer - [ ] [ "interactor" set ] unit-test + [ ] [ "interactor" get register-self ] unit-test + [ ] [ "[ 1 2 3" "interactor" get set-editor-string ] unit-test [ ] [ "promise" set ] unit-test [ + self "interactor" get (>>thread) "interactor" get stream-read-quot "promise" get fulfill ] "Interactor test" spawn drop @@ -27,3 +30,14 @@ tools.test kernel calendar parser ; [ [ [ 1 2 3 ] ] ] [ "promise" get 5 seconds ?promise-timeout ] unit-test ] with-interactive-vocabs + +! Hang +[ ] [ "interactor" set ] unit-test + +[ ] [ [ "interactor" get stream-read-quot drop ] "A" spawn drop ] unit-test + +[ ] [ [ "interactor" get stream-read-quot drop ] "B" spawn drop ] unit-test + +[ ] [ 1000 sleep ] unit-test + +[ ] [ "interactor" get interactor-eof ] unit-test diff --git a/extra/ui/tools/interactor/interactor.factor b/extra/ui/tools/interactor/interactor.factor index 6c8b77d1f2..2e59363531 100755 --- a/extra/ui/tools/interactor/interactor.factor +++ b/extra/ui/tools/interactor/interactor.factor @@ -1,53 +1,55 @@ ! Copyright (C) 2006, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays assocs combinators continuations documents - hashtables io io.styles kernel math -math.vectors models namespaces parser prettyprint quotations -sequences strings threads listener -classes.tuple ui.commands ui.gadgets ui.gadgets.editors -ui.gadgets.presentations ui.gadgets.worlds ui.gestures -definitions boxes calendar concurrency.flags ui.tools.workspace -accessors math.order ; +hashtables io io.styles kernel math math.order math.vectors +models namespaces parser prettyprint quotations sequences +strings threads listener classes.tuple ui.commands ui.gadgets +ui.gadgets.editors ui.gadgets.presentations ui.gadgets.worlds +ui.gestures definitions calendar concurrency.flags +concurrency.mailboxes ui.tools.workspace accessors ; IN: ui.tools.interactor -TUPLE: interactor history output flag thread help ; +! If waiting is t, we're waiting for user input, and invoking +! evaluate-input resumes the thread. +TUPLE: interactor output history flag mailbox thread waiting help ; + +: register-self ( interactor -- ) + >>mailbox + self >>thread + drop ; : interactor-continuation ( interactor -- continuation ) - interactor-thread box-value - thread-continuation box-value ; + thread>> continuation>> value>> ; : interactor-busy? ( interactor -- ? ) - interactor-thread box-full? not ; + #! We're busy if there's no thread to resume. + [ waiting>> ] + [ thread>> dup [ thread-registered? ] when ] + bi and not ; : interactor-use ( interactor -- seq ) dup interactor-busy? [ drop f ] [ use swap - interactor-continuation continuation-name + interactor-continuation name>> assoc-stack ] if ; -: init-caret-help ( interactor -- ) - dup editor-caret 1/3 seconds - swap set-interactor-help ; - -: init-interactor-history ( interactor -- ) - V{ } clone swap set-interactor-history ; - -: init-interactor-state ( interactor -- ) - over set-interactor-flag - swap set-interactor-thread ; +: ( interactor -- model ) + editor-caret 1/3 seconds ; : ( output -- gadget ) interactor construct-editor - tuck set-interactor-output - dup init-interactor-history - dup init-interactor-state - dup init-caret-help ; + V{ } clone >>history + >>flag + dup >>help + swap >>output ; M: interactor graft* - dup delegate graft* - dup interactor-help add-connection ; + [ delegate graft* ] [ dup help>> add-connection ] bi ; + +M: interactor ungraft* + [ dup help>> remove-connection ] [ delegate ungraft ] bi ; : word-at-loc ( loc interactor -- word ) over [ @@ -58,7 +60,7 @@ M: interactor graft* ] if ; M: interactor model-changed - 2dup interactor-help eq? [ + 2dup help>> eq? [ swap model-value over word-at-loc swap show-summary ] [ delegate model-changed @@ -69,15 +71,15 @@ M: interactor model-changed [ H{ { font-style bold } } format ] with-nesting ; : interactor-input. ( string interactor -- ) - interactor-output [ + output>> [ dup string? [ dup write-input nl ] [ short. ] if - ] with-stream* ; + ] with-output-stream* ; : add-interactor-history ( str interactor -- ) over empty? [ 2drop ] [ interactor-history push-new ] if ; : interactor-continue ( obj interactor -- ) - interactor-thread box> resume-with ; + mailbox>> mailbox-put ; : clear-input ( interactor -- ) gadget-model clear-doc ; @@ -99,13 +101,17 @@ M: interactor model-changed ] unless drop ; : interactor-yield ( interactor -- obj ) - [ - [ interactor-thread >box ] keep - interactor-flag raise-flag - ] curry "input" suspend ; + dup thread>> self eq? [ + { + [ t >>waiting drop ] + [ flag>> raise-flag ] + [ mailbox>> mailbox-get ] + [ f >>waiting drop ] + } cleave + ] [ drop f ] if ; M: interactor stream-readln - [ interactor-yield ] keep interactor-finish + [ interactor-yield ] [ interactor-finish ] bi dup [ first ] when ; : interactor-call ( quot interactor -- ) @@ -161,7 +167,8 @@ M: interactor stream-read-quot } cond ; M: interactor pref-dim* - 0 over line-height 4 * 2array swap delegate pref-dim* vmax ; + [ line-height 4 * 0 swap 2array ] [ delegate pref-dim* ] bi + vmax ; interactor "interactor" f { { T{ key-down f f "RET" } evaluate-input } diff --git a/extra/ui/tools/listener/listener-tests.factor b/extra/ui/tools/listener/listener-tests.factor index cc218533d8..2fae62a8fc 100755 --- a/extra/ui/tools/listener/listener-tests.factor +++ b/extra/ui/tools/listener/listener-tests.factor @@ -2,7 +2,7 @@ USING: continuations documents ui.tools.interactor ui.tools.listener hashtables kernel namespaces parser sequences tools.test ui.commands ui.gadgets ui.gadgets.editors ui.gadgets.panes vocabs words tools.test.ui slots.private -threads arrays generic ; +threads arrays generic threads accessors listener ; IN: ui.tools.listener.tests [ f ] [ "word" source-editor command-map empty? ] unit-test @@ -15,7 +15,7 @@ IN: ui.tools.listener.tests [ "dup" ] [ \ dup word-completion-string ] unit-test - + [ "equal?" ] [ \ array \ equal? method word-completion-string ] unit-test @@ -28,9 +28,26 @@ IN: ui.tools.listener.tests [ ] [ "i" get [ { "SYMBOL:" } parse-lines ] [ go-to-error ] recover ] unit-test - + [ t ] [ "i" get gadget-model doc-end "i" get editor-caret* = ] unit-test + + ! Race condition discovered by SimonRC + [ ] [ + [ + "listener" get input>> + [ stream-read-quot drop ] + [ stream-read-quot drop ] bi + ] "OH, HAI" spawn drop + ] unit-test + + [ ] [ "listener" get clear-output ] unit-test + + [ ] [ "listener" get restart-listener ] unit-test + + [ ] [ 1000 sleep ] unit-test + + [ ] [ "listener" get com-end ] unit-test ] with-grafted-gadget diff --git a/extra/ui/tools/listener/listener.factor b/extra/ui/tools/listener/listener.factor index d96270075f..48800c0918 100755 --- a/extra/ui/tools/listener/listener.factor +++ b/extra/ui/tools/listener/listener.factor @@ -1,13 +1,13 @@ ! Copyright (C) 2005, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: inspector ui.tools.interactor ui.tools.inspector -ui.tools.workspace help.markup io io.streams.duplex io.styles +ui.tools.workspace help.markup io io.styles kernel models namespaces parser quotations sequences ui.commands ui.gadgets ui.gadgets.editors ui.gadgets.labelled ui.gadgets.panes ui.gadgets.buttons ui.gadgets.scrollers ui.gadgets.tracks ui.gestures ui.operations vocabs words prettyprint listener debugger threads boxes concurrency.flags -math arrays generic accessors combinators ; +math arrays generic accessors combinators assocs ; IN: ui.tools.listener TUPLE: listener-gadget input output stack ; @@ -16,13 +16,11 @@ TUPLE: listener-gadget input output stack ; g-> set-listener-gadget-output "Output" 1 track, ; -: listener-stream ( listener -- stream ) - dup listener-gadget-input - swap listener-gadget-output - ; +: listener-streams ( listener -- input output ) + [ input>> ] [ output>> ] bi ; : ( listener -- gadget ) - listener-gadget-output ; + output>> ; : listener-input, ( -- ) g g-> set-listener-gadget-input @@ -34,31 +32,29 @@ TUPLE: listener-gadget input output stack ; "cookbook" ($link) "." print nl ; M: listener-gadget focusable-child* - listener-gadget-input ; + input>> ; M: listener-gadget call-tool* ( input listener -- ) - >r input-string r> listener-gadget-input set-editor-string ; + >r string>> r> input>> set-editor-string ; M: listener-gadget tool-scroller - listener-gadget-output find-scroller ; + output>> find-scroller ; : wait-for-listener ( listener -- ) #! Wait for the listener to start. - listener-gadget-input interactor-flag wait-for-flag ; + input>> flag>> wait-for-flag ; : workspace-busy? ( workspace -- ? ) - workspace-listener listener-gadget-input interactor-busy? ; + listener>> input>> interactor-busy? ; : listener-input ( string -- ) - get-workspace - workspace-listener - listener-gadget-input set-editor-string ; + get-workspace listener>> input>> set-editor-string ; : (call-listener) ( quot listener -- ) - listener-gadget-input interactor-call ; + input>> interactor-call ; : call-listener ( quot -- ) - [ workspace-busy? not ] get-workspace* workspace-listener + [ workspace-busy? not ] get-workspace* listener>> [ dup wait-for-listener (call-listener) ] 2curry "Listener call" spawn drop ; @@ -70,8 +66,7 @@ M: listener-operation invoke-command ( target command -- ) : eval-listener ( string -- ) get-workspace - workspace-listener - listener-gadget-input [ set-editor-string ] keep + listener>> input>> [ set-editor-string ] keep evaluate-input ; : listener-run-files ( seq -- ) @@ -82,10 +77,10 @@ M: listener-operation invoke-command ( target command -- ) ] if ; : com-end ( listener -- ) - listener-gadget-input interactor-eof ; + input>> interactor-eof ; : clear-output ( listener -- ) - listener-gadget-output pane-clear ; + output>> pane-clear ; \ clear-output H{ { +listener+ t } } define-command @@ -106,12 +101,11 @@ M: engine-word word-completion-string "engine-generic" word-prop word-completion-string ; : use-if-necessary ( word seq -- ) - >r word-vocabulary vocab-words r> - { - { [ dup not ] [ 2drop ] } - { [ 2dup memq? ] [ 2drop ] } - [ push ] - } cond ; + over word-vocabulary [ + 2dup assoc-stack pick = [ 2drop ] [ + >r word-vocabulary vocab-words r> push + ] if + ] [ 2drop ] if ; : insert-word ( word -- ) get-workspace workspace-listener input>> @@ -130,7 +124,7 @@ TUPLE: stack-display ; stack-display new g workspace-listener swap [ dup f track, - listener-gadget-stack [ stack. ] + stack>> [ [ stack. ] curry try ] t "Data stack" 1 track, ] { 0 1 } build-track ; @@ -148,22 +142,27 @@ M: stack-display tool-scroller swap show-tool inspect-object ; : listener-thread ( listener -- ) - dup listener-stream [ - dup [ ui-listener-hook ] curry listener-hook set - dup [ ui-error-hook ] curry error-hook set - [ ui-inspector-hook ] curry inspector-hook set + dup listener-streams [ + [ [ ui-listener-hook ] curry listener-hook set ] + [ [ ui-error-hook ] curry error-hook set ] + [ [ ui-inspector-hook ] curry inspector-hook set ] tri welcome. listener - ] with-stream* ; + ] with-streams* ; : start-listener-thread ( listener -- ) - [ listener-thread ] curry "Listener" spawn drop ; + [ + [ input>> register-self ] [ listener-thread ] bi + ] curry "Listener" spawn drop ; : restart-listener ( listener -- ) #! Returns when listener is ready to receive input. - dup com-end dup clear-output - dup start-listener-thread - wait-for-listener ; + { + [ com-end ] + [ clear-output ] + [ start-listener-thread ] + [ wait-for-listener ] + } cleave ; : init-listener ( listener -- ) f swap set-listener-gadget-stack ; @@ -189,10 +188,7 @@ M: listener-gadget handle-gesture* ( gadget gesture delegate -- ? ) [ default-gesture-handler ] [ 3drop f ] if ; M: listener-gadget graft* - dup delegate graft* - dup listener-gadget-input interactor-thread ?box 2drop - restart-listener ; + [ delegate graft* ] [ restart-listener ] bi ; M: listener-gadget ungraft* - dup com-end - delegate ungraft* ; + [ com-end ] [ delegate ungraft* ] bi ; diff --git a/extra/unicode/breaks/breaks.factor b/extra/unicode/breaks/breaks.factor index d8e4f8c24e..9635a62e49 100644 --- a/extra/unicode/breaks/breaks.factor +++ b/extra/unicode/breaks/breaks.factor @@ -30,7 +30,7 @@ CATEGORY: grapheme-control Zl Zp Cc Cf ; concat [ dup ] H{ } map>assoc ; : other-extend-lines ( -- lines ) - "extra/unicode/PropList.txt" resource-path ascii file-lines ; + "resource:extra/unicode/PropList.txt" ascii file-lines ; VALUE: other-extend @@ -105,9 +105,6 @@ VALUE: grapheme-table : string-reverse ( str -- rts ) >graphemes reverse concat ; -: unclip-last-slice ( seq -- beginning last ) - dup 1 head-slice* swap peek ; - : last-grapheme ( str -- i ) unclip-last-slice grapheme-class swap [ grapheme-class dup rot grapheme-break? ] find-last-index ?1+ nip ; diff --git a/extra/unicode/data/data.factor b/extra/unicode/data/data.factor index 85ce50acb9..f33338137a 100755 --- a/extra/unicode/data/data.factor +++ b/extra/unicode/data/data.factor @@ -14,7 +14,7 @@ IN: unicode.data ascii file-lines [ ";" split ] map ; : load-data ( -- data ) - "extra/unicode/UnicodeData.txt" resource-path data ; + "resource:extra/unicode/UnicodeData.txt" data ; : (process-data) ( index data -- newdata ) [ [ nth ] keep first swap 2array ] with map @@ -120,7 +120,7 @@ VALUE: special-casing ! Special casing data : load-special-casing ( -- special-casing ) - "extra/unicode/SpecialCasing.txt" resource-path data + "resource:extra/unicode/SpecialCasing.txt" data [ length 5 = ] filter [ [ set-code-point ] each ] H{ } make-assoc ; diff --git a/extra/unicode/script/Scripts.txt b/extra/unicode/script/Scripts.txt new file mode 100755 index 0000000000..7065486d3a --- /dev/null +++ b/extra/unicode/script/Scripts.txt @@ -0,0 +1,1747 @@ +# Scripts-5.1.0.txt +# Date: 2008-03-20, 17:55:33 GMT [MD] +# +# Unicode Character Database +# Copyright (c) 1991-2008 Unicode, Inc. +# For terms of use, see http://www.unicode.org/terms_of_use.html +# For documentation, see UCD.html + +# ================================================ + +# Property: Script + +# All code points not explicitly listed for Script +# have the value Unknown (Zzzz). + +# @missing: 0000..10FFFF; Unknown + +# ================================================ + +0000..001F ; Common # Cc [32] .. +0020 ; Common # Zs SPACE +0021..0023 ; Common # Po [3] EXCLAMATION MARK..NUMBER SIGN +0024 ; Common # Sc DOLLAR SIGN +0025..0027 ; Common # Po [3] PERCENT SIGN..APOSTROPHE +0028 ; Common # Ps LEFT PARENTHESIS +0029 ; Common # Pe RIGHT PARENTHESIS +002A ; Common # Po ASTERISK +002B ; Common # Sm PLUS SIGN +002C ; Common # Po COMMA +002D ; Common # Pd HYPHEN-MINUS +002E..002F ; Common # Po [2] FULL STOP..SOLIDUS +0030..0039 ; Common # Nd [10] DIGIT ZERO..DIGIT NINE +003A..003B ; Common # Po [2] COLON..SEMICOLON +003C..003E ; Common # Sm [3] LESS-THAN SIGN..GREATER-THAN SIGN +003F..0040 ; Common # Po [2] QUESTION MARK..COMMERCIAL AT +005B ; Common # Ps LEFT SQUARE BRACKET +005C ; Common # Po REVERSE SOLIDUS +005D ; Common # Pe RIGHT SQUARE BRACKET +005E ; Common # Sk CIRCUMFLEX ACCENT +005F ; Common # Pc LOW LINE +0060 ; Common # Sk GRAVE ACCENT +007B ; Common # Ps LEFT CURLY BRACKET +007C ; Common # Sm VERTICAL LINE +007D ; Common # Pe RIGHT CURLY BRACKET +007E ; Common # Sm TILDE +007F..009F ; Common # Cc [33] .. +00A0 ; Common # Zs NO-BREAK SPACE +00A1 ; Common # Po INVERTED EXCLAMATION MARK +00A2..00A5 ; Common # Sc [4] CENT SIGN..YEN SIGN +00A6..00A7 ; Common # So [2] BROKEN BAR..SECTION SIGN +00A8 ; Common # Sk DIAERESIS +00A9 ; Common # So COPYRIGHT SIGN +00AB ; Common # Pi LEFT-POINTING DOUBLE ANGLE QUOTATION MARK +00AC ; Common # Sm NOT SIGN +00AD ; Common # Cf SOFT HYPHEN +00AE ; Common # So REGISTERED SIGN +00AF ; Common # Sk MACRON +00B0 ; Common # So DEGREE SIGN +00B1 ; Common # Sm PLUS-MINUS SIGN +00B2..00B3 ; Common # No [2] SUPERSCRIPT TWO..SUPERSCRIPT THREE +00B4 ; Common # Sk ACUTE ACCENT +00B5 ; Common # L& MICRO SIGN +00B6 ; Common # So PILCROW SIGN +00B7 ; Common # Po MIDDLE DOT +00B8 ; Common # Sk CEDILLA +00B9 ; Common # No SUPERSCRIPT ONE +00BB ; Common # Pf RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK +00BC..00BE ; Common # No [3] VULGAR FRACTION ONE QUARTER..VULGAR FRACTION THREE QUARTERS +00BF ; Common # Po INVERTED QUESTION MARK +00D7 ; Common # Sm MULTIPLICATION SIGN +00F7 ; Common # Sm DIVISION SIGN +02B9..02C1 ; Common # Lm [9] MODIFIER LETTER PRIME..MODIFIER LETTER REVERSED GLOTTAL STOP +02C2..02C5 ; Common # Sk [4] MODIFIER LETTER LEFT ARROWHEAD..MODIFIER LETTER DOWN ARROWHEAD +02C6..02D1 ; Common # Lm [12] MODIFIER LETTER CIRCUMFLEX ACCENT..MODIFIER LETTER HALF TRIANGULAR COLON +02D2..02DF ; Common # Sk [14] MODIFIER LETTER CENTRED RIGHT HALF RING..MODIFIER LETTER CROSS ACCENT +02E5..02EB ; Common # Sk [7] MODIFIER LETTER EXTRA-HIGH TONE BAR..MODIFIER LETTER YANG DEPARTING TONE MARK +02EC ; Common # Lm MODIFIER LETTER VOICING +02ED ; Common # Sk MODIFIER LETTER UNASPIRATED +02EE ; Common # Lm MODIFIER LETTER DOUBLE APOSTROPHE +02EF..02FF ; Common # Sk [17] MODIFIER LETTER LOW DOWN ARROWHEAD..MODIFIER LETTER LOW LEFT ARROW +0374 ; Common # Lm GREEK NUMERAL SIGN +037E ; Common # Po GREEK QUESTION MARK +0385 ; Common # Sk GREEK DIALYTIKA TONOS +0387 ; Common # Po GREEK ANO TELEIA +0589 ; Common # Po ARMENIAN FULL STOP +0600..0603 ; Common # Cf [4] ARABIC NUMBER SIGN..ARABIC SIGN SAFHA +060C ; Common # Po ARABIC COMMA +061B ; Common # Po ARABIC SEMICOLON +061F ; Common # Po ARABIC QUESTION MARK +0640 ; Common # Lm ARABIC TATWEEL +0660..0669 ; Common # Nd [10] ARABIC-INDIC DIGIT ZERO..ARABIC-INDIC DIGIT NINE +06DD ; Common # Cf ARABIC END OF AYAH +0964..0965 ; Common # Po [2] DEVANAGARI DANDA..DEVANAGARI DOUBLE DANDA +0970 ; Common # Po DEVANAGARI ABBREVIATION SIGN +0CF1..0CF2 ; Common # So [2] KANNADA SIGN JIHVAMULIYA..KANNADA SIGN UPADHMANIYA +0E3F ; Common # Sc THAI CURRENCY SYMBOL BAHT +10FB ; Common # Po GEORGIAN PARAGRAPH SEPARATOR +16EB..16ED ; Common # Po [3] RUNIC SINGLE PUNCTUATION..RUNIC CROSS PUNCTUATION +1735..1736 ; Common # Po [2] PHILIPPINE SINGLE PUNCTUATION..PHILIPPINE DOUBLE PUNCTUATION +1802..1803 ; Common # Po [2] MONGOLIAN COMMA..MONGOLIAN FULL STOP +1805 ; Common # Po MONGOLIAN FOUR DOTS +2000..200A ; Common # Zs [11] EN QUAD..HAIR SPACE +200B ; Common # Cf ZERO WIDTH SPACE +200E..200F ; Common # Cf [2] LEFT-TO-RIGHT MARK..RIGHT-TO-LEFT MARK +2010..2015 ; Common # Pd [6] HYPHEN..HORIZONTAL BAR +2016..2017 ; Common # Po [2] DOUBLE VERTICAL LINE..DOUBLE LOW LINE +2018 ; Common # Pi LEFT SINGLE QUOTATION MARK +2019 ; Common # Pf RIGHT SINGLE QUOTATION MARK +201A ; Common # Ps SINGLE LOW-9 QUOTATION MARK +201B..201C ; Common # Pi [2] SINGLE HIGH-REVERSED-9 QUOTATION MARK..LEFT DOUBLE QUOTATION MARK +201D ; Common # Pf RIGHT DOUBLE QUOTATION MARK +201E ; Common # Ps DOUBLE LOW-9 QUOTATION MARK +201F ; Common # Pi DOUBLE HIGH-REVERSED-9 QUOTATION MARK +2020..2027 ; Common # Po [8] DAGGER..HYPHENATION POINT +2028 ; Common # Zl LINE SEPARATOR +2029 ; Common # Zp PARAGRAPH SEPARATOR +202A..202E ; Common # Cf [5] LEFT-TO-RIGHT EMBEDDING..RIGHT-TO-LEFT OVERRIDE +202F ; Common # Zs NARROW NO-BREAK SPACE +2030..2038 ; Common # Po [9] PER MILLE SIGN..CARET +2039 ; Common # Pi SINGLE LEFT-POINTING ANGLE QUOTATION MARK +203A ; Common # Pf SINGLE RIGHT-POINTING ANGLE QUOTATION MARK +203B..203E ; Common # Po [4] REFERENCE MARK..OVERLINE +203F..2040 ; Common # Pc [2] UNDERTIE..CHARACTER TIE +2041..2043 ; Common # Po [3] CARET INSERTION POINT..HYPHEN BULLET +2044 ; Common # Sm FRACTION SLASH +2045 ; Common # Ps LEFT SQUARE BRACKET WITH QUILL +2046 ; Common # Pe RIGHT SQUARE BRACKET WITH QUILL +2047..2051 ; Common # Po [11] DOUBLE QUESTION MARK..TWO ASTERISKS ALIGNED VERTICALLY +2052 ; Common # Sm COMMERCIAL MINUS SIGN +2053 ; Common # Po SWUNG DASH +2054 ; Common # Pc INVERTED UNDERTIE +2055..205E ; Common # Po [10] FLOWER PUNCTUATION MARK..VERTICAL FOUR DOTS +205F ; Common # Zs MEDIUM MATHEMATICAL SPACE +2060..2064 ; Common # Cf [5] WORD JOINER..INVISIBLE PLUS +206A..206F ; Common # Cf [6] INHIBIT SYMMETRIC SWAPPING..NOMINAL DIGIT SHAPES +2070 ; Common # No SUPERSCRIPT ZERO +2074..2079 ; Common # No [6] SUPERSCRIPT FOUR..SUPERSCRIPT NINE +207A..207C ; Common # Sm [3] SUPERSCRIPT PLUS SIGN..SUPERSCRIPT EQUALS SIGN +207D ; Common # Ps SUPERSCRIPT LEFT PARENTHESIS +207E ; Common # Pe SUPERSCRIPT RIGHT PARENTHESIS +2080..2089 ; Common # No [10] SUBSCRIPT ZERO..SUBSCRIPT NINE +208A..208C ; Common # Sm [3] SUBSCRIPT PLUS SIGN..SUBSCRIPT EQUALS SIGN +208D ; Common # Ps SUBSCRIPT LEFT PARENTHESIS +208E ; Common # Pe SUBSCRIPT RIGHT PARENTHESIS +20A0..20B5 ; Common # Sc [22] EURO-CURRENCY SIGN..CEDI SIGN +2100..2101 ; Common # So [2] ACCOUNT OF..ADDRESSED TO THE SUBJECT +2102 ; Common # L& DOUBLE-STRUCK CAPITAL C +2103..2106 ; Common # So [4] DEGREE CELSIUS..CADA UNA +2107 ; Common # L& EULER CONSTANT +2108..2109 ; Common # So [2] SCRUPLE..DEGREE FAHRENHEIT +210A..2113 ; Common # L& [10] SCRIPT SMALL G..SCRIPT SMALL L +2114 ; Common # So L B BAR SYMBOL +2115 ; Common # L& DOUBLE-STRUCK CAPITAL N +2116..2118 ; Common # So [3] NUMERO SIGN..SCRIPT CAPITAL P +2119..211D ; Common # L& [5] DOUBLE-STRUCK CAPITAL P..DOUBLE-STRUCK CAPITAL R +211E..2123 ; Common # So [6] PRESCRIPTION TAKE..VERSICLE +2124 ; Common # L& DOUBLE-STRUCK CAPITAL Z +2125 ; Common # So OUNCE SIGN +2127 ; Common # So INVERTED OHM SIGN +2128 ; Common # L& BLACK-LETTER CAPITAL Z +2129 ; Common # So TURNED GREEK SMALL LETTER IOTA +212C..212D ; Common # L& [2] SCRIPT CAPITAL B..BLACK-LETTER CAPITAL C +212E ; Common # So ESTIMATED SYMBOL +212F..2131 ; Common # L& [3] SCRIPT SMALL E..SCRIPT CAPITAL F +2133..2134 ; Common # L& [2] SCRIPT CAPITAL M..SCRIPT SMALL O +2135..2138 ; Common # Lo [4] ALEF SYMBOL..DALET SYMBOL +2139 ; Common # L& INFORMATION SOURCE +213A..213B ; Common # So [2] ROTATED CAPITAL Q..FACSIMILE SIGN +213C..213F ; Common # L& [4] DOUBLE-STRUCK SMALL PI..DOUBLE-STRUCK CAPITAL PI +2140..2144 ; Common # Sm [5] DOUBLE-STRUCK N-ARY SUMMATION..TURNED SANS-SERIF CAPITAL Y +2145..2149 ; Common # L& [5] DOUBLE-STRUCK ITALIC CAPITAL D..DOUBLE-STRUCK ITALIC SMALL J +214A ; Common # So PROPERTY LINE +214B ; Common # Sm TURNED AMPERSAND +214C..214D ; Common # So [2] PER SIGN..AKTIESELSKAB +214F ; Common # So SYMBOL FOR SAMARITAN SOURCE +2153..215F ; Common # No [13] VULGAR FRACTION ONE THIRD..FRACTION NUMERATOR ONE +2190..2194 ; Common # Sm [5] LEFTWARDS ARROW..LEFT RIGHT ARROW +2195..2199 ; Common # So [5] UP DOWN ARROW..SOUTH WEST ARROW +219A..219B ; Common # Sm [2] LEFTWARDS ARROW WITH STROKE..RIGHTWARDS ARROW WITH STROKE +219C..219F ; Common # So [4] LEFTWARDS WAVE ARROW..UPWARDS TWO HEADED ARROW +21A0 ; Common # Sm RIGHTWARDS TWO HEADED ARROW +21A1..21A2 ; Common # So [2] DOWNWARDS TWO HEADED ARROW..LEFTWARDS ARROW WITH TAIL +21A3 ; Common # Sm RIGHTWARDS ARROW WITH TAIL +21A4..21A5 ; Common # So [2] LEFTWARDS ARROW FROM BAR..UPWARDS ARROW FROM BAR +21A6 ; Common # Sm RIGHTWARDS ARROW FROM BAR +21A7..21AD ; Common # So [7] DOWNWARDS ARROW FROM BAR..LEFT RIGHT WAVE ARROW +21AE ; Common # Sm LEFT RIGHT ARROW WITH STROKE +21AF..21CD ; Common # So [31] DOWNWARDS ZIGZAG ARROW..LEFTWARDS DOUBLE ARROW WITH STROKE +21CE..21CF ; Common # Sm [2] LEFT RIGHT DOUBLE ARROW WITH STROKE..RIGHTWARDS DOUBLE ARROW WITH STROKE +21D0..21D1 ; Common # So [2] LEFTWARDS DOUBLE ARROW..UPWARDS DOUBLE ARROW +21D2 ; Common # Sm RIGHTWARDS DOUBLE ARROW +21D3 ; Common # So DOWNWARDS DOUBLE ARROW +21D4 ; Common # Sm LEFT RIGHT DOUBLE ARROW +21D5..21F3 ; Common # So [31] UP DOWN DOUBLE ARROW..UP DOWN WHITE ARROW +21F4..22FF ; Common # Sm [268] RIGHT ARROW WITH SMALL CIRCLE..Z NOTATION BAG MEMBERSHIP +2300..2307 ; Common # So [8] DIAMETER SIGN..WAVY LINE +2308..230B ; Common # Sm [4] LEFT CEILING..RIGHT FLOOR +230C..231F ; Common # So [20] BOTTOM RIGHT CROP..BOTTOM RIGHT CORNER +2320..2321 ; Common # Sm [2] TOP HALF INTEGRAL..BOTTOM HALF INTEGRAL +2322..2328 ; Common # So [7] FROWN..KEYBOARD +2329 ; Common # Ps LEFT-POINTING ANGLE BRACKET +232A ; Common # Pe RIGHT-POINTING ANGLE BRACKET +232B..237B ; Common # So [81] ERASE TO THE LEFT..NOT CHECK MARK +237C ; Common # Sm RIGHT ANGLE WITH DOWNWARDS ZIGZAG ARROW +237D..239A ; Common # So [30] SHOULDERED OPEN BOX..CLEAR SCREEN SYMBOL +239B..23B3 ; Common # Sm [25] LEFT PARENTHESIS UPPER HOOK..SUMMATION BOTTOM +23B4..23DB ; Common # So [40] TOP SQUARE BRACKET..FUSE +23DC..23E1 ; Common # Sm [6] TOP PARENTHESIS..BOTTOM TORTOISE SHELL BRACKET +23E2..23E7 ; Common # So [6] WHITE TRAPEZIUM..ELECTRICAL INTERSECTION +2400..2426 ; Common # So [39] SYMBOL FOR NULL..SYMBOL FOR SUBSTITUTE FORM TWO +2440..244A ; Common # So [11] OCR HOOK..OCR DOUBLE BACKSLASH +2460..249B ; Common # No [60] CIRCLED DIGIT ONE..NUMBER TWENTY FULL STOP +249C..24E9 ; Common # So [78] PARENTHESIZED LATIN SMALL LETTER A..CIRCLED LATIN SMALL LETTER Z +24EA..24FF ; Common # No [22] CIRCLED DIGIT ZERO..NEGATIVE CIRCLED DIGIT ZERO +2500..25B6 ; Common # So [183] BOX DRAWINGS LIGHT HORIZONTAL..BLACK RIGHT-POINTING TRIANGLE +25B7 ; Common # Sm WHITE RIGHT-POINTING TRIANGLE +25B8..25C0 ; Common # So [9] BLACK RIGHT-POINTING SMALL TRIANGLE..BLACK LEFT-POINTING TRIANGLE +25C1 ; Common # Sm WHITE LEFT-POINTING TRIANGLE +25C2..25F7 ; Common # So [54] BLACK LEFT-POINTING SMALL TRIANGLE..WHITE CIRCLE WITH UPPER RIGHT QUADRANT +25F8..25FF ; Common # Sm [8] UPPER LEFT TRIANGLE..LOWER RIGHT TRIANGLE +2600..266E ; Common # So [111] BLACK SUN WITH RAYS..MUSIC NATURAL SIGN +266F ; Common # Sm MUSIC SHARP SIGN +2670..269D ; Common # So [46] WEST SYRIAC CROSS..OUTLINED WHITE STAR +26A0..26BC ; Common # So [29] WARNING SIGN..SESQUIQUADRATE +26C0..26C3 ; Common # So [4] WHITE DRAUGHTS MAN..BLACK DRAUGHTS KING +2701..2704 ; Common # So [4] UPPER BLADE SCISSORS..WHITE SCISSORS +2706..2709 ; Common # So [4] TELEPHONE LOCATION SIGN..ENVELOPE +270C..2727 ; Common # So [28] VICTORY HAND..WHITE FOUR POINTED STAR +2729..274B ; Common # So [35] STRESS OUTLINED WHITE STAR..HEAVY EIGHT TEARDROP-SPOKED PROPELLER ASTERISK +274D ; Common # So SHADOWED WHITE CIRCLE +274F..2752 ; Common # So [4] LOWER RIGHT DROP-SHADOWED WHITE SQUARE..UPPER RIGHT SHADOWED WHITE SQUARE +2756 ; Common # So BLACK DIAMOND MINUS WHITE X +2758..275E ; Common # So [7] LIGHT VERTICAL BAR..HEAVY DOUBLE COMMA QUOTATION MARK ORNAMENT +2761..2767 ; Common # So [7] CURVED STEM PARAGRAPH SIGN ORNAMENT..ROTATED FLORAL HEART BULLET +2768 ; Common # Ps MEDIUM LEFT PARENTHESIS ORNAMENT +2769 ; Common # Pe MEDIUM RIGHT PARENTHESIS ORNAMENT +276A ; Common # Ps MEDIUM FLATTENED LEFT PARENTHESIS ORNAMENT +276B ; Common # Pe MEDIUM FLATTENED RIGHT PARENTHESIS ORNAMENT +276C ; Common # Ps MEDIUM LEFT-POINTING ANGLE BRACKET ORNAMENT +276D ; Common # Pe MEDIUM RIGHT-POINTING ANGLE BRACKET ORNAMENT +276E ; Common # Ps HEAVY LEFT-POINTING ANGLE QUOTATION MARK ORNAMENT +276F ; Common # Pe HEAVY RIGHT-POINTING ANGLE QUOTATION MARK ORNAMENT +2770 ; Common # Ps HEAVY LEFT-POINTING ANGLE BRACKET ORNAMENT +2771 ; Common # Pe HEAVY RIGHT-POINTING ANGLE BRACKET ORNAMENT +2772 ; Common # Ps LIGHT LEFT TORTOISE SHELL BRACKET ORNAMENT +2773 ; Common # Pe LIGHT RIGHT TORTOISE SHELL BRACKET ORNAMENT +2774 ; Common # Ps MEDIUM LEFT CURLY BRACKET ORNAMENT +2775 ; Common # Pe MEDIUM RIGHT CURLY BRACKET ORNAMENT +2776..2793 ; Common # No [30] DINGBAT NEGATIVE CIRCLED DIGIT ONE..DINGBAT NEGATIVE CIRCLED SANS-SERIF NUMBER TEN +2794 ; Common # So HEAVY WIDE-HEADED RIGHTWARDS ARROW +2798..27AF ; Common # So [24] HEAVY SOUTH EAST ARROW..NOTCHED LOWER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW +27B1..27BE ; Common # So [14] NOTCHED UPPER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW..OPEN-OUTLINED RIGHTWARDS ARROW +27C0..27C4 ; Common # Sm [5] THREE DIMENSIONAL ANGLE..OPEN SUPERSET +27C5 ; Common # Ps LEFT S-SHAPED BAG DELIMITER +27C6 ; Common # Pe RIGHT S-SHAPED BAG DELIMITER +27C7..27CA ; Common # Sm [4] OR WITH DOT INSIDE..VERTICAL BAR WITH HORIZONTAL STROKE +27CC ; Common # Sm LONG DIVISION +27D0..27E5 ; Common # Sm [22] WHITE DIAMOND WITH CENTRED DOT..WHITE SQUARE WITH RIGHTWARDS TICK +27E6 ; Common # Ps MATHEMATICAL LEFT WHITE SQUARE BRACKET +27E7 ; Common # Pe MATHEMATICAL RIGHT WHITE SQUARE BRACKET +27E8 ; Common # Ps MATHEMATICAL LEFT ANGLE BRACKET +27E9 ; Common # Pe MATHEMATICAL RIGHT ANGLE BRACKET +27EA ; Common # Ps MATHEMATICAL LEFT DOUBLE ANGLE BRACKET +27EB ; Common # Pe MATHEMATICAL RIGHT DOUBLE ANGLE BRACKET +27EC ; Common # Ps MATHEMATICAL LEFT WHITE TORTOISE SHELL BRACKET +27ED ; Common # Pe MATHEMATICAL RIGHT WHITE TORTOISE SHELL BRACKET +27EE ; Common # Ps MATHEMATICAL LEFT FLATTENED PARENTHESIS +27EF ; Common # Pe MATHEMATICAL RIGHT FLATTENED PARENTHESIS +27F0..27FF ; Common # Sm [16] UPWARDS QUADRUPLE ARROW..LONG RIGHTWARDS SQUIGGLE ARROW +2900..2982 ; Common # Sm [131] RIGHTWARDS TWO-HEADED ARROW WITH VERTICAL STROKE..Z NOTATION TYPE COLON +2983 ; Common # Ps LEFT WHITE CURLY BRACKET +2984 ; Common # Pe RIGHT WHITE CURLY BRACKET +2985 ; Common # Ps LEFT WHITE PARENTHESIS +2986 ; Common # Pe RIGHT WHITE PARENTHESIS +2987 ; Common # Ps Z NOTATION LEFT IMAGE BRACKET +2988 ; Common # Pe Z NOTATION RIGHT IMAGE BRACKET +2989 ; Common # Ps Z NOTATION LEFT BINDING BRACKET +298A ; Common # Pe Z NOTATION RIGHT BINDING BRACKET +298B ; Common # Ps LEFT SQUARE BRACKET WITH UNDERBAR +298C ; Common # Pe RIGHT SQUARE BRACKET WITH UNDERBAR +298D ; Common # Ps LEFT SQUARE BRACKET WITH TICK IN TOP CORNER +298E ; Common # Pe RIGHT SQUARE BRACKET WITH TICK IN BOTTOM CORNER +298F ; Common # Ps LEFT SQUARE BRACKET WITH TICK IN BOTTOM CORNER +2990 ; Common # Pe RIGHT SQUARE BRACKET WITH TICK IN TOP CORNER +2991 ; Common # Ps LEFT ANGLE BRACKET WITH DOT +2992 ; Common # Pe RIGHT ANGLE BRACKET WITH DOT +2993 ; Common # Ps LEFT ARC LESS-THAN BRACKET +2994 ; Common # Pe RIGHT ARC GREATER-THAN BRACKET +2995 ; Common # Ps DOUBLE LEFT ARC GREATER-THAN BRACKET +2996 ; Common # Pe DOUBLE RIGHT ARC LESS-THAN BRACKET +2997 ; Common # Ps LEFT BLACK TORTOISE SHELL BRACKET +2998 ; Common # Pe RIGHT BLACK TORTOISE SHELL BRACKET +2999..29D7 ; Common # Sm [63] DOTTED FENCE..BLACK HOURGLASS +29D8 ; Common # Ps LEFT WIGGLY FENCE +29D9 ; Common # Pe RIGHT WIGGLY FENCE +29DA ; Common # Ps LEFT DOUBLE WIGGLY FENCE +29DB ; Common # Pe RIGHT DOUBLE WIGGLY FENCE +29DC..29FB ; Common # Sm [32] INCOMPLETE INFINITY..TRIPLE PLUS +29FC ; Common # Ps LEFT-POINTING CURVED ANGLE BRACKET +29FD ; Common # Pe RIGHT-POINTING CURVED ANGLE BRACKET +29FE..2AFF ; Common # Sm [258] TINY..N-ARY WHITE VERTICAL BAR +2B00..2B2F ; Common # So [48] NORTH EAST WHITE ARROW..WHITE VERTICAL ELLIPSE +2B30..2B44 ; Common # Sm [21] LEFT ARROW WITH SMALL CIRCLE..RIGHTWARDS ARROW THROUGH SUPERSET +2B45..2B46 ; Common # So [2] LEFTWARDS QUADRUPLE ARROW..RIGHTWARDS QUADRUPLE ARROW +2B47..2B4C ; Common # Sm [6] REVERSE TILDE OPERATOR ABOVE RIGHTWARDS ARROW..RIGHTWARDS ARROW ABOVE REVERSE TILDE OPERATOR +2B50..2B54 ; Common # So [5] WHITE MEDIUM STAR..WHITE RIGHT-POINTING PENTAGON +2E00..2E01 ; Common # Po [2] RIGHT ANGLE SUBSTITUTION MARKER..RIGHT ANGLE DOTTED SUBSTITUTION MARKER +2E02 ; Common # Pi LEFT SUBSTITUTION BRACKET +2E03 ; Common # Pf RIGHT SUBSTITUTION BRACKET +2E04 ; Common # Pi LEFT DOTTED SUBSTITUTION BRACKET +2E05 ; Common # Pf RIGHT DOTTED SUBSTITUTION BRACKET +2E06..2E08 ; Common # Po [3] RAISED INTERPOLATION MARKER..DOTTED TRANSPOSITION MARKER +2E09 ; Common # Pi LEFT TRANSPOSITION BRACKET +2E0A ; Common # Pf RIGHT TRANSPOSITION BRACKET +2E0B ; Common # Po RAISED SQUARE +2E0C ; Common # Pi LEFT RAISED OMISSION BRACKET +2E0D ; Common # Pf RIGHT RAISED OMISSION BRACKET +2E0E..2E16 ; Common # Po [9] EDITORIAL CORONIS..DOTTED RIGHT-POINTING ANGLE +2E17 ; Common # Pd DOUBLE OBLIQUE HYPHEN +2E18..2E19 ; Common # Po [2] INVERTED INTERROBANG..PALM BRANCH +2E1A ; Common # Pd HYPHEN WITH DIAERESIS +2E1B ; Common # Po TILDE WITH RING ABOVE +2E1C ; Common # Pi LEFT LOW PARAPHRASE BRACKET +2E1D ; Common # Pf RIGHT LOW PARAPHRASE BRACKET +2E1E..2E1F ; Common # Po [2] TILDE WITH DOT ABOVE..TILDE WITH DOT BELOW +2E20 ; Common # Pi LEFT VERTICAL BAR WITH QUILL +2E21 ; Common # Pf RIGHT VERTICAL BAR WITH QUILL +2E22 ; Common # Ps TOP LEFT HALF BRACKET +2E23 ; Common # Pe TOP RIGHT HALF BRACKET +2E24 ; Common # Ps BOTTOM LEFT HALF BRACKET +2E25 ; Common # Pe BOTTOM RIGHT HALF BRACKET +2E26 ; Common # Ps LEFT SIDEWAYS U BRACKET +2E27 ; Common # Pe RIGHT SIDEWAYS U BRACKET +2E28 ; Common # Ps LEFT DOUBLE PARENTHESIS +2E29 ; Common # Pe RIGHT DOUBLE PARENTHESIS +2E2A..2E2E ; Common # Po [5] TWO DOTS OVER ONE DOT PUNCTUATION..REVERSED QUESTION MARK +2E2F ; Common # Lm VERTICAL TILDE +2E30 ; Common # Po RING POINT +2FF0..2FFB ; Common # So [12] IDEOGRAPHIC DESCRIPTION CHARACTER LEFT TO RIGHT..IDEOGRAPHIC DESCRIPTION CHARACTER OVERLAID +3000 ; Common # Zs IDEOGRAPHIC SPACE +3001..3003 ; Common # Po [3] IDEOGRAPHIC COMMA..DITTO MARK +3004 ; Common # So JAPANESE INDUSTRIAL STANDARD SYMBOL +3006 ; Common # Lo IDEOGRAPHIC CLOSING MARK +3008 ; Common # Ps LEFT ANGLE BRACKET +3009 ; Common # Pe RIGHT ANGLE BRACKET +300A ; Common # Ps LEFT DOUBLE ANGLE BRACKET +300B ; Common # Pe RIGHT DOUBLE ANGLE BRACKET +300C ; Common # Ps LEFT CORNER BRACKET +300D ; Common # Pe RIGHT CORNER BRACKET +300E ; Common # Ps LEFT WHITE CORNER BRACKET +300F ; Common # Pe RIGHT WHITE CORNER BRACKET +3010 ; Common # Ps LEFT BLACK LENTICULAR BRACKET +3011 ; Common # Pe RIGHT BLACK LENTICULAR BRACKET +3012..3013 ; Common # So [2] POSTAL MARK..GETA MARK +3014 ; Common # Ps LEFT TORTOISE SHELL BRACKET +3015 ; Common # Pe RIGHT TORTOISE SHELL BRACKET +3016 ; Common # Ps LEFT WHITE LENTICULAR BRACKET +3017 ; Common # Pe RIGHT WHITE LENTICULAR BRACKET +3018 ; Common # Ps LEFT WHITE TORTOISE SHELL BRACKET +3019 ; Common # Pe RIGHT WHITE TORTOISE SHELL BRACKET +301A ; Common # Ps LEFT WHITE SQUARE BRACKET +301B ; Common # Pe RIGHT WHITE SQUARE BRACKET +301C ; Common # Pd WAVE DASH +301D ; Common # Ps REVERSED DOUBLE PRIME QUOTATION MARK +301E..301F ; Common # Pe [2] DOUBLE PRIME QUOTATION MARK..LOW DOUBLE PRIME QUOTATION MARK +3020 ; Common # So POSTAL MARK FACE +3030 ; Common # Pd WAVY DASH +3031..3035 ; Common # Lm [5] VERTICAL KANA REPEAT MARK..VERTICAL KANA REPEAT MARK LOWER HALF +3036..3037 ; Common # So [2] CIRCLED POSTAL MARK..IDEOGRAPHIC TELEGRAPH LINE FEED SEPARATOR SYMBOL +303C ; Common # Lo MASU MARK +303D ; Common # Po PART ALTERNATION MARK +303E..303F ; Common # So [2] IDEOGRAPHIC VARIATION INDICATOR..IDEOGRAPHIC HALF FILL SPACE +309B..309C ; Common # Sk [2] KATAKANA-HIRAGANA VOICED SOUND MARK..KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK +30A0 ; Common # Pd KATAKANA-HIRAGANA DOUBLE HYPHEN +30FB ; Common # Po KATAKANA MIDDLE DOT +30FC ; Common # Lm KATAKANA-HIRAGANA PROLONGED SOUND MARK +3190..3191 ; Common # So [2] IDEOGRAPHIC ANNOTATION LINKING MARK..IDEOGRAPHIC ANNOTATION REVERSE MARK +3192..3195 ; Common # No [4] IDEOGRAPHIC ANNOTATION ONE MARK..IDEOGRAPHIC ANNOTATION FOUR MARK +3196..319F ; Common # So [10] IDEOGRAPHIC ANNOTATION TOP MARK..IDEOGRAPHIC ANNOTATION MAN MARK +31C0..31E3 ; Common # So [36] CJK STROKE T..CJK STROKE Q +3220..3229 ; Common # No [10] PARENTHESIZED IDEOGRAPH ONE..PARENTHESIZED IDEOGRAPH TEN +322A..3243 ; Common # So [26] PARENTHESIZED IDEOGRAPH MOON..PARENTHESIZED IDEOGRAPH REACH +3250 ; Common # So PARTNERSHIP SIGN +3251..325F ; Common # No [15] CIRCLED NUMBER TWENTY ONE..CIRCLED NUMBER THIRTY FIVE +327F ; Common # So KOREAN STANDARD SYMBOL +3280..3289 ; Common # No [10] CIRCLED IDEOGRAPH ONE..CIRCLED IDEOGRAPH TEN +328A..32B0 ; Common # So [39] CIRCLED IDEOGRAPH MOON..CIRCLED IDEOGRAPH NIGHT +32B1..32BF ; Common # No [15] CIRCLED NUMBER THIRTY SIX..CIRCLED NUMBER FIFTY +32C0..32CF ; Common # So [16] IDEOGRAPHIC TELEGRAPH SYMBOL FOR JANUARY..LIMITED LIABILITY SIGN +3358..33FF ; Common # So [168] IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR ZERO..SQUARE GAL +4DC0..4DFF ; Common # So [64] HEXAGRAM FOR THE CREATIVE HEAVEN..HEXAGRAM FOR BEFORE COMPLETION +A700..A716 ; Common # Sk [23] MODIFIER LETTER CHINESE TONE YIN PING..MODIFIER LETTER EXTRA-LOW LEFT-STEM TONE BAR +A717..A71F ; Common # Lm [9] MODIFIER LETTER DOT VERTICAL BAR..MODIFIER LETTER LOW INVERTED EXCLAMATION MARK +A720..A721 ; Common # Sk [2] MODIFIER LETTER STRESS AND HIGH TONE..MODIFIER LETTER STRESS AND LOW TONE +A788 ; Common # Lm MODIFIER LETTER LOW CIRCUMFLEX ACCENT +A789..A78A ; Common # Sk [2] MODIFIER LETTER COLON..MODIFIER LETTER SHORT EQUALS SIGN +FD3E ; Common # Ps ORNATE LEFT PARENTHESIS +FD3F ; Common # Pe ORNATE RIGHT PARENTHESIS +FDFD ; Common # So ARABIC LIGATURE BISMILLAH AR-RAHMAN AR-RAHEEM +FE10..FE16 ; Common # Po [7] PRESENTATION FORM FOR VERTICAL COMMA..PRESENTATION FORM FOR VERTICAL QUESTION MARK +FE17 ; Common # Ps PRESENTATION FORM FOR VERTICAL LEFT WHITE LENTICULAR BRACKET +FE18 ; Common # Pe PRESENTATION FORM FOR VERTICAL RIGHT WHITE LENTICULAR BRAKCET +FE19 ; Common # Po PRESENTATION FORM FOR VERTICAL HORIZONTAL ELLIPSIS +FE30 ; Common # Po PRESENTATION FORM FOR VERTICAL TWO DOT LEADER +FE31..FE32 ; Common # Pd [2] PRESENTATION FORM FOR VERTICAL EM DASH..PRESENTATION FORM FOR VERTICAL EN DASH +FE33..FE34 ; Common # Pc [2] PRESENTATION FORM FOR VERTICAL LOW LINE..PRESENTATION FORM FOR VERTICAL WAVY LOW LINE +FE35 ; Common # Ps PRESENTATION FORM FOR VERTICAL LEFT PARENTHESIS +FE36 ; Common # Pe PRESENTATION FORM FOR VERTICAL RIGHT PARENTHESIS +FE37 ; Common # Ps PRESENTATION FORM FOR VERTICAL LEFT CURLY BRACKET +FE38 ; Common # Pe PRESENTATION FORM FOR VERTICAL RIGHT CURLY BRACKET +FE39 ; Common # Ps PRESENTATION FORM FOR VERTICAL LEFT TORTOISE SHELL BRACKET +FE3A ; Common # Pe PRESENTATION FORM FOR VERTICAL RIGHT TORTOISE SHELL BRACKET +FE3B ; Common # Ps PRESENTATION FORM FOR VERTICAL LEFT BLACK LENTICULAR BRACKET +FE3C ; Common # Pe PRESENTATION FORM FOR VERTICAL RIGHT BLACK LENTICULAR BRACKET +FE3D ; Common # Ps PRESENTATION FORM FOR VERTICAL LEFT DOUBLE ANGLE BRACKET +FE3E ; Common # Pe PRESENTATION FORM FOR VERTICAL RIGHT DOUBLE ANGLE BRACKET +FE3F ; Common # Ps PRESENTATION FORM FOR VERTICAL LEFT ANGLE BRACKET +FE40 ; Common # Pe PRESENTATION FORM FOR VERTICAL RIGHT ANGLE BRACKET +FE41 ; Common # Ps PRESENTATION FORM FOR VERTICAL LEFT CORNER BRACKET +FE42 ; Common # Pe PRESENTATION FORM FOR VERTICAL RIGHT CORNER BRACKET +FE43 ; Common # Ps PRESENTATION FORM FOR VERTICAL LEFT WHITE CORNER BRACKET +FE44 ; Common # Pe PRESENTATION FORM FOR VERTICAL RIGHT WHITE CORNER BRACKET +FE45..FE46 ; Common # Po [2] SESAME DOT..WHITE SESAME DOT +FE47 ; Common # Ps PRESENTATION FORM FOR VERTICAL LEFT SQUARE BRACKET +FE48 ; Common # Pe PRESENTATION FORM FOR VERTICAL RIGHT SQUARE BRACKET +FE49..FE4C ; Common # Po [4] DASHED OVERLINE..DOUBLE WAVY OVERLINE +FE4D..FE4F ; Common # Pc [3] DASHED LOW LINE..WAVY LOW LINE +FE50..FE52 ; Common # Po [3] SMALL COMMA..SMALL FULL STOP +FE54..FE57 ; Common # Po [4] SMALL SEMICOLON..SMALL EXCLAMATION MARK +FE58 ; Common # Pd SMALL EM DASH +FE59 ; Common # Ps SMALL LEFT PARENTHESIS +FE5A ; Common # Pe SMALL RIGHT PARENTHESIS +FE5B ; Common # Ps SMALL LEFT CURLY BRACKET +FE5C ; Common # Pe SMALL RIGHT CURLY BRACKET +FE5D ; Common # Ps SMALL LEFT TORTOISE SHELL BRACKET +FE5E ; Common # Pe SMALL RIGHT TORTOISE SHELL BRACKET +FE5F..FE61 ; Common # Po [3] SMALL NUMBER SIGN..SMALL ASTERISK +FE62 ; Common # Sm SMALL PLUS SIGN +FE63 ; Common # Pd SMALL HYPHEN-MINUS +FE64..FE66 ; Common # Sm [3] SMALL LESS-THAN SIGN..SMALL EQUALS SIGN +FE68 ; Common # Po SMALL REVERSE SOLIDUS +FE69 ; Common # Sc SMALL DOLLAR SIGN +FE6A..FE6B ; Common # Po [2] SMALL PERCENT SIGN..SMALL COMMERCIAL AT +FEFF ; Common # Cf ZERO WIDTH NO-BREAK SPACE +FF01..FF03 ; Common # Po [3] FULLWIDTH EXCLAMATION MARK..FULLWIDTH NUMBER SIGN +FF04 ; Common # Sc FULLWIDTH DOLLAR SIGN +FF05..FF07 ; Common # Po [3] FULLWIDTH PERCENT SIGN..FULLWIDTH APOSTROPHE +FF08 ; Common # Ps FULLWIDTH LEFT PARENTHESIS +FF09 ; Common # Pe FULLWIDTH RIGHT PARENTHESIS +FF0A ; Common # Po FULLWIDTH ASTERISK +FF0B ; Common # Sm FULLWIDTH PLUS SIGN +FF0C ; Common # Po FULLWIDTH COMMA +FF0D ; Common # Pd FULLWIDTH HYPHEN-MINUS +FF0E..FF0F ; Common # Po [2] FULLWIDTH FULL STOP..FULLWIDTH SOLIDUS +FF10..FF19 ; Common # Nd [10] FULLWIDTH DIGIT ZERO..FULLWIDTH DIGIT NINE +FF1A..FF1B ; Common # Po [2] FULLWIDTH COLON..FULLWIDTH SEMICOLON +FF1C..FF1E ; Common # Sm [3] FULLWIDTH LESS-THAN SIGN..FULLWIDTH GREATER-THAN SIGN +FF1F..FF20 ; Common # Po [2] FULLWIDTH QUESTION MARK..FULLWIDTH COMMERCIAL AT +FF3B ; Common # Ps FULLWIDTH LEFT SQUARE BRACKET +FF3C ; Common # Po FULLWIDTH REVERSE SOLIDUS +FF3D ; Common # Pe FULLWIDTH RIGHT SQUARE BRACKET +FF3E ; Common # Sk FULLWIDTH CIRCUMFLEX ACCENT +FF3F ; Common # Pc FULLWIDTH LOW LINE +FF40 ; Common # Sk FULLWIDTH GRAVE ACCENT +FF5B ; Common # Ps FULLWIDTH LEFT CURLY BRACKET +FF5C ; Common # Sm FULLWIDTH VERTICAL LINE +FF5D ; Common # Pe FULLWIDTH RIGHT CURLY BRACKET +FF5E ; Common # Sm FULLWIDTH TILDE +FF5F ; Common # Ps FULLWIDTH LEFT WHITE PARENTHESIS +FF60 ; Common # Pe FULLWIDTH RIGHT WHITE PARENTHESIS +FF61 ; Common # Po HALFWIDTH IDEOGRAPHIC FULL STOP +FF62 ; Common # Ps HALFWIDTH LEFT CORNER BRACKET +FF63 ; Common # Pe HALFWIDTH RIGHT CORNER BRACKET +FF64..FF65 ; Common # Po [2] HALFWIDTH IDEOGRAPHIC COMMA..HALFWIDTH KATAKANA MIDDLE DOT +FF70 ; Common # Lm HALFWIDTH KATAKANA-HIRAGANA PROLONGED SOUND MARK +FF9E..FF9F ; Common # Lm [2] HALFWIDTH KATAKANA VOICED SOUND MARK..HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK +FFE0..FFE1 ; Common # Sc [2] FULLWIDTH CENT SIGN..FULLWIDTH POUND SIGN +FFE2 ; Common # Sm FULLWIDTH NOT SIGN +FFE3 ; Common # Sk FULLWIDTH MACRON +FFE4 ; Common # So FULLWIDTH BROKEN BAR +FFE5..FFE6 ; Common # Sc [2] FULLWIDTH YEN SIGN..FULLWIDTH WON SIGN +FFE8 ; Common # So HALFWIDTH FORMS LIGHT VERTICAL +FFE9..FFEC ; Common # Sm [4] HALFWIDTH LEFTWARDS ARROW..HALFWIDTH DOWNWARDS ARROW +FFED..FFEE ; Common # So [2] HALFWIDTH BLACK SQUARE..HALFWIDTH WHITE CIRCLE +FFF9..FFFB ; Common # Cf [3] INTERLINEAR ANNOTATION ANCHOR..INTERLINEAR ANNOTATION TERMINATOR +FFFC..FFFD ; Common # So [2] OBJECT REPLACEMENT CHARACTER..REPLACEMENT CHARACTER +10100..10101 ; Common # Po [2] AEGEAN WORD SEPARATOR LINE..AEGEAN WORD SEPARATOR DOT +10102 ; Common # So AEGEAN CHECK MARK +10107..10133 ; Common # No [45] AEGEAN NUMBER ONE..AEGEAN NUMBER NINETY THOUSAND +10137..1013F ; Common # So [9] AEGEAN WEIGHT BASE UNIT..AEGEAN MEASURE THIRD SUBUNIT +10190..1019B ; Common # So [12] ROMAN SEXTANS SIGN..ROMAN CENTURIAL SIGN +101D0..101FC ; Common # So [45] PHAISTOS DISC SIGN PEDESTRIAN..PHAISTOS DISC SIGN WAVY BAND +1D000..1D0F5 ; Common # So [246] BYZANTINE MUSICAL SYMBOL PSILI..BYZANTINE MUSICAL SYMBOL GORGON NEO KATO +1D100..1D126 ; Common # So [39] MUSICAL SYMBOL SINGLE BARLINE..MUSICAL SYMBOL DRUM CLEF-2 +1D129..1D164 ; Common # So [60] MUSICAL SYMBOL MULTIPLE MEASURE REST..MUSICAL SYMBOL ONE HUNDRED TWENTY-EIGHTH NOTE +1D165..1D166 ; Common # Mc [2] MUSICAL SYMBOL COMBINING STEM..MUSICAL SYMBOL COMBINING SPRECHGESANG STEM +1D16A..1D16C ; Common # So [3] MUSICAL SYMBOL FINGERED TREMOLO-1..MUSICAL SYMBOL FINGERED TREMOLO-3 +1D16D..1D172 ; Common # Mc [6] MUSICAL SYMBOL COMBINING AUGMENTATION DOT..MUSICAL SYMBOL COMBINING FLAG-5 +1D173..1D17A ; Common # Cf [8] MUSICAL SYMBOL BEGIN BEAM..MUSICAL SYMBOL END PHRASE +1D183..1D184 ; Common # So [2] MUSICAL SYMBOL ARPEGGIATO UP..MUSICAL SYMBOL ARPEGGIATO DOWN +1D18C..1D1A9 ; Common # So [30] MUSICAL SYMBOL RINFORZANDO..MUSICAL SYMBOL DEGREE SLASH +1D1AE..1D1DD ; Common # So [48] MUSICAL SYMBOL PEDAL MARK..MUSICAL SYMBOL PES SUBPUNCTIS +1D300..1D356 ; Common # So [87] MONOGRAM FOR EARTH..TETRAGRAM FOR FOSTERING +1D360..1D371 ; Common # No [18] COUNTING ROD UNIT DIGIT ONE..COUNTING ROD TENS DIGIT NINE +1D400..1D454 ; Common # L& [85] MATHEMATICAL BOLD CAPITAL A..MATHEMATICAL ITALIC SMALL G +1D456..1D49C ; Common # L& [71] MATHEMATICAL ITALIC SMALL I..MATHEMATICAL SCRIPT CAPITAL A +1D49E..1D49F ; Common # L& [2] MATHEMATICAL SCRIPT CAPITAL C..MATHEMATICAL SCRIPT CAPITAL D +1D4A2 ; Common # L& MATHEMATICAL SCRIPT CAPITAL G +1D4A5..1D4A6 ; Common # L& [2] MATHEMATICAL SCRIPT CAPITAL J..MATHEMATICAL SCRIPT CAPITAL K +1D4A9..1D4AC ; Common # L& [4] MATHEMATICAL SCRIPT CAPITAL N..MATHEMATICAL SCRIPT CAPITAL Q +1D4AE..1D4B9 ; Common # L& [12] MATHEMATICAL SCRIPT CAPITAL S..MATHEMATICAL SCRIPT SMALL D +1D4BB ; Common # L& MATHEMATICAL SCRIPT SMALL F +1D4BD..1D4C3 ; Common # L& [7] MATHEMATICAL SCRIPT SMALL H..MATHEMATICAL SCRIPT SMALL N +1D4C5..1D505 ; Common # L& [65] MATHEMATICAL SCRIPT SMALL P..MATHEMATICAL FRAKTUR CAPITAL B +1D507..1D50A ; Common # L& [4] MATHEMATICAL FRAKTUR CAPITAL D..MATHEMATICAL FRAKTUR CAPITAL G +1D50D..1D514 ; Common # L& [8] MATHEMATICAL FRAKTUR CAPITAL J..MATHEMATICAL FRAKTUR CAPITAL Q +1D516..1D51C ; Common # L& [7] MATHEMATICAL FRAKTUR CAPITAL S..MATHEMATICAL FRAKTUR CAPITAL Y +1D51E..1D539 ; Common # L& [28] MATHEMATICAL FRAKTUR SMALL A..MATHEMATICAL DOUBLE-STRUCK CAPITAL B +1D53B..1D53E ; Common # L& [4] MATHEMATICAL DOUBLE-STRUCK CAPITAL D..MATHEMATICAL DOUBLE-STRUCK CAPITAL G +1D540..1D544 ; Common # L& [5] MATHEMATICAL DOUBLE-STRUCK CAPITAL I..MATHEMATICAL DOUBLE-STRUCK CAPITAL M +1D546 ; Common # L& MATHEMATICAL DOUBLE-STRUCK CAPITAL O +1D54A..1D550 ; Common # L& [7] MATHEMATICAL DOUBLE-STRUCK CAPITAL S..MATHEMATICAL DOUBLE-STRUCK CAPITAL Y +1D552..1D6A5 ; Common # L& [340] MATHEMATICAL DOUBLE-STRUCK SMALL A..MATHEMATICAL ITALIC SMALL DOTLESS J +1D6A8..1D6C0 ; Common # L& [25] MATHEMATICAL BOLD CAPITAL ALPHA..MATHEMATICAL BOLD CAPITAL OMEGA +1D6C1 ; Common # Sm MATHEMATICAL BOLD NABLA +1D6C2..1D6DA ; Common # L& [25] MATHEMATICAL BOLD SMALL ALPHA..MATHEMATICAL BOLD SMALL OMEGA +1D6DB ; Common # Sm MATHEMATICAL BOLD PARTIAL DIFFERENTIAL +1D6DC..1D6FA ; Common # L& [31] MATHEMATICAL BOLD EPSILON SYMBOL..MATHEMATICAL ITALIC CAPITAL OMEGA +1D6FB ; Common # Sm MATHEMATICAL ITALIC NABLA +1D6FC..1D714 ; Common # L& [25] MATHEMATICAL ITALIC SMALL ALPHA..MATHEMATICAL ITALIC SMALL OMEGA +1D715 ; Common # Sm MATHEMATICAL ITALIC PARTIAL DIFFERENTIAL +1D716..1D734 ; Common # L& [31] MATHEMATICAL ITALIC EPSILON SYMBOL..MATHEMATICAL BOLD ITALIC CAPITAL OMEGA +1D735 ; Common # Sm MATHEMATICAL BOLD ITALIC NABLA +1D736..1D74E ; Common # L& [25] MATHEMATICAL BOLD ITALIC SMALL ALPHA..MATHEMATICAL BOLD ITALIC SMALL OMEGA +1D74F ; Common # Sm MATHEMATICAL BOLD ITALIC PARTIAL DIFFERENTIAL +1D750..1D76E ; Common # L& [31] MATHEMATICAL BOLD ITALIC EPSILON SYMBOL..MATHEMATICAL SANS-SERIF BOLD CAPITAL OMEGA +1D76F ; Common # Sm MATHEMATICAL SANS-SERIF BOLD NABLA +1D770..1D788 ; Common # L& [25] MATHEMATICAL SANS-SERIF BOLD SMALL ALPHA..MATHEMATICAL SANS-SERIF BOLD SMALL OMEGA +1D789 ; Common # Sm MATHEMATICAL SANS-SERIF BOLD PARTIAL DIFFERENTIAL +1D78A..1D7A8 ; Common # L& [31] MATHEMATICAL SANS-SERIF BOLD EPSILON SYMBOL..MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL OMEGA +1D7A9 ; Common # Sm MATHEMATICAL SANS-SERIF BOLD ITALIC NABLA +1D7AA..1D7C2 ; Common # L& [25] MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL ALPHA..MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL OMEGA +1D7C3 ; Common # Sm MATHEMATICAL SANS-SERIF BOLD ITALIC PARTIAL DIFFERENTIAL +1D7C4..1D7CB ; Common # L& [8] MATHEMATICAL SANS-SERIF BOLD ITALIC EPSILON SYMBOL..MATHEMATICAL BOLD SMALL DIGAMMA +1D7CE..1D7FF ; Common # Nd [50] MATHEMATICAL BOLD DIGIT ZERO..MATHEMATICAL MONOSPACE DIGIT NINE +1F000..1F02B ; Common # So [44] MAHJONG TILE EAST WIND..MAHJONG TILE BACK +1F030..1F093 ; Common # So [100] DOMINO TILE HORIZONTAL BACK..DOMINO TILE VERTICAL-06-06 +E0001 ; Common # Cf LANGUAGE TAG +E0020..E007F ; Common # Cf [96] TAG SPACE..CANCEL TAG + +# Total code points: 5178 + +# ================================================ + +0041..005A ; Latin # L& [26] LATIN CAPITAL LETTER A..LATIN CAPITAL LETTER Z +0061..007A ; Latin # L& [26] LATIN SMALL LETTER A..LATIN SMALL LETTER Z +00AA ; Latin # L& FEMININE ORDINAL INDICATOR +00BA ; Latin # L& MASCULINE ORDINAL INDICATOR +00C0..00D6 ; Latin # L& [23] LATIN CAPITAL LETTER A WITH GRAVE..LATIN CAPITAL LETTER O WITH DIAERESIS +00D8..00F6 ; Latin # L& [31] LATIN CAPITAL LETTER O WITH STROKE..LATIN SMALL LETTER O WITH DIAERESIS +00F8..01BA ; Latin # L& [195] LATIN SMALL LETTER O WITH STROKE..LATIN SMALL LETTER EZH WITH TAIL +01BB ; Latin # Lo LATIN LETTER TWO WITH STROKE +01BC..01BF ; Latin # L& [4] LATIN CAPITAL LETTER TONE FIVE..LATIN LETTER WYNN +01C0..01C3 ; Latin # Lo [4] LATIN LETTER DENTAL CLICK..LATIN LETTER RETROFLEX CLICK +01C4..0293 ; Latin # L& [208] LATIN CAPITAL LETTER DZ WITH CARON..LATIN SMALL LETTER EZH WITH CURL +0294 ; Latin # Lo LATIN LETTER GLOTTAL STOP +0295..02AF ; Latin # L& [27] LATIN LETTER PHARYNGEAL VOICED FRICATIVE..LATIN SMALL LETTER TURNED H WITH FISHHOOK AND TAIL +02B0..02B8 ; Latin # Lm [9] MODIFIER LETTER SMALL H..MODIFIER LETTER SMALL Y +02E0..02E4 ; Latin # Lm [5] MODIFIER LETTER SMALL GAMMA..MODIFIER LETTER SMALL REVERSED GLOTTAL STOP +1D00..1D25 ; Latin # L& [38] LATIN LETTER SMALL CAPITAL A..LATIN LETTER AIN +1D2C..1D5C ; Latin # Lm [49] MODIFIER LETTER CAPITAL A..MODIFIER LETTER SMALL AIN +1D62..1D65 ; Latin # L& [4] LATIN SUBSCRIPT SMALL LETTER I..LATIN SUBSCRIPT SMALL LETTER V +1D6B..1D77 ; Latin # L& [13] LATIN SMALL LETTER UE..LATIN SMALL LETTER TURNED G +1D79..1D9A ; Latin # L& [34] LATIN SMALL LETTER INSULAR G..LATIN SMALL LETTER EZH WITH RETROFLEX HOOK +1D9B..1DBE ; Latin # Lm [36] MODIFIER LETTER SMALL TURNED ALPHA..MODIFIER LETTER SMALL EZH +1E00..1EFF ; Latin # L& [256] LATIN CAPITAL LETTER A WITH RING BELOW..LATIN SMALL LETTER Y WITH LOOP +2071 ; Latin # L& SUPERSCRIPT LATIN SMALL LETTER I +207F ; Latin # L& SUPERSCRIPT LATIN SMALL LETTER N +2090..2094 ; Latin # Lm [5] LATIN SUBSCRIPT SMALL LETTER A..LATIN SUBSCRIPT SMALL LETTER SCHWA +212A..212B ; Latin # L& [2] KELVIN SIGN..ANGSTROM SIGN +2132 ; Latin # L& TURNED CAPITAL F +214E ; Latin # L& TURNED SMALL F +2160..2182 ; Latin # Nl [35] ROMAN NUMERAL ONE..ROMAN NUMERAL TEN THOUSAND +2183..2184 ; Latin # L& [2] ROMAN NUMERAL REVERSED ONE HUNDRED..LATIN SMALL LETTER REVERSED C +2185..2188 ; Latin # Nl [4] ROMAN NUMERAL SIX LATE FORM..ROMAN NUMERAL ONE HUNDRED THOUSAND +2C60..2C6F ; Latin # L& [16] LATIN CAPITAL LETTER L WITH DOUBLE BAR..LATIN CAPITAL LETTER TURNED A +2C71..2C7C ; Latin # L& [12] LATIN SMALL LETTER V WITH RIGHT HOOK..LATIN SUBSCRIPT SMALL LETTER J +2C7D ; Latin # Lm MODIFIER LETTER CAPITAL V +A722..A76F ; Latin # L& [78] LATIN CAPITAL LETTER EGYPTOLOGICAL ALEF..LATIN SMALL LETTER CON +A770 ; Latin # Lm MODIFIER LETTER US +A771..A787 ; Latin # L& [23] LATIN SMALL LETTER DUM..LATIN SMALL LETTER INSULAR T +A78B..A78C ; Latin # L& [2] LATIN CAPITAL LETTER SALTILLO..LATIN SMALL LETTER SALTILLO +A7FB..A7FF ; Latin # Lo [5] LATIN EPIGRAPHIC LETTER REVERSED F..LATIN EPIGRAPHIC LETTER ARCHAIC M +FB00..FB06 ; Latin # L& [7] LATIN SMALL LIGATURE FF..LATIN SMALL LIGATURE ST +FF21..FF3A ; Latin # L& [26] FULLWIDTH LATIN CAPITAL LETTER A..FULLWIDTH LATIN CAPITAL LETTER Z +FF41..FF5A ; Latin # L& [26] FULLWIDTH LATIN SMALL LETTER A..FULLWIDTH LATIN SMALL LETTER Z + +# Total code points: 1241 + +# ================================================ + +0370..0373 ; Greek # L& [4] GREEK CAPITAL LETTER HETA..GREEK SMALL LETTER ARCHAIC SAMPI +0375 ; Greek # Sk GREEK LOWER NUMERAL SIGN +0376..0377 ; Greek # L& [2] GREEK CAPITAL LETTER PAMPHYLIAN DIGAMMA..GREEK SMALL LETTER PAMPHYLIAN DIGAMMA +037A ; Greek # Lm GREEK YPOGEGRAMMENI +037B..037D ; Greek # L& [3] GREEK SMALL REVERSED LUNATE SIGMA SYMBOL..GREEK SMALL REVERSED DOTTED LUNATE SIGMA SYMBOL +0384 ; Greek # Sk GREEK TONOS +0386 ; Greek # L& GREEK CAPITAL LETTER ALPHA WITH TONOS +0388..038A ; Greek # L& [3] GREEK CAPITAL LETTER EPSILON WITH TONOS..GREEK CAPITAL LETTER IOTA WITH TONOS +038C ; Greek # L& GREEK CAPITAL LETTER OMICRON WITH TONOS +038E..03A1 ; Greek # L& [20] GREEK CAPITAL LETTER UPSILON WITH TONOS..GREEK CAPITAL LETTER RHO +03A3..03E1 ; Greek # L& [63] GREEK CAPITAL LETTER SIGMA..GREEK SMALL LETTER SAMPI +03F0..03F5 ; Greek # L& [6] GREEK KAPPA SYMBOL..GREEK LUNATE EPSILON SYMBOL +03F6 ; Greek # Sm GREEK REVERSED LUNATE EPSILON SYMBOL +03F7..03FF ; Greek # L& [9] GREEK CAPITAL LETTER SHO..GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL +1D26..1D2A ; Greek # L& [5] GREEK LETTER SMALL CAPITAL GAMMA..GREEK LETTER SMALL CAPITAL PSI +1D5D..1D61 ; Greek # Lm [5] MODIFIER LETTER SMALL BETA..MODIFIER LETTER SMALL CHI +1D66..1D6A ; Greek # L& [5] GREEK SUBSCRIPT SMALL LETTER BETA..GREEK SUBSCRIPT SMALL LETTER CHI +1DBF ; Greek # Lm MODIFIER LETTER SMALL THETA +1F00..1F15 ; Greek # L& [22] GREEK SMALL LETTER ALPHA WITH PSILI..GREEK SMALL LETTER EPSILON WITH DASIA AND OXIA +1F18..1F1D ; Greek # L& [6] GREEK CAPITAL LETTER EPSILON WITH PSILI..GREEK CAPITAL LETTER EPSILON WITH DASIA AND OXIA +1F20..1F45 ; Greek # L& [38] GREEK SMALL LETTER ETA WITH PSILI..GREEK SMALL LETTER OMICRON WITH DASIA AND OXIA +1F48..1F4D ; Greek # L& [6] GREEK CAPITAL LETTER OMICRON WITH PSILI..GREEK CAPITAL LETTER OMICRON WITH DASIA AND OXIA +1F50..1F57 ; Greek # L& [8] GREEK SMALL LETTER UPSILON WITH PSILI..GREEK SMALL LETTER UPSILON WITH DASIA AND PERISPOMENI +1F59 ; Greek # L& GREEK CAPITAL LETTER UPSILON WITH DASIA +1F5B ; Greek # L& GREEK CAPITAL LETTER UPSILON WITH DASIA AND VARIA +1F5D ; Greek # L& GREEK CAPITAL LETTER UPSILON WITH DASIA AND OXIA +1F5F..1F7D ; Greek # L& [31] GREEK CAPITAL LETTER UPSILON WITH DASIA AND PERISPOMENI..GREEK SMALL LETTER OMEGA WITH OXIA +1F80..1FB4 ; Greek # L& [53] GREEK SMALL LETTER ALPHA WITH PSILI AND YPOGEGRAMMENI..GREEK SMALL LETTER ALPHA WITH OXIA AND YPOGEGRAMMENI +1FB6..1FBC ; Greek # L& [7] GREEK SMALL LETTER ALPHA WITH PERISPOMENI..GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI +1FBD ; Greek # Sk GREEK KORONIS +1FBE ; Greek # L& GREEK PROSGEGRAMMENI +1FBF..1FC1 ; Greek # Sk [3] GREEK PSILI..GREEK DIALYTIKA AND PERISPOMENI +1FC2..1FC4 ; Greek # L& [3] GREEK SMALL LETTER ETA WITH VARIA AND YPOGEGRAMMENI..GREEK SMALL LETTER ETA WITH OXIA AND YPOGEGRAMMENI +1FC6..1FCC ; Greek # L& [7] GREEK SMALL LETTER ETA WITH PERISPOMENI..GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI +1FCD..1FCF ; Greek # Sk [3] GREEK PSILI AND VARIA..GREEK PSILI AND PERISPOMENI +1FD0..1FD3 ; Greek # L& [4] GREEK SMALL LETTER IOTA WITH VRACHY..GREEK SMALL LETTER IOTA WITH DIALYTIKA AND OXIA +1FD6..1FDB ; Greek # L& [6] GREEK SMALL LETTER IOTA WITH PERISPOMENI..GREEK CAPITAL LETTER IOTA WITH OXIA +1FDD..1FDF ; Greek # Sk [3] GREEK DASIA AND VARIA..GREEK DASIA AND PERISPOMENI +1FE0..1FEC ; Greek # L& [13] GREEK SMALL LETTER UPSILON WITH VRACHY..GREEK CAPITAL LETTER RHO WITH DASIA +1FED..1FEF ; Greek # Sk [3] GREEK DIALYTIKA AND VARIA..GREEK VARIA +1FF2..1FF4 ; Greek # L& [3] GREEK SMALL LETTER OMEGA WITH VARIA AND YPOGEGRAMMENI..GREEK SMALL LETTER OMEGA WITH OXIA AND YPOGEGRAMMENI +1FF6..1FFC ; Greek # L& [7] GREEK SMALL LETTER OMEGA WITH PERISPOMENI..GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI +1FFD..1FFE ; Greek # Sk [2] GREEK OXIA..GREEK DASIA +2126 ; Greek # L& OHM SIGN +10140..10174 ; Greek # Nl [53] GREEK ACROPHONIC ATTIC ONE QUARTER..GREEK ACROPHONIC STRATIAN FIFTY MNAS +10175..10178 ; Greek # No [4] GREEK ONE HALF SIGN..GREEK THREE QUARTERS SIGN +10179..10189 ; Greek # So [17] GREEK YEAR SIGN..GREEK TRYBLION BASE SIGN +1018A ; Greek # No GREEK ZERO SIGN +1D200..1D241 ; Greek # So [66] GREEK VOCAL NOTATION SYMBOL-1..GREEK INSTRUMENTAL NOTATION SYMBOL-54 +1D242..1D244 ; Greek # Mn [3] COMBINING GREEK MUSICAL TRISEME..COMBINING GREEK MUSICAL PENTASEME +1D245 ; Greek # So GREEK MUSICAL LEIMMA + +# Total code points: 511 + +# ================================================ + +0400..0481 ; Cyrillic # L& [130] CYRILLIC CAPITAL LETTER IE WITH GRAVE..CYRILLIC SMALL LETTER KOPPA +0482 ; Cyrillic # So CYRILLIC THOUSANDS SIGN +0483..0487 ; Cyrillic # Mn [5] COMBINING CYRILLIC TITLO..COMBINING CYRILLIC POKRYTIE +0488..0489 ; Cyrillic # Me [2] COMBINING CYRILLIC HUNDRED THOUSANDS SIGN..COMBINING CYRILLIC MILLIONS SIGN +048A..0523 ; Cyrillic # L& [154] CYRILLIC CAPITAL LETTER SHORT I WITH TAIL..CYRILLIC SMALL LETTER EN WITH MIDDLE HOOK +1D2B ; Cyrillic # L& CYRILLIC LETTER SMALL CAPITAL EL +1D78 ; Cyrillic # Lm MODIFIER LETTER CYRILLIC EN +2DE0..2DFF ; Cyrillic # Mn [32] COMBINING CYRILLIC LETTER BE..COMBINING CYRILLIC LETTER IOTIFIED BIG YUS +A640..A65F ; Cyrillic # L& [32] CYRILLIC CAPITAL LETTER ZEMLYA..CYRILLIC SMALL LETTER YN +A662..A66D ; Cyrillic # L& [12] CYRILLIC CAPITAL LETTER SOFT DE..CYRILLIC SMALL LETTER DOUBLE MONOCULAR O +A66E ; Cyrillic # Lo CYRILLIC LETTER MULTIOCULAR O +A66F ; Cyrillic # Mn COMBINING CYRILLIC VZMET +A670..A672 ; Cyrillic # Me [3] COMBINING CYRILLIC TEN MILLIONS SIGN..COMBINING CYRILLIC THOUSAND MILLIONS SIGN +A673 ; Cyrillic # Po SLAVONIC ASTERISK +A67C..A67D ; Cyrillic # Mn [2] COMBINING CYRILLIC KAVYKA..COMBINING CYRILLIC PAYEROK +A67E ; Cyrillic # Po CYRILLIC KAVYKA +A67F ; Cyrillic # Lm CYRILLIC PAYEROK +A680..A697 ; Cyrillic # L& [24] CYRILLIC CAPITAL LETTER DWE..CYRILLIC SMALL LETTER SHWE + +# Total code points: 404 + +# ================================================ + +0531..0556 ; Armenian # L& [38] ARMENIAN CAPITAL LETTER AYB..ARMENIAN CAPITAL LETTER FEH +0559 ; Armenian # Lm ARMENIAN MODIFIER LETTER LEFT HALF RING +055A..055F ; Armenian # Po [6] ARMENIAN APOSTROPHE..ARMENIAN ABBREVIATION MARK +0561..0587 ; Armenian # L& [39] ARMENIAN SMALL LETTER AYB..ARMENIAN SMALL LIGATURE ECH YIWN +058A ; Armenian # Pd ARMENIAN HYPHEN +FB13..FB17 ; Armenian # L& [5] ARMENIAN SMALL LIGATURE MEN NOW..ARMENIAN SMALL LIGATURE MEN XEH + +# Total code points: 90 + +# ================================================ + +0591..05BD ; Hebrew # Mn [45] HEBREW ACCENT ETNAHTA..HEBREW POINT METEG +05BE ; Hebrew # Pd HEBREW PUNCTUATION MAQAF +05BF ; Hebrew # Mn HEBREW POINT RAFE +05C0 ; Hebrew # Po HEBREW PUNCTUATION PASEQ +05C1..05C2 ; Hebrew # Mn [2] HEBREW POINT SHIN DOT..HEBREW POINT SIN DOT +05C3 ; Hebrew # Po HEBREW PUNCTUATION SOF PASUQ +05C4..05C5 ; Hebrew # Mn [2] HEBREW MARK UPPER DOT..HEBREW MARK LOWER DOT +05C6 ; Hebrew # Po HEBREW PUNCTUATION NUN HAFUKHA +05C7 ; Hebrew # Mn HEBREW POINT QAMATS QATAN +05D0..05EA ; Hebrew # Lo [27] HEBREW LETTER ALEF..HEBREW LETTER TAV +05F0..05F2 ; Hebrew # Lo [3] HEBREW LIGATURE YIDDISH DOUBLE VAV..HEBREW LIGATURE YIDDISH DOUBLE YOD +05F3..05F4 ; Hebrew # Po [2] HEBREW PUNCTUATION GERESH..HEBREW PUNCTUATION GERSHAYIM +FB1D ; Hebrew # Lo HEBREW LETTER YOD WITH HIRIQ +FB1E ; Hebrew # Mn HEBREW POINT JUDEO-SPANISH VARIKA +FB1F..FB28 ; Hebrew # Lo [10] HEBREW LIGATURE YIDDISH YOD YOD PATAH..HEBREW LETTER WIDE TAV +FB29 ; Hebrew # Sm HEBREW LETTER ALTERNATIVE PLUS SIGN +FB2A..FB36 ; Hebrew # Lo [13] HEBREW LETTER SHIN WITH SHIN DOT..HEBREW LETTER ZAYIN WITH DAGESH +FB38..FB3C ; Hebrew # Lo [5] HEBREW LETTER TET WITH DAGESH..HEBREW LETTER LAMED WITH DAGESH +FB3E ; Hebrew # Lo HEBREW LETTER MEM WITH DAGESH +FB40..FB41 ; Hebrew # Lo [2] HEBREW LETTER NUN WITH DAGESH..HEBREW LETTER SAMEKH WITH DAGESH +FB43..FB44 ; Hebrew # Lo [2] HEBREW LETTER FINAL PE WITH DAGESH..HEBREW LETTER PE WITH DAGESH +FB46..FB4F ; Hebrew # Lo [10] HEBREW LETTER TSADI WITH DAGESH..HEBREW LIGATURE ALEF LAMED + +# Total code points: 133 + +# ================================================ + +0606..0608 ; Arabic # Sm [3] ARABIC-INDIC CUBE ROOT..ARABIC RAY +0609..060A ; Arabic # Po [2] ARABIC-INDIC PER MILLE SIGN..ARABIC-INDIC PER TEN THOUSAND SIGN +060B ; Arabic # Sc AFGHANI SIGN +060D ; Arabic # Po ARABIC DATE SEPARATOR +060E..060F ; Arabic # So [2] ARABIC POETIC VERSE SIGN..ARABIC SIGN MISRA +0610..061A ; Arabic # Mn [11] ARABIC SIGN SALLALLAHOU ALAYHE WASSALLAM..ARABIC SMALL KASRA +061E ; Arabic # Po ARABIC TRIPLE DOT PUNCTUATION MARK +0621..063F ; Arabic # Lo [31] ARABIC LETTER HAMZA..ARABIC LETTER FARSI YEH WITH THREE DOTS ABOVE +0641..064A ; Arabic # Lo [10] ARABIC LETTER FEH..ARABIC LETTER YEH +0656..065E ; Arabic # Mn [9] ARABIC SUBSCRIPT ALEF..ARABIC FATHA WITH TWO DOTS +066A..066D ; Arabic # Po [4] ARABIC PERCENT SIGN..ARABIC FIVE POINTED STAR +066E..066F ; Arabic # Lo [2] ARABIC LETTER DOTLESS BEH..ARABIC LETTER DOTLESS QAF +0671..06D3 ; Arabic # Lo [99] ARABIC LETTER ALEF WASLA..ARABIC LETTER YEH BARREE WITH HAMZA ABOVE +06D4 ; Arabic # Po ARABIC FULL STOP +06D5 ; Arabic # Lo ARABIC LETTER AE +06D6..06DC ; Arabic # Mn [7] ARABIC SMALL HIGH LIGATURE SAD WITH LAM WITH ALEF MAKSURA..ARABIC SMALL HIGH SEEN +06DE ; Arabic # Me ARABIC START OF RUB EL HIZB +06DF..06E4 ; Arabic # Mn [6] ARABIC SMALL HIGH ROUNDED ZERO..ARABIC SMALL HIGH MADDA +06E5..06E6 ; Arabic # Lm [2] ARABIC SMALL WAW..ARABIC SMALL YEH +06E7..06E8 ; Arabic # Mn [2] ARABIC SMALL HIGH YEH..ARABIC SMALL HIGH NOON +06E9 ; Arabic # So ARABIC PLACE OF SAJDAH +06EA..06ED ; Arabic # Mn [4] ARABIC EMPTY CENTRE LOW STOP..ARABIC SMALL LOW MEEM +06EE..06EF ; Arabic # Lo [2] ARABIC LETTER DAL WITH INVERTED V..ARABIC LETTER REH WITH INVERTED V +06F0..06F9 ; Arabic # Nd [10] EXTENDED ARABIC-INDIC DIGIT ZERO..EXTENDED ARABIC-INDIC DIGIT NINE +06FA..06FC ; Arabic # Lo [3] ARABIC LETTER SHEEN WITH DOT BELOW..ARABIC LETTER GHAIN WITH DOT BELOW +06FD..06FE ; Arabic # So [2] ARABIC SIGN SINDHI AMPERSAND..ARABIC SIGN SINDHI POSTPOSITION MEN +06FF ; Arabic # Lo ARABIC LETTER HEH WITH INVERTED V +0750..077F ; Arabic # Lo [48] ARABIC LETTER BEH WITH THREE DOTS HORIZONTALLY BELOW..ARABIC LETTER KAF WITH TWO DOTS ABOVE +FB50..FBB1 ; Arabic # Lo [98] ARABIC LETTER ALEF WASLA ISOLATED FORM..ARABIC LETTER YEH BARREE WITH HAMZA ABOVE FINAL FORM +FBD3..FD3D ; Arabic # Lo [363] ARABIC LETTER NG ISOLATED FORM..ARABIC LIGATURE ALEF WITH FATHATAN ISOLATED FORM +FD50..FD8F ; Arabic # Lo [64] ARABIC LIGATURE TEH WITH JEEM WITH MEEM INITIAL FORM..ARABIC LIGATURE MEEM WITH KHAH WITH MEEM INITIAL FORM +FD92..FDC7 ; Arabic # Lo [54] ARABIC LIGATURE MEEM WITH JEEM WITH KHAH INITIAL FORM..ARABIC LIGATURE NOON WITH JEEM WITH YEH FINAL FORM +FDF0..FDFB ; Arabic # Lo [12] ARABIC LIGATURE SALLA USED AS KORANIC STOP SIGN ISOLATED FORM..ARABIC LIGATURE JALLAJALALOUHOU +FDFC ; Arabic # Sc RIAL SIGN +FE70..FE74 ; Arabic # Lo [5] ARABIC FATHATAN ISOLATED FORM..ARABIC KASRATAN ISOLATED FORM +FE76..FEFC ; Arabic # Lo [135] ARABIC FATHA ISOLATED FORM..ARABIC LIGATURE LAM WITH ALEF FINAL FORM + +# Total code points: 999 + +# ================================================ + +0700..070D ; Syriac # Po [14] SYRIAC END OF PARAGRAPH..SYRIAC HARKLEAN ASTERISCUS +070F ; Syriac # Cf SYRIAC ABBREVIATION MARK +0710 ; Syriac # Lo SYRIAC LETTER ALAPH +0711 ; Syriac # Mn SYRIAC LETTER SUPERSCRIPT ALAPH +0712..072F ; Syriac # Lo [30] SYRIAC LETTER BETH..SYRIAC LETTER PERSIAN DHALATH +0730..074A ; Syriac # Mn [27] SYRIAC PTHAHA ABOVE..SYRIAC BARREKH +074D..074F ; Syriac # Lo [3] SYRIAC LETTER SOGDIAN ZHAIN..SYRIAC LETTER SOGDIAN FE + +# Total code points: 77 + +# ================================================ + +0780..07A5 ; Thaana # Lo [38] THAANA LETTER HAA..THAANA LETTER WAAVU +07A6..07B0 ; Thaana # Mn [11] THAANA ABAFILI..THAANA SUKUN +07B1 ; Thaana # Lo THAANA LETTER NAA + +# Total code points: 50 + +# ================================================ + +0901..0902 ; Devanagari # Mn [2] DEVANAGARI SIGN CANDRABINDU..DEVANAGARI SIGN ANUSVARA +0903 ; Devanagari # Mc DEVANAGARI SIGN VISARGA +0904..0939 ; Devanagari # Lo [54] DEVANAGARI LETTER SHORT A..DEVANAGARI LETTER HA +093C ; Devanagari # Mn DEVANAGARI SIGN NUKTA +093D ; Devanagari # Lo DEVANAGARI SIGN AVAGRAHA +093E..0940 ; Devanagari # Mc [3] DEVANAGARI VOWEL SIGN AA..DEVANAGARI VOWEL SIGN II +0941..0948 ; Devanagari # Mn [8] DEVANAGARI VOWEL SIGN U..DEVANAGARI VOWEL SIGN AI +0949..094C ; Devanagari # Mc [4] DEVANAGARI VOWEL SIGN CANDRA O..DEVANAGARI VOWEL SIGN AU +094D ; Devanagari # Mn DEVANAGARI SIGN VIRAMA +0950 ; Devanagari # Lo DEVANAGARI OM +0953..0954 ; Devanagari # Mn [2] DEVANAGARI GRAVE ACCENT..DEVANAGARI ACUTE ACCENT +0958..0961 ; Devanagari # Lo [10] DEVANAGARI LETTER QA..DEVANAGARI LETTER VOCALIC LL +0962..0963 ; Devanagari # Mn [2] DEVANAGARI VOWEL SIGN VOCALIC L..DEVANAGARI VOWEL SIGN VOCALIC LL +0966..096F ; Devanagari # Nd [10] DEVANAGARI DIGIT ZERO..DEVANAGARI DIGIT NINE +0971 ; Devanagari # Lm DEVANAGARI SIGN HIGH SPACING DOT +0972 ; Devanagari # Lo DEVANAGARI LETTER CANDRA A +097B..097F ; Devanagari # Lo [5] DEVANAGARI LETTER GGA..DEVANAGARI LETTER BBA + +# Total code points: 107 + +# ================================================ + +0981 ; Bengali # Mn BENGALI SIGN CANDRABINDU +0982..0983 ; Bengali # Mc [2] BENGALI SIGN ANUSVARA..BENGALI SIGN VISARGA +0985..098C ; Bengali # Lo [8] BENGALI LETTER A..BENGALI LETTER VOCALIC L +098F..0990 ; Bengali # Lo [2] BENGALI LETTER E..BENGALI LETTER AI +0993..09A8 ; Bengali # Lo [22] BENGALI LETTER O..BENGALI LETTER NA +09AA..09B0 ; Bengali # Lo [7] BENGALI LETTER PA..BENGALI LETTER RA +09B2 ; Bengali # Lo BENGALI LETTER LA +09B6..09B9 ; Bengali # Lo [4] BENGALI LETTER SHA..BENGALI LETTER HA +09BC ; Bengali # Mn BENGALI SIGN NUKTA +09BD ; Bengali # Lo BENGALI SIGN AVAGRAHA +09BE..09C0 ; Bengali # Mc [3] BENGALI VOWEL SIGN AA..BENGALI VOWEL SIGN II +09C1..09C4 ; Bengali # Mn [4] BENGALI VOWEL SIGN U..BENGALI VOWEL SIGN VOCALIC RR +09C7..09C8 ; Bengali # Mc [2] BENGALI VOWEL SIGN E..BENGALI VOWEL SIGN AI +09CB..09CC ; Bengali # Mc [2] BENGALI VOWEL SIGN O..BENGALI VOWEL SIGN AU +09CD ; Bengali # Mn BENGALI SIGN VIRAMA +09CE ; Bengali # Lo BENGALI LETTER KHANDA TA +09D7 ; Bengali # Mc BENGALI AU LENGTH MARK +09DC..09DD ; Bengali # Lo [2] BENGALI LETTER RRA..BENGALI LETTER RHA +09DF..09E1 ; Bengali # Lo [3] BENGALI LETTER YYA..BENGALI LETTER VOCALIC LL +09E2..09E3 ; Bengali # Mn [2] BENGALI VOWEL SIGN VOCALIC L..BENGALI VOWEL SIGN VOCALIC LL +09E6..09EF ; Bengali # Nd [10] BENGALI DIGIT ZERO..BENGALI DIGIT NINE +09F0..09F1 ; Bengali # Lo [2] BENGALI LETTER RA WITH MIDDLE DIAGONAL..BENGALI LETTER RA WITH LOWER DIAGONAL +09F2..09F3 ; Bengali # Sc [2] BENGALI RUPEE MARK..BENGALI RUPEE SIGN +09F4..09F9 ; Bengali # No [6] BENGALI CURRENCY NUMERATOR ONE..BENGALI CURRENCY DENOMINATOR SIXTEEN +09FA ; Bengali # So BENGALI ISSHAR + +# Total code points: 91 + +# ================================================ + +0A01..0A02 ; Gurmukhi # Mn [2] GURMUKHI SIGN ADAK BINDI..GURMUKHI SIGN BINDI +0A03 ; Gurmukhi # Mc GURMUKHI SIGN VISARGA +0A05..0A0A ; Gurmukhi # Lo [6] GURMUKHI LETTER A..GURMUKHI LETTER UU +0A0F..0A10 ; Gurmukhi # Lo [2] GURMUKHI LETTER EE..GURMUKHI LETTER AI +0A13..0A28 ; Gurmukhi # Lo [22] GURMUKHI LETTER OO..GURMUKHI LETTER NA +0A2A..0A30 ; Gurmukhi # Lo [7] GURMUKHI LETTER PA..GURMUKHI LETTER RA +0A32..0A33 ; Gurmukhi # Lo [2] GURMUKHI LETTER LA..GURMUKHI LETTER LLA +0A35..0A36 ; Gurmukhi # Lo [2] GURMUKHI LETTER VA..GURMUKHI LETTER SHA +0A38..0A39 ; Gurmukhi # Lo [2] GURMUKHI LETTER SA..GURMUKHI LETTER HA +0A3C ; Gurmukhi # Mn GURMUKHI SIGN NUKTA +0A3E..0A40 ; Gurmukhi # Mc [3] GURMUKHI VOWEL SIGN AA..GURMUKHI VOWEL SIGN II +0A41..0A42 ; Gurmukhi # Mn [2] GURMUKHI VOWEL SIGN U..GURMUKHI VOWEL SIGN UU +0A47..0A48 ; Gurmukhi # Mn [2] GURMUKHI VOWEL SIGN EE..GURMUKHI VOWEL SIGN AI +0A4B..0A4D ; Gurmukhi # Mn [3] GURMUKHI VOWEL SIGN OO..GURMUKHI SIGN VIRAMA +0A51 ; Gurmukhi # Mn GURMUKHI SIGN UDAAT +0A59..0A5C ; Gurmukhi # Lo [4] GURMUKHI LETTER KHHA..GURMUKHI LETTER RRA +0A5E ; Gurmukhi # Lo GURMUKHI LETTER FA +0A66..0A6F ; Gurmukhi # Nd [10] GURMUKHI DIGIT ZERO..GURMUKHI DIGIT NINE +0A70..0A71 ; Gurmukhi # Mn [2] GURMUKHI TIPPI..GURMUKHI ADDAK +0A72..0A74 ; Gurmukhi # Lo [3] GURMUKHI IRI..GURMUKHI EK ONKAR +0A75 ; Gurmukhi # Mn GURMUKHI SIGN YAKASH + +# Total code points: 79 + +# ================================================ + +0A81..0A82 ; Gujarati # Mn [2] GUJARATI SIGN CANDRABINDU..GUJARATI SIGN ANUSVARA +0A83 ; Gujarati # Mc GUJARATI SIGN VISARGA +0A85..0A8D ; Gujarati # Lo [9] GUJARATI LETTER A..GUJARATI VOWEL CANDRA E +0A8F..0A91 ; Gujarati # Lo [3] GUJARATI LETTER E..GUJARATI VOWEL CANDRA O +0A93..0AA8 ; Gujarati # Lo [22] GUJARATI LETTER O..GUJARATI LETTER NA +0AAA..0AB0 ; Gujarati # Lo [7] GUJARATI LETTER PA..GUJARATI LETTER RA +0AB2..0AB3 ; Gujarati # Lo [2] GUJARATI LETTER LA..GUJARATI LETTER LLA +0AB5..0AB9 ; Gujarati # Lo [5] GUJARATI LETTER VA..GUJARATI LETTER HA +0ABC ; Gujarati # Mn GUJARATI SIGN NUKTA +0ABD ; Gujarati # Lo GUJARATI SIGN AVAGRAHA +0ABE..0AC0 ; Gujarati # Mc [3] GUJARATI VOWEL SIGN AA..GUJARATI VOWEL SIGN II +0AC1..0AC5 ; Gujarati # Mn [5] GUJARATI VOWEL SIGN U..GUJARATI VOWEL SIGN CANDRA E +0AC7..0AC8 ; Gujarati # Mn [2] GUJARATI VOWEL SIGN E..GUJARATI VOWEL SIGN AI +0AC9 ; Gujarati # Mc GUJARATI VOWEL SIGN CANDRA O +0ACB..0ACC ; Gujarati # Mc [2] GUJARATI VOWEL SIGN O..GUJARATI VOWEL SIGN AU +0ACD ; Gujarati # Mn GUJARATI SIGN VIRAMA +0AD0 ; Gujarati # Lo GUJARATI OM +0AE0..0AE1 ; Gujarati # Lo [2] GUJARATI LETTER VOCALIC RR..GUJARATI LETTER VOCALIC LL +0AE2..0AE3 ; Gujarati # Mn [2] GUJARATI VOWEL SIGN VOCALIC L..GUJARATI VOWEL SIGN VOCALIC LL +0AE6..0AEF ; Gujarati # Nd [10] GUJARATI DIGIT ZERO..GUJARATI DIGIT NINE +0AF1 ; Gujarati # Sc GUJARATI RUPEE SIGN + +# Total code points: 83 + +# ================================================ + +0B01 ; Oriya # Mn ORIYA SIGN CANDRABINDU +0B02..0B03 ; Oriya # Mc [2] ORIYA SIGN ANUSVARA..ORIYA SIGN VISARGA +0B05..0B0C ; Oriya # Lo [8] ORIYA LETTER A..ORIYA LETTER VOCALIC L +0B0F..0B10 ; Oriya # Lo [2] ORIYA LETTER E..ORIYA LETTER AI +0B13..0B28 ; Oriya # Lo [22] ORIYA LETTER O..ORIYA LETTER NA +0B2A..0B30 ; Oriya # Lo [7] ORIYA LETTER PA..ORIYA LETTER RA +0B32..0B33 ; Oriya # Lo [2] ORIYA LETTER LA..ORIYA LETTER LLA +0B35..0B39 ; Oriya # Lo [5] ORIYA LETTER VA..ORIYA LETTER HA +0B3C ; Oriya # Mn ORIYA SIGN NUKTA +0B3D ; Oriya # Lo ORIYA SIGN AVAGRAHA +0B3E ; Oriya # Mc ORIYA VOWEL SIGN AA +0B3F ; Oriya # Mn ORIYA VOWEL SIGN I +0B40 ; Oriya # Mc ORIYA VOWEL SIGN II +0B41..0B44 ; Oriya # Mn [4] ORIYA VOWEL SIGN U..ORIYA VOWEL SIGN VOCALIC RR +0B47..0B48 ; Oriya # Mc [2] ORIYA VOWEL SIGN E..ORIYA VOWEL SIGN AI +0B4B..0B4C ; Oriya # Mc [2] ORIYA VOWEL SIGN O..ORIYA VOWEL SIGN AU +0B4D ; Oriya # Mn ORIYA SIGN VIRAMA +0B56 ; Oriya # Mn ORIYA AI LENGTH MARK +0B57 ; Oriya # Mc ORIYA AU LENGTH MARK +0B5C..0B5D ; Oriya # Lo [2] ORIYA LETTER RRA..ORIYA LETTER RHA +0B5F..0B61 ; Oriya # Lo [3] ORIYA LETTER YYA..ORIYA LETTER VOCALIC LL +0B62..0B63 ; Oriya # Mn [2] ORIYA VOWEL SIGN VOCALIC L..ORIYA VOWEL SIGN VOCALIC LL +0B66..0B6F ; Oriya # Nd [10] ORIYA DIGIT ZERO..ORIYA DIGIT NINE +0B70 ; Oriya # So ORIYA ISSHAR +0B71 ; Oriya # Lo ORIYA LETTER WA + +# Total code points: 84 + +# ================================================ + +0B82 ; Tamil # Mn TAMIL SIGN ANUSVARA +0B83 ; Tamil # Lo TAMIL SIGN VISARGA +0B85..0B8A ; Tamil # Lo [6] TAMIL LETTER A..TAMIL LETTER UU +0B8E..0B90 ; Tamil # Lo [3] TAMIL LETTER E..TAMIL LETTER AI +0B92..0B95 ; Tamil # Lo [4] TAMIL LETTER O..TAMIL LETTER KA +0B99..0B9A ; Tamil # Lo [2] TAMIL LETTER NGA..TAMIL LETTER CA +0B9C ; Tamil # Lo TAMIL LETTER JA +0B9E..0B9F ; Tamil # Lo [2] TAMIL LETTER NYA..TAMIL LETTER TTA +0BA3..0BA4 ; Tamil # Lo [2] TAMIL LETTER NNA..TAMIL LETTER TA +0BA8..0BAA ; Tamil # Lo [3] TAMIL LETTER NA..TAMIL LETTER PA +0BAE..0BB9 ; Tamil # Lo [12] TAMIL LETTER MA..TAMIL LETTER HA +0BBE..0BBF ; Tamil # Mc [2] TAMIL VOWEL SIGN AA..TAMIL VOWEL SIGN I +0BC0 ; Tamil # Mn TAMIL VOWEL SIGN II +0BC1..0BC2 ; Tamil # Mc [2] TAMIL VOWEL SIGN U..TAMIL VOWEL SIGN UU +0BC6..0BC8 ; Tamil # Mc [3] TAMIL VOWEL SIGN E..TAMIL VOWEL SIGN AI +0BCA..0BCC ; Tamil # Mc [3] TAMIL VOWEL SIGN O..TAMIL VOWEL SIGN AU +0BCD ; Tamil # Mn TAMIL SIGN VIRAMA +0BD0 ; Tamil # Lo TAMIL OM +0BD7 ; Tamil # Mc TAMIL AU LENGTH MARK +0BE6..0BEF ; Tamil # Nd [10] TAMIL DIGIT ZERO..TAMIL DIGIT NINE +0BF0..0BF2 ; Tamil # No [3] TAMIL NUMBER TEN..TAMIL NUMBER ONE THOUSAND +0BF3..0BF8 ; Tamil # So [6] TAMIL DAY SIGN..TAMIL AS ABOVE SIGN +0BF9 ; Tamil # Sc TAMIL RUPEE SIGN +0BFA ; Tamil # So TAMIL NUMBER SIGN + +# Total code points: 72 + +# ================================================ + +0C01..0C03 ; Telugu # Mc [3] TELUGU SIGN CANDRABINDU..TELUGU SIGN VISARGA +0C05..0C0C ; Telugu # Lo [8] TELUGU LETTER A..TELUGU LETTER VOCALIC L +0C0E..0C10 ; Telugu # Lo [3] TELUGU LETTER E..TELUGU LETTER AI +0C12..0C28 ; Telugu # Lo [23] TELUGU LETTER O..TELUGU LETTER NA +0C2A..0C33 ; Telugu # Lo [10] TELUGU LETTER PA..TELUGU LETTER LLA +0C35..0C39 ; Telugu # Lo [5] TELUGU LETTER VA..TELUGU LETTER HA +0C3D ; Telugu # Lo TELUGU SIGN AVAGRAHA +0C3E..0C40 ; Telugu # Mn [3] TELUGU VOWEL SIGN AA..TELUGU VOWEL SIGN II +0C41..0C44 ; Telugu # Mc [4] TELUGU VOWEL SIGN U..TELUGU VOWEL SIGN VOCALIC RR +0C46..0C48 ; Telugu # Mn [3] TELUGU VOWEL SIGN E..TELUGU VOWEL SIGN AI +0C4A..0C4D ; Telugu # Mn [4] TELUGU VOWEL SIGN O..TELUGU SIGN VIRAMA +0C55..0C56 ; Telugu # Mn [2] TELUGU LENGTH MARK..TELUGU AI LENGTH MARK +0C58..0C59 ; Telugu # Lo [2] TELUGU LETTER TSA..TELUGU LETTER DZA +0C60..0C61 ; Telugu # Lo [2] TELUGU LETTER VOCALIC RR..TELUGU LETTER VOCALIC LL +0C62..0C63 ; Telugu # Mn [2] TELUGU VOWEL SIGN VOCALIC L..TELUGU VOWEL SIGN VOCALIC LL +0C66..0C6F ; Telugu # Nd [10] TELUGU DIGIT ZERO..TELUGU DIGIT NINE +0C78..0C7E ; Telugu # No [7] TELUGU FRACTION DIGIT ZERO FOR ODD POWERS OF FOUR..TELUGU FRACTION DIGIT THREE FOR EVEN POWERS OF FOUR +0C7F ; Telugu # So TELUGU SIGN TUUMU + +# Total code points: 93 + +# ================================================ + +0C82..0C83 ; Kannada # Mc [2] KANNADA SIGN ANUSVARA..KANNADA SIGN VISARGA +0C85..0C8C ; Kannada # Lo [8] KANNADA LETTER A..KANNADA LETTER VOCALIC L +0C8E..0C90 ; Kannada # Lo [3] KANNADA LETTER E..KANNADA LETTER AI +0C92..0CA8 ; Kannada # Lo [23] KANNADA LETTER O..KANNADA LETTER NA +0CAA..0CB3 ; Kannada # Lo [10] KANNADA LETTER PA..KANNADA LETTER LLA +0CB5..0CB9 ; Kannada # Lo [5] KANNADA LETTER VA..KANNADA LETTER HA +0CBC ; Kannada # Mn KANNADA SIGN NUKTA +0CBD ; Kannada # Lo KANNADA SIGN AVAGRAHA +0CBE ; Kannada # Mc KANNADA VOWEL SIGN AA +0CBF ; Kannada # Mn KANNADA VOWEL SIGN I +0CC0..0CC4 ; Kannada # Mc [5] KANNADA VOWEL SIGN II..KANNADA VOWEL SIGN VOCALIC RR +0CC6 ; Kannada # Mn KANNADA VOWEL SIGN E +0CC7..0CC8 ; Kannada # Mc [2] KANNADA VOWEL SIGN EE..KANNADA VOWEL SIGN AI +0CCA..0CCB ; Kannada # Mc [2] KANNADA VOWEL SIGN O..KANNADA VOWEL SIGN OO +0CCC..0CCD ; Kannada # Mn [2] KANNADA VOWEL SIGN AU..KANNADA SIGN VIRAMA +0CD5..0CD6 ; Kannada # Mc [2] KANNADA LENGTH MARK..KANNADA AI LENGTH MARK +0CDE ; Kannada # Lo KANNADA LETTER FA +0CE0..0CE1 ; Kannada # Lo [2] KANNADA LETTER VOCALIC RR..KANNADA LETTER VOCALIC LL +0CE2..0CE3 ; Kannada # Mn [2] KANNADA VOWEL SIGN VOCALIC L..KANNADA VOWEL SIGN VOCALIC LL +0CE6..0CEF ; Kannada # Nd [10] KANNADA DIGIT ZERO..KANNADA DIGIT NINE + +# Total code points: 84 + +# ================================================ + +0D02..0D03 ; Malayalam # Mc [2] MALAYALAM SIGN ANUSVARA..MALAYALAM SIGN VISARGA +0D05..0D0C ; Malayalam # Lo [8] MALAYALAM LETTER A..MALAYALAM LETTER VOCALIC L +0D0E..0D10 ; Malayalam # Lo [3] MALAYALAM LETTER E..MALAYALAM LETTER AI +0D12..0D28 ; Malayalam # Lo [23] MALAYALAM LETTER O..MALAYALAM LETTER NA +0D2A..0D39 ; Malayalam # Lo [16] MALAYALAM LETTER PA..MALAYALAM LETTER HA +0D3D ; Malayalam # Lo MALAYALAM SIGN AVAGRAHA +0D3E..0D40 ; Malayalam # Mc [3] MALAYALAM VOWEL SIGN AA..MALAYALAM VOWEL SIGN II +0D41..0D44 ; Malayalam # Mn [4] MALAYALAM VOWEL SIGN U..MALAYALAM VOWEL SIGN VOCALIC RR +0D46..0D48 ; Malayalam # Mc [3] MALAYALAM VOWEL SIGN E..MALAYALAM VOWEL SIGN AI +0D4A..0D4C ; Malayalam # Mc [3] MALAYALAM VOWEL SIGN O..MALAYALAM VOWEL SIGN AU +0D4D ; Malayalam # Mn MALAYALAM SIGN VIRAMA +0D57 ; Malayalam # Mc MALAYALAM AU LENGTH MARK +0D60..0D61 ; Malayalam # Lo [2] MALAYALAM LETTER VOCALIC RR..MALAYALAM LETTER VOCALIC LL +0D62..0D63 ; Malayalam # Mn [2] MALAYALAM VOWEL SIGN VOCALIC L..MALAYALAM VOWEL SIGN VOCALIC LL +0D66..0D6F ; Malayalam # Nd [10] MALAYALAM DIGIT ZERO..MALAYALAM DIGIT NINE +0D70..0D75 ; Malayalam # No [6] MALAYALAM NUMBER TEN..MALAYALAM FRACTION THREE QUARTERS +0D79 ; Malayalam # So MALAYALAM DATE MARK +0D7A..0D7F ; Malayalam # Lo [6] MALAYALAM LETTER CHILLU NN..MALAYALAM LETTER CHILLU K + +# Total code points: 95 + +# ================================================ + +0D82..0D83 ; Sinhala # Mc [2] SINHALA SIGN ANUSVARAYA..SINHALA SIGN VISARGAYA +0D85..0D96 ; Sinhala # Lo [18] SINHALA LETTER AYANNA..SINHALA LETTER AUYANNA +0D9A..0DB1 ; Sinhala # Lo [24] SINHALA LETTER ALPAPRAANA KAYANNA..SINHALA LETTER DANTAJA NAYANNA +0DB3..0DBB ; Sinhala # Lo [9] SINHALA LETTER SANYAKA DAYANNA..SINHALA LETTER RAYANNA +0DBD ; Sinhala # Lo SINHALA LETTER DANTAJA LAYANNA +0DC0..0DC6 ; Sinhala # Lo [7] SINHALA LETTER VAYANNA..SINHALA LETTER FAYANNA +0DCA ; Sinhala # Mn SINHALA SIGN AL-LAKUNA +0DCF..0DD1 ; Sinhala # Mc [3] SINHALA VOWEL SIGN AELA-PILLA..SINHALA VOWEL SIGN DIGA AEDA-PILLA +0DD2..0DD4 ; Sinhala # Mn [3] SINHALA VOWEL SIGN KETTI IS-PILLA..SINHALA VOWEL SIGN KETTI PAA-PILLA +0DD6 ; Sinhala # Mn SINHALA VOWEL SIGN DIGA PAA-PILLA +0DD8..0DDF ; Sinhala # Mc [8] SINHALA VOWEL SIGN GAETTA-PILLA..SINHALA VOWEL SIGN GAYANUKITTA +0DF2..0DF3 ; Sinhala # Mc [2] SINHALA VOWEL SIGN DIGA GAETTA-PILLA..SINHALA VOWEL SIGN DIGA GAYANUKITTA +0DF4 ; Sinhala # Po SINHALA PUNCTUATION KUNDDALIYA + +# Total code points: 80 + +# ================================================ + +0E01..0E30 ; Thai # Lo [48] THAI CHARACTER KO KAI..THAI CHARACTER SARA A +0E31 ; Thai # Mn THAI CHARACTER MAI HAN-AKAT +0E32..0E33 ; Thai # Lo [2] THAI CHARACTER SARA AA..THAI CHARACTER SARA AM +0E34..0E3A ; Thai # Mn [7] THAI CHARACTER SARA I..THAI CHARACTER PHINTHU +0E40..0E45 ; Thai # Lo [6] THAI CHARACTER SARA E..THAI CHARACTER LAKKHANGYAO +0E46 ; Thai # Lm THAI CHARACTER MAIYAMOK +0E47..0E4E ; Thai # Mn [8] THAI CHARACTER MAITAIKHU..THAI CHARACTER YAMAKKAN +0E4F ; Thai # Po THAI CHARACTER FONGMAN +0E50..0E59 ; Thai # Nd [10] THAI DIGIT ZERO..THAI DIGIT NINE +0E5A..0E5B ; Thai # Po [2] THAI CHARACTER ANGKHANKHU..THAI CHARACTER KHOMUT + +# Total code points: 86 + +# ================================================ + +0E81..0E82 ; Lao # Lo [2] LAO LETTER KO..LAO LETTER KHO SUNG +0E84 ; Lao # Lo LAO LETTER KHO TAM +0E87..0E88 ; Lao # Lo [2] LAO LETTER NGO..LAO LETTER CO +0E8A ; Lao # Lo LAO LETTER SO TAM +0E8D ; Lao # Lo LAO LETTER NYO +0E94..0E97 ; Lao # Lo [4] LAO LETTER DO..LAO LETTER THO TAM +0E99..0E9F ; Lao # Lo [7] LAO LETTER NO..LAO LETTER FO SUNG +0EA1..0EA3 ; Lao # Lo [3] LAO LETTER MO..LAO LETTER LO LING +0EA5 ; Lao # Lo LAO LETTER LO LOOT +0EA7 ; Lao # Lo LAO LETTER WO +0EAA..0EAB ; Lao # Lo [2] LAO LETTER SO SUNG..LAO LETTER HO SUNG +0EAD..0EB0 ; Lao # Lo [4] LAO LETTER O..LAO VOWEL SIGN A +0EB1 ; Lao # Mn LAO VOWEL SIGN MAI KAN +0EB2..0EB3 ; Lao # Lo [2] LAO VOWEL SIGN AA..LAO VOWEL SIGN AM +0EB4..0EB9 ; Lao # Mn [6] LAO VOWEL SIGN I..LAO VOWEL SIGN UU +0EBB..0EBC ; Lao # Mn [2] LAO VOWEL SIGN MAI KON..LAO SEMIVOWEL SIGN LO +0EBD ; Lao # Lo LAO SEMIVOWEL SIGN NYO +0EC0..0EC4 ; Lao # Lo [5] LAO VOWEL SIGN E..LAO VOWEL SIGN AI +0EC6 ; Lao # Lm LAO KO LA +0EC8..0ECD ; Lao # Mn [6] LAO TONE MAI EK..LAO NIGGAHITA +0ED0..0ED9 ; Lao # Nd [10] LAO DIGIT ZERO..LAO DIGIT NINE +0EDC..0EDD ; Lao # Lo [2] LAO HO NO..LAO HO MO + +# Total code points: 65 + +# ================================================ + +0F00 ; Tibetan # Lo TIBETAN SYLLABLE OM +0F01..0F03 ; Tibetan # So [3] TIBETAN MARK GTER YIG MGO TRUNCATED A..TIBETAN MARK GTER YIG MGO -UM GTER TSHEG MA +0F04..0F12 ; Tibetan # Po [15] TIBETAN MARK INITIAL YIG MGO MDUN MA..TIBETAN MARK RGYA GRAM SHAD +0F13..0F17 ; Tibetan # So [5] TIBETAN MARK CARET -DZUD RTAGS ME LONG CAN..TIBETAN ASTROLOGICAL SIGN SGRA GCAN -CHAR RTAGS +0F18..0F19 ; Tibetan # Mn [2] TIBETAN ASTROLOGICAL SIGN -KHYUD PA..TIBETAN ASTROLOGICAL SIGN SDONG TSHUGS +0F1A..0F1F ; Tibetan # So [6] TIBETAN SIGN RDEL DKAR GCIG..TIBETAN SIGN RDEL DKAR RDEL NAG +0F20..0F29 ; Tibetan # Nd [10] TIBETAN DIGIT ZERO..TIBETAN DIGIT NINE +0F2A..0F33 ; Tibetan # No [10] TIBETAN DIGIT HALF ONE..TIBETAN DIGIT HALF ZERO +0F34 ; Tibetan # So TIBETAN MARK BSDUS RTAGS +0F35 ; Tibetan # Mn TIBETAN MARK NGAS BZUNG NYI ZLA +0F36 ; Tibetan # So TIBETAN MARK CARET -DZUD RTAGS BZHI MIG CAN +0F37 ; Tibetan # Mn TIBETAN MARK NGAS BZUNG SGOR RTAGS +0F38 ; Tibetan # So TIBETAN MARK CHE MGO +0F39 ; Tibetan # Mn TIBETAN MARK TSA -PHRU +0F3A ; Tibetan # Ps TIBETAN MARK GUG RTAGS GYON +0F3B ; Tibetan # Pe TIBETAN MARK GUG RTAGS GYAS +0F3C ; Tibetan # Ps TIBETAN MARK ANG KHANG GYON +0F3D ; Tibetan # Pe TIBETAN MARK ANG KHANG GYAS +0F3E..0F3F ; Tibetan # Mc [2] TIBETAN SIGN YAR TSHES..TIBETAN SIGN MAR TSHES +0F40..0F47 ; Tibetan # Lo [8] TIBETAN LETTER KA..TIBETAN LETTER JA +0F49..0F6C ; Tibetan # Lo [36] TIBETAN LETTER NYA..TIBETAN LETTER RRA +0F71..0F7E ; Tibetan # Mn [14] TIBETAN VOWEL SIGN AA..TIBETAN SIGN RJES SU NGA RO +0F7F ; Tibetan # Mc TIBETAN SIGN RNAM BCAD +0F80..0F84 ; Tibetan # Mn [5] TIBETAN VOWEL SIGN REVERSED I..TIBETAN MARK HALANTA +0F85 ; Tibetan # Po TIBETAN MARK PALUTA +0F86..0F87 ; Tibetan # Mn [2] TIBETAN SIGN LCI RTAGS..TIBETAN SIGN YANG RTAGS +0F88..0F8B ; Tibetan # Lo [4] TIBETAN SIGN LCE TSA CAN..TIBETAN SIGN GRU MED RGYINGS +0F90..0F97 ; Tibetan # Mn [8] TIBETAN SUBJOINED LETTER KA..TIBETAN SUBJOINED LETTER JA +0F99..0FBC ; Tibetan # Mn [36] TIBETAN SUBJOINED LETTER NYA..TIBETAN SUBJOINED LETTER FIXED-FORM RA +0FBE..0FC5 ; Tibetan # So [8] TIBETAN KU RU KHA..TIBETAN SYMBOL RDO RJE +0FC6 ; Tibetan # Mn TIBETAN SYMBOL PADMA GDAN +0FC7..0FCC ; Tibetan # So [6] TIBETAN SYMBOL RDO RJE RGYA GRAM..TIBETAN SYMBOL NOR BU BZHI -KHYIL +0FCE..0FCF ; Tibetan # So [2] TIBETAN SIGN RDEL NAG RDEL DKAR..TIBETAN SIGN RDEL NAG GSUM +0FD0..0FD4 ; Tibetan # Po [5] TIBETAN MARK BSKA- SHOG GI MGO RGYAN..TIBETAN MARK CLOSING BRDA RNYING YIG MGO SGAB MA + +# Total code points: 201 + +# ================================================ + +1000..102A ; Myanmar # Lo [43] MYANMAR LETTER KA..MYANMAR LETTER AU +102B..102C ; Myanmar # Mc [2] MYANMAR VOWEL SIGN TALL AA..MYANMAR VOWEL SIGN AA +102D..1030 ; Myanmar # Mn [4] MYANMAR VOWEL SIGN I..MYANMAR VOWEL SIGN UU +1031 ; Myanmar # Mc MYANMAR VOWEL SIGN E +1032..1037 ; Myanmar # Mn [6] MYANMAR VOWEL SIGN AI..MYANMAR SIGN DOT BELOW +1038 ; Myanmar # Mc MYANMAR SIGN VISARGA +1039..103A ; Myanmar # Mn [2] MYANMAR SIGN VIRAMA..MYANMAR SIGN ASAT +103B..103C ; Myanmar # Mc [2] MYANMAR CONSONANT SIGN MEDIAL YA..MYANMAR CONSONANT SIGN MEDIAL RA +103D..103E ; Myanmar # Mn [2] MYANMAR CONSONANT SIGN MEDIAL WA..MYANMAR CONSONANT SIGN MEDIAL HA +103F ; Myanmar # Lo MYANMAR LETTER GREAT SA +1040..1049 ; Myanmar # Nd [10] MYANMAR DIGIT ZERO..MYANMAR DIGIT NINE +104A..104F ; Myanmar # Po [6] MYANMAR SIGN LITTLE SECTION..MYANMAR SYMBOL GENITIVE +1050..1055 ; Myanmar # Lo [6] MYANMAR LETTER SHA..MYANMAR LETTER VOCALIC LL +1056..1057 ; Myanmar # Mc [2] MYANMAR VOWEL SIGN VOCALIC R..MYANMAR VOWEL SIGN VOCALIC RR +1058..1059 ; Myanmar # Mn [2] MYANMAR VOWEL SIGN VOCALIC L..MYANMAR VOWEL SIGN VOCALIC LL +105A..105D ; Myanmar # Lo [4] MYANMAR LETTER MON NGA..MYANMAR LETTER MON BBE +105E..1060 ; Myanmar # Mn [3] MYANMAR CONSONANT SIGN MON MEDIAL NA..MYANMAR CONSONANT SIGN MON MEDIAL LA +1061 ; Myanmar # Lo MYANMAR LETTER SGAW KAREN SHA +1062..1064 ; Myanmar # Mc [3] MYANMAR VOWEL SIGN SGAW KAREN EU..MYANMAR TONE MARK SGAW KAREN KE PHO +1065..1066 ; Myanmar # Lo [2] MYANMAR LETTER WESTERN PWO KAREN THA..MYANMAR LETTER WESTERN PWO KAREN PWA +1067..106D ; Myanmar # Mc [7] MYANMAR VOWEL SIGN WESTERN PWO KAREN EU..MYANMAR SIGN WESTERN PWO KAREN TONE-5 +106E..1070 ; Myanmar # Lo [3] MYANMAR LETTER EASTERN PWO KAREN NNA..MYANMAR LETTER EASTERN PWO KAREN GHWA +1071..1074 ; Myanmar # Mn [4] MYANMAR VOWEL SIGN GEBA KAREN I..MYANMAR VOWEL SIGN KAYAH EE +1075..1081 ; Myanmar # Lo [13] MYANMAR LETTER SHAN KA..MYANMAR LETTER SHAN HA +1082 ; Myanmar # Mn MYANMAR CONSONANT SIGN SHAN MEDIAL WA +1083..1084 ; Myanmar # Mc [2] MYANMAR VOWEL SIGN SHAN AA..MYANMAR VOWEL SIGN SHAN E +1085..1086 ; Myanmar # Mn [2] MYANMAR VOWEL SIGN SHAN E ABOVE..MYANMAR VOWEL SIGN SHAN FINAL Y +1087..108C ; Myanmar # Mc [6] MYANMAR SIGN SHAN TONE-2..MYANMAR SIGN SHAN COUNCIL TONE-3 +108D ; Myanmar # Mn MYANMAR SIGN SHAN COUNCIL EMPHATIC TONE +108E ; Myanmar # Lo MYANMAR LETTER RUMAI PALAUNG FA +108F ; Myanmar # Mc MYANMAR SIGN RUMAI PALAUNG TONE-5 +1090..1099 ; Myanmar # Nd [10] MYANMAR SHAN DIGIT ZERO..MYANMAR SHAN DIGIT NINE +109E..109F ; Myanmar # So [2] MYANMAR SYMBOL SHAN ONE..MYANMAR SYMBOL SHAN EXCLAMATION + +# Total code points: 156 + +# ================================================ + +10A0..10C5 ; Georgian # L& [38] GEORGIAN CAPITAL LETTER AN..GEORGIAN CAPITAL LETTER HOE +10D0..10FA ; Georgian # Lo [43] GEORGIAN LETTER AN..GEORGIAN LETTER AIN +10FC ; Georgian # Lm MODIFIER LETTER GEORGIAN NAR +2D00..2D25 ; Georgian # L& [38] GEORGIAN SMALL LETTER AN..GEORGIAN SMALL LETTER HOE + +# Total code points: 120 + +# ================================================ + +1100..1159 ; Hangul # Lo [90] HANGUL CHOSEONG KIYEOK..HANGUL CHOSEONG YEORINHIEUH +115F..11A2 ; Hangul # Lo [68] HANGUL CHOSEONG FILLER..HANGUL JUNGSEONG SSANGARAEA +11A8..11F9 ; Hangul # Lo [82] HANGUL JONGSEONG KIYEOK..HANGUL JONGSEONG YEORINHIEUH +3131..318E ; Hangul # Lo [94] HANGUL LETTER KIYEOK..HANGUL LETTER ARAEAE +3200..321E ; Hangul # So [31] PARENTHESIZED HANGUL KIYEOK..PARENTHESIZED KOREAN CHARACTER O HU +3260..327E ; Hangul # So [31] CIRCLED HANGUL KIYEOK..CIRCLED HANGUL IEUNG U +AC00..D7A3 ; Hangul # Lo [11172] HANGUL SYLLABLE GA..HANGUL SYLLABLE HIH +FFA0..FFBE ; Hangul # Lo [31] HALFWIDTH HANGUL FILLER..HALFWIDTH HANGUL LETTER HIEUH +FFC2..FFC7 ; Hangul # Lo [6] HALFWIDTH HANGUL LETTER A..HALFWIDTH HANGUL LETTER E +FFCA..FFCF ; Hangul # Lo [6] HALFWIDTH HANGUL LETTER YEO..HALFWIDTH HANGUL LETTER OE +FFD2..FFD7 ; Hangul # Lo [6] HALFWIDTH HANGUL LETTER YO..HALFWIDTH HANGUL LETTER YU +FFDA..FFDC ; Hangul # Lo [3] HALFWIDTH HANGUL LETTER EU..HALFWIDTH HANGUL LETTER I + +# Total code points: 11620 + +# ================================================ + +1200..1248 ; Ethiopic # Lo [73] ETHIOPIC SYLLABLE HA..ETHIOPIC SYLLABLE QWA +124A..124D ; Ethiopic # Lo [4] ETHIOPIC SYLLABLE QWI..ETHIOPIC SYLLABLE QWE +1250..1256 ; Ethiopic # Lo [7] ETHIOPIC SYLLABLE QHA..ETHIOPIC SYLLABLE QHO +1258 ; Ethiopic # Lo ETHIOPIC SYLLABLE QHWA +125A..125D ; Ethiopic # Lo [4] ETHIOPIC SYLLABLE QHWI..ETHIOPIC SYLLABLE QHWE +1260..1288 ; Ethiopic # Lo [41] ETHIOPIC SYLLABLE BA..ETHIOPIC SYLLABLE XWA +128A..128D ; Ethiopic # Lo [4] ETHIOPIC SYLLABLE XWI..ETHIOPIC SYLLABLE XWE +1290..12B0 ; Ethiopic # Lo [33] ETHIOPIC SYLLABLE NA..ETHIOPIC SYLLABLE KWA +12B2..12B5 ; Ethiopic # Lo [4] ETHIOPIC SYLLABLE KWI..ETHIOPIC SYLLABLE KWE +12B8..12BE ; Ethiopic # Lo [7] ETHIOPIC SYLLABLE KXA..ETHIOPIC SYLLABLE KXO +12C0 ; Ethiopic # Lo ETHIOPIC SYLLABLE KXWA +12C2..12C5 ; Ethiopic # Lo [4] ETHIOPIC SYLLABLE KXWI..ETHIOPIC SYLLABLE KXWE +12C8..12D6 ; Ethiopic # Lo [15] ETHIOPIC SYLLABLE WA..ETHIOPIC SYLLABLE PHARYNGEAL O +12D8..1310 ; Ethiopic # Lo [57] ETHIOPIC SYLLABLE ZA..ETHIOPIC SYLLABLE GWA +1312..1315 ; Ethiopic # Lo [4] ETHIOPIC SYLLABLE GWI..ETHIOPIC SYLLABLE GWE +1318..135A ; Ethiopic # Lo [67] ETHIOPIC SYLLABLE GGA..ETHIOPIC SYLLABLE FYA +135F ; Ethiopic # Mn ETHIOPIC COMBINING GEMINATION MARK +1360 ; Ethiopic # So ETHIOPIC SECTION MARK +1361..1368 ; Ethiopic # Po [8] ETHIOPIC WORDSPACE..ETHIOPIC PARAGRAPH SEPARATOR +1369..137C ; Ethiopic # No [20] ETHIOPIC DIGIT ONE..ETHIOPIC NUMBER TEN THOUSAND +1380..138F ; Ethiopic # Lo [16] ETHIOPIC SYLLABLE SEBATBEIT MWA..ETHIOPIC SYLLABLE PWE +1390..1399 ; Ethiopic # So [10] ETHIOPIC TONAL MARK YIZET..ETHIOPIC TONAL MARK KURT +2D80..2D96 ; Ethiopic # Lo [23] ETHIOPIC SYLLABLE LOA..ETHIOPIC SYLLABLE GGWE +2DA0..2DA6 ; Ethiopic # Lo [7] ETHIOPIC SYLLABLE SSA..ETHIOPIC SYLLABLE SSO +2DA8..2DAE ; Ethiopic # Lo [7] ETHIOPIC SYLLABLE CCA..ETHIOPIC SYLLABLE CCO +2DB0..2DB6 ; Ethiopic # Lo [7] ETHIOPIC SYLLABLE ZZA..ETHIOPIC SYLLABLE ZZO +2DB8..2DBE ; Ethiopic # Lo [7] ETHIOPIC SYLLABLE CCHA..ETHIOPIC SYLLABLE CCHO +2DC0..2DC6 ; Ethiopic # Lo [7] ETHIOPIC SYLLABLE QYA..ETHIOPIC SYLLABLE QYO +2DC8..2DCE ; Ethiopic # Lo [7] ETHIOPIC SYLLABLE KYA..ETHIOPIC SYLLABLE KYO +2DD0..2DD6 ; Ethiopic # Lo [7] ETHIOPIC SYLLABLE XYA..ETHIOPIC SYLLABLE XYO +2DD8..2DDE ; Ethiopic # Lo [7] ETHIOPIC SYLLABLE GYA..ETHIOPIC SYLLABLE GYO + +# Total code points: 461 + +# ================================================ + +13A0..13F4 ; Cherokee # Lo [85] CHEROKEE LETTER A..CHEROKEE LETTER YV + +# Total code points: 85 + +# ================================================ + +1401..166C ; Canadian_Aboriginal # Lo [620] CANADIAN SYLLABICS E..CANADIAN SYLLABICS CARRIER TTSA +166D..166E ; Canadian_Aboriginal # Po [2] CANADIAN SYLLABICS CHI SIGN..CANADIAN SYLLABICS FULL STOP +166F..1676 ; Canadian_Aboriginal # Lo [8] CANADIAN SYLLABICS QAI..CANADIAN SYLLABICS NNGAA + +# Total code points: 630 + +# ================================================ + +1680 ; Ogham # Zs OGHAM SPACE MARK +1681..169A ; Ogham # Lo [26] OGHAM LETTER BEITH..OGHAM LETTER PEITH +169B ; Ogham # Ps OGHAM FEATHER MARK +169C ; Ogham # Pe OGHAM REVERSED FEATHER MARK + +# Total code points: 29 + +# ================================================ + +16A0..16EA ; Runic # Lo [75] RUNIC LETTER FEHU FEOH FE F..RUNIC LETTER X +16EE..16F0 ; Runic # Nl [3] RUNIC ARLAUG SYMBOL..RUNIC BELGTHOR SYMBOL + +# Total code points: 78 + +# ================================================ + +1780..17B3 ; Khmer # Lo [52] KHMER LETTER KA..KHMER INDEPENDENT VOWEL QAU +17B4..17B5 ; Khmer # Cf [2] KHMER VOWEL INHERENT AQ..KHMER VOWEL INHERENT AA +17B6 ; Khmer # Mc KHMER VOWEL SIGN AA +17B7..17BD ; Khmer # Mn [7] KHMER VOWEL SIGN I..KHMER VOWEL SIGN UA +17BE..17C5 ; Khmer # Mc [8] KHMER VOWEL SIGN OE..KHMER VOWEL SIGN AU +17C6 ; Khmer # Mn KHMER SIGN NIKAHIT +17C7..17C8 ; Khmer # Mc [2] KHMER SIGN REAHMUK..KHMER SIGN YUUKALEAPINTU +17C9..17D3 ; Khmer # Mn [11] KHMER SIGN MUUSIKATOAN..KHMER SIGN BATHAMASAT +17D4..17D6 ; Khmer # Po [3] KHMER SIGN KHAN..KHMER SIGN CAMNUC PII KUUH +17D7 ; Khmer # Lm KHMER SIGN LEK TOO +17D8..17DA ; Khmer # Po [3] KHMER SIGN BEYYAL..KHMER SIGN KOOMUUT +17DB ; Khmer # Sc KHMER CURRENCY SYMBOL RIEL +17DC ; Khmer # Lo KHMER SIGN AVAKRAHASANYA +17DD ; Khmer # Mn KHMER SIGN ATTHACAN +17E0..17E9 ; Khmer # Nd [10] KHMER DIGIT ZERO..KHMER DIGIT NINE +17F0..17F9 ; Khmer # No [10] KHMER SYMBOL LEK ATTAK SON..KHMER SYMBOL LEK ATTAK PRAM-BUON +19E0..19FF ; Khmer # So [32] KHMER SYMBOL PATHAMASAT..KHMER SYMBOL DAP-PRAM ROC + +# Total code points: 146 + +# ================================================ + +1800..1801 ; Mongolian # Po [2] MONGOLIAN BIRGA..MONGOLIAN ELLIPSIS +1804 ; Mongolian # Po MONGOLIAN COLON +1806 ; Mongolian # Pd MONGOLIAN TODO SOFT HYPHEN +1807..180A ; Mongolian # Po [4] MONGOLIAN SIBE SYLLABLE BOUNDARY MARKER..MONGOLIAN NIRUGU +180B..180D ; Mongolian # Mn [3] MONGOLIAN FREE VARIATION SELECTOR ONE..MONGOLIAN FREE VARIATION SELECTOR THREE +180E ; Mongolian # Zs MONGOLIAN VOWEL SEPARATOR +1810..1819 ; Mongolian # Nd [10] MONGOLIAN DIGIT ZERO..MONGOLIAN DIGIT NINE +1820..1842 ; Mongolian # Lo [35] MONGOLIAN LETTER A..MONGOLIAN LETTER CHI +1843 ; Mongolian # Lm MONGOLIAN LETTER TODO LONG VOWEL SIGN +1844..1877 ; Mongolian # Lo [52] MONGOLIAN LETTER TODO E..MONGOLIAN LETTER MANCHU ZHA +1880..18A8 ; Mongolian # Lo [41] MONGOLIAN LETTER ALI GALI ANUSVARA ONE..MONGOLIAN LETTER MANCHU ALI GALI BHA +18A9 ; Mongolian # Mn MONGOLIAN LETTER ALI GALI DAGALGA +18AA ; Mongolian # Lo MONGOLIAN LETTER MANCHU ALI GALI LHA + +# Total code points: 153 + +# ================================================ + +3041..3096 ; Hiragana # Lo [86] HIRAGANA LETTER SMALL A..HIRAGANA LETTER SMALL KE +309D..309E ; Hiragana # Lm [2] HIRAGANA ITERATION MARK..HIRAGANA VOICED ITERATION MARK +309F ; Hiragana # Lo HIRAGANA DIGRAPH YORI + +# Total code points: 89 + +# ================================================ + +30A1..30FA ; Katakana # Lo [90] KATAKANA LETTER SMALL A..KATAKANA LETTER VO +30FD..30FE ; Katakana # Lm [2] KATAKANA ITERATION MARK..KATAKANA VOICED ITERATION MARK +30FF ; Katakana # Lo KATAKANA DIGRAPH KOTO +31F0..31FF ; Katakana # Lo [16] KATAKANA LETTER SMALL KU..KATAKANA LETTER SMALL RO +32D0..32FE ; Katakana # So [47] CIRCLED KATAKANA A..CIRCLED KATAKANA WO +3300..3357 ; Katakana # So [88] SQUARE APAATO..SQUARE WATTO +FF66..FF6F ; Katakana # Lo [10] HALFWIDTH KATAKANA LETTER WO..HALFWIDTH KATAKANA LETTER SMALL TU +FF71..FF9D ; Katakana # Lo [45] HALFWIDTH KATAKANA LETTER A..HALFWIDTH KATAKANA LETTER N + +# Total code points: 299 + +# ================================================ + +3105..312D ; Bopomofo # Lo [41] BOPOMOFO LETTER B..BOPOMOFO LETTER IH +31A0..31B7 ; Bopomofo # Lo [24] BOPOMOFO LETTER BU..BOPOMOFO FINAL LETTER H + +# Total code points: 65 + +# ================================================ + +2E80..2E99 ; Han # So [26] CJK RADICAL REPEAT..CJK RADICAL RAP +2E9B..2EF3 ; Han # So [89] CJK RADICAL CHOKE..CJK RADICAL C-SIMPLIFIED TURTLE +2F00..2FD5 ; Han # So [214] KANGXI RADICAL ONE..KANGXI RADICAL FLUTE +3005 ; Han # Lm IDEOGRAPHIC ITERATION MARK +3007 ; Han # Nl IDEOGRAPHIC NUMBER ZERO +3021..3029 ; Han # Nl [9] HANGZHOU NUMERAL ONE..HANGZHOU NUMERAL NINE +3038..303A ; Han # Nl [3] HANGZHOU NUMERAL TEN..HANGZHOU NUMERAL THIRTY +303B ; Han # Lm VERTICAL IDEOGRAPHIC ITERATION MARK +3400..4DB5 ; Han # Lo [6582] CJK UNIFIED IDEOGRAPH-3400..CJK UNIFIED IDEOGRAPH-4DB5 +4E00..9FC3 ; Han # Lo [20932] CJK UNIFIED IDEOGRAPH-4E00..CJK UNIFIED IDEOGRAPH-9FC3 +F900..FA2D ; Han # Lo [302] CJK COMPATIBILITY IDEOGRAPH-F900..CJK COMPATIBILITY IDEOGRAPH-FA2D +FA30..FA6A ; Han # Lo [59] CJK COMPATIBILITY IDEOGRAPH-FA30..CJK COMPATIBILITY IDEOGRAPH-FA6A +FA70..FAD9 ; Han # Lo [106] CJK COMPATIBILITY IDEOGRAPH-FA70..CJK COMPATIBILITY IDEOGRAPH-FAD9 +20000..2A6D6 ; Han # Lo [42711] CJK UNIFIED IDEOGRAPH-20000..CJK UNIFIED IDEOGRAPH-2A6D6 +2F800..2FA1D ; Han # Lo [542] CJK COMPATIBILITY IDEOGRAPH-2F800..CJK COMPATIBILITY IDEOGRAPH-2FA1D + +# Total code points: 71578 + +# ================================================ + +A000..A014 ; Yi # Lo [21] YI SYLLABLE IT..YI SYLLABLE E +A015 ; Yi # Lm YI SYLLABLE WU +A016..A48C ; Yi # Lo [1143] YI SYLLABLE BIT..YI SYLLABLE YYR +A490..A4C6 ; Yi # So [55] YI RADICAL QOT..YI RADICAL KE + +# Total code points: 1220 + +# ================================================ + +10300..1031E ; Old_Italic # Lo [31] OLD ITALIC LETTER A..OLD ITALIC LETTER UU +10320..10323 ; Old_Italic # No [4] OLD ITALIC NUMERAL ONE..OLD ITALIC NUMERAL FIFTY + +# Total code points: 35 + +# ================================================ + +10330..10340 ; Gothic # Lo [17] GOTHIC LETTER AHSA..GOTHIC LETTER PAIRTHRA +10341 ; Gothic # Nl GOTHIC LETTER NINETY +10342..10349 ; Gothic # Lo [8] GOTHIC LETTER RAIDA..GOTHIC LETTER OTHAL +1034A ; Gothic # Nl GOTHIC LETTER NINE HUNDRED + +# Total code points: 27 + +# ================================================ + +10400..1044F ; Deseret # L& [80] DESERET CAPITAL LETTER LONG I..DESERET SMALL LETTER EW + +# Total code points: 80 + +# ================================================ + +0300..036F ; Inherited # Mn [112] COMBINING GRAVE ACCENT..COMBINING LATIN SMALL LETTER X +064B..0655 ; Inherited # Mn [11] ARABIC FATHATAN..ARABIC HAMZA BELOW +0670 ; Inherited # Mn ARABIC LETTER SUPERSCRIPT ALEF +0951..0952 ; Inherited # Mn [2] DEVANAGARI STRESS SIGN UDATTA..DEVANAGARI STRESS SIGN ANUDATTA +1DC0..1DE6 ; Inherited # Mn [39] COMBINING DOTTED GRAVE ACCENT..COMBINING LATIN SMALL LETTER Z +1DFE..1DFF ; Inherited # Mn [2] COMBINING LEFT ARROWHEAD ABOVE..COMBINING RIGHT ARROWHEAD AND DOWN ARROWHEAD BELOW +200C..200D ; Inherited # Cf [2] ZERO WIDTH NON-JOINER..ZERO WIDTH JOINER +20D0..20DC ; Inherited # Mn [13] COMBINING LEFT HARPOON ABOVE..COMBINING FOUR DOTS ABOVE +20DD..20E0 ; Inherited # Me [4] COMBINING ENCLOSING CIRCLE..COMBINING ENCLOSING CIRCLE BACKSLASH +20E1 ; Inherited # Mn COMBINING LEFT RIGHT ARROW ABOVE +20E2..20E4 ; Inherited # Me [3] COMBINING ENCLOSING SCREEN..COMBINING ENCLOSING UPWARD POINTING TRIANGLE +20E5..20F0 ; Inherited # Mn [12] COMBINING REVERSE SOLIDUS OVERLAY..COMBINING ASTERISK ABOVE +302A..302F ; Inherited # Mn [6] IDEOGRAPHIC LEVEL TONE MARK..HANGUL DOUBLE DOT TONE MARK +3099..309A ; Inherited # Mn [2] COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK..COMBINING KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK +FE00..FE0F ; Inherited # Mn [16] VARIATION SELECTOR-1..VARIATION SELECTOR-16 +FE20..FE26 ; Inherited # Mn [7] COMBINING LIGATURE LEFT HALF..COMBINING CONJOINING MACRON +101FD ; Inherited # Mn PHAISTOS DISC SIGN COMBINING OBLIQUE STROKE +1D167..1D169 ; Inherited # Mn [3] MUSICAL SYMBOL COMBINING TREMOLO-1..MUSICAL SYMBOL COMBINING TREMOLO-3 +1D17B..1D182 ; Inherited # Mn [8] MUSICAL SYMBOL COMBINING ACCENT..MUSICAL SYMBOL COMBINING LOURE +1D185..1D18B ; Inherited # Mn [7] MUSICAL SYMBOL COMBINING DOIT..MUSICAL SYMBOL COMBINING TRIPLE TONGUE +1D1AA..1D1AD ; Inherited # Mn [4] MUSICAL SYMBOL COMBINING DOWN BOW..MUSICAL SYMBOL COMBINING SNAP PIZZICATO +E0100..E01EF ; Inherited # Mn [240] VARIATION SELECTOR-17..VARIATION SELECTOR-256 + +# Total code points: 496 + +# ================================================ + +1700..170C ; Tagalog # Lo [13] TAGALOG LETTER A..TAGALOG LETTER YA +170E..1711 ; Tagalog # Lo [4] TAGALOG LETTER LA..TAGALOG LETTER HA +1712..1714 ; Tagalog # Mn [3] TAGALOG VOWEL SIGN I..TAGALOG SIGN VIRAMA + +# Total code points: 20 + +# ================================================ + +1720..1731 ; Hanunoo # Lo [18] HANUNOO LETTER A..HANUNOO LETTER HA +1732..1734 ; Hanunoo # Mn [3] HANUNOO VOWEL SIGN I..HANUNOO SIGN PAMUDPOD + +# Total code points: 21 + +# ================================================ + +1740..1751 ; Buhid # Lo [18] BUHID LETTER A..BUHID LETTER HA +1752..1753 ; Buhid # Mn [2] BUHID VOWEL SIGN I..BUHID VOWEL SIGN U + +# Total code points: 20 + +# ================================================ + +1760..176C ; Tagbanwa # Lo [13] TAGBANWA LETTER A..TAGBANWA LETTER YA +176E..1770 ; Tagbanwa # Lo [3] TAGBANWA LETTER LA..TAGBANWA LETTER SA +1772..1773 ; Tagbanwa # Mn [2] TAGBANWA VOWEL SIGN I..TAGBANWA VOWEL SIGN U + +# Total code points: 18 + +# ================================================ + +1900..191C ; Limbu # Lo [29] LIMBU VOWEL-CARRIER LETTER..LIMBU LETTER HA +1920..1922 ; Limbu # Mn [3] LIMBU VOWEL SIGN A..LIMBU VOWEL SIGN U +1923..1926 ; Limbu # Mc [4] LIMBU VOWEL SIGN EE..LIMBU VOWEL SIGN AU +1927..1928 ; Limbu # Mn [2] LIMBU VOWEL SIGN E..LIMBU VOWEL SIGN O +1929..192B ; Limbu # Mc [3] LIMBU SUBJOINED LETTER YA..LIMBU SUBJOINED LETTER WA +1930..1931 ; Limbu # Mc [2] LIMBU SMALL LETTER KA..LIMBU SMALL LETTER NGA +1932 ; Limbu # Mn LIMBU SMALL LETTER ANUSVARA +1933..1938 ; Limbu # Mc [6] LIMBU SMALL LETTER TA..LIMBU SMALL LETTER LA +1939..193B ; Limbu # Mn [3] LIMBU SIGN MUKPHRENG..LIMBU SIGN SA-I +1940 ; Limbu # So LIMBU SIGN LOO +1944..1945 ; Limbu # Po [2] LIMBU EXCLAMATION MARK..LIMBU QUESTION MARK +1946..194F ; Limbu # Nd [10] LIMBU DIGIT ZERO..LIMBU DIGIT NINE + +# Total code points: 66 + +# ================================================ + +1950..196D ; Tai_Le # Lo [30] TAI LE LETTER KA..TAI LE LETTER AI +1970..1974 ; Tai_Le # Lo [5] TAI LE LETTER TONE-2..TAI LE LETTER TONE-6 + +# Total code points: 35 + +# ================================================ + +10000..1000B ; Linear_B # Lo [12] LINEAR B SYLLABLE B008 A..LINEAR B SYLLABLE B046 JE +1000D..10026 ; Linear_B # Lo [26] LINEAR B SYLLABLE B036 JO..LINEAR B SYLLABLE B032 QO +10028..1003A ; Linear_B # Lo [19] LINEAR B SYLLABLE B060 RA..LINEAR B SYLLABLE B042 WO +1003C..1003D ; Linear_B # Lo [2] LINEAR B SYLLABLE B017 ZA..LINEAR B SYLLABLE B074 ZE +1003F..1004D ; Linear_B # Lo [15] LINEAR B SYLLABLE B020 ZO..LINEAR B SYLLABLE B091 TWO +10050..1005D ; Linear_B # Lo [14] LINEAR B SYMBOL B018..LINEAR B SYMBOL B089 +10080..100FA ; Linear_B # Lo [123] LINEAR B IDEOGRAM B100 MAN..LINEAR B IDEOGRAM VESSEL B305 + +# Total code points: 211 + +# ================================================ + +10380..1039D ; Ugaritic # Lo [30] UGARITIC LETTER ALPA..UGARITIC LETTER SSU +1039F ; Ugaritic # Po UGARITIC WORD DIVIDER + +# Total code points: 31 + +# ================================================ + +10450..1047F ; Shavian # Lo [48] SHAVIAN LETTER PEEP..SHAVIAN LETTER YEW + +# Total code points: 48 + +# ================================================ + +10480..1049D ; Osmanya # Lo [30] OSMANYA LETTER ALEF..OSMANYA LETTER OO +104A0..104A9 ; Osmanya # Nd [10] OSMANYA DIGIT ZERO..OSMANYA DIGIT NINE + +# Total code points: 40 + +# ================================================ + +10800..10805 ; Cypriot # Lo [6] CYPRIOT SYLLABLE A..CYPRIOT SYLLABLE JA +10808 ; Cypriot # Lo CYPRIOT SYLLABLE JO +1080A..10835 ; Cypriot # Lo [44] CYPRIOT SYLLABLE KA..CYPRIOT SYLLABLE WO +10837..10838 ; Cypriot # Lo [2] CYPRIOT SYLLABLE XA..CYPRIOT SYLLABLE XE +1083C ; Cypriot # Lo CYPRIOT SYLLABLE ZA +1083F ; Cypriot # Lo CYPRIOT SYLLABLE ZO + +# Total code points: 55 + +# ================================================ + +2800..28FF ; Braille # So [256] BRAILLE PATTERN BLANK..BRAILLE PATTERN DOTS-12345678 + +# Total code points: 256 + +# ================================================ + +1A00..1A16 ; Buginese # Lo [23] BUGINESE LETTER KA..BUGINESE LETTER HA +1A17..1A18 ; Buginese # Mn [2] BUGINESE VOWEL SIGN I..BUGINESE VOWEL SIGN U +1A19..1A1B ; Buginese # Mc [3] BUGINESE VOWEL SIGN E..BUGINESE VOWEL SIGN AE +1A1E..1A1F ; Buginese # Po [2] BUGINESE PALLAWA..BUGINESE END OF SECTION + +# Total code points: 30 + +# ================================================ + +03E2..03EF ; Coptic # L& [14] COPTIC CAPITAL LETTER SHEI..COPTIC SMALL LETTER DEI +2C80..2CE4 ; Coptic # L& [101] COPTIC CAPITAL LETTER ALFA..COPTIC SYMBOL KAI +2CE5..2CEA ; Coptic # So [6] COPTIC SYMBOL MI RO..COPTIC SYMBOL SHIMA SIMA +2CF9..2CFC ; Coptic # Po [4] COPTIC OLD NUBIAN FULL STOP..COPTIC OLD NUBIAN VERSE DIVIDER +2CFD ; Coptic # No COPTIC FRACTION ONE HALF +2CFE..2CFF ; Coptic # Po [2] COPTIC FULL STOP..COPTIC MORPHOLOGICAL DIVIDER + +# Total code points: 128 + +# ================================================ + +1980..19A9 ; New_Tai_Lue # Lo [42] NEW TAI LUE LETTER HIGH QA..NEW TAI LUE LETTER LOW XVA +19B0..19C0 ; New_Tai_Lue # Mc [17] NEW TAI LUE VOWEL SIGN VOWEL SHORTENER..NEW TAI LUE VOWEL SIGN IY +19C1..19C7 ; New_Tai_Lue # Lo [7] NEW TAI LUE LETTER FINAL V..NEW TAI LUE LETTER FINAL B +19C8..19C9 ; New_Tai_Lue # Mc [2] NEW TAI LUE TONE MARK-1..NEW TAI LUE TONE MARK-2 +19D0..19D9 ; New_Tai_Lue # Nd [10] NEW TAI LUE DIGIT ZERO..NEW TAI LUE DIGIT NINE +19DE..19DF ; New_Tai_Lue # Po [2] NEW TAI LUE SIGN LAE..NEW TAI LUE SIGN LAEV + +# Total code points: 80 + +# ================================================ + +2C00..2C2E ; Glagolitic # L& [47] GLAGOLITIC CAPITAL LETTER AZU..GLAGOLITIC CAPITAL LETTER LATINATE MYSLITE +2C30..2C5E ; Glagolitic # L& [47] GLAGOLITIC SMALL LETTER AZU..GLAGOLITIC SMALL LETTER LATINATE MYSLITE + +# Total code points: 94 + +# ================================================ + +2D30..2D65 ; Tifinagh # Lo [54] TIFINAGH LETTER YA..TIFINAGH LETTER YAZZ +2D6F ; Tifinagh # Lm TIFINAGH MODIFIER LETTER LABIALIZATION MARK + +# Total code points: 55 + +# ================================================ + +A800..A801 ; Syloti_Nagri # Lo [2] SYLOTI NAGRI LETTER A..SYLOTI NAGRI LETTER I +A802 ; Syloti_Nagri # Mn SYLOTI NAGRI SIGN DVISVARA +A803..A805 ; Syloti_Nagri # Lo [3] SYLOTI NAGRI LETTER U..SYLOTI NAGRI LETTER O +A806 ; Syloti_Nagri # Mn SYLOTI NAGRI SIGN HASANTA +A807..A80A ; Syloti_Nagri # Lo [4] SYLOTI NAGRI LETTER KO..SYLOTI NAGRI LETTER GHO +A80B ; Syloti_Nagri # Mn SYLOTI NAGRI SIGN ANUSVARA +A80C..A822 ; Syloti_Nagri # Lo [23] SYLOTI NAGRI LETTER CO..SYLOTI NAGRI LETTER HO +A823..A824 ; Syloti_Nagri # Mc [2] SYLOTI NAGRI VOWEL SIGN A..SYLOTI NAGRI VOWEL SIGN I +A825..A826 ; Syloti_Nagri # Mn [2] SYLOTI NAGRI VOWEL SIGN U..SYLOTI NAGRI VOWEL SIGN E +A827 ; Syloti_Nagri # Mc SYLOTI NAGRI VOWEL SIGN OO +A828..A82B ; Syloti_Nagri # So [4] SYLOTI NAGRI POETRY MARK-1..SYLOTI NAGRI POETRY MARK-4 + +# Total code points: 44 + +# ================================================ + +103A0..103C3 ; Old_Persian # Lo [36] OLD PERSIAN SIGN A..OLD PERSIAN SIGN HA +103C8..103CF ; Old_Persian # Lo [8] OLD PERSIAN SIGN AURAMAZDAA..OLD PERSIAN SIGN BUUMISH +103D0 ; Old_Persian # Po OLD PERSIAN WORD DIVIDER +103D1..103D5 ; Old_Persian # Nl [5] OLD PERSIAN NUMBER ONE..OLD PERSIAN NUMBER HUNDRED + +# Total code points: 50 + +# ================================================ + +10A00 ; Kharoshthi # Lo KHAROSHTHI LETTER A +10A01..10A03 ; Kharoshthi # Mn [3] KHAROSHTHI VOWEL SIGN I..KHAROSHTHI VOWEL SIGN VOCALIC R +10A05..10A06 ; Kharoshthi # Mn [2] KHAROSHTHI VOWEL SIGN E..KHAROSHTHI VOWEL SIGN O +10A0C..10A0F ; Kharoshthi # Mn [4] KHAROSHTHI VOWEL LENGTH MARK..KHAROSHTHI SIGN VISARGA +10A10..10A13 ; Kharoshthi # Lo [4] KHAROSHTHI LETTER KA..KHAROSHTHI LETTER GHA +10A15..10A17 ; Kharoshthi # Lo [3] KHAROSHTHI LETTER CA..KHAROSHTHI LETTER JA +10A19..10A33 ; Kharoshthi # Lo [27] KHAROSHTHI LETTER NYA..KHAROSHTHI LETTER TTTHA +10A38..10A3A ; Kharoshthi # Mn [3] KHAROSHTHI SIGN BAR ABOVE..KHAROSHTHI SIGN DOT BELOW +10A3F ; Kharoshthi # Mn KHAROSHTHI VIRAMA +10A40..10A47 ; Kharoshthi # No [8] KHAROSHTHI DIGIT ONE..KHAROSHTHI NUMBER ONE THOUSAND +10A50..10A58 ; Kharoshthi # Po [9] KHAROSHTHI PUNCTUATION DOT..KHAROSHTHI PUNCTUATION LINES + +# Total code points: 65 + +# ================================================ + +1B00..1B03 ; Balinese # Mn [4] BALINESE SIGN ULU RICEM..BALINESE SIGN SURANG +1B04 ; Balinese # Mc BALINESE SIGN BISAH +1B05..1B33 ; Balinese # Lo [47] BALINESE LETTER AKARA..BALINESE LETTER HA +1B34 ; Balinese # Mn BALINESE SIGN REREKAN +1B35 ; Balinese # Mc BALINESE VOWEL SIGN TEDUNG +1B36..1B3A ; Balinese # Mn [5] BALINESE VOWEL SIGN ULU..BALINESE VOWEL SIGN RA REPA +1B3B ; Balinese # Mc BALINESE VOWEL SIGN RA REPA TEDUNG +1B3C ; Balinese # Mn BALINESE VOWEL SIGN LA LENGA +1B3D..1B41 ; Balinese # Mc [5] BALINESE VOWEL SIGN LA LENGA TEDUNG..BALINESE VOWEL SIGN TALING REPA TEDUNG +1B42 ; Balinese # Mn BALINESE VOWEL SIGN PEPET +1B43..1B44 ; Balinese # Mc [2] BALINESE VOWEL SIGN PEPET TEDUNG..BALINESE ADEG ADEG +1B45..1B4B ; Balinese # Lo [7] BALINESE LETTER KAF SASAK..BALINESE LETTER ASYURA SASAK +1B50..1B59 ; Balinese # Nd [10] BALINESE DIGIT ZERO..BALINESE DIGIT NINE +1B5A..1B60 ; Balinese # Po [7] BALINESE PANTI..BALINESE PAMENENG +1B61..1B6A ; Balinese # So [10] BALINESE MUSICAL SYMBOL DONG..BALINESE MUSICAL SYMBOL DANG GEDE +1B6B..1B73 ; Balinese # Mn [9] BALINESE MUSICAL SYMBOL COMBINING TEGEH..BALINESE MUSICAL SYMBOL COMBINING GONG +1B74..1B7C ; Balinese # So [9] BALINESE MUSICAL SYMBOL RIGHT-HAND OPEN DUG..BALINESE MUSICAL SYMBOL LEFT-HAND OPEN PING + +# Total code points: 121 + +# ================================================ + +12000..1236E ; Cuneiform # Lo [879] CUNEIFORM SIGN A..CUNEIFORM SIGN ZUM +12400..12462 ; Cuneiform # Nl [99] CUNEIFORM NUMERIC SIGN TWO ASH..CUNEIFORM NUMERIC SIGN OLD ASSYRIAN ONE QUARTER +12470..12473 ; Cuneiform # Po [4] CUNEIFORM PUNCTUATION SIGN OLD ASSYRIAN WORD DIVIDER..CUNEIFORM PUNCTUATION SIGN DIAGONAL TRICOLON + +# Total code points: 982 + +# ================================================ + +10900..10915 ; Phoenician # Lo [22] PHOENICIAN LETTER ALF..PHOENICIAN LETTER TAU +10916..10919 ; Phoenician # No [4] PHOENICIAN NUMBER ONE..PHOENICIAN NUMBER ONE HUNDRED +1091F ; Phoenician # Po PHOENICIAN WORD SEPARATOR + +# Total code points: 27 + +# ================================================ + +A840..A873 ; Phags_Pa # Lo [52] PHAGS-PA LETTER KA..PHAGS-PA LETTER CANDRABINDU +A874..A877 ; Phags_Pa # Po [4] PHAGS-PA SINGLE HEAD MARK..PHAGS-PA MARK DOUBLE SHAD + +# Total code points: 56 + +# ================================================ + +07C0..07C9 ; Nko # Nd [10] NKO DIGIT ZERO..NKO DIGIT NINE +07CA..07EA ; Nko # Lo [33] NKO LETTER A..NKO LETTER JONA RA +07EB..07F3 ; Nko # Mn [9] NKO COMBINING SHORT HIGH TONE..NKO COMBINING DOUBLE DOT ABOVE +07F4..07F5 ; Nko # Lm [2] NKO HIGH TONE APOSTROPHE..NKO LOW TONE APOSTROPHE +07F6 ; Nko # So NKO SYMBOL OO DENNEN +07F7..07F9 ; Nko # Po [3] NKO SYMBOL GBAKURUNEN..NKO EXCLAMATION MARK +07FA ; Nko # Lm NKO LAJANYALAN + +# Total code points: 59 + +# ================================================ + +1B80..1B81 ; Sundanese # Mn [2] SUNDANESE SIGN PANYECEK..SUNDANESE SIGN PANGLAYAR +1B82 ; Sundanese # Mc SUNDANESE SIGN PANGWISAD +1B83..1BA0 ; Sundanese # Lo [30] SUNDANESE LETTER A..SUNDANESE LETTER HA +1BA1 ; Sundanese # Mc SUNDANESE CONSONANT SIGN PAMINGKAL +1BA2..1BA5 ; Sundanese # Mn [4] SUNDANESE CONSONANT SIGN PANYAKRA..SUNDANESE VOWEL SIGN PANYUKU +1BA6..1BA7 ; Sundanese # Mc [2] SUNDANESE VOWEL SIGN PANAELAENG..SUNDANESE VOWEL SIGN PANOLONG +1BA8..1BA9 ; Sundanese # Mn [2] SUNDANESE VOWEL SIGN PAMEPET..SUNDANESE VOWEL SIGN PANEULEUNG +1BAA ; Sundanese # Mc SUNDANESE SIGN PAMAAEH +1BAE..1BAF ; Sundanese # Lo [2] SUNDANESE LETTER KHA..SUNDANESE LETTER SYA +1BB0..1BB9 ; Sundanese # Nd [10] SUNDANESE DIGIT ZERO..SUNDANESE DIGIT NINE + +# Total code points: 55 + +# ================================================ + +1C00..1C23 ; Lepcha # Lo [36] LEPCHA LETTER KA..LEPCHA LETTER A +1C24..1C2B ; Lepcha # Mc [8] LEPCHA SUBJOINED LETTER YA..LEPCHA VOWEL SIGN UU +1C2C..1C33 ; Lepcha # Mn [8] LEPCHA VOWEL SIGN E..LEPCHA CONSONANT SIGN T +1C34..1C35 ; Lepcha # Mc [2] LEPCHA CONSONANT SIGN NYIN-DO..LEPCHA CONSONANT SIGN KANG +1C36..1C37 ; Lepcha # Mn [2] LEPCHA SIGN RAN..LEPCHA SIGN NUKTA +1C3B..1C3F ; Lepcha # Po [5] LEPCHA PUNCTUATION TA-ROL..LEPCHA PUNCTUATION TSHOOK +1C40..1C49 ; Lepcha # Nd [10] LEPCHA DIGIT ZERO..LEPCHA DIGIT NINE +1C4D..1C4F ; Lepcha # Lo [3] LEPCHA LETTER TTA..LEPCHA LETTER DDA + +# Total code points: 74 + +# ================================================ + +1C50..1C59 ; Ol_Chiki # Nd [10] OL CHIKI DIGIT ZERO..OL CHIKI DIGIT NINE +1C5A..1C77 ; Ol_Chiki # Lo [30] OL CHIKI LETTER LA..OL CHIKI LETTER OH +1C78..1C7D ; Ol_Chiki # Lm [6] OL CHIKI MU TTUDDAG..OL CHIKI AHAD +1C7E..1C7F ; Ol_Chiki # Po [2] OL CHIKI PUNCTUATION MUCAAD..OL CHIKI PUNCTUATION DOUBLE MUCAAD + +# Total code points: 48 + +# ================================================ + +A500..A60B ; Vai # Lo [268] VAI SYLLABLE EE..VAI SYLLABLE NG +A60C ; Vai # Lm VAI SYLLABLE LENGTHENER +A60D..A60F ; Vai # Po [3] VAI COMMA..VAI QUESTION MARK +A610..A61F ; Vai # Lo [16] VAI SYLLABLE NDOLE FA..VAI SYMBOL JONG +A620..A629 ; Vai # Nd [10] VAI DIGIT ZERO..VAI DIGIT NINE +A62A..A62B ; Vai # Lo [2] VAI SYLLABLE NDOLE MA..VAI SYLLABLE NDOLE DO + +# Total code points: 300 + +# ================================================ + +A880..A881 ; Saurashtra # Mc [2] SAURASHTRA SIGN ANUSVARA..SAURASHTRA SIGN VISARGA +A882..A8B3 ; Saurashtra # Lo [50] SAURASHTRA LETTER A..SAURASHTRA LETTER LLA +A8B4..A8C3 ; Saurashtra # Mc [16] SAURASHTRA CONSONANT SIGN HAARU..SAURASHTRA VOWEL SIGN AU +A8C4 ; Saurashtra # Mn SAURASHTRA SIGN VIRAMA +A8CE..A8CF ; Saurashtra # Po [2] SAURASHTRA DANDA..SAURASHTRA DOUBLE DANDA +A8D0..A8D9 ; Saurashtra # Nd [10] SAURASHTRA DIGIT ZERO..SAURASHTRA DIGIT NINE + +# Total code points: 81 + +# ================================================ + +A900..A909 ; Kayah_Li # Nd [10] KAYAH LI DIGIT ZERO..KAYAH LI DIGIT NINE +A90A..A925 ; Kayah_Li # Lo [28] KAYAH LI LETTER KA..KAYAH LI LETTER OO +A926..A92D ; Kayah_Li # Mn [8] KAYAH LI VOWEL UE..KAYAH LI TONE CALYA PLOPHU +A92E..A92F ; Kayah_Li # Po [2] KAYAH LI SIGN CWI..KAYAH LI SIGN SHYA + +# Total code points: 48 + +# ================================================ + +A930..A946 ; Rejang # Lo [23] REJANG LETTER KA..REJANG LETTER A +A947..A951 ; Rejang # Mn [11] REJANG VOWEL SIGN I..REJANG CONSONANT SIGN R +A952..A953 ; Rejang # Mc [2] REJANG CONSONANT SIGN H..REJANG VIRAMA +A95F ; Rejang # Po REJANG SECTION MARK + +# Total code points: 37 + +# ================================================ + +10280..1029C ; Lycian # Lo [29] LYCIAN LETTER A..LYCIAN LETTER X + +# Total code points: 29 + +# ================================================ + +102A0..102D0 ; Carian # Lo [49] CARIAN LETTER A..CARIAN LETTER UUU3 + +# Total code points: 49 + +# ================================================ + +10920..10939 ; Lydian # Lo [26] LYDIAN LETTER A..LYDIAN LETTER C +1093F ; Lydian # Po LYDIAN TRIANGULAR MARK + +# Total code points: 27 + +# ================================================ + +AA00..AA28 ; Cham # Lo [41] CHAM LETTER A..CHAM LETTER HA +AA29..AA2E ; Cham # Mn [6] CHAM VOWEL SIGN AA..CHAM VOWEL SIGN OE +AA2F..AA30 ; Cham # Mc [2] CHAM VOWEL SIGN O..CHAM VOWEL SIGN AI +AA31..AA32 ; Cham # Mn [2] CHAM VOWEL SIGN AU..CHAM VOWEL SIGN UE +AA33..AA34 ; Cham # Mc [2] CHAM CONSONANT SIGN YA..CHAM CONSONANT SIGN RA +AA35..AA36 ; Cham # Mn [2] CHAM CONSONANT SIGN LA..CHAM CONSONANT SIGN WA +AA40..AA42 ; Cham # Lo [3] CHAM LETTER FINAL K..CHAM LETTER FINAL NG +AA43 ; Cham # Mn CHAM CONSONANT SIGN FINAL NG +AA44..AA4B ; Cham # Lo [8] CHAM LETTER FINAL CH..CHAM LETTER FINAL SS +AA4C ; Cham # Mn CHAM CONSONANT SIGN FINAL M +AA4D ; Cham # Mc CHAM CONSONANT SIGN FINAL H +AA50..AA59 ; Cham # Nd [10] CHAM DIGIT ZERO..CHAM DIGIT NINE +AA5C..AA5F ; Cham # Po [4] CHAM PUNCTUATION SPIRAL..CHAM PUNCTUATION TRIPLE DANDA + +# Total code points: 83 + +# EOF diff --git a/extra/unicode/script/authors.txt b/extra/unicode/script/authors.txt new file mode 100755 index 0000000000..504363d316 --- /dev/null +++ b/extra/unicode/script/authors.txt @@ -0,0 +1 @@ +Daniel Ehrenberg diff --git a/extra/unicode/script/script-docs.factor b/extra/unicode/script/script-docs.factor new file mode 100755 index 0000000000..05828b778f --- /dev/null +++ b/extra/unicode/script/script-docs.factor @@ -0,0 +1,8 @@ +USING: help.syntax help.markup ; +IN: unicode.script + +HELP: script-of +{ $values { "char" "a code point" } { "script" "a symbol" } } +{ $description "Gets a symbol representing the code point of a given character. The word name of the symbol is the same as the one " } ; + +ABOUT: script-of diff --git a/extra/unicode/script/script-tests.factor b/extra/unicode/script/script-tests.factor new file mode 100755 index 0000000000..905837123b --- /dev/null +++ b/extra/unicode/script/script-tests.factor @@ -0,0 +1,4 @@ +USING: unicode.script tools.test ; + +[ Latin ] [ CHAR: a script-of ] unit-test +[ Common ] [ 0 script-of ] unit-test diff --git a/extra/unicode/script/script.factor b/extra/unicode/script/script.factor new file mode 100755 index 0000000000..d0bb4ac30d --- /dev/null +++ b/extra/unicode/script/script.factor @@ -0,0 +1,50 @@ +USING: unicode.syntax.backend kernel sequences assocs io.files +io.encodings ascii math.ranges io splitting math.parser +namespaces byte-arrays locals math sets io.encodings.ascii +words compiler.units arrays interval-maps ; +IN: unicode.script + + name + lines [ "#" split1 drop ] map [ empty? not ] filter [ + ";" split1 [ [ blank? ] trim ] bi@ + ] H{ } map>assoc ; + +: range, ( value key -- ) + swap interned get + [ word-name = ] with find nip 2array , ; + +: expand-ranges ( assoc -- interval-map ) + [ + [ + CHAR: . pick member? [ + swap ".." split1 [ hex> ] bi@ 2array + ] [ swap hex> ] if range, + ] assoc-each + ] { } make ; + +: >symbols ( strings -- symbols ) + [ + [ "unicode.script" create dup define-symbol ] map + ] with-compilation-unit ; + +: process-script ( ranges -- ) + dup values prune >symbols interned [ + expand-ranges \ script-table set-value + ] with-variable ; + +: load-script ( -- ) + "resource:extra/unicode/script/Scripts.txt" + ascii parse-script process-script ; + +load-script +PRIVATE> + +SYMBOL: Unknown + +: script-of ( char -- script ) + script-table interval-at [ Unknown ] unless* ; diff --git a/extra/unicode/script/summary.txt b/extra/unicode/script/summary.txt new file mode 100755 index 0000000000..a2de844e30 --- /dev/null +++ b/extra/unicode/script/summary.txt @@ -0,0 +1 @@ +Reads the UCD to get the script of a code point diff --git a/extra/unix/bsd/bsd.factor b/extra/unix/bsd/bsd.factor index d80db44348..158dbeaddb 100755 --- a/extra/unix/bsd/bsd.factor +++ b/extra/unix/bsd/bsd.factor @@ -21,7 +21,9 @@ IN: unix : SO_SNDTIMEO HEX: 1005 ; inline : SO_RCVTIMEO HEX: 1006 ; inline +: F_SETFD 2 ; inline : F_SETFL 4 ; inline +: FD_CLOEXEC 1 ; inline : O_NONBLOCK 4 ; inline C-STRUCT: sockaddr-in diff --git a/extra/unix/linux/linux.factor b/extra/unix/linux/linux.factor index 11db6cc862..74195fae36 100755 --- a/extra/unix/linux/linux.factor +++ b/extra/unix/linux/linux.factor @@ -24,6 +24,9 @@ USING: alien.syntax ; : SO_SNDTIMEO HEX: 15 ; inline : SO_RCVTIMEO HEX: 14 ; inline +: F_SETFD 2 ; inline +: FD_CLOEXEC 1 ; inline + : F_SETFL 4 ; inline : O_NONBLOCK HEX: 800 ; inline diff --git a/extra/update/backup/backup.factor b/extra/update/backup/backup.factor new file mode 100644 index 0000000000..bb6d17f6dd --- /dev/null +++ b/extra/update/backup/backup.factor @@ -0,0 +1,25 @@ + +USING: namespaces io.files bootstrap.image builder.util ; + +IN: update.backup + +: backup-boot-image ( -- ) + my-boot-image-name + { "boot." my-arch "-" [ "datestamp" get ] ".image" } to-string + move-file ; + +: backup-image ( -- ) + "factor.image" + { "factor" "-" [ "datestamp" get ] ".image" } to-string + move-file ; + +: backup-vm ( -- ) + "factor" + { "factor" "-" [ "datestamp" get ] } to-string + move-file ; + +: backup ( -- ) + datestamp "datestamp" set + backup-boot-image + backup-image + backup-vm ; diff --git a/extra/update/latest/latest.factor b/extra/update/latest/latest.factor new file mode 100644 index 0000000000..df057422f9 --- /dev/null +++ b/extra/update/latest/latest.factor @@ -0,0 +1,53 @@ + +USING: kernel namespaces system io.files bootstrap.image http.client + builder.util update update.backup ; + +IN: update.latest + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: git-pull-master ( -- ) + image parent-directory + [ + { "git" "pull" "git://factorcode.org/git/factor.git" "master" } + run-command + ] + with-directory ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: remote-latest-image ( -- url ) + { "http://factorcode.org/images/latest/" my-boot-image-name } to-string ; + +: download-latest-image ( -- ) remote-latest-image download ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: rebuild-latest ( -- ) + image parent-directory + [ + backup + download-latest-image + make-clean + make + boot + ] + with-directory ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: update-latest ( -- ) + image parent-directory + [ + git-id + git-pull-master + git-id + = not + [ rebuild-latest ] + when + ] + with-directory ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +MAIN: update-latest \ No newline at end of file diff --git a/extra/webapps/factor-website/page.css b/extra/webapps/factor-website/page.css index 9846e7b20c..55721d7bef 100644 --- a/extra/webapps/factor-website/page.css +++ b/extra/webapps/factor-website/page.css @@ -43,6 +43,13 @@ a:hover, .link:hover { border: 1px dashed #ccc; background-color: #f5f5f5; padding: 5px; - font-size: 150%; - color: #000000; + color: #000; +} + +.description p:first-child { + margin-top: 0px; +} + +.description p:last-child { + margin-bottom: 0px; } diff --git a/extra/webapps/pastebin/annotation.xml b/extra/webapps/pastebin/annotation.xml index e5a95d8908..d5b4ea8d3a 100644 --- a/extra/webapps/pastebin/annotation.xml +++ b/extra/webapps/pastebin/annotation.xml @@ -10,14 +10,8 @@
Date:
-
- -
+
- - - - - + Delete Annotation
diff --git a/extra/webapps/pastebin/new-annotation.xml b/extra/webapps/pastebin/new-annotation.xml index ad7152d209..5d18860977 100644 --- a/extra/webapps/pastebin/new-annotation.xml +++ b/extra/webapps/pastebin/new-annotation.xml @@ -4,8 +4,7 @@ New Annotation - - + diff --git a/extra/webapps/pastebin/paste-summary.xml b/extra/webapps/pastebin/paste-summary.xml index eca46e254d..c751b110c0 100644 --- a/extra/webapps/pastebin/paste-summary.xml +++ b/extra/webapps/pastebin/paste-summary.xml @@ -3,7 +3,7 @@ - + diff --git a/extra/webapps/pastebin/paste.xml b/extra/webapps/pastebin/paste.xml index 9db60bfcc3..9141ee4ef1 100644 --- a/extra/webapps/pastebin/paste.xml +++ b/extra/webapps/pastebin/paste.xml @@ -2,9 +2,7 @@ - Pastebin - -

Paste:

+ Paste:
Summary:
@@ -14,10 +12,7 @@
- - - - + Delete Paste | Annotate diff --git a/extra/webapps/pastebin/pastebin.factor b/extra/webapps/pastebin/pastebin.factor index 144900d6ec..a18eb8147c 100644 --- a/extra/webapps/pastebin/pastebin.factor +++ b/extra/webapps/pastebin/pastebin.factor @@ -207,12 +207,11 @@ annotation "ANNOTATION" :: ( ctor next -- action ) - { { "id" [ v-number ] } { "aid" [ v-number ] } } >>post-params + { { "aid" [ v-number ] } } >>post-params [ - "id" get "aid" get ctor call delete-tuples - - "id" get next + f "aid" get ctor call select-tuple + [ delete-tuples ] [ id>> next ] bi ] >>submit ; :: ( form ctor next -- action ) @@ -247,7 +246,7 @@ can-delete-pastes? define-capability "feed.xml" add-responder [ ] "view-paste" add-responder [ ] "$pastebin/list" { can-delete-pastes? } "delete-paste" add-responder - [ ] "$pastebin/view-paste" { can-delete-pastes? } "delete-annotation" add-responder + [ ] "$pastebin/view-paste" { can-delete-pastes? } "delete-annotation" add-responder [ ] "$pastebin/view-paste" add-responder [ now >>date ] "$pastebin/view-paste" "new-paste" add-responder [ now >>date ] "$pastebin/view-paste" "annotate" add-responder diff --git a/extra/webapps/pastebin/pastebin.xml b/extra/webapps/pastebin/pastebin.xml index 461a7be384..7ca4c95f8e 100644 --- a/extra/webapps/pastebin/pastebin.xml +++ b/extra/webapps/pastebin/pastebin.xml @@ -11,15 +11,13 @@ | New Paste | Atom Feed - + | Edit Profile - - | - + | Logout diff --git a/extra/webapps/planet/edit-blog.xml b/extra/webapps/planet/edit-blog.xml index b2eab2b0b4..ebfccc47de 100644 --- a/extra/webapps/planet/edit-blog.xml +++ b/extra/webapps/planet/edit-blog.xml @@ -4,9 +4,7 @@ Edit Blog - - - +
Author:
@@ -31,8 +29,5 @@ - - - - + Delete diff --git a/extra/webapps/planet/planet.xml b/extra/webapps/planet/planet.xml index 7f2b034366..29609e12ba 100644 --- a/extra/webapps/planet/planet.xml +++ b/extra/webapps/planet/planet.xml @@ -9,14 +9,12 @@ | Atom Feed | Admin - + | Edit Profile - - | - + | Logout diff --git a/extra/webapps/todo/edit-todo.xml b/extra/webapps/todo/edit-todo.xml index 9b7e9e667a..e1d4c40e23 100644 --- a/extra/webapps/todo/edit-todo.xml +++ b/extra/webapps/todo/edit-todo.xml @@ -4,9 +4,7 @@ Edit Item - - - +
@@ -16,11 +14,12 @@ - View - | - - - - + + + View + | + Delete + + diff --git a/extra/webapps/todo/todo.xml b/extra/webapps/todo/todo.xml index 3e6d3cfd44..651e29d867 100644 --- a/extra/webapps/todo/todo.xml +++ b/extra/webapps/todo/todo.xml @@ -12,9 +12,7 @@ | Edit Profile - - | - + Logout

diff --git a/extra/webapps/todo/view-todo.xml b/extra/webapps/todo/view-todo.xml index 1bd73f48e1..8c90ba9056 100644 --- a/extra/webapps/todo/view-todo.xml +++ b/extra/webapps/todo/view-todo.xml @@ -15,9 +15,6 @@ Edit | - - - - + Delete diff --git a/extra/xml/backend/backend.factor b/extra/xml/backend/backend.factor new file mode 100644 index 0000000000..5dee38695d --- /dev/null +++ b/extra/xml/backend/backend.factor @@ -0,0 +1,6 @@ +! Copyright (C) 2008 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +IN: xml.backend + +! A stack of { tag children } pairs +SYMBOL: xml-stack diff --git a/extra/xml/errors/errors-tests.factor b/extra/xml/errors/errors-tests.factor new file mode 100755 index 0000000000..402c76dc01 --- /dev/null +++ b/extra/xml/errors/errors-tests.factor @@ -0,0 +1,28 @@ +USING: continuations xml xml.errors tools.test kernel arrays xml.data state-parser quotations ; +IN: xml.errors.tests + +: xml-error-test ( expected-error xml-string -- ) + [ string>xml ] curry swap [ = ] curry must-fail-with ; + +T{ no-entity f 1 10 "nbsp" } " " xml-error-test +T{ mismatched f 1 8 T{ name f "" "x" "" } T{ name f "" "y" "" } +} "" xml-error-test +T{ unclosed f 1 4 V{ T{ name f "" "x" "" } } } "" xml-error-test +T{ nonexist-ns f 1 5 "x" } "" xml-error-test +T{ unopened f 1 5 } "" xml-error-test +T{ not-yes/no f 1 41 "maybe" } "" xml-error-test +T{ extra-attrs f 1 32 V{ T{ name f "" "foo" f } } +} "" xml-error-test +T{ bad-version f 1 28 "5 million" } "" xml-error-test +T{ notags f 1 0 } "" xml-error-test +T{ multitags } "" xml-error-test +T{ bad-prolog f 1 26 T{ prolog f "1.0" "UTF-8" f } +} "" xml-error-test +T{ capitalized-prolog f 1 6 "XmL" } "" +xml-error-test +T{ pre/post-content f "x" t } "x" xml-error-test +T{ versionless-prolog f 1 8 } "" xml-error-test +T{ bad-instruction f 1 11 T{ instruction f "xsl" } +} "" xml-error-test +T{ bad-directive f 1 15 T{ directive f "DOCTYPE" } +} "" xml-error-test diff --git a/extra/xml/errors/errors.factor b/extra/xml/errors/errors.factor index 5b41a7ff9f..53f2046a54 100644 --- a/extra/xml/errors/errors.factor +++ b/extra/xml/errors/errors.factor @@ -1,150 +1,178 @@ ! Copyright (C) 2005, 2006 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. USING: xml.data xml.writer kernel generic io prettyprint math -debugger sequences state-parser ; +debugger sequences state-parser accessors inspector +namespaces io.streams.string xml.backend ; IN: xml.errors -TUPLE: no-entity thing ; -: ( string -- error ) - { set-no-entity-thing } no-entity construct-parsing-error ; -M: no-entity error. - dup parsing-error. - "Entity does not exist: &" write no-entity-thing write ";" print ; - -TUPLE: xml-string-error string ; ! this should not exist -: ( string -- xml-string-error ) - { set-xml-string-error-string } - xml-string-error construct-parsing-error ; -M: xml-string-error error. - dup parsing-error. - xml-string-error-string print ; - -TUPLE: mismatched open close ; -: - { set-mismatched-open set-mismatched-close } - mismatched construct-parsing-error ; -M: mismatched error. - dup parsing-error. - "Mismatched tags" print - "Opening tag: <" write dup mismatched-open print-name ">" print - "Closing tag: " print ; - -TUPLE: unclosed tags ; -! is ( -- unclosed ), see presentation.factor -M: unclosed error. - "Unclosed tags" print - "Tags: " print - unclosed-tags [ " <" write print-name ">" print ] each ; - -TUPLE: bad-uri string ; -: ( string -- bad-uri ) - { set-bad-uri-string } bad-uri construct-parsing-error ; -M: bad-uri error. - dup parsing-error. - "Bad URI:" print bad-uri-string . ; - -TUPLE: nonexist-ns name ; -: ( name-string -- nonexist-ns ) - { set-nonexist-ns-name } - nonexist-ns construct-parsing-error ; -M: nonexist-ns error. - dup parsing-error. - "Namespace " write nonexist-ns-name write " has not been declared" print ; - -TUPLE: unopened ; ! this should give which tag was unopened -: ( -- unopened ) - { } unopened construct-parsing-error ; -M: unopened error. - parsing-error. - "Closed an unopened tag" print ; - -TUPLE: not-yes/no text ; -: ( text -- not-yes/no ) - { set-not-yes/no-text } not-yes/no construct-parsing-error ; -M: not-yes/no error. - dup parsing-error. - "standalone must be either yes or no, not \"" write - not-yes/no-text write "\"." print ; - -TUPLE: extra-attrs attrs ; ! this should actually print the names -: ( attrs -- extra-attrs ) - { set-extra-attrs-attrs } - extra-attrs construct-parsing-error ; -M: extra-attrs error. - dup parsing-error. - "Extra attributes included in xml version declaration:" print - extra-attrs-attrs . ; - -TUPLE: bad-version num ; -: - { set-bad-version-num } - bad-version construct-parsing-error ; -M: bad-version error. - "XML version must be \"1.0\" or \"1.1\". Version here was " write - bad-version-num . ; - -TUPLE: notags ; -C: notags -M: notags error. - drop "XML document lacks a main tag" print ; - TUPLE: multitags ; C: multitags -M: multitags error. - drop "XML document contains multiple main tags" print ; - -TUPLE: bad-prolog prolog ; -: ( prolog -- bad-prolog ) - { set-bad-prolog-prolog } - bad-prolog construct-parsing-error ; -M: bad-prolog error. - dup parsing-error. - "Misplaced XML prolog" print - bad-prolog-prolog write-prolog nl ; - -TUPLE: capitalized-prolog name ; -: ( name -- capitalized-prolog ) - { set-capitalized-prolog-name } - capitalized-prolog construct-parsing-error ; -M: capitalized-prolog error. - dup parsing-error. - "XML prolog name was partially or totally capitalized, using" print - "" write - " instead of " print ; +M: multitags summary ( obj -- str ) + drop "XML document contains multiple main tags" ; TUPLE: pre/post-content string pre? ; C:
 pre/post-content
-M: pre/post-content error.
-    "The text string:" print
-    dup pre/post-content-string .
-    "was used " write
-    pre/post-content-pre? "before" "after" ? write
-    " the main tag." print ;
+M: pre/post-content summary ( obj -- str )
+    [
+        "The text string:" print
+        dup string>> .
+        "was used " write
+        pre?>> "before" "after" ? write
+        " the main tag." print
+    ] with-string-writer ;
 
-TUPLE: versionless-prolog ;
+TUPLE: no-entity < parsing-error thing ;
+:  ( string -- error )
+    \ no-entity parsing-error swap >>thing ;
+M: no-entity summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Entity does not exist: &" write thing>> write ";" print
+    ] with-string-writer ;
+
+TUPLE: xml-string-error < parsing-error string ; ! this should not exist
+:  ( string -- xml-string-error )
+    \ xml-string-error parsing-error swap >>string ;
+M: xml-string-error summary ( obj -- str )
+    [
+        dup call-next-method write
+        string>> print
+    ] with-string-writer ;
+
+TUPLE: mismatched < parsing-error open close ;
+: 
+    \ mismatched parsing-error swap >>close swap >>open ;
+M: mismatched summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Mismatched tags" print
+        "Opening tag: <" write dup open>> print-name ">" print
+        "Closing tag: > print-name ">" print
+    ] with-string-writer ;
+
+TUPLE: unclosed < parsing-error tags ;
+:  ( -- unclosed )
+    unclosed parsing-error
+        xml-stack get rest-slice [ first opener-name ] map >>tags ;
+M: unclosed summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Unclosed tags" print
+        "Tags: " print
+        tags>> [ "  <" write print-name ">" print ] each
+    ] with-string-writer ;
+
+TUPLE: bad-uri < parsing-error string ;
+:  ( string -- bad-uri )
+    \ bad-uri parsing-error swap >>string ;
+M: bad-uri summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Bad URI:" print string>> .
+    ] with-string-writer ;
+
+TUPLE: nonexist-ns < parsing-error name ;
+:  ( name-string -- nonexist-ns )
+    \ nonexist-ns parsing-error swap >>name ;
+M: nonexist-ns summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Namespace " write name>> write " has not been declared" print
+    ] with-string-writer ;
+
+TUPLE: unopened < parsing-error ; ! this should give which tag was unopened
+:  ( -- unopened )
+    \ unopened parsing-error ;
+M: unopened summary ( obj -- str )
+    [
+        call-next-method write
+        "Closed an unopened tag" print
+    ] with-string-writer ;
+
+TUPLE: not-yes/no < parsing-error text ;
+:  ( text -- not-yes/no )
+    \ not-yes/no parsing-error swap >>text ;
+M: not-yes/no summary ( obj -- str )
+    [
+        dup call-next-method write
+        "standalone must be either yes or no, not \"" write
+        text>> write "\"." print
+    ] with-string-writer ;
+
+! this should actually print the names
+TUPLE: extra-attrs < parsing-error attrs ;
+:  ( attrs -- extra-attrs )
+    \ extra-attrs parsing-error swap >>attrs ;
+M: extra-attrs summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Extra attributes included in xml version declaration:" print
+        attrs>> .
+    ] with-string-writer ;
+
+TUPLE: bad-version < parsing-error num ;
+: 
+    \ bad-version parsing-error swap >>num ;
+M: bad-version summary ( obj -- str )
+    [
+        "XML version must be \"1.0\" or \"1.1\". Version here was " write
+        num>> .
+    ] with-string-writer ;
+
+TUPLE: notags ;
+C:  notags
+M: notags summary ( obj -- str )
+    drop "XML document lacks a main tag" ;
+
+TUPLE: bad-prolog < parsing-error prolog ;
+:  ( prolog -- bad-prolog )
+    \ bad-prolog parsing-error swap >>prolog ;
+M: bad-prolog summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Misplaced XML prolog" print
+        prolog>> write-prolog nl
+    ] with-string-writer ;
+
+TUPLE: capitalized-prolog < parsing-error name ;
+:  ( name -- capitalized-prolog )
+    \ capitalized-prolog parsing-error swap >>name ;
+M: capitalized-prolog summary ( obj -- str )
+    [
+        dup call-next-method write
+        "XML prolog name was partially or totally capitalized, using" print
+        "> write "...?>" write
+        " instead of " print
+    ] with-string-writer ;
+
+TUPLE: versionless-prolog < parsing-error ;
 :  ( -- versionless-prolog )
-    { } versionless-prolog construct-parsing-error ;
-M: versionless-prolog error.
-    parsing-error.
-    "XML prolog lacks a version declaration" print ;
+    \ versionless-prolog parsing-error ;
+M: versionless-prolog summary ( obj -- str )
+    [
+        call-next-method write
+        "XML prolog lacks a version declaration" print
+    ] with-string-writer ;
 
-TUPLE: bad-instruction inst ;
+TUPLE: bad-instruction < parsing-error instruction ;
 :  ( instruction -- bad-instruction )
-    { set-bad-instruction-inst }
-    bad-instruction construct-parsing-error ;
-M: bad-instruction error.
-    dup parsing-error.
-    "Misplaced processor instruction:" print
-    bad-instruction-inst write-item nl ;
+    \ bad-instruction parsing-error swap >>instruction ;
+M: bad-instruction summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Misplaced processor instruction:" print
+        instruction>> write-item nl
+    ] with-string-writer ;
 
-TUPLE: bad-directive dir ;
+TUPLE: bad-directive < parsing-error dir ;
 :  ( directive -- bad-directive )
-    { set-bad-directive-dir }
-    bad-directive construct-parsing-error ;
-M: bad-directive error.
-    dup parsing-error.
-    "Misplaced directive:" print
-    bad-directive-dir write-item nl ;
+    \ bad-directive parsing-error swap >>dir ;
+M: bad-directive summary ( obj -- str )
+    [
+        dup call-next-method write
+        "Misplaced directive:" print
+        bad-directive-dir write-item nl
+    ] with-string-writer ;
 
 UNION: xml-parse-error multitags notags extra-attrs nonexist-ns
        not-yes/no unclosed mismatched xml-string-error expected no-entity
diff --git a/extra/xml/tests/errors.factor b/extra/xml/tests/errors.factor
deleted file mode 100755
index 6ba0b0d560..0000000000
--- a/extra/xml/tests/errors.factor
+++ /dev/null
@@ -1,28 +0,0 @@
-USING: continuations xml xml.errors tools.test kernel arrays xml.data state-parser quotations ;
-IN: xml.tests
-
-: xml-error-test ( expected-error xml-string -- )
-    [ string>xml ] curry swap [ = ] curry must-fail-with ;
-
-T{ no-entity T{ parsing-error f 1 10 } "nbsp" } " " xml-error-test
-T{ mismatched T{ parsing-error f 1 8 } T{ name f "" "x" "" } T{ name f "" "y" "" }
-} "" xml-error-test
-T{ unclosed f V{ T{ name f "" "x" "" } } } "" xml-error-test
-T{ nonexist-ns T{ parsing-error f 1 5 } "x" } "" xml-error-test
-T{ unopened T{ parsing-error f 1 5 } } "" xml-error-test
-T{ not-yes/no T{ parsing-error f 1 41 } "maybe" } "" xml-error-test
-T{ extra-attrs T{ parsing-error f 1 32 } V{ T{ name f "" "foo" f } }
-} "" xml-error-test
-T{ bad-version T{ parsing-error f 1 28 } "5 million" } "" xml-error-test
-T{ notags f } "" xml-error-test
-T{ multitags f } "" xml-error-test
-T{ bad-prolog T{ parsing-error f 1 26 } T{ prolog f "1.0" "UTF-8" f }
-} "" xml-error-test
-T{ capitalized-prolog T{ parsing-error f 1 6 } "XmL" } ""
-xml-error-test
-T{ pre/post-content f "x" t } "x" xml-error-test
-T{ versionless-prolog T{ parsing-error f 1 8 } } "" xml-error-test
-T{ bad-instruction T{ parsing-error f 1 11 } T{ instruction f "xsl" }
-} "" xml-error-test
-T{ bad-directive T{ parsing-error f 1 15 } T{ directive f "DOCTYPE" }
-} "" xml-error-test
diff --git a/extra/xml/tests/soap.factor b/extra/xml/tests/soap.factor
index 775930025f..c7452bb079 100755
--- a/extra/xml/tests/soap.factor
+++ b/extra/xml/tests/soap.factor
@@ -10,6 +10,6 @@ IN: xml.tests
     [ assemble-data ] map ;
 
 [ "http://www.foxnews.com/oreilly/" ] [
-    "extra/xml/tests/soap.xml" resource-path file>xml
+    "resource:extra/xml/tests/soap.xml" file>xml
     parse-result first first
 ] unit-test
diff --git a/extra/xml/tests/test.factor b/extra/xml/tests/test.factor
index d85345b3c7..7794930144 100644
--- a/extra/xml/tests/test.factor
+++ b/extra/xml/tests/test.factor
@@ -9,7 +9,7 @@ USING: kernel xml tools.test io namespaces sequences xml.errors xml.entities
 \ read-xml must-infer
 
 SYMBOL: xml-file
-[ ] [ "extra/xml/tests/test.xml" resource-path
+[ ] [ "resource:extra/xml/tests/test.xml"
     [ file>xml ] with-html-entities xml-file set ] unit-test
 [ "1.0" ] [ xml-file get xml-prolog prolog-version ] unit-test
 [ f ] [ xml-file get xml-prolog prolog-standalone ] unit-test
diff --git a/extra/xml/xml-docs.factor b/extra/xml/xml-docs.factor
index dd77d7c766..6a2ff1109e 100644
--- a/extra/xml/xml-docs.factor
+++ b/extra/xml/xml-docs.factor
@@ -42,17 +42,17 @@ HELP: xml-reprint
 
 HELP: write-xml
 { $values { "xml" "an XML document" } }
-{ $description "prints the contents of an XML document (" { $link xml } ") to stdio" }
+{ $description "prints the contents of an XML document (" { $link xml } ") to " { $link output-stream } "." }
 { $notes "does not preserve what type of quotes were used or what data was omitted from version declaration" } ;
 
 HELP: print-xml
 { $values { "xml" "an XML document" } }
-{ $description "prints the contents of an XML document (" { $link xml } ") to stdio, followed by a newline" }
+{ $description "prints the contents of an XML document (" { $link xml } ") to " { $link output-stream } ", followed by a newline" }
 { $notes "does not preserve what type of quotes were used or what data was omitted from version declaration" } ;
 
 HELP: pprint-xml
 { $values { "xml" "an XML document" } }
-{ $description "prints the contents of an XML document (" { $link xml } ") to stdio in a prettyprinted form." }
+{ $description "prints the contents of an XML document (" { $link xml } ") to " { $link output-stream } " in a prettyprinted form." }
 { $notes "does not preserve what type of quotes were used or what data was omitted from version declaration" } ;
 
 HELP: pprint-xml-but
@@ -226,7 +226,7 @@ HELP: pull-xml
 
 HELP: 
 { $values { "pull-xml" "a pull-xml tuple" } }
-{ $description "creates an XML pull-based parser which reads from the " { $link stdio } " stream, executing all initial XML commands to set up the parser." }
+{ $description "creates an XML pull-based parser which reads from " { $link input-stream } ", executing all initial XML commands to set up the parser." }
 { $see-also pull-xml pull-elem pull-event } ;
 
 HELP: pull-elem
@@ -241,12 +241,12 @@ HELP: pull-event
 
 HELP: write-item
 { $values { "object" "an XML element" } }
-{ $description "writes an XML element to the " { $link stdio } " stream." }
+{ $description "writes an XML element to " { $link output-stream } "." }
 { $see-also write-chunk write-xml } ;
 
 HELP: write-chunk
 { $values { "seq" "an XML document fragment" } }
-{ $description "writes an XML document fragment, ie a sequence of XML elements, to the " { $link stdio } " stream." }
+{ $description "writes an XML document fragment, ie a sequence of XML elements, to " { $link output-stream } "." }
 { $see-also write-item write-xml } ;
 
 HELP: deep-tag-named
diff --git a/extra/xml/xml.factor b/extra/xml/xml.factor
index 2d7c8c8ff8..4e2ad7a672 100644
--- a/extra/xml/xml.factor
+++ b/extra/xml/xml.factor
@@ -3,18 +3,12 @@
 USING: io io.streams.string io.files kernel math namespaces
 prettyprint sequences arrays generic strings vectors
 xml.char-classes xml.data xml.errors xml.tokenize xml.writer
-xml.utilities state-parser assocs ascii io.encodings.utf8 ;
+xml.utilities state-parser assocs ascii io.encodings.utf8
+accessors xml.backend ;
 IN: xml
 
 !   -- Overall parser with data tree
 
-! A stack of { tag children } pairs
-SYMBOL: xml-stack
-
-:  ( -- unclosed )
-    xml-stack get rest-slice [ first opener-name ] map
-    { set-unclosed-tags } unclosed construct ;
-
 : add-child ( object -- )
     xml-stack get peek second push ;
 
@@ -104,7 +98,7 @@ SYMBOL: text-now?
 TUPLE: pull-xml scope ;
 :  ( -- pull-xml )
     [
-        stdio [ ] change ! bring stdio var in this scope
+        input-stream [ ] change ! bring var in this scope
         init-parser reset-prolog init-ns-stack
         text-now? on
     ] H{ } make-assoc
diff --git a/extra/xmode/catalog/catalog.factor b/extra/xmode/catalog/catalog.factor
index 22d3217ee6..277439c0cd 100755
--- a/extra/xmode/catalog/catalog.factor
+++ b/extra/xmode/catalog/catalog.factor
@@ -24,7 +24,7 @@ TAGS>
     ] keep ;
 
 : load-catalog ( -- modes )
-    "extra/xmode/modes/catalog" resource-path
+    "resource:extra/xmode/modes/catalog"
     file>xml parse-modes-tag ;
 
 : modes ( -- assoc )
@@ -38,8 +38,8 @@ TAGS>
 MEMO: (load-mode) ( name -- rule-sets )
     modes at [
         mode-file
-        "extra/xmode/modes/" prepend
-        resource-path utf8  parse-mode
+        "resource:extra/xmode/modes/" prepend
+        utf8  parse-mode
     ] [
         "text" (load-mode)
     ] if* ;
diff --git a/extra/xmode/code2html/code2html.factor b/extra/xmode/code2html/code2html.factor
index a13e412afe..3977f4277c 100755
--- a/extra/xmode/code2html/code2html.factor
+++ b/extra/xmode/code2html/code2html.factor
@@ -20,8 +20,8 @@ IN: xmode.code2html
 
 : default-stylesheet ( -- )
      ;
 
 : htmlize-stream ( path stream -- )
@@ -42,8 +42,7 @@ IN: xmode.code2html
 
 : htmlize-file ( path -- )
     dup utf8 [
-        stdio get
-        over ".html" append utf8 [
-            htmlize-stream
+        dup ".html" append utf8 [
+            input-stream get htmlize-stream
         ] with-file-writer
     ] with-file-reader ;
diff --git a/extra/xmode/utilities/utilities-tests.factor b/extra/xmode/utilities/utilities-tests.factor
index 99689d8819..a2183edbc9 100755
--- a/extra/xmode/utilities/utilities-tests.factor
+++ b/extra/xmode/utilities/utilities-tests.factor
@@ -48,6 +48,6 @@ TAGS>
         "This is a great company"
     }
 ] [
-    "extra/xmode/utilities/test.xml"
-    resource-path file>xml parse-company-tag
+    "resource:extra/xmode/utilities/test.xml"
+    file>xml parse-company-tag
 ] unit-test
diff --git a/extra/yahoo/yahoo-tests.factor b/extra/yahoo/yahoo-tests.factor
index 197fa4900b..46d05ce720 100644
--- a/extra/yahoo/yahoo-tests.factor
+++ b/extra/yahoo/yahoo-tests.factor
@@ -6,6 +6,6 @@ USING: tools.test yahoo kernel io.files xml sequences ;
     "Official Foo Fighters"
     "http://www.foofighters.com/"
     "Official site with news, tour dates, discography, store, community, and more."
-} ] [ "extra/yahoo/test-results.xml" resource-path file>xml parse-yahoo first ] unit-test
+} ] [ "resource:extra/yahoo/test-results.xml" file>xml parse-yahoo first ] unit-test
 
 [ "http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=Factor-search&query=hi&results=1" ] [ "hi" 1 query ] unit-test
diff --git a/misc/Factor.tmbundle/Syntaxes/HTML (Factor).tmLanguage b/misc/Factor.tmbundle/Syntaxes/HTML (Factor).tmLanguage
index 03394b933c..1bf9a17aa6 100644
--- a/misc/Factor.tmbundle/Syntaxes/HTML (Factor).tmLanguage	
+++ b/misc/Factor.tmbundle/Syntaxes/HTML (Factor).tmLanguage	
@@ -29,7 +29,7 @@
 			begin
 			<%\s
 			end
-			\s%>
+			(?<=\s)%>
 			name
 			source.factor.embedded.html
 			patterns
diff --git a/extra/openssl/authors.txt b/unmaintained/openssl/authors.txt
similarity index 100%
rename from extra/openssl/authors.txt
rename to unmaintained/openssl/authors.txt
diff --git a/extra/openssl/libcrypto/libcrypto.factor b/unmaintained/openssl/libcrypto/libcrypto.factor
similarity index 100%
rename from extra/openssl/libcrypto/libcrypto.factor
rename to unmaintained/openssl/libcrypto/libcrypto.factor
diff --git a/extra/openssl/libssl/libssl.factor b/unmaintained/openssl/libssl/libssl.factor
similarity index 100%
rename from extra/openssl/libssl/libssl.factor
rename to unmaintained/openssl/libssl/libssl.factor
diff --git a/extra/openssl/openssl-docs.factor b/unmaintained/openssl/openssl-docs.factor
similarity index 100%
rename from extra/openssl/openssl-docs.factor
rename to unmaintained/openssl/openssl-docs.factor
diff --git a/extra/openssl/openssl-tests.factor b/unmaintained/openssl/openssl-tests.factor
similarity index 91%
rename from extra/openssl/openssl-tests.factor
rename to unmaintained/openssl/openssl-tests.factor
index f42c611fc0..2b840bdb9c 100755
--- a/extra/openssl/openssl-tests.factor
+++ b/unmaintained/openssl/openssl-tests.factor
@@ -27,7 +27,7 @@ math.parser openssl prettyprint sequences tools.test ;
 
 [ ] [ ssl-v23 new-ctx ] unit-test
 
-[ ] [ get-ctx "extra/openssl/test/server.pem" resource-path use-cert-chain ] unit-test
+[ ] [ get-ctx "resource:extra/openssl/test/server.pem" use-cert-chain ] unit-test
 
 ! TODO: debug 'Memory protection fault at address 6c'
 ! get-ctx 1024 "char" malloc-array 1024 0 f password-cb set-default-passwd
@@ -35,10 +35,10 @@ math.parser openssl prettyprint sequences tools.test ;
 [ ] [ get-ctx "password" ascii string>alien set-default-passwd-userdata ] unit-test
 
 ! Enter PEM pass phrase: password
-[ ] [ get-ctx "extra/openssl/test/server.pem" resource-path
+[ ] [ get-ctx "resource:extra/openssl/test/server.pem"
 SSL_FILETYPE_PEM use-private-key ] unit-test
 
-[ ] [ get-ctx "extra/openssl/test/root.pem" resource-path f
+[ ] [ get-ctx "resource:extra/openssl/test/root.pem" f
 verify-load-locations ] unit-test
 
 [ ] [ get-ctx 1 set-verify-depth ] unit-test
@@ -47,7 +47,7 @@ verify-load-locations ] unit-test
 ! Load Diffie-Hellman parameters
 ! =========================================================
 
-[ ] [ "extra/openssl/test/dh1024.pem" resource-path "r" bio-new-file ] unit-test
+[ ] [ "resource:extra/openssl/test/dh1024.pem" "r" bio-new-file ] unit-test
 
 [ ] [ get-bio f f f read-pem-dh-params ] unit-test
 
@@ -131,7 +131,7 @@ verify-load-locations ] unit-test
 ! Dump errors to file
 ! =========================================================
 
-[ ] [ "extra/openssl/test/errors.txt" resource-path "w" bio-new-file ] unit-test
+[ ] [ "resource:extra/openssl/test/errors.txt" "w" bio-new-file ] unit-test
 
 [ 6 ] [ get-bio "Hello\n" bio-print ] unit-test
 
diff --git a/extra/openssl/openssl.factor b/unmaintained/openssl/openssl.factor
similarity index 100%
rename from extra/openssl/openssl.factor
rename to unmaintained/openssl/openssl.factor
diff --git a/extra/openssl/summary.txt b/unmaintained/openssl/summary.txt
similarity index 100%
rename from extra/openssl/summary.txt
rename to unmaintained/openssl/summary.txt
diff --git a/extra/openssl/tags.txt b/unmaintained/openssl/tags.txt
similarity index 100%
rename from extra/openssl/tags.txt
rename to unmaintained/openssl/tags.txt
diff --git a/extra/openssl/test/dh1024.pem b/unmaintained/openssl/test/dh1024.pem
similarity index 100%
rename from extra/openssl/test/dh1024.pem
rename to unmaintained/openssl/test/dh1024.pem
diff --git a/extra/openssl/test/errors.txt b/unmaintained/openssl/test/errors.txt
similarity index 100%
rename from extra/openssl/test/errors.txt
rename to unmaintained/openssl/test/errors.txt
diff --git a/extra/openssl/test/root.pem b/unmaintained/openssl/test/root.pem
similarity index 100%
rename from extra/openssl/test/root.pem
rename to unmaintained/openssl/test/root.pem
diff --git a/extra/openssl/test/server.pem b/unmaintained/openssl/test/server.pem
similarity index 100%
rename from extra/openssl/test/server.pem
rename to unmaintained/openssl/test/server.pem
Summary:
Priority: