diff --git a/README.txt b/README.txt index dfe70c00f4..bd9da0ab2b 100755 --- a/README.txt +++ b/README.txt @@ -24,7 +24,7 @@ The Factor runtime is written in GNU C99, and is built with GNU make and gcc. Factor supports various platforms. For an up-to-date list, see -<http://factorcode.org/getfactor.fhtml>. +<http://factorcode.org>. Factor requires gcc 3.4 or later. @@ -36,17 +36,6 @@ arguments for make. Run 'make' ('gmake' on *BSD) with no parameters to build the Factor VM. -Compilation will yield an executable named 'factor' on Unix, -'factor.exe' on Windows XP/Vista, and 'factor-ce.exe' on Windows CE. - -* Libraries needed for compilation - -For X11 support, you need recent development libraries for libc, -Freetype, X11, OpenGL and GLUT. On a Debian-derived Linux distribution -(like Ubuntu), you can use the following line to grab everything: - - sudo apt-get install libc6-dev libfreetype6-dev libx11-dev glutg3-dev - * Bootstrapping the Factor image Once you have compiled the Factor runtime, you must bootstrap the Factor @@ -69,6 +58,12 @@ machines. On Unix, Factor can either run a graphical user interface using X11, or a terminal listener. +For X11 support, you need recent development libraries for libc, +Pango, X11, OpenGL and GLUT. On a Debian-derived Linux distribution +(like Ubuntu), you can use the following line to grab everything: + + sudo apt-get install libc6-dev libpango-1.0-dev libx11-dev glutg3-dev + If your DISPLAY environment variable is set, the UI will start automatically: @@ -78,14 +73,6 @@ To run an interactive terminal listener: ./factor -run=listener -If you're inside a terminal session, you can start the UI with one of -the following two commands: - - ui - [ ui ] in-thread - -The latter keeps the terminal listener running. - * Running Factor on Mac OS X - Cocoa UI On Mac OS X, a Cocoa UI is available in addition to the terminal @@ -110,7 +97,7 @@ When compiling Factor, pass the X11=1 parameter: Then bootstrap with the following switches: - ./factor -i=boot.<cpu>.image -ui-backend=x11 + ./factor -i=boot.<cpu>.image -ui-backend=x11 -ui-text-backend=pango Now if $DISPLAY is set, running ./factor will start the UI. @@ -126,6 +113,12 @@ the command prompt using the console application: factor.com -i=boot.<cpu>.image +Before bootstrapping, you will need to download the DLLs for the Pango +text rendering library. The required DLLs are listed in +build-support/dlls.txt and are available from the following location: + + <http://factorcode.org/dlls> + Once bootstrapped, double-clicking factor.exe or factor.com starts the Factor UI. @@ -135,7 +128,9 @@ To run the listener in the command prompt: * The Factor FAQ -The Factor FAQ is available at <http://factorcode.org/faq.fhtml>. +The Factor FAQ is available at the following location: + + <http://concatenative.org/wiki/view/Factor/FAQ> * Command line usage diff --git a/basis/alien/c-types/c-types-docs.factor b/basis/alien/c-types/c-types-docs.factor index dc29ea9bb3..46afc05e2d 100644 --- a/basis/alien/c-types/c-types-docs.factor +++ b/basis/alien/c-types/c-types-docs.factor @@ -217,6 +217,8 @@ $nl "Utilities for automatically freeing memory in conjunction with " { $link with-destructors } ":" { $subsection &free } { $subsection |free } +"The " { $link &free } " and " { $link |free } " words are generated using " { $link "alien.destructors" } "." +$nl "You can unsafely copy a range of bytes from one memory location to another:" { $subsection memcpy } "You can copy a range of bytes from memory into a byte array:" @@ -243,4 +245,6 @@ $nl "New C types can be defined:" { $subsection "c-structs" } { $subsection "c-unions" } +"A utility for defining " { $link "destructors" } " for deallocating memory:" +{ $subsection "alien.destructors" } { $see-also "aliens" } ; diff --git a/basis/alien/destructors/destructors-docs.factor b/basis/alien/destructors/destructors-docs.factor new file mode 100644 index 0000000000..bc08dc7486 --- /dev/null +++ b/basis/alien/destructors/destructors-docs.factor @@ -0,0 +1,30 @@ +IN: alien.destructors +USING: help.markup help.syntax alien destructors ; + +HELP: DESTRUCTOR: +{ $syntax "DESTRUCTOR: word" } +{ $description "Defines four things:" + { $list + { "a tuple named " { $snippet "word" } " with a single slot holding a " { $link c-ptr } } + { "a " { $link dispose } " method on the tuple which calls " { $snippet "word" } " with the " { $link c-ptr } } + { "a pair of words, " { $snippet "&word" } " and " { $snippet "|word" } ", which call " { $link &dispose } " and " { $link |dispose } " with a new instance of the tuple" } + } + "The " { $snippet "word" } " must be defined in the current vocabulary, and must have stack effect " { $snippet "( c-ptr -- )" } "." +} +{ $examples + "Suppose you are writing a binding to the GLib library, which as a " { $snippet "g_object_unref" } " function. Then you can define the function and destructor like so," + { $code + "FUNCTION: void g_object_unref ( gpointer object ) ;" + "DESTRUCTOR: g_object_unref" + } + "Now, memory management becomes easier:" + { $code + "[ g_new_foo &g_object_unref ... ] with-destructors" + } +} ; + +ARTICLE: "alien.destructors" "Alien destructors" +"The " { $vocab-link "alien.destructors" } " vocabulary defines a utility parsing word for defining new disposable classes." +{ $subsection POSTPONE: DESTRUCTOR: } ; + +ABOUT: "alien.destructors" \ No newline at end of file diff --git a/basis/ascii/ascii.factor b/basis/ascii/ascii.factor index 193e847d27..bd1b86b279 100644 --- a/basis/ascii/ascii.factor +++ b/basis/ascii/ascii.factor @@ -10,7 +10,7 @@ IN: ascii : LETTER? ( ch -- ? ) CHAR: A CHAR: Z between? ; inline : digit? ( ch -- ? ) CHAR: 0 CHAR: 9 between? ; inline : printable? ( ch -- ? ) CHAR: \s CHAR: ~ between? ; inline -: control? ( ch -- ? ) "\0\e\r\n\t\u000008\u00007f" member? ; inline +: control? ( ch -- ? ) { [ 0 HEX: 1F between? ] [ HEX: 7F = ] } 1|| ; inline : quotable? ( ch -- ? ) { [ printable? ] [ "\"\\" member? not ] } 1&& ; inline : Letter? ( ch -- ? ) { [ letter? ] [ LETTER? ] } 1|| ; inline : alpha? ( ch -- ? ) { [ Letter? ] [ digit? ] } 1|| ; inline @@ -20,4 +20,4 @@ IN: ascii : >upper ( str -- upper ) [ ch>upper ] map ; HINTS: >lower string ; -HINTS: >upper string ; \ No newline at end of file +HINTS: >upper string ; diff --git a/basis/binary-search/binary-search.factor b/basis/binary-search/binary-search.factor index f29e05c023..aba3cfbfe5 100644 --- a/basis/binary-search/binary-search.factor +++ b/basis/binary-search/binary-search.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences sequences.private accessors math math.order combinators hints arrays ; @@ -16,14 +16,19 @@ IN: binary-search [ [ from>> ] [ midpoint@ ] bi + ] [ seq>> ] bi [ drop ] [ dup ] [ ] tri* nth ; inline +DEFER: (search) + +: keep-searching ( seq quot -- slice ) + [ dup midpoint@ ] dip call collapse-slice slice boa (search) ; inline + : (search) ( quot: ( elt -- <=> ) seq -- i elt ) dup length 1 <= [ finish ] [ decide { { +eq+ [ finish ] } - { +lt+ [ dup midpoint@ head-slice (search) ] } - { +gt+ [ dup midpoint@ tail-slice (search) ] } + { +lt+ [ [ (head) ] keep-searching ] } + { +gt+ [ [ (tail) ] keep-searching ] } } case ] if ; inline recursive diff --git a/basis/bitstreams/bitstreams-tests.factor b/basis/bitstreams/bitstreams-tests.factor index d55910b131..769efcbb04 100644 --- a/basis/bitstreams/bitstreams-tests.factor +++ b/basis/bitstreams/bitstreams-tests.factor @@ -6,17 +6,17 @@ io.streams.byte-array ; IN: bitstreams.tests [ 1 t ] -[ B{ 254 } <string-reader> <bitstream-reader> read-bit ] unit-test +[ B{ 254 } binary <byte-reader> <bitstream-reader> read-bit ] unit-test [ 254 8 t ] -[ B{ 254 } <string-reader> <bitstream-reader> 8 swap read-bits ] unit-test +[ B{ 254 } binary <byte-reader> <bitstream-reader> 8 swap read-bits ] unit-test [ 4095 12 t ] -[ B{ 255 255 } <string-reader> <bitstream-reader> 12 swap read-bits ] unit-test +[ B{ 255 255 } binary <byte-reader> <bitstream-reader> 12 swap read-bits ] unit-test [ B{ 254 } ] [ - <string-writer> <bitstream-writer> 254 8 rot + binary <byte-writer> <bitstream-writer> 254 8 rot [ write-bits ] keep stream>> >byte-array ] unit-test diff --git a/basis/cocoa/plists/plists-tests.factor b/basis/cocoa/plists/plists-tests.factor index beb766561f..4f74cd850a 100644 --- a/basis/cocoa/plists/plists-tests.factor +++ b/basis/cocoa/plists/plists-tests.factor @@ -7,4 +7,34 @@ assocs cocoa.enumeration ; [ V{ } ] [ H{ } >cf &CFRelease [ ] NSFastEnumeration-map ] unit-test [ V{ "A" } ] [ { "A" } >cf &CFRelease plist> ] unit-test [ H{ { "A" "B" } } ] [ "B" "A" associate >cf &CFRelease plist> ] unit-test + [ H{ { "A" "B" } } ] [ "B" "A" associate >cf &CFRelease plist> ] unit-test + + [ t ] [ + { + H{ { "DeviceUsagePage" 1 } { "DeviceUsage" 4 } } + H{ { "DeviceUsagePage" 1 } { "DeviceUsage" 5 } } + H{ { "DeviceUsagePage" 1 } { "DeviceUsage" 6 } } + } [ >cf &CFRelease ] [ >cf &CFRelease ] bi + [ plist> ] bi@ = + ] unit-test + + [ t ] [ + { "DeviceUsagePage" 1 } + [ >cf &CFRelease ] [ >cf &CFRelease ] bi + [ plist> ] bi@ = + ] unit-test + + [ V{ "DeviceUsagePage" "Yes" } ] [ + { "DeviceUsagePage" "Yes" } + >cf &CFRelease plist> + ] unit-test + + [ V{ 2.0 1.0 } ] [ + { 2.0 1.0 } + >cf &CFRelease plist> + ] unit-test + + [ 3.5 ] [ + 3.5 >cf &CFRelease plist> + ] unit-test ] with-destructors \ No newline at end of file diff --git a/basis/colors/constants/constants-docs.factor b/basis/colors/constants/constants-docs.factor index 633bd20ed2..49d6fce3a1 100644 --- a/basis/colors/constants/constants-docs.factor +++ b/basis/colors/constants/constants-docs.factor @@ -2,7 +2,7 @@ IN: colors.constants USING: help.markup help.syntax strings colors ; HELP: named-color -{ $values { "string" string } { "color" color } } +{ $values { "name" string } { "color" color } } { $description "Outputs a named color from the " { $snippet "rgb.txt" } " database." } { $notes "In most cases, " { $link POSTPONE: COLOR: } " should be used instead." } { $errors "Throws an error if the color is not listed in " { $snippet "rgb.txt" } "." } ; diff --git a/basis/colors/constants/constants.factor b/basis/colors/constants/constants.factor index 0e5610a144..91621c110b 100644 --- a/basis/colors/constants/constants.factor +++ b/basis/colors/constants/constants.factor @@ -27,7 +27,7 @@ PRIVATE> ERROR: no-such-color name ; -: named-color ( name -- rgb ) +: named-color ( name -- color ) dup rgb.txt at [ ] [ no-such-color ] ?if ; : COLOR: scan named-color parsed ; parsing \ No newline at end of file diff --git a/basis/compiler/compiler.factor b/basis/compiler/compiler.factor index d6da95408d..24ce3debeb 100644 --- a/basis/compiler/compiler.factor +++ b/basis/compiler/compiler.factor @@ -1,15 +1,14 @@ ! Copyright (C) 2004, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel namespaces arrays sequences io words fry -continuations vocabs assocs dlists definitions math graphs -generic combinators deques search-deques io stack-checker -stack-checker.state stack-checker.inlining -combinators.short-circuit compiler.errors compiler.units -compiler.tree.builder compiler.tree.optimizer -compiler.cfg.builder compiler.cfg.optimizer +continuations vocabs assocs dlists definitions math graphs generic +combinators deques search-deques macros io stack-checker +stack-checker.state stack-checker.inlining combinators.short-circuit +compiler.errors compiler.units compiler.tree.builder +compiler.tree.optimizer compiler.cfg.builder compiler.cfg.optimizer compiler.cfg.linearization compiler.cfg.two-operand -compiler.cfg.linear-scan compiler.cfg.stack-frame -compiler.codegen compiler.utilities ; +compiler.cfg.linear-scan compiler.cfg.stack-frame compiler.codegen +compiler.utilities ; IN: compiler SYMBOL: compile-queue @@ -50,8 +49,12 @@ SYMBOLS: +optimized+ +unoptimized+ ; H{ } clone generic-dependencies set f swap compiler-error ; +: ignore-error? ( word error -- ? ) + [ [ inline? ] [ macro? ] bi or ] + [ compiler-error-type +warning+ eq? ] bi* and ; + : fail ( word error -- * ) - [ swap compiler-error ] + [ 2dup ignore-error? [ 2drop ] [ swap compiler-error ] if ] [ drop [ compiled-unxref ] diff --git a/basis/compiler/tests/redefine1.factor b/basis/compiler/tests/redefine1.factor index b5835de5fd..0875967bd2 100644 --- a/basis/compiler/tests/redefine1.factor +++ b/basis/compiler/tests/redefine1.factor @@ -1,24 +1,42 @@ USING: accessors compiler compiler.units tools.test math parser kernel sequences sequences.private classes.mixin generic -definitions arrays words assocs eval ; +definitions arrays words assocs eval strings ; IN: compiler.tests -GENERIC: method-redefine-test ( a -- b ) +GENERIC: method-redefine-generic-1 ( a -- b ) -M: integer method-redefine-test 3 + ; +M: integer method-redefine-generic-1 3 + ; -: method-redefine-test-1 ( -- b ) 3 method-redefine-test ; +: method-redefine-test-1 ( -- b ) 3 method-redefine-generic-1 ; [ 6 ] [ method-redefine-test-1 ] unit-test -[ ] [ "IN: compiler.tests USE: math M: fixnum method-redefine-test 4 + ;" eval ] unit-test +[ ] [ "IN: compiler.tests USE: math M: fixnum method-redefine-generic-1 4 + ;" eval ] unit-test [ 7 ] [ method-redefine-test-1 ] unit-test -[ ] [ [ fixnum \ method-redefine-test method forget ] with-compilation-unit ] unit-test +[ ] [ [ fixnum \ method-redefine-generic-1 method forget ] with-compilation-unit ] unit-test [ 6 ] [ method-redefine-test-1 ] unit-test +GENERIC: method-redefine-generic-2 ( a -- b ) + +M: integer method-redefine-generic-2 3 + ; + +: method-redefine-test-2 ( -- b ) 3 method-redefine-generic-2 ; + +[ 6 ] [ method-redefine-test-2 ] unit-test + +[ ] [ "IN: compiler.tests USE: kernel USE: math M: fixnum method-redefine-generic-2 4 + ; USE: strings M: string method-redefine-generic-2 drop f ;" eval ] unit-test + +[ 7 ] [ method-redefine-test-2 ] unit-test + +[ ] [ + [ + fixnum string [ \ method-redefine-generic-2 method forget ] bi@ + ] with-compilation-unit +] unit-test + ! Test ripple-up behavior : hey ( -- ) ; : there ( -- ) hey ; diff --git a/basis/compiler/tree/cleanup/cleanup-tests.factor b/basis/compiler/tree/cleanup/cleanup-tests.factor index 4a2e8671fb..e451694f48 100755 --- a/basis/compiler/tree/cleanup/cleanup-tests.factor +++ b/basis/compiler/tree/cleanup/cleanup-tests.factor @@ -514,4 +514,9 @@ cell-bits 32 = [ [ t ] [ [ { fixnum fixnum } declare = ] \ both-fixnums? inlined? +] unit-test + +[ t ] [ + [ { integer integer } declare + drop ] + { + +-integer-integer } inlined? ] unit-test \ No newline at end of file diff --git a/basis/compiler/tree/finalization/finalization.factor b/basis/compiler/tree/finalization/finalization.factor index ecd5429baf..0e72deb6fa 100644 --- a/basis/compiler/tree/finalization/finalization.factor +++ b/basis/compiler/tree/finalization/finalization.factor @@ -46,9 +46,6 @@ M: predicate finalize-word [ drop ] } cond ; -! M: math-partial finalize-word -! dup primitive? [ drop ] [ nip cached-expansion ] if ; - M: word finalize-word drop ; M: #call finalize* diff --git a/basis/compiler/tree/propagation/info/info.factor b/basis/compiler/tree/propagation/info/info.factor index 7b1723620b..c56db570b2 100644 --- a/basis/compiler/tree/propagation/info/info.factor +++ b/basis/compiler/tree/propagation/info/info.factor @@ -238,7 +238,7 @@ DEFER: (value-info-union) : value-infos-union ( infos -- info ) [ null-info ] - [ dup first [ value-info-union ] reduce ] if-empty ; + [ unclip-slice [ value-info-union ] reduce ] if-empty ; : literals<= ( info1 info2 -- ? ) { diff --git a/basis/compiler/tree/propagation/inlining/inlining.factor b/basis/compiler/tree/propagation/inlining/inlining.factor index b2388c30d2..953956c3bd 100755 --- a/basis/compiler/tree/propagation/inlining/inlining.factor +++ b/basis/compiler/tree/propagation/inlining/inlining.factor @@ -17,8 +17,10 @@ IN: compiler.tree.propagation.inlining ! we are more eager to inline SYMBOL: node-count -: count-nodes ( nodes -- ) - 0 swap [ drop 1+ ] each-node node-count set ; +: count-nodes ( nodes -- n ) + 0 swap [ drop 1+ ] each-node ; + +: compute-node-count ( nodes -- ) count-nodes node-count set ; ! We try not to inline the same word too many times, to avoid ! combinatorial explosion @@ -33,9 +35,6 @@ M: word splicing-nodes M: callable splicing-nodes build-sub-tree analyze-recursive normalize ; -: propagate-body ( #call -- ) - body>> (propagate) ; - ! Dispatch elimination : eliminate-dispatch ( #call class/f word/quot/f -- ? ) dup [ @@ -44,7 +43,7 @@ M: callable splicing-nodes 2dup splicing-nodes [ >>method ] [ >>body ] bi* ] if - propagate-body t + body>> (propagate) t ] [ 2drop f >>method f >>body f >>class drop f ] if ; : inlining-standard-method ( #call word -- class/f method/f ) @@ -161,10 +160,10 @@ SYMBOL: history : inline-word-def ( #call word quot -- ? ) over history get memq? [ 3drop f ] [ [ - swap remember-inlining - dupd splicing-nodes >>body - propagate-body - ] with-scope + [ remember-inlining ] dip + [ drop ] [ splicing-nodes ] 2bi + [ >>body drop ] [ count-nodes ] [ (propagate) ] tri + ] with-scope node-count +@ t ] if ; diff --git a/basis/compiler/tree/propagation/propagation-tests.factor b/basis/compiler/tree/propagation/propagation-tests.factor index 52ae83eb12..5dd647ae89 100644 --- a/basis/compiler/tree/propagation/propagation-tests.factor +++ b/basis/compiler/tree/propagation/propagation-tests.factor @@ -655,3 +655,36 @@ MIXIN: empty-mixin ! [ t ] [ [ dup t xor and ] final-classes first false-class? ] unit-test ! [ t ] [ [ dup t xor swap and ] final-classes first false-class? ] unit-test + +! generalize-counter-interval wasn't being called in all the right places. +! bug found by littledan + +TUPLE: littledan-1 { a read-only } ; + +: (littledan-1-test) ( a -- ) a>> 1+ littledan-1 boa (littledan-1-test) ; inline recursive + +: littledan-1-test ( -- ) 0 littledan-1 boa (littledan-1-test) ; inline + +[ ] [ [ littledan-1-test ] final-classes drop ] unit-test + +TUPLE: littledan-2 { from read-only } { to read-only } ; + +: (littledan-2-test) ( x -- i elt ) + [ from>> ] [ to>> ] bi + dup littledan-2 boa (littledan-2-test) ; inline recursive + +: littledan-2-test ( x -- i elt ) + [ 0 ] dip { array-capacity } declare littledan-2 boa (littledan-2-test) ; inline + +[ ] [ [ littledan-2-test ] final-classes drop ] unit-test + +: (littledan-3-test) ( x -- ) + length 1+ f <array> (littledan-3-test) ; inline recursive + +: littledan-3-test ( x -- ) + 0 f <array> (littledan-3-test) ; inline + +[ ] [ [ littledan-3-test ] final-classes drop ] unit-test + +[ V{ 0 } ] [ [ { } length ] final-literals ] unit-test + +[ V{ 1 } ] [ [ { } length 1+ f <array> length ] final-literals ] unit-test \ No newline at end of file diff --git a/basis/compiler/tree/propagation/propagation.factor b/basis/compiler/tree/propagation/propagation.factor index 2a9825e3f1..3dd2c4998a 100644 --- a/basis/compiler/tree/propagation/propagation.factor +++ b/basis/compiler/tree/propagation/propagation.factor @@ -20,5 +20,5 @@ IN: compiler.tree.propagation H{ } clone 1array value-infos set H{ } clone 1array constraints set H{ } clone inlining-count set - dup count-nodes + dup compute-node-count dup (propagate) ; diff --git a/basis/compiler/tree/propagation/recursive/recursive.factor b/basis/compiler/tree/propagation/recursive/recursive.factor index ff9f262d28..1bcd36f6b0 100644 --- a/basis/compiler/tree/propagation/recursive/recursive.factor +++ b/basis/compiler/tree/propagation/recursive/recursive.factor @@ -34,9 +34,14 @@ IN: compiler.tree.propagation.recursive } cond interval-union nip ; : generalize-counter ( info' initial -- info ) - 2dup [ class>> null-class? ] either? [ drop ] [ - [ drop clone ] [ [ interval>> ] bi@ ] 2bi - generalize-counter-interval >>interval + 2dup [ not ] either? [ drop ] [ + 2dup [ class>> null-class? ] either? [ drop ] [ + [ clone ] dip + [ [ drop ] [ [ interval>> ] bi@ generalize-counter-interval ] 2bi >>interval ] + [ [ drop ] [ [ slots>> ] bi@ [ generalize-counter ] 2map ] 2bi >>slots ] + [ [ drop ] [ [ length>> ] bi@ generalize-counter ] 2bi >>length ] + tri + ] if ] if ; : unify-recursive-stacks ( stacks initial -- infos ) diff --git a/extra/rewrite-closures/tags.txt b/basis/constructors/tags.txt similarity index 100% rename from extra/rewrite-closures/tags.txt rename to basis/constructors/tags.txt diff --git a/basis/core-foundation/arrays/arrays.factor b/basis/core-foundation/arrays/arrays.factor index 3708059f2b..1205352fcb 100644 --- a/basis/core-foundation/arrays/arrays.factor +++ b/basis/core-foundation/arrays/arrays.factor @@ -1,6 +1,6 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.syntax kernel sequences ; +USING: alien.syntax kernel sequences fry ; IN: core-foundation.arrays TYPEDEF: void* CFArrayRef @@ -17,6 +17,5 @@ FUNCTION: CFIndex CFArrayGetCount ( CFArrayRef array ) ; dup CFArrayGetCount [ CFArrayGetValueAtIndex ] with map ; : <CFArray> ( seq -- alien ) - [ f swap length f CFArrayCreateMutable ] keep - [ length ] keep - [ [ dupd ] dip CFArraySetValueAtIndex ] 2each ; + f over length &: kCFTypeArrayCallBacks CFArrayCreateMutable + [ '[ [ _ ] 2dip swap CFArraySetValueAtIndex ] each-index ] keep ; diff --git a/unmaintained/ifreq/tags.txt b/basis/core-foundation/attributed-strings/tags.txt similarity index 55% rename from unmaintained/ifreq/tags.txt rename to basis/core-foundation/attributed-strings/tags.txt index 6bf68304bb..2320bdd648 100644 --- a/unmaintained/ifreq/tags.txt +++ b/basis/core-foundation/attributed-strings/tags.txt @@ -1 +1,2 @@ unportable +bindings diff --git a/basis/core-text/core-text-tests.factor b/basis/core-text/core-text-tests.factor index 93f92391c8..a5cf69fdee 100644 --- a/basis/core-text/core-text-tests.factor +++ b/basis/core-text/core-text-tests.factor @@ -1,10 +1,9 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: tools.test core-text core-foundation -core-foundation.dictionaries destructors -arrays kernel generalizations math accessors -core-foundation.utilities -combinators hashtables colors ; +USING: tools.test core-text core-text.fonts core-foundation +core-foundation.dictionaries destructors arrays kernel generalizations +math accessors core-foundation.utilities combinators hashtables colors +colors.constants ; IN: core-text.tests : test-font ( name -- font ) @@ -21,8 +20,8 @@ IN: core-text.tests : test-typographic-bounds ( string font -- ? ) [ - test-font &CFRelease white <CTLine> &CFRelease - line-typographic-bounds { + test-font &CFRelease tuck COLOR: white <CTLine> &CFRelease + compute-line-metrics { [ width>> float? ] [ ascent>> float? ] [ descent>> float? ] diff --git a/unmaintained/raptor/cron/tags.txt b/basis/core-text/fonts/tags.txt similarity index 55% rename from unmaintained/raptor/cron/tags.txt rename to basis/core-text/fonts/tags.txt index 6bf68304bb..2320bdd648 100644 --- a/unmaintained/raptor/cron/tags.txt +++ b/basis/core-text/fonts/tags.txt @@ -1 +1,2 @@ unportable +bindings diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index 45bc5bf50a..627fd95384 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -220,7 +220,7 @@ M: assert error. 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 ; + ] tabular-output nl ; M: immutable summary drop "Sequence is immutable" ; diff --git a/basis/delegate/delegate-docs.factor b/basis/delegate/delegate-docs.factor index 5a2f4802e9..42b727852e 100644 --- a/basis/delegate/delegate-docs.factor +++ b/basis/delegate/delegate-docs.factor @@ -1,4 +1,4 @@ -USING: help.syntax help.markup ; +USING: help.syntax help.markup delegate.private ; IN: delegate HELP: define-protocol @@ -8,13 +8,13 @@ HELP: define-protocol HELP: PROTOCOL: { $syntax "PROTOCOL: protocol-name words... ;" } -{ $description "Defines an explicit protocol, which can be used as a basis for delegation or mimicry." } ; +{ $description "Defines an explicit protocol, which can be used as a basis for delegation." } ; { define-protocol POSTPONE: PROTOCOL: } related-words HELP: define-consult -{ $values { "class" "a class" } { "group" "a protocol, generic word or tuple class" } { "quot" "a quotation" } } -{ $description "Defines a class to consult, using the given quotation, on the generic words contained in the group." } +{ $values { "consultation" consultation } } +{ $description "Defines a class to consult, using the quotation, on the generic words contained in the group." } { $notes "Usually, " { $link POSTPONE: CONSULT: } " should be used instead. This is only for runtime use." } ; HELP: CONSULT: @@ -22,6 +22,12 @@ HELP: CONSULT: { $values { "group" "a protocol, generic word or tuple class" } { "class" "a class" } { "getter" "code to get where the method should be forwarded" } } { $description "Defines a class to consult, using the given code, on the generic words contained in the group. This means that, when one of the words in the group is called on an object of this class, the quotation will be called, and then the generic word called again. If the getter is empty, this will cause an infinite loop. Consultation overwrites the existing methods, but others can be defined afterwards." } ; +HELP: SLOT-PROTOCOL: +{ $syntax "SLOT-PROTOCOL: protocol-name slots... ;" } +{ $description "Defines a protocol consisting of reader and writer words for the listen slot names." } ; + +{ define-protocol POSTPONE: PROTOCOL: } related-words + { define-consult POSTPONE: CONSULT: } related-words HELP: group-words @@ -40,6 +46,8 @@ $nl "Defining new protocols:" { $subsection POSTPONE: PROTOCOL: } { $subsection define-protocol } +"Defining new protocols consisting of slot accessors:" +{ $subsection POSTPONE: SLOT-PROTOCOL: } "Defining consultation:" { $subsection POSTPONE: CONSULT: } { $subsection define-consult } diff --git a/basis/delegate/delegate-tests.factor b/basis/delegate/delegate-tests.factor index 4b02407735..9bf07a5330 100644 --- a/basis/delegate/delegate-tests.factor +++ b/basis/delegate/delegate-tests.factor @@ -1,6 +1,7 @@ USING: delegate kernel arrays tools.test words math definitions compiler.units parser generic prettyprint io.streams.string -accessors eval multiline ; +accessors eval multiline generic.standard delegate.protocols +delegate.private assocs see ; IN: delegate.tests TUPLE: hello this that ; @@ -35,7 +36,7 @@ M: hello bing hello-test ; [ 3 ] [ 1 0 <hello> f <goodbye> 2 whoa ] unit-test [ ] [ 3 [ "USING: accessors delegate ; IN: delegate.tests CONSULT: baz goodbye these>> ;" eval ] times ] unit-test -[ H{ { goodbye [ these>> ] } } ] [ baz protocol-consult ] unit-test +[ H{ { goodbye T{ consultation f baz goodbye [ these>> ] } } } ] [ baz protocol-consult ] unit-test [ H{ } ] [ bee protocol-consult ] unit-test [ "USING: delegate ;\nIN: delegate.tests\nPROTOCOL: baz foo bar { whoa 1 } ; inline\n" ] [ [ baz see ] with-string-writer ] unit-test @@ -112,6 +113,7 @@ PROTOCOL: silly-protocol do-me ; [ ] [ T{ a-tuple } do-me ] unit-test +! Change method definition to consultation [ [ ] ] [ <" IN: delegate.tests USE: kernel @@ -119,13 +121,22 @@ PROTOCOL: silly-protocol do-me ; CONSULT: silly-protocol a-tuple drop f ; "> <string-reader> "delegate-test" parse-stream ] unit-test +! Method should be there [ ] [ T{ a-tuple } do-me ] unit-test +! Now try removing the consulation +[ [ ] ] [ + <" IN: delegate.tests "> <string-reader> "delegate-test" parse-stream +] unit-test + +! Method should be gone +[ T{ a-tuple } do-me ] [ no-method? ] must-fail-with + ! A slot protocol issue DEFER: slot-protocol-test-3 SLOT: y -[ f ] [ \ y>> \ slot-protocol-test-3 method >boolean ] unit-test +[ f ] [ \ slot-protocol-test-3 \ y>> method >boolean ] unit-test [ [ ] ] [ <" IN: delegate.tests @@ -135,7 +146,7 @@ CONSULT: y>> slot-protocol-test-3 x>> ;"> <string-reader> "delegate-test-1" parse-stream ] unit-test -[ t ] [ \ y>> \ slot-protocol-test-3 method >boolean ] unit-test +[ t ] [ \ slot-protocol-test-3 \ y>> method >boolean ] unit-test [ [ ] ] [ <" IN: delegate.tests @@ -143,4 +154,46 @@ TUPLE: slot-protocol-test-3 x y ;"> <string-reader> "delegate-test-1" parse-stream ] unit-test -[ t ] [ \ y>> \ slot-protocol-test-3 method >boolean ] unit-test \ No newline at end of file +! We now have a real accessor for the y slot; we don't want it to +! get lost +[ t ] [ \ slot-protocol-test-3 \ y>> method >boolean ] unit-test + +! We want to be able to override methods after consultation +[ [ ] ] [ + <" IN: delegate.tests + USING: delegate kernel sequences delegate.protocols accessors ; + TUPLE: override-method-test seq ; + CONSULT: sequence-protocol override-method-test seq>> ; + M: override-method-test like drop ; "> + <string-reader> "delegate-test-2" parse-stream +] unit-test + +DEFER: seq-delegate + +! See if removing a consultation updates protocol-consult word prop +[ [ ] ] [ + <" IN: delegate.tests + USING: accessors delegate delegate.protocols ; + TUPLE: seq-delegate seq ; + CONSULT: sequence-protocol seq-delegate seq>> ;"> + <string-reader> "remove-consult-test" parse-stream +] unit-test + +[ t ] [ + seq-delegate + sequence-protocol \ protocol-consult word-prop + key? +] unit-test + +[ [ ] ] [ + <" IN: delegate.tests + USING: delegate delegate.protocols ; + TUPLE: seq-delegate seq ;"> + <string-reader> "remove-consult-test" parse-stream +] unit-test + +[ f ] [ + seq-delegate + sequence-protocol \ protocol-consult word-prop + key? +] unit-test \ No newline at end of file diff --git a/basis/delegate/delegate.factor b/basis/delegate/delegate.factor index a4eef54907..0c16b7c336 100644 --- a/basis/delegate/delegate.factor +++ b/basis/delegate/delegate.factor @@ -2,10 +2,13 @@ ! Portions copyright (C) 2009 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs classes.tuple definitions generic -generic.standard hashtables kernel lexer make math parser -generic.parser sequences sets slots words words.symbol fry ; +generic.standard hashtables kernel lexer math parser +generic.parser sequences sets slots words words.symbol fry +compiler.units ; IN: delegate +<PRIVATE + : protocol-words ( protocol -- words ) \ protocol-words word-prop ; @@ -27,27 +30,74 @@ M: tuple-class group-words ! Consultation -: consult-method ( word class quot -- ) - [ drop swap first create-method-in ] - [ nip [ swap [ second [ [ dip ] curry ] times % ] [ first , ] bi ] [ ] make ] 3bi +TUPLE: consultation group class quot loc ; + +: <consultation> ( group class quot -- consultation ) + f consultation boa ; + +: create-consult-method ( word consultation -- method ) + [ class>> swap first create-method dup fake-definition ] keep + [ drop ] [ "consultation" set-word-prop ] 2bi ; + +PREDICATE: consult-method < method-body "consultation" word-prop ; + +M: consult-method reset-word + [ call-next-method ] [ f "consultation" set-word-prop ] bi ; + +: consult-method-quot ( quot word -- object ) + [ second [ [ dip ] curry ] times ] [ first ] bi + '[ _ call _ execute ] ; + +: consult-method ( word consultation -- ) + [ create-consult-method ] + [ quot>> swap consult-method-quot ] 2bi define ; : change-word-prop ( word prop quot -- ) [ swap props>> ] dip change-at ; inline -: register-protocol ( group class quot -- ) - [ \ protocol-consult ] 2dip - '[ [ _ _ swap ] dip ?set-at ] change-word-prop ; +: each-generic ( consultation quot -- ) + [ [ group>> group-words ] keep ] dip curry each ; inline -: define-consult ( group class quot -- ) - [ register-protocol ] - [ [ group-words ] 2dip '[ _ _ consult-method ] each ] - 3bi ; +: register-consult ( consultation -- ) + [ group>> \ protocol-consult ] [ ] [ class>> ] tri + '[ [ _ _ ] dip ?set-at ] change-word-prop ; + +: consult-methods ( consultation -- ) + [ consult-method ] each-generic ; + +: unregister-consult ( consultation -- ) + [ class>> ] [ group>> ] bi + \ protocol-consult word-prop delete-at ; + +: unconsult-method ( word consultation -- ) + [ class>> swap first method ] keep + over [ + over "consultation" word-prop eq? + [ forget ] [ drop ] if + ] [ 2drop ] if ; + +: unconsult-methods ( consultation -- ) + [ unconsult-method ] each-generic ; + +PRIVATE> + +: define-consult ( consultation -- ) + [ register-consult ] [ consult-methods ] bi ; : CONSULT: - scan-word scan-word parse-definition define-consult ; parsing + scan-word scan-word parse-definition <consultation> + [ save-location ] [ define-consult ] bi ; parsing + +M: consultation where loc>> ; + +M: consultation set-where (>>loc) ; + +M: consultation forget* + [ unconsult-methods ] [ unregister-consult ] bi ; ! Protocols +<PRIVATE : cross-2each ( seq1 seq2 quot -- ) [ with each ] 2curry each ; inline @@ -69,8 +119,8 @@ M: tuple-class group-words swap protocol-words diff ; : add-new-definitions ( protocol wordlist -- ) - [ drop protocol-consult >alist ] [ added-words ] 2bi - [ swap first2 consult-method ] cross-2each ; + [ drop protocol-consult values ] [ added-words ] 2bi + [ swap consult-method ] cross-2each ; : initialize-protocol-props ( protocol wordlist -- ) [ @@ -81,6 +131,11 @@ M: tuple-class group-words : fill-in-depth ( wordlist -- wordlist' ) [ dup word? [ 0 2array ] when ] map ; +: show-words ( wordlist' -- wordlist ) + [ dup second zero? [ first ] when ] map ; + +PRIVATE> + : define-protocol ( protocol wordlist -- ) [ drop define-symbol ] [ fill-in-depth @@ -97,8 +152,6 @@ PREDICATE: protocol < word protocol-words ; ! Subclass of symbol? M: protocol forget* [ f forget-old-definitions ] [ call-next-method ] bi ; -: show-words ( wordlist' -- wordlist ) - [ dup second zero? [ first ] when ] map ; M: protocol definition protocol-words show-words ; diff --git a/unmaintained/bitfields/tags.txt b/basis/delegate/tags.txt similarity index 100% rename from unmaintained/bitfields/tags.txt rename to basis/delegate/tags.txt diff --git a/basis/farkup/farkup-tests.factor b/basis/farkup/farkup-tests.factor index 60a9f785e6..246da48b32 100644 --- a/basis/farkup/farkup-tests.factor +++ b/basis/farkup/farkup-tests.factor @@ -99,6 +99,7 @@ link-no-follow? off [ "<p><img src=\"lol.jpg\" alt=\"teh lol\"/></p>" ] [ "[[image:lol.jpg|teh lol]]" convert-farkup ] unit-test [ "<p><a href=\"http://lol.com\">http://lol.com</a></p>" ] [ "[[http://lol.com]]" convert-farkup ] unit-test [ "<p><a href=\"http://lol.com\">haha</a></p>" ] [ "[[http://lol.com|haha]]" convert-farkup ] unit-test +[ "<p><a href=\"http://lol.com/search?q=sex\">haha</a></p>" ] [ "[[http://lol.com/search?q=sex|haha]]" convert-farkup ] unit-test [ "<p><a href=\"Foo/Bar\">Bar</a></p>" ] [ "[[Foo/Bar]]" convert-farkup ] unit-test "/wiki/view/" relative-link-prefix [ diff --git a/basis/farkup/farkup.factor b/basis/farkup/farkup.factor index 50ee938659..4041d92773 100755 --- a/basis/farkup/farkup.factor +++ b/basis/farkup/farkup.factor @@ -165,12 +165,12 @@ CONSTANT: invalid-url "javascript:alert('Invalid URL in farkup');" { [ dup [ 127 > ] any? ] [ drop invalid-url ] } { [ dup first "/\\" member? ] [ drop invalid-url ] } { [ CHAR: : over member? ] [ dup absolute-url? [ drop invalid-url ] unless ] } - [ relative-link-prefix get prepend "" like ] - } cond url-encode ; + [ relative-link-prefix get prepend "" like url-encode ] + } cond ; : write-link ( href text -- xml ) - [ check-url link-no-follow? get "true" and ] dip - [XML <a href=<-> nofollow=<->><-></a> XML] ; + [ check-url link-no-follow? get "nofollow" and ] dip + [XML <a href=<-> rel=<->><-></a> XML] ; : write-image-link ( href text -- xml ) disable-images? get [ diff --git a/basis/fry/fry.factor b/basis/fry/fry.factor index e62a42749f..9ffad43cf4 100644 --- a/basis/fry/fry.factor +++ b/basis/fry/fry.factor @@ -53,4 +53,4 @@ M: callable deep-fry M: object deep-fry , ; -: '[ \ ] parse-until fry over push-all ; parsing +: '[ parse-quotation fry over push-all ; parsing diff --git a/basis/functors/functors.factor b/basis/functors/functors.factor index 0b9c9caa45..6592a3c4f2 100644 --- a/basis/functors/functors.factor +++ b/basis/functors/functors.factor @@ -122,20 +122,13 @@ DEFER: ;FUNCTOR delimiter functor-words use get delq ; : parse-functor-body ( -- form ) - t in-lambda? [ - V{ } clone - push-functor-words - "WHERE" parse-bindings* \ ;FUNCTOR (parse-lambda) - <let*> parsed-lambda - pop-functor-words - >quotation - ] with-variable ; + push-functor-words + "WHERE" parse-bindings* + [ \ ;FUNCTOR parse-until >quotation ] ((parse-lambda)) <let*> 1quotation + pop-functor-words ; : (FUNCTOR:) ( -- word def ) - CREATE - parse-locals dup push-locals - parse-functor-body swap pop-locals <lambda> - rewrite-closures first ; + CREATE-WORD [ parse-functor-body ] parse-locals-definition ; PRIVATE> diff --git a/basis/globs/globs-tests.factor b/basis/globs/globs-tests.factor index 446f1ee0a9..45eb27ea62 100644 --- a/basis/globs/globs-tests.factor +++ b/basis/globs/globs-tests.factor @@ -14,5 +14,6 @@ USING: tools.test globs ; [ f ] [ "foo.java" "*.{xml,txt}" glob-matches? ] unit-test [ t ] [ "foo.txt" "*.{xml,txt}" glob-matches? ] unit-test [ t ] [ "foo.xml" "*.{xml,txt}" glob-matches? ] unit-test -[ f ] [ "foo." "*.{,xml,txt}" glob-matches? ] unit-test +[ f ] [ "foo." "*.{xml,txt}" glob-matches? ] unit-test +[ t ] [ "foo." "*.{,xml,txt}" glob-matches? ] unit-test [ t ] [ "foo.{" "*.{" glob-matches? ] unit-test diff --git a/basis/globs/globs.factor b/basis/globs/globs.factor index 14ddb0ed9b..cac7fd9a2f 100644 --- a/basis/globs/globs.factor +++ b/basis/globs/globs.factor @@ -1,42 +1,42 @@ -! Copyright (C) 2007 Slava Pestov. +! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: parser-combinators parser-combinators.regexp lists sequences kernel -promises strings unicode.case ; +USING: sequences kernel regexp.combinators strings unicode.case +peg.ebnf regexp arrays ; IN: globs -<PRIVATE +EBNF: <glob> -: 'char' ( -- parser ) - [ ",*?" member? not ] satisfy ; +Character = "\\" .:c => [[ c 1string <literal> ]] + | !(","|"}") . => [[ 1string <literal> ]] -: 'string' ( -- parser ) - 'char' <+> [ >lower token ] <@ ; +RangeCharacter = !("]") . -: 'escaped-char' ( -- parser ) - "\\" token any-char-parser &> [ 1token ] <@ ; +Range = RangeCharacter:a "-" RangeCharacter:b => [[ a b <char-range> ]] + | RangeCharacter => [[ 1string <literal> ]] -: 'escaped-string' ( -- parser ) - 'string' 'escaped-char' <|> ; +StartRange = .:a "-" RangeCharacter:b => [[ a b <char-range> ]] + | . => [[ 1string <literal> ]] -DEFER: 'term' +Ranges = StartRange:s Range*:r => [[ r s prefix ]] -: 'glob' ( -- parser ) - 'term' <*> [ <and-parser> ] <@ ; +CharClass = "^"?:n Ranges:e => [[ e <or> n [ <not> ] when ]] -: 'union' ( -- parser ) - 'glob' "," token nonempty-list-of "{" "}" surrounded-by - [ <or-parser> ] <@ ; +AlternationBody = Concatenation:c "," AlternationBody:a => [[ a c prefix ]] + | Concatenation => [[ 1array ]] -LAZY: 'term' ( -- parser ) - 'union' - 'character-class' <|> - "?" token [ drop any-char-parser ] <@ <|> - "*" token [ drop any-char-parser <*> ] <@ <|> - 'escaped-string' <|> ; +Element = "*" => [[ R/ .*/ ]] + | "?" => [[ R/ ./ ]] + | "[" CharClass:c "]" => [[ c ]] + | "{" AlternationBody:b "}" => [[ b <or> ]] + | Character -PRIVATE> +Concatenation = Element* => [[ <sequence> ]] -: <glob> ( string -- glob ) 'glob' just parse-1 just ; +End = !(.) + +Main = Concatenation End + +;EBNF : glob-matches? ( input glob -- ? ) - [ >lower ] [ <glob> ] bi* parse nil? not ; + [ >case-fold ] bi@ <glob> matches? ; diff --git a/basis/help/cookbook/cookbook.factor b/basis/help/cookbook/cookbook.factor index b2b65c3913..d6693cd94f 100644 --- a/basis/help/cookbook/cookbook.factor +++ b/basis/help/cookbook/cookbook.factor @@ -1,6 +1,6 @@ USING: help.markup help.syntax io kernel math namespaces parser prettyprint sequences vocabs.loader namespaces stack-checker -help command-line multiline ; +help command-line multiline see ; IN: help.cookbook ARTICLE: "cookbook-syntax" "Basic syntax cookbook" diff --git a/basis/help/definitions/definitions-tests.factor b/basis/help/definitions/definitions-tests.factor index d95f6988a2..5d83afae88 100644 --- a/basis/help/definitions/definitions-tests.factor +++ b/basis/help/definitions/definitions-tests.factor @@ -1,6 +1,6 @@ USING: math definitions help.topics help tools.test prettyprint parser io.streams.string kernel source-files -assocs namespaces words io sequences eval accessors ; +assocs namespaces words io sequences eval accessors see ; IN: help.definitions.tests [ ] [ \ + >link see ] unit-test diff --git a/basis/help/definitions/definitions.factor b/basis/help/definitions/definitions.factor index 3e4066d8b7..91ee1c9c79 100644 --- a/basis/help/definitions/definitions.factor +++ b/basis/help/definitions/definitions.factor @@ -1,8 +1,8 @@ -! Copyright (C) 2007, 2008 Slava Pestov. +! Copyright (C) 2007, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors definitions help help.topics help.syntax prettyprint.backend prettyprint.custom prettyprint words kernel -effects ; +effects see ; IN: help.definitions ! Definition protocol implementation diff --git a/basis/help/handbook/handbook.factor b/basis/help/handbook/handbook.factor index 331fafbbd1..f20732c7ee 100644 --- a/basis/help/handbook/handbook.factor +++ b/basis/help/handbook/handbook.factor @@ -194,6 +194,7 @@ ARTICLE: "io" "Input and output" ARTICLE: "tools" "Developer tools" { $subsection "tools.vocabs" } "Exploratory tools:" +{ $subsection "see" } { $subsection "editor" } { $subsection "listener" } { $subsection "tools.crossref" } diff --git a/basis/help/help-docs.factor b/basis/help/help-docs.factor index 8384799dbd..733199fc60 100644 --- a/basis/help/help-docs.factor +++ b/basis/help/help-docs.factor @@ -1,6 +1,6 @@ USING: help.markup help.crossref help.stylesheet help.topics help.syntax definitions io prettyprint summary arrays math -sequences vocabs strings ; +sequences vocabs strings see ; IN: help ARTICLE: "printing-elements" "Printing markup elements" diff --git a/basis/help/lint/lint.factor b/basis/help/lint/lint.factor index 57f64459c8..2281c295c3 100755 --- a/basis/help/lint/lint.factor +++ b/basis/help/lint/lint.factor @@ -132,6 +132,11 @@ SYMBOL: vocabs-quot [ check-descriptions ] } cleave ; +: check-class-description ( word element -- ) + [ class? not ] + [ { $class-description } swap elements empty? not ] bi* and + [ "A word that is not a class has a $class-description" throw ] when ; + : all-word-help ( words -- seq ) [ word-help ] filter ; @@ -153,7 +158,8 @@ M: help-error error. dup '[ _ dup word-help [ check-values ] - [ nip [ check-nulls ] [ check-see-also ] [ check-markup ] tri ] 2bi + [ check-class-description ] + [ nip [ check-nulls ] [ check-see-also ] [ check-markup ] tri ] 2tri ] check-something ] [ drop ] if ; diff --git a/basis/help/markup/markup.factor b/basis/help/markup/markup.factor index d4f664d6ff..ea64def751 100644 --- a/basis/help/markup/markup.factor +++ b/basis/help/markup/markup.factor @@ -4,7 +4,7 @@ USING: accessors arrays definitions generic io kernel assocs hashtables namespaces make parser prettyprint sequences strings io.styles vectors words math sorting splitting classes slots fry sets vocabs help.stylesheet help.topics vocabs.loader quotations -combinators call ; +combinators call see ; IN: help.markup PREDICATE: simple-element < array @@ -13,7 +13,6 @@ PREDICATE: simple-element < array SYMBOL: last-element SYMBOL: span SYMBOL: block -SYMBOL: table : last-span? ( -- ? ) last-element get span eq? ; : last-block? ( -- ? ) last-element get block eq? ; @@ -44,7 +43,7 @@ M: f print-element drop ; [ print-element ] with-default-style ; : ($block) ( quot -- ) - last-element get { f table } member? [ nl ] unless + last-element get [ nl ] when span last-element set call block last-element set ; inline @@ -218,7 +217,7 @@ ALIAS: $slot $snippet table-content-style get [ swap [ last-element off call ] tabular-output ] with-style - ] ($block) table last-element set ; inline + ] ($block) ; inline : $list ( element -- ) list-style get [ @@ -301,7 +300,7 @@ M: f ($instance) ] with-style ] ($block) ; inline -: $see ( element -- ) first [ see ] ($see) ; +: $see ( element -- ) first [ see* ] ($see) ; : $synopsis ( element -- ) first [ synopsis write ] ($see) ; @@ -346,6 +345,8 @@ M: f ($instance) drop "Throws an error if the I/O operation fails." $errors ; +FROM: prettyprint.private => with-pprint ; + : $prettyprinting-note ( children -- ) drop { "This word should only be called from inside the " diff --git a/basis/html/components/components-tests.factor b/basis/html/components/components-tests.factor index 410c3ce223..0b85455c2e 100644 --- a/basis/html/components/components-tests.factor +++ b/basis/html/components/components-tests.factor @@ -4,6 +4,8 @@ io.streams.null accessors inspector html.streams html.components html.forms namespaces xml.writer ; +\ render must-infer + [ ] [ begin-form ] unit-test [ ] [ 3 "hi" set-value ] unit-test diff --git a/basis/http/http-tests.factor b/basis/http/http-tests.factor index 229d05615e..0d4282b1d7 100644 --- a/basis/http/http-tests.factor +++ b/basis/http/http-tests.factor @@ -9,14 +9,10 @@ IN: http.tests [ "text/html" utf8 ] [ "text/html; charset=UTF-8" parse-content-type ] unit-test +[ "text/html" utf8 ] [ "text/html; charset=\"utf-8\"" parse-content-type ] unit-test + [ "application/octet-stream" binary ] [ "application/octet-stream" parse-content-type ] unit-test -[ { } ] [ "" parse-cookie ] unit-test -[ { } ] [ "" parse-set-cookie ] unit-test - -! Make sure that totally invalid cookies don't confuse us -[ { } ] [ "hello world; how are you" parse-cookie ] unit-test - : lf>crlf "\n" split "\r\n" join ; STRING: read-request-test-1 diff --git a/basis/http/http.factor b/basis/http/http.factor index a64a11690c..bf58f5c238 100755 --- a/basis/http/http.factor +++ b/basis/http/http.factor @@ -34,7 +34,7 @@ IN: http : check-header-string ( str -- str ) #! http://en.wikipedia.org/wiki/HTTP_Header_Injection - dup "\r\n\"" intersects? + dup "\r\n" intersects? [ "Header injection attack" throw ] when ; : write-header ( assoc -- ) @@ -213,7 +213,10 @@ TUPLE: post-data data params content-type content-encoding ; swap >>content-type ; : parse-content-type-attributes ( string -- attributes ) - " " split harvest [ "=" split1 [ >lower ] dip ] { } map>assoc ; + " " split harvest [ + "=" split1 + [ >lower ] [ "\"" ?head drop "\"" ?tail drop ] bi* + ] { } map>assoc ; : parse-content-type ( content-type -- type encoding ) ";" split1 diff --git a/basis/http/parsers/parsers-tests.factor b/basis/http/parsers/parsers-tests.factor new file mode 100644 index 0000000000..f87ed47f00 --- /dev/null +++ b/basis/http/parsers/parsers-tests.factor @@ -0,0 +1,16 @@ +IN: http.parsers.tests +USING: http http.parsers tools.test ; + +[ { } ] [ "" parse-cookie ] unit-test +[ { } ] [ "" parse-set-cookie ] unit-test + +! Make sure that totally invalid cookies don't confuse us +[ { } ] [ "hello world; how are you" parse-cookie ] unit-test + +[ { T{ cookie { name "__s" } { value "12345567" } } } ] +[ "__s=12345567" parse-cookie ] +unit-test + +[ { T{ cookie { name "__s" } { value "12345567" } } } ] +[ "__s=12345567;" parse-cookie ] +unit-test \ No newline at end of file diff --git a/basis/http/parsers/parsers.factor b/basis/http/parsers/parsers.factor index d72147b381..2520c35acb 100644 --- a/basis/http/parsers/parsers.factor +++ b/basis/http/parsers/parsers.factor @@ -162,7 +162,7 @@ PEG: (parse-set-cookie) ( string -- alist ) 'value' , 'space' , ] seq* - [ ";,=" member? not ] satisfy repeat1 [ drop f ] action + [ ";,=" member? not ] satisfy repeat0 [ drop f ] action 2choice ; PEG: (parse-cookie) ( string -- alist ) diff --git a/basis/http/server/cgi/cgi.factor b/basis/http/server/cgi/cgi.factor index a64fe9af3c..d2f453034a 100644 --- a/basis/http/server/cgi/cgi.factor +++ b/basis/http/server/cgi/cgi.factor @@ -53,9 +53,9 @@ IN: http.server.cgi "CGI output follows" >>message swap '[ binary encode-output - _ output-stream get swap <cgi-process> binary <process-stream> [ + output-stream get _ <cgi-process> binary <process-stream> [ post-request? [ request get post-data>> data>> write flush ] when - '[ _ write ] each-block + '[ _ stream-write ] each-block ] with-stream ] >>body ; diff --git a/basis/images/bitmap/bitmap.factor b/basis/images/bitmap/bitmap.factor index 88eb984488..cf16df7d82 100755 --- a/basis/images/bitmap/bitmap.factor +++ b/basis/images/bitmap/bitmap.factor @@ -108,11 +108,6 @@ M: bitmap-image load-image* ( path bitmap -- bitmap ) load-bitmap-data process-bitmap-data fill-image-slots ; -M: bitmap-image normalize-scan-line-order - dup dim>> '[ - _ first 4 * <sliced-groups> reverse concat - ] change-bitmap ; - MACRO: (nbits>bitmap) ( bits -- ) [ -3 shift ] keep '[ bitmap-image new @@ -121,6 +116,7 @@ MACRO: (nbits>bitmap) ( bits -- ) swap >>width swap array-copy [ >>bitmap ] [ >>color-index ] bi _ >>bit-count fill-image-slots + t >>upside-down? ] ; : bgr>bitmap ( array height width -- bitmap ) diff --git a/basis/images/images.factor b/basis/images/images.factor index 82576774f4..cb44825e62 100644 --- a/basis/images/images.factor +++ b/basis/images/images.factor @@ -27,7 +27,7 @@ R16G16B16 R32G32B32 R16G16B16A16 R32G32B32A32 ; { R32G32B32A32 [ 16 ] } } case ; -TUPLE: image dim component-order bitmap ; +TUPLE: image dim component-order upside-down? bitmap ; : <image> ( -- image ) image new ; inline @@ -82,11 +82,16 @@ M: ARGB normalize-component-order* M: ABGR normalize-component-order* drop ARGB>RGBA 4 BGR>RGB ; -GENERIC: normalize-scan-line-order ( image -- image ) - -M: image normalize-scan-line-order ; +: normalize-scan-line-order ( image -- image ) + dup upside-down?>> [ + dup dim>> first 4 * '[ + _ <groups> reverse concat + ] change-bitmap + f >>upside-down? + ] when ; : normalize-image ( image -- image ) [ >byte-array ] change-bitmap normalize-component-order - normalize-scan-line-order ; + normalize-scan-line-order + RGBA >>component-order ; diff --git a/basis/images/tiff/tiff.factor b/basis/images/tiff/tiff.factor index a50ac0cad9..2ea1b08e20 100755 --- a/basis/images/tiff/tiff.factor +++ b/basis/images/tiff/tiff.factor @@ -503,7 +503,7 @@ ERROR: unknown-component-order ifd ; : ifd>image ( ifd -- image ) { [ [ image-width find-tag ] [ image-length find-tag ] bi 2array ] - [ ifd-component-order ] + [ ifd-component-order f ] [ bitmap>> ] } cleave tiff-image boa ; diff --git a/basis/inspector/inspector-tests.factor b/basis/inspector/inspector-tests.factor index 4ce549ac83..3f3e7f13df 100644 --- a/basis/inspector/inspector-tests.factor +++ b/basis/inspector/inspector-tests.factor @@ -8,7 +8,7 @@ f describe H{ } describe H{ } describe -[ "fixnum instance\n" ] [ [ 3 describe ] with-string-writer ] unit-test +[ "fixnum instance\n\n" ] [ [ 3 describe ] with-string-writer ] unit-test [ ] [ H{ } clone inspect ] unit-test diff --git a/basis/inspector/inspector.factor b/basis/inspector/inspector.factor index 05c4dc2a94..8cab5b5ad3 100644 --- a/basis/inspector/inspector.factor +++ b/basis/inspector/inspector.factor @@ -9,7 +9,7 @@ IN: inspector SYMBOL: +number-rows+ -: summary. ( obj -- ) [ summary ] keep write-object nl ; +: print-summary ( obj -- ) [ summary ] keep write-object ; <PRIVATE @@ -40,7 +40,7 @@ M: mirror fix-slot-names : (describe) ( obj assoc -- keys ) t pprint-string-cells? [ - [ summary. ] [ + [ print-summary nl ] [ dup hashtable? [ sort-unparsed-keys ] when [ fix-slot-names add-numbers simple-table. ] [ keys ] bi ] bi* diff --git a/basis/io/encodings/big5/big5.factor b/basis/io/encodings/big5/big5.factor index 97943a52ad..749815a22d 100644 --- a/basis/io/encodings/big5/big5.factor +++ b/basis/io/encodings/big5/big5.factor @@ -3,7 +3,7 @@ USING: io.encodings.iana io.encodings.euc ; IN: io.encodings.big5 -EUC: big5 "vocab:io/encodings/big5/CP950.txt" +EUC: big5 "vocab:io/encodings/big5/CP950.TXT" big5 "Big5" register-encoding diff --git a/basis/io/encodings/euc-kr/euc-kr-docs.factor b/basis/io/encodings/euc-kr/euc-kr-docs.factor index 5e109f3536..60cd41ac57 100644 --- a/basis/io/encodings/euc-kr/euc-kr-docs.factor +++ b/basis/io/encodings/euc-kr/euc-kr-docs.factor @@ -3,8 +3,11 @@ USING: help.syntax help.markup ; IN: io.encodings.euc-kr -ABOUT: euc-kr - HELP: euc-kr -{ $class-description "This encoding class implements Microsoft's code page #949 encoding, also called Unified Hangul Code or ks_c_5601-1987, UHC. CP949 is extended version of EUC-KR and downward-compatibility to EUC-KR, in practice." } +{ $class-description "This encoding class implements Microsoft's CP949 encoding, also called Unified Hangul Code or ks_c_5601-1987, UHC. CP949 is extended version of EUC-KR and downward-compatible with EUC-KR in practice." } { $see-also "encodings-introduction" } ; + +ARTICLE: "io.encodings.euc-kr" "EUC-KR encoding" +{ $subsection euc-kr } ; + +ABOUT: "io.encodings.euc-kr" \ No newline at end of file diff --git a/basis/io/encodings/johab/johab-docs.factor b/basis/io/encodings/johab/johab-docs.factor index 1d707e0f7d..d2eac30b25 100644 --- a/basis/io/encodings/johab/johab-docs.factor +++ b/basis/io/encodings/johab/johab-docs.factor @@ -3,7 +3,10 @@ USING: help.syntax help.markup ; IN: io.encodings.johab -ABOUT: johab - HELP: johab { $class-description "Korean Johab encoding (KSC5601-1992). This encoding is not commonly used anymore." } ; + +ARTICLE: "io.encodings.johab" "Korean Johab encoding" +{ $subsection johab } ; + +ABOUT: "io.encodings.johab" \ No newline at end of file diff --git a/basis/io/streams/byte-array/byte-array.factor b/basis/io/streams/byte-array/byte-array.factor index b877e97cf1..16160cd42d 100644 --- a/basis/io/streams/byte-array/byte-array.factor +++ b/basis/io/streams/byte-array/byte-array.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: byte-arrays byte-vectors kernel io.encodings io.streams.string sequences io namespaces io.encodings.private accessors sequences.private -io.streams.sequence destructors ; +io.streams.sequence destructors math combinators ; IN: io.streams.byte-array : <byte-writer> ( encoding -- stream ) @@ -20,6 +20,14 @@ M: byte-reader stream-read1 sequence-read1 ; M: byte-reader stream-read-until sequence-read-until ; M: byte-reader dispose drop ; +M: byte-reader stream-seek ( n seek-type stream -- ) + swap { + { seek-absolute [ (>>i) ] } + { seek-relative [ [ + ] change-i drop ] } + { seek-end [ dup underlying>> length >>i [ + ] change-i drop ] } + [ bad-seek-type ] + } case ; + : <byte-reader> ( byte-array encoding -- stream ) [ B{ } like 0 byte-reader boa ] dip <decoder> ; diff --git a/basis/io/styles/styles.factor b/basis/io/styles/styles.factor index 8e93dc9450..55dc6ca9a4 100644 --- a/basis/io/styles/styles.factor +++ b/basis/io/styles/styles.factor @@ -97,7 +97,7 @@ M: plain-writer make-block-stream nip <ignore-close-stream> ; M: plain-writer stream-write-table - [ drop format-table [ print ] each ] with-output-stream* ; + [ drop format-table [ nl ] [ write ] interleave ] with-output-stream* ; M: plain-writer make-cell-stream 2drop <string-writer> ; diff --git a/basis/listener/listener.factor b/basis/listener/listener.factor index 2ee0832269..78a9c03d20 100644 --- a/basis/listener/listener.factor +++ b/basis/listener/listener.factor @@ -84,7 +84,7 @@ SYMBOL: max-stack-items bi ] with-row ] each - ] tabular-output + ] tabular-output nl ] unless-empty ; : trimmed-stack. ( seq -- ) diff --git a/basis/locals/definitions/definitions.factor b/basis/locals/definitions/definitions.factor index 99f9d0bd22..a4299d0684 100644 --- a/basis/locals/definitions/definitions.factor +++ b/basis/locals/definitions/definitions.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2008 Slava Pestov, Eduardo Cavazos. ! See http://factorcode.org/license.txt for BSD license. USING: accessors definitions effects generic kernel locals -macros memoize prettyprint prettyprint.backend words ; +macros memoize prettyprint prettyprint.backend see words ; IN: locals.definitions PREDICATE: lambda-word < word "lambda" word-prop >boolean ; diff --git a/basis/locals/errors/errors.factor b/basis/locals/errors/errors.factor index d11405ddb5..e7b4c5a884 100644 --- a/basis/locals/errors/errors.factor +++ b/basis/locals/errors/errors.factor @@ -29,12 +29,12 @@ ERROR: :>-outside-lambda-error ; M: :>-outside-lambda-error summary drop ":> cannot be used outside of lambda expressions" ; -ERROR: bad-lambda-rewrite output ; - -M: bad-lambda-rewrite summary - drop "You have found a bug in locals. Please report." ; - ERROR: bad-local args obj ; M: bad-local summary drop "You have found a bug in locals. Please report." ; + +ERROR: bad-rewrite args obj ; + +M: bad-rewrite summary + drop "You have found a bug in locals. Please report." ; diff --git a/basis/locals/locals-docs.factor b/basis/locals/locals-docs.factor index a4a9ca448b..18dabed4b0 100644 --- a/basis/locals/locals-docs.factor +++ b/basis/locals/locals-docs.factor @@ -1,5 +1,5 @@ USING: help.syntax help.markup kernel macros prettyprint -memoize combinators arrays generalizations ; +memoize combinators arrays generalizations see ; IN: locals HELP: [| @@ -134,19 +134,30 @@ $nl "ordinary-word-test ordinary-word-test eq? ." "t" } -"In a word with locals, literals expand into code which constructs the literal, and so every invocation pushes a new object:" +"In a word with locals, literals which do not contain locals still behave in the same way:" { $example "USE: locals" "IN: scratchpad" "TUPLE: person first-name last-name ;" - ":: ordinary-word-test ( -- tuple )" + ":: locals-word-test ( -- tuple )" " T{ person { first-name \"Alan\" } { last-name \"Kay\" } } ;" - "ordinary-word-test ordinary-word-test eq? ." + "locals-word-test locals-word-test eq? ." + "t" +} +"However, literals with locals in them actually expand into code for constructing a new object:" +{ $example + "USING: locals splitting ;" + "IN: scratchpad" + "TUPLE: person first-name last-name ;" + ":: constructor-test ( -- tuple )" + " \"Jane Smith\" \" \" split1 :> last :> first" + " T{ person { first-name first } { last-name last } } ;" + "constructor-test constructor-test eq? ." "f" } "One exception to the above rule is that array instances containing no free variables do retain identity. This allows macros such as " { $link cond } " to recognize that the array is constant and expand at compile-time." { $heading "Example" } -"For example, here is an implementation of the " { $link 3array } " word which uses this feature:" +"Here is an implementation of the " { $link 3array } " word which uses this feature:" { $code ":: 3array ( x y z -- array ) { x y z } ;" } ; ARTICLE: "locals-mutable" "Mutable locals" diff --git a/basis/locals/locals-tests.factor b/basis/locals/locals-tests.factor index 08c667447c..558fa78494 100644 --- a/basis/locals/locals-tests.factor +++ b/basis/locals/locals-tests.factor @@ -2,7 +2,7 @@ USING: locals math sequences tools.test hashtables words kernel namespaces arrays strings prettyprint io.streams.string parser accessors generic eval combinators combinators.short-circuit combinators.short-circuit.smart math.order math.functions -definitions compiler.units fry lexer words.symbol ; +definitions compiler.units fry lexer words.symbol see ; IN: locals.tests :: foo ( a b -- a a ) a a ; @@ -357,12 +357,12 @@ ERROR: punned-class x ; [ T{ punned-class f 3 } ] [ 3 [| a | T{ punned-class f a } ] call ] unit-test :: literal-identity-test ( -- a b ) - { } V{ } ; + { 1 } V{ } ; -[ t f ] [ +[ t t ] [ literal-identity-test literal-identity-test - swapd [ eq? ] [ eq? ] 2bi* + [ eq? ] [ eq? ] bi-curry* bi* ] unit-test :: mutable-local-in-literal-test ( a! -- b ) a 1 + a! { a } ; @@ -401,9 +401,10 @@ M:: integer lambda-method-forget-test ( a -- b ) ; [ 10 ] [ 10 [| A | { [ A ] } ] call first call ] unit-test [ - "USING: locals fry math ; [ 0 '[ [let | A [ 10 ] | A _ + ] ] ]" eval + "USING: locals fry math ; 1 '[ [let | A [ 10 ] | A _ + ] ]" + eval call ] [ error>> >r/r>-in-fry-error? ] must-fail-with - + :: (funny-macro-test) ( obj quot -- ? ) obj { quot } 1&& ; inline : funny-macro-test ( n -- ? ) [ odd? ] (funny-macro-test) ; @@ -492,7 +493,7 @@ M:: integer lambda-method-forget-test ( a -- b ) ; [| | 0 '[ [let | A [ 10 ] | A _ + ] ] call ] call ] unit-test -! Discovered by littledan +! littledan found this problem [ "bar" ] [ [let | a [ [let | foo [ "bar" ] | foo ] ] | a ] ] unit-test [ 10 ] [ [let | a [ 10 ] | [let | b [ a ] | b ] ] ] unit-test @@ -503,8 +504,25 @@ M:: integer lambda-method-forget-test ( a -- b ) ; [ 3 ] [ [let | a [ \ + ] | 1 2 [ \ a execute ] ] call ] unit-test ! erg found this problem -:: erg's-:>-bug ( n ? -- n ) [ n :> n n ] [ n :> b b ] if ; +:: erg's-:>-bug ( n ? -- n ) ? [ n :> n n ] [ n :> b b ] if ; [ 3 ] [ 3 f erg's-:>-bug ] unit-test -[ 3 ] [ 3 t erg's-:>-bug ] unit-test \ No newline at end of file +[ 3 ] [ 3 t erg's-:>-bug ] unit-test + +:: erg's-:>-bug-2 ( n ? -- n ) ? n '[ _ :> n n ] [ n :> b b ] if ; + +[ 3 ] [ 3 f erg's-:>-bug-2 ] unit-test + +[ 3 ] [ 3 t erg's-:>-bug-2 ] unit-test + +! dharmatech found this problem +GENERIC: ed's-bug ( a -- b ) + +M: string ed's-bug reverse ; +M: integer ed's-bug neg ; + +:: ed's-test-case ( a -- b ) + { [ a ed's-bug ] } && ; + +[ t ] [ \ ed's-test-case optimized>> ] unit-test \ No newline at end of file diff --git a/basis/locals/locals.factor b/basis/locals/locals.factor index f745f6243f..190be61e23 100644 --- a/basis/locals/locals.factor +++ b/basis/locals/locals.factor @@ -9,19 +9,13 @@ IN: locals scan locals get [ :>-outside-lambda-error ] unless* [ make-local ] bind <def> parsed ; parsing -: [| parse-lambda parsed-lambda ; parsing +: [| parse-lambda over push-all ; parsing -: [let - "|" expect "|" parse-bindings - \ ] (parse-lambda) <let> parsed-lambda ; parsing +: [let parse-let over push-all ; parsing -: [let* - "|" expect "|" parse-bindings* - \ ] (parse-lambda) <let*> parsed-lambda ; parsing +: [let* parse-let* over push-all ; parsing -: [wlet - "|" expect "|" parse-wbindings - \ ] (parse-lambda) <wlet> parsed-lambda ; parsing +: [wlet parse-wlet over push-all ; parsing : :: (::) define ; parsing @@ -31,6 +25,8 @@ IN: locals : MEMO:: (::) define-memoized ; parsing +USE: syntax + { "locals.macros" "locals.fry" diff --git a/basis/locals/parser/parser.factor b/basis/locals/parser/parser.factor index f6baaf9ba7..d987e2c91d 100644 --- a/basis/locals/parser/parser.factor +++ b/basis/locals/parser/parser.factor @@ -6,6 +6,11 @@ locals.rewrite.closures locals.types make namespaces parser quotations sequences splitting words vocabs.parser ; IN: locals.parser +SYMBOL: in-lambda? + +: ?rewrite-closures ( form -- form' ) + in-lambda? get [ 1array ] [ rewrite-closures ] if ; + : make-local ( name -- word ) "!" ?tail [ <local-reader> @@ -20,28 +25,33 @@ IN: locals.parser [ <local-word> [ dup name>> set ] [ ] [ ] tri ] dip "local-word-def" set-word-prop ; -SYMBOL: locals - : push-locals ( assoc -- ) use get push ; : pop-locals ( assoc -- ) - use get delete ; + use get delq ; -SYMBOL: in-lambda? +SINGLETON: lambda-parser -: (parse-lambda) ( assoc end -- quot ) - [ +SYMBOL: locals + +: ((parse-lambda)) ( assoc quot -- quot' ) + '[ in-lambda? on - over locals set - over push-locals - parse-until >quotation - swap pop-locals - ] with-scope ; + lambda-parser quotation-parser set + [ locals set ] [ push-locals @ ] [ pop-locals ] tri + ] with-scope ; inline + +: (parse-lambda) ( assoc -- quot ) + [ \ ] parse-until >quotation ] ((parse-lambda)) ; : parse-lambda ( -- lambda ) "|" parse-tokens make-locals - \ ] (parse-lambda) <lambda> ; + (parse-lambda) <lambda> + ?rewrite-closures ; + +M: lambda-parser parse-quotation ( -- quotation ) + H{ } clone (parse-lambda) ; : parse-binding ( end -- pair/f ) scan { @@ -65,6 +75,10 @@ SYMBOL: in-lambda? : parse-bindings ( end -- bindings vars ) [ (parse-bindings) ] with-bindings ; +: parse-let ( -- form ) + "|" expect "|" parse-bindings + (parse-lambda) <let> ?rewrite-closures ; + : parse-bindings* ( end -- words assoc ) [ namespace push-locals @@ -72,6 +86,10 @@ SYMBOL: in-lambda? namespace pop-locals ] with-bindings ; +: parse-let* ( -- form ) + "|" expect "|" parse-bindings* + (parse-lambda) <let*> ?rewrite-closures ; + : (parse-wbindings) ( end -- ) dup parse-binding dup [ first2 [ make-local-word ] keep 2array , @@ -81,21 +99,29 @@ SYMBOL: in-lambda? : parse-wbindings ( end -- bindings vars ) [ (parse-wbindings) ] with-bindings ; +: parse-wlet ( -- form ) + "|" expect "|" parse-wbindings + (parse-lambda) <wlet> ?rewrite-closures ; + : parse-locals ( -- vars assoc ) "(" expect ")" parse-effect word [ over "declared-effect" set-word-prop ] when* in>> [ dup pair? [ first ] when ] map make-locals ; -: parse-locals-definition ( word -- word quot ) - parse-locals \ ; (parse-lambda) <lambda> +: parse-locals-definition ( word reader -- word quot ) + [ parse-locals ] dip + ((parse-lambda)) <lambda> [ "lambda" set-word-prop ] - [ rewrite-closures dup length 1 = [ first ] [ bad-lambda-rewrite ] if ] 2bi ; + [ rewrite-closures dup length 1 = [ first ] [ bad-rewrite ] if ] 2bi ; inline -: (::) ( -- word def ) CREATE-WORD parse-locals-definition ; +: (::) ( -- word def ) + CREATE-WORD + [ parse-definition ] + parse-locals-definition ; : (M::) ( -- word def ) CREATE-METHOD - [ parse-locals-definition ] with-method-definition ; - -: parsed-lambda ( accum form -- accum ) - in-lambda? get [ parsed ] [ rewrite-closures over push-all ] if ; + [ + [ parse-definition ] + parse-locals-definition + ] with-method-definition ; \ No newline at end of file diff --git a/basis/locals/rewrite/sugar/sugar.factor b/basis/locals/rewrite/sugar/sugar.factor index f0b8ac7240..87568d596a 100755 --- a/basis/locals/rewrite/sugar/sugar.factor +++ b/basis/locals/rewrite/sugar/sugar.factor @@ -37,13 +37,13 @@ M: array rewrite-literal? [ rewrite-literal? ] any? ; M: quotation rewrite-literal? [ rewrite-literal? ] any? ; +M: vector rewrite-literal? [ rewrite-literal? ] any? ; + M: wrapper rewrite-literal? wrapped>> rewrite-literal? ; -M: hashtable rewrite-literal? drop t ; +M: hashtable rewrite-literal? >alist rewrite-literal? ; -M: vector rewrite-literal? drop t ; - -M: tuple rewrite-literal? drop t ; +M: tuple rewrite-literal? tuple>array rewrite-literal? ; M: object rewrite-literal? drop f ; @@ -58,12 +58,16 @@ GENERIC: rewrite-element ( obj -- ) M: array rewrite-element dup rewrite-literal? [ rewrite-sequence ] [ , ] if ; -M: vector rewrite-element rewrite-sequence ; +M: vector rewrite-element + dup rewrite-literal? [ rewrite-sequence ] [ , ] if ; -M: hashtable rewrite-element >alist rewrite-sequence \ >hashtable , ; +M: hashtable rewrite-element + dup rewrite-literal? [ >alist rewrite-sequence \ >hashtable , ] [ , ] if ; M: tuple rewrite-element - [ tuple-slots rewrite-elements ] [ class ] bi '[ _ boa ] % ; + dup rewrite-literal? [ + [ tuple-slots rewrite-elements ] [ class ] bi '[ _ boa ] % + ] [ , ] if ; M: quotation rewrite-element rewrite-sugar* ; diff --git a/basis/macros/macros-tests.factor b/basis/macros/macros-tests.factor index 7b061ab2f5..7d93ce8a9e 100644 --- a/basis/macros/macros-tests.factor +++ b/basis/macros/macros-tests.factor @@ -1,6 +1,6 @@ IN: macros.tests USING: tools.test macros math kernel arrays -vectors io.streams.string prettyprint parser eval ; +vectors io.streams.string prettyprint parser eval see ; MACRO: see-test ( a b -- c ) + ; diff --git a/basis/math/partial-dispatch/partial-dispatch.factor b/basis/math/partial-dispatch/partial-dispatch.factor index 6618578a99..08cd8fb470 100644 --- a/basis/math/partial-dispatch/partial-dispatch.factor +++ b/basis/math/partial-dispatch/partial-dispatch.factor @@ -84,7 +84,7 @@ M: word integer-op-input-classes : define-integer-op-word ( fix-word big-word triple -- ) [ - [ 2nip integer-op-word ] [ integer-op-quot ] 3bi + [ 2nip integer-op-word dup make-foldable ] [ integer-op-quot ] 3bi (( x y -- z )) define-declared ] [ 2nip diff --git a/basis/memoize/memoize-tests.factor b/basis/memoize/memoize-tests.factor index 168a0061e3..54378bd37e 100644 --- a/basis/memoize/memoize-tests.factor +++ b/basis/memoize/memoize-tests.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. USING: math kernel memoize tools.test parser generalizations -prettyprint io.streams.string sequences eval namespaces ; +prettyprint io.streams.string sequences eval namespaces see ; IN: memoize.tests MEMO: fib ( m -- n ) diff --git a/basis/models/models-docs.factor b/basis/models/models-docs.factor index 4db71c4595..82dd035467 100644 --- a/basis/models/models-docs.factor +++ b/basis/models/models-docs.factor @@ -137,7 +137,7 @@ $nl { $subsection "models-delay" } ; ARTICLE: "models-impl" "Implementing models" -"New types of models can be defined, for example see " { $vocab-link "models.filter" } "." +"New types of models can be defined, for example see " { $vocab-link "models.arrow" } "." $nl "Models can execute hooks when activated:" { $subsection model-activated } diff --git a/basis/opengl/opengl.factor b/basis/opengl/opengl.factor index 4b2906db95..e08a7487ae 100644 --- a/basis/opengl/opengl.factor +++ b/basis/opengl/opengl.factor @@ -42,7 +42,7 @@ MACRO: all-enabled ( seq quot -- ) [ words>values ] dip '[ _ _ (all-enabled) ] ; MACRO: all-enabled-client-state ( seq quot -- ) - [ words>values ] dip '[ _ (all-enabled-client-state) ] ; + [ words>values ] dip '[ _ _ (all-enabled-client-state) ] ; : do-matrix ( mode quot -- ) swap [ glMatrixMode glPushMatrix call ] keep diff --git a/basis/opengl/textures/textures-tests.factor b/basis/opengl/textures/textures-tests.factor index 45b1d8f706..7141caa67d 100644 --- a/basis/opengl/textures/textures-tests.factor +++ b/basis/opengl/textures/textures-tests.factor @@ -5,15 +5,19 @@ images kernel namespaces ; IN: opengl.textures.tests [ ] [ - { 3 5 } - RGB - B{ - 1 2 3 4 5 6 7 8 9 - 10 11 12 13 14 15 16 17 18 - 19 20 21 22 23 24 25 26 27 - 28 29 30 31 32 33 34 35 36 - 37 38 39 40 41 42 43 44 45 - } image boa "image" set + T{ image + { dim { 3 5 } } + { component-order RGB } + { bitmap + B{ + 1 2 3 4 5 6 7 8 9 + 10 11 12 13 14 15 16 17 18 + 19 20 21 22 23 24 25 26 27 + 28 29 30 31 32 33 34 35 36 + 37 38 39 40 41 42 43 44 45 + } + } + } "image" set ] unit-test [ diff --git a/basis/opengl/textures/textures.factor b/basis/opengl/textures/textures.factor index 79af9be48b..48cdafb837 100644 --- a/basis/opengl/textures/textures.factor +++ b/basis/opengl/textures/textures.factor @@ -11,14 +11,16 @@ IN: opengl.textures TUPLE: texture loc dim texture-coords texture display-list disposed ; -<PRIVATE - GENERIC: component-order>format ( component-order -- format type ) +M: RGB component-order>format drop GL_RGB GL_UNSIGNED_BYTE ; +M: BGR component-order>format drop GL_BGR GL_UNSIGNED_BYTE ; M: RGBA component-order>format drop GL_RGBA GL_UNSIGNED_BYTE ; M: ARGB component-order>format drop GL_BGRA_EXT GL_UNSIGNED_INT_8_8_8_8_REV ; M: BGRA component-order>format drop GL_BGRA_EXT GL_UNSIGNED_BYTE ; +<PRIVATE + : repeat-last ( seq n -- seq' ) over peek pad-tail concat ; diff --git a/basis/peg/ebnf/ebnf.factor b/basis/peg/ebnf/ebnf.factor index ca97886235..399b5b0fc9 100644 --- a/basis/peg/ebnf/ebnf.factor +++ b/basis/peg/ebnf/ebnf.factor @@ -128,28 +128,28 @@ PEG: escaper ( string -- ast ) #! in the EBNF syntax itself. [ { - [ dup blank? ] - [ dup CHAR: " = ] - [ dup CHAR: ' = ] - [ dup CHAR: | = ] - [ dup CHAR: { = ] - [ dup CHAR: } = ] - [ dup CHAR: = = ] - [ dup CHAR: ) = ] - [ dup CHAR: ( = ] - [ dup CHAR: ] = ] - [ dup CHAR: [ = ] - [ dup CHAR: . = ] - [ dup CHAR: ! = ] - [ dup CHAR: & = ] - [ dup CHAR: * = ] - [ dup CHAR: + = ] - [ dup CHAR: ? = ] - [ dup CHAR: : = ] - [ dup CHAR: ~ = ] - [ dup CHAR: < = ] - [ dup CHAR: > = ] - } 0|| not nip + [ blank? ] + [ CHAR: " = ] + [ CHAR: ' = ] + [ CHAR: | = ] + [ CHAR: { = ] + [ CHAR: } = ] + [ CHAR: = = ] + [ CHAR: ) = ] + [ CHAR: ( = ] + [ CHAR: ] = ] + [ CHAR: [ = ] + [ CHAR: . = ] + [ CHAR: ! = ] + [ CHAR: & = ] + [ CHAR: * = ] + [ CHAR: + = ] + [ CHAR: ? = ] + [ CHAR: : = ] + [ CHAR: ~ = ] + [ CHAR: < = ] + [ CHAR: > = ] + } 1|| not ] satisfy repeat1 [ >string <ebnf-non-terminal> ] action ; : 'terminal' ( -- parser ) @@ -161,9 +161,9 @@ PEG: escaper ( string -- ast ) #! Parse a valid foreign parser name [ { - [ dup blank? ] - [ dup CHAR: > = ] - } 0|| not nip + [ blank? ] + [ CHAR: > = ] + } 1|| not ] satisfy repeat1 [ >string ] action ; : 'foreign' ( -- parser ) diff --git a/basis/prettyprint/prettyprint-docs.factor b/basis/prettyprint/prettyprint-docs.factor index 1e372d7cc0..2be725c0f6 100644 --- a/basis/prettyprint/prettyprint-docs.factor +++ b/basis/prettyprint/prettyprint-docs.factor @@ -1,6 +1,7 @@ USING: prettyprint.backend prettyprint.config prettyprint.custom prettyprint.sections prettyprint.private help.markup help.syntax -io kernel words definitions quotations strings generic classes ; +io kernel words definitions quotations strings generic classes +prettyprint.private ; IN: prettyprint ARTICLE: "prettyprint-numbers" "Prettyprinting numbers" @@ -149,10 +150,6 @@ $nl { $subsection unparse-use } "Utility for tabular output:" { $subsection pprint-cell } -"Printing a definition (see " { $link "definitions" } "):" -{ $subsection see } -"Printing the methods defined on a generic word or class (see " { $link "objects" } "):" -{ $subsection see-methods } "More prettyprinter usage:" { $subsection "prettyprint-numbers" } { $subsection "prettyprint-stacks" } @@ -160,7 +157,7 @@ $nl { $subsection "prettyprint-variables" } { $subsection "prettyprint-extension" } { $subsection "prettyprint-limitations" } -{ $see-also "number-strings" } ; +{ $see-also "number-strings" "see" } ; ABOUT: "prettyprint" @@ -232,51 +229,4 @@ HELP: .s HELP: in. { $values { "vocab" "a vocabulary specifier" } } { $description "Prettyprints a " { $snippet "IN:" } " declaration." } -$prettyprinting-note ; - -HELP: synopsis -{ $values { "defspec" "a definition specifier" } { "str" string } } -{ $contract "Prettyprints the prologue of a definition." } ; - -HELP: synopsis* -{ $values { "defspec" "a definition specifier" } } -{ $contract "Adds sections to the current block corresponding to a the prologue of a definition, in source code-like form." } -{ $notes "This word should only be called from inside the " { $link with-pprint } " combinator. Client code should call " { $link synopsis } " instead." } ; - -HELP: comment. -{ $values { "string" "a string" } } -{ $description "Prettyprints some text with the comment style." } -$prettyprinting-note ; - -HELP: see -{ $values { "defspec" "a definition specifier" } } -{ $contract "Prettyprints a definition." } ; - -HELP: see-methods -{ $values { "word" "a " { $link generic } " or a " { $link class } } } -{ $contract "Prettyprints the methods defined on a generic word or class." } ; - -HELP: definer -{ $values { "defspec" "a definition specifier" } { "start" word } { "end" "a word or " { $link f } } } -{ $contract "Outputs the parsing words which delimit the definition." } -{ $examples - { $example "USING: definitions prettyprint ;" - "IN: scratchpad" - ": foo ; \\ foo definer . ." - ";\nPOSTPONE: :" - } - { $example "USING: definitions prettyprint ;" - "IN: scratchpad" - "SYMBOL: foo \\ foo definer . ." - "f\nPOSTPONE: SYMBOL:" - } -} -{ $notes "This word is used in the implementation of " { $link see } "." } ; - -HELP: definition -{ $values { "defspec" "a definition specifier" } { "seq" "a sequence" } } -{ $contract "Outputs the body of a definition." } -{ $examples - { $example "USING: definitions math prettyprint ;" "\\ sq definition ." "[ dup * ]" } -} -{ $notes "This word is used in the implementation of " { $link see } "." } ; +$prettyprinting-note ; \ No newline at end of file diff --git a/basis/prettyprint/prettyprint-tests.factor b/basis/prettyprint/prettyprint-tests.factor index b1239086d7..aaaf6b80d1 100644 --- a/basis/prettyprint/prettyprint-tests.factor +++ b/basis/prettyprint/prettyprint-tests.factor @@ -3,7 +3,7 @@ kernel math namespaces parser prettyprint prettyprint.config prettyprint.sections sequences tools.test vectors words effects splitting generic.standard prettyprint.private continuations generic compiler.units tools.walker eval -accessors make vocabs.parser ; +accessors make vocabs.parser see ; IN: prettyprint.tests [ "4" ] [ 4 unparse ] unit-test diff --git a/basis/prettyprint/prettyprint.factor b/basis/prettyprint/prettyprint.factor index 63d7bf217a..5eb04c9510 100644 --- a/basis/prettyprint/prettyprint.factor +++ b/basis/prettyprint/prettyprint.factor @@ -1,16 +1,14 @@ -! Copyright (C) 2003, 2008 Slava Pestov. +! Copyright (C) 2003, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays generic generic.standard assocs io kernel math -namespaces make sequences strings io.styles io.streams.string -vectors words words.symbol prettyprint.backend prettyprint.custom -prettyprint.sections prettyprint.config sorting splitting -grouping math.parser vocabs definitions effects classes.builtin -classes.tuple io.pathnames classes continuations hashtables -classes.mixin classes.union classes.intersection -classes.predicate classes.singleton combinators quotations sets -accessors colors parser summary vocabs.parser ; +USING: accessors assocs colors combinators grouping io +io.streams.string io.styles kernel make math math.parser namespaces +parser prettyprint.backend prettyprint.config prettyprint.custom +prettyprint.sections quotations sequences sorting strings vocabs +vocabs.parser words sets ; IN: prettyprint +<PRIVATE + : make-pprint ( obj quot -- block in use ) [ 0 position set @@ -34,7 +32,7 @@ IN: prettyprint [ \ IN: pprint-word pprint-vocab ] with-pprint ; : in. ( vocab -- ) - [ write-in nl ] when* ; + [ write-in ] when* ; : use. ( seq -- ) [ @@ -54,19 +52,23 @@ IN: prettyprint [ [ words>> eq? nip ] with assoc-find 2drop ] curry map sift ; : prelude. ( -- ) - in get use get vocab-names use/in. ; + in get use get vocab-names prune in get ".private" append swap remove use/in. ; [ nl - "Restarts were invoked adding vocabularies to the search path." print - "To avoid doing this in the future, add the following USING:" print - "and IN: forms at the top of the source file:" print nl - prelude. - nl + { { font-style bold } { font-name "sans-serif" } } [ + "Restarts were invoked adding vocabularies to the search path." print + "To avoid doing this in the future, add the following USING:" print + "and IN: forms at the top of the source file:" print nl + ] with-style + { { page-color T{ rgba f 0.8 0.8 0.8 1.0 } } } [ prelude. ] with-nesting + nl nl ] print-use-hook set-global +PRIVATE> + : with-use ( obj quot -- ) - make-pprint use/in. do-pprint ; inline + make-pprint use/in. nl do-pprint ; inline : with-in ( obj quot -- ) make-pprint drop [ write-in bl ] when* do-pprint ; inline @@ -165,214 +167,4 @@ SYMBOL: pprint-string-cells? ] each ] with-row ] each - ] tabular-output ; - -GENERIC: see ( defspec -- ) - -: comment. ( string -- ) - [ H{ { font-style italic } } styled-text ] when* ; - -: seeing-word ( word -- ) - vocabulary>> pprinter-in set ; - -: definer. ( defspec -- ) - definer drop pprint-word ; - -: stack-effect. ( word -- ) - [ [ parsing-word? ] [ symbol? ] bi or not ] [ stack-effect ] bi and - [ effect>string comment. ] when* ; - -: word-synopsis ( word -- ) - { - [ seeing-word ] - [ definer. ] - [ pprint-word ] - [ stack-effect. ] - } cleave ; - -M: word synopsis* word-synopsis ; - -M: simple-generic synopsis* word-synopsis ; - -M: standard-generic synopsis* - { - [ definer. ] - [ seeing-word ] - [ pprint-word ] - [ dispatch# pprint* ] - [ stack-effect. ] - } cleave ; - -M: hook-generic synopsis* - { - [ definer. ] - [ seeing-word ] - [ pprint-word ] - [ "combination" word-prop var>> pprint* ] - [ stack-effect. ] - } cleave ; - -M: method-spec synopsis* - first2 method synopsis* ; - -M: method-body synopsis* - [ definer. ] - [ "method-class" word-prop pprint-word ] - [ "method-generic" word-prop pprint-word ] tri ; - -M: mixin-instance synopsis* - [ definer. ] - [ class>> pprint-word ] - [ mixin>> pprint-word ] tri ; - -M: pathname synopsis* pprint* ; - -: synopsis ( defspec -- str ) - [ - 0 margin set - 1 line-limit set - [ synopsis* ] with-in - ] with-string-writer ; - -M: word summary synopsis ; - -GENERIC: declarations. ( obj -- ) - -M: object declarations. drop ; - -: declaration. ( word prop -- ) - [ nip ] [ name>> word-prop ] 2bi - [ pprint-word ] [ drop ] if ; - -M: word declarations. - { - POSTPONE: parsing - POSTPONE: delimiter - POSTPONE: inline - POSTPONE: recursive - POSTPONE: foldable - POSTPONE: flushable - } [ declaration. ] with each ; - -: pprint-; ( -- ) \ ; pprint-word ; - -M: object see - [ - 12 nesting-limit set - 100 length-limit set - <colon dup synopsis* - <block dup definition pprint-elements block> - dup definer nip [ pprint-word ] when* declarations. - block> - ] with-use nl ; - -M: method-spec see - first2 method see ; - -GENERIC: see-class* ( word -- ) - -M: union-class see-class* - <colon \ UNION: pprint-word - dup pprint-word - members pprint-elements pprint-; block> ; - -M: intersection-class see-class* - <colon \ INTERSECTION: pprint-word - dup pprint-word - participants pprint-elements pprint-; block> ; - -M: mixin-class see-class* - <block \ MIXIN: pprint-word - dup pprint-word <block - dup members [ - hard line-break - \ INSTANCE: pprint-word pprint-word pprint-word - ] with each block> block> ; - -M: predicate-class see-class* - <colon \ PREDICATE: pprint-word - dup pprint-word - "<" text - dup superclass pprint-word - <block - "predicate-definition" word-prop pprint-elements - pprint-; block> block> ; - -M: singleton-class see-class* ( class -- ) - \ SINGLETON: pprint-word pprint-word ; - -GENERIC: pprint-slot-name ( object -- ) - -M: string pprint-slot-name text ; - -M: array pprint-slot-name - <flow \ { pprint-word - f <inset unclip text pprint-elements block> - \ } pprint-word block> ; - -: unparse-slot ( slot-spec -- array ) - [ - dup name>> , - dup class>> object eq? [ - dup class>> , - initial: , - dup initial>> , - ] unless - dup read-only>> [ - read-only , - ] when - drop - ] { } make ; - -: pprint-slot ( slot-spec -- ) - unparse-slot - dup length 1 = [ first ] when - pprint-slot-name ; - -M: tuple-class see-class* - <colon \ TUPLE: pprint-word - dup pprint-word - dup superclass tuple eq? [ - "<" text dup superclass pprint-word - ] unless - <block "slots" word-prop [ pprint-slot ] each block> - pprint-; block> ; - -M: word see-class* drop ; - -M: builtin-class see-class* - drop "! Built-in class" comment. ; - -: see-class ( class -- ) - dup class? [ - [ - dup seeing-word dup see-class* - ] with-use nl - ] when drop ; - -M: word see - [ see-class ] - [ [ class? ] [ symbol? not ] bi and [ nl ] when ] - [ - dup [ class? ] [ symbol? ] bi and - [ drop ] [ call-next-method ] if - ] tri ; - -: see-all ( seq -- ) - natural-sort [ nl ] [ see ] interleave ; - -: (see-implementors) ( class -- seq ) - dup implementors [ method ] with map natural-sort ; - -: (see-methods) ( generic -- seq ) - "methods" word-prop values natural-sort ; - -: methods ( word -- seq ) - [ - dup class? [ dup (see-implementors) % ] when - dup generic? [ dup (see-methods) % ] when - drop - ] { } make prune ; - -: see-methods ( word -- ) - methods see-all ; + ] tabular-output nl ; \ No newline at end of file diff --git a/basis/prettyprint/sections/sections-docs.factor b/basis/prettyprint/sections/sections-docs.factor index 4f1c073a2d..ce7430d040 100644 --- a/basis/prettyprint/sections/sections-docs.factor +++ b/basis/prettyprint/sections/sections-docs.factor @@ -199,7 +199,7 @@ HELP: <flow HELP: colon { $class-description "A " { $link block } " section. When printed as a " { $link long-section } ", indents every line except the first." } -{ $notes "Colon sections are used to enclose word definitions printed by " { $link see } "." } ; +{ $notes "Colon sections are used to enclose word definitions when " { $link "see" } "." } ; HELP: <colon { $description "Begins a " { $link colon } " section." } ; diff --git a/basis/regexp/ast/ast.factor b/basis/regexp/ast/ast.factor new file mode 100644 index 0000000000..ffaed2db62 --- /dev/null +++ b/basis/regexp/ast/ast.factor @@ -0,0 +1,65 @@ +! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel arrays accessors fry sequences regexp.classes ; +FROM: math.ranges => [a,b] ; +IN: regexp.ast + +TUPLE: negation term ; +C: <negation> negation + +TUPLE: from-to n m ; +C: <from-to> from-to + +TUPLE: at-least n ; +C: <at-least> at-least + +TUPLE: tagged-epsilon tag ; +C: <tagged-epsilon> tagged-epsilon + +CONSTANT: epsilon T{ tagged-epsilon { tag t } } + +TUPLE: concatenation first second ; + +: <concatenation> ( seq -- concatenation ) + [ epsilon ] [ unclip [ concatenation boa ] reduce ] if-empty ; + +TUPLE: alternation first second ; + +: <alternation> ( seq -- alternation ) + unclip [ alternation boa ] reduce ; + +TUPLE: star term ; +C: <star> star + +TUPLE: with-options tree options ; +C: <with-options> with-options + +TUPLE: options on off ; +C: <options> options + +SINGLETONS: unix-lines dotall multiline comments case-insensitive +unicode-case reversed-regexp ; + +: <maybe> ( term -- term' ) + f <concatenation> 2array <alternation> ; + +: <plus> ( term -- term' ) + dup <star> 2array <concatenation> ; + +: repetition ( n term -- term' ) + <array> <concatenation> ; + +GENERIC: <times> ( term times -- term' ) +M: at-least <times> + n>> swap [ repetition ] [ <star> ] bi 2array <concatenation> ; +M: from-to <times> + [ n>> ] [ m>> ] bi [a,b] swap '[ _ repetition ] map <alternation> ; + +: char-class ( ranges ? -- term ) + [ <or-class> ] dip [ <not-class> ] when ; + +TUPLE: lookahead term ; +C: <lookahead> lookahead + +TUPLE: lookbehind term ; +C: <lookbehind> lookbehind diff --git a/basis/regexp/backend/backend.factor b/basis/regexp/backend/backend.factor deleted file mode 100644 index 5eff0579c8..0000000000 --- a/basis/regexp/backend/backend.factor +++ /dev/null @@ -1,27 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors hashtables kernel math vectors ; -IN: regexp.backend - -TUPLE: regexp - raw - { options hashtable } - stack - parse-tree - nfa-table - dfa-table - minimized-table - matchers - { nfa-traversal-flags hashtable } - { dfa-traversal-flags hashtable } - { state integer } - { new-states vector } - { visited-states hashtable } ; - -: reset-regexp ( regexp -- regexp ) - 0 >>state - V{ } clone >>stack - V{ } clone >>new-states - H{ } clone >>visited-states ; - -SYMBOL: current-regexp diff --git a/basis/regexp/classes/classes-tests.factor b/basis/regexp/classes/classes-tests.factor new file mode 100644 index 0000000000..e2db86f6c1 --- /dev/null +++ b/basis/regexp/classes/classes-tests.factor @@ -0,0 +1,60 @@ +! Copyright (C) 2009 Daniel Ehrenberg. +! See http://factorcode.org/license.txt for BSD license. +USING: regexp.classes tools.test arrays kernel ; +IN: regexp.classes.tests + +! Class algebra + +[ f ] [ { 1 2 } <and-class> ] unit-test +[ T{ or-class f { 1 2 } } ] [ { 1 2 } <or-class> ] unit-test +[ 3 ] [ { 1 2 } <and-class> 3 2array <or-class> ] unit-test +[ CHAR: A ] [ CHAR: A LETTER-class <primitive-class> 2array <and-class> ] unit-test +[ CHAR: A ] [ LETTER-class <primitive-class> CHAR: A 2array <and-class> ] unit-test +[ T{ primitive-class { class LETTER-class } } ] [ CHAR: A LETTER-class <primitive-class> 2array <or-class> ] unit-test +[ T{ primitive-class { class LETTER-class } } ] [ LETTER-class <primitive-class> CHAR: A 2array <or-class> ] unit-test +[ t ] [ { t 1 } <or-class> ] unit-test +[ t ] [ { 1 t } <or-class> ] unit-test +[ f ] [ { f 1 } <and-class> ] unit-test +[ f ] [ { 1 f } <and-class> ] unit-test +[ 1 ] [ { f 1 } <or-class> ] unit-test +[ 1 ] [ { 1 f } <or-class> ] unit-test +[ 1 ] [ { t 1 } <and-class> ] unit-test +[ 1 ] [ { 1 t } <and-class> ] unit-test +[ 1 ] [ 1 <not-class> <not-class> ] unit-test +[ 1 ] [ { 1 1 } <and-class> ] unit-test +[ 1 ] [ { 1 1 } <or-class> ] unit-test +[ t ] [ { t t } <or-class> ] unit-test +[ T{ primitive-class { class letter-class } } ] [ letter-class <primitive-class> dup 2array <and-class> ] unit-test +[ T{ primitive-class { class letter-class } } ] [ letter-class <primitive-class> dup 2array <or-class> ] unit-test +[ T{ or-class { seq { 1 2 3 } } } ] [ { 1 2 } <or-class> { 2 3 } <or-class> 2array <or-class> ] unit-test +[ T{ or-class { seq { 2 3 } } } ] [ { 2 3 } <or-class> 1 <not-class> 2array <and-class> ] unit-test +[ f ] [ t <not-class> ] unit-test +[ t ] [ f <not-class> ] unit-test +[ f ] [ 1 <not-class> 1 t answer ] unit-test +[ t ] [ { 1 2 } <or-class> <not-class> 1 2 3array <or-class> ] unit-test +[ f ] [ { 1 2 } <and-class> <not-class> 1 2 3array <and-class> ] unit-test + +! Making classes into nested conditionals + +[ V{ 1 2 3 4 } ] [ T{ and-class f { 1 T{ not-class f 2 } T{ or-class f { 3 4 } } 2 } } class>questions ] unit-test +[ { 3 } ] [ { { 3 t } } table>condition ] unit-test +[ { T{ primitive-class } } ] [ { { 1 t } { 2 T{ primitive-class } } } table>questions ] unit-test +[ { { 1 t } { 2 t } } ] [ { { 1 t } { 2 T{ primitive-class } } } T{ primitive-class } t assoc-answer ] unit-test +[ { { 1 t } } ] [ { { 1 t } { 2 T{ primitive-class } } } T{ primitive-class } f assoc-answer ] unit-test +[ T{ condition f T{ primitive-class } { 1 2 } { 1 } } ] [ { { 1 t } { 2 T{ primitive-class } } } table>condition ] unit-test + +SYMBOL: foo +SYMBOL: bar + +[ T{ condition f T{ primitive-class f bar } T{ condition f T{ primitive-class f foo } { 1 3 2 } { 1 3 } } T{ condition f T{ primitive-class f foo } { 1 2 } { 1 } } } ] [ { { 1 t } { 3 T{ primitive-class f bar } } { 2 T{ primitive-class f foo } } } table>condition ] unit-test + +[ t ] [ foo <primitive-class> dup t answer ] unit-test +[ f ] [ foo <primitive-class> dup f answer ] unit-test +[ T{ primitive-class f foo } ] [ foo <primitive-class> bar <primitive-class> t answer ] unit-test +[ T{ primitive-class f foo } ] [ foo <primitive-class> bar <primitive-class> f answer ] unit-test +[ T{ primitive-class f foo } ] [ foo <primitive-class> bar <primitive-class> 2array <and-class> bar <primitive-class> t answer ] unit-test +[ T{ primitive-class f bar } ] [ foo <primitive-class> bar <primitive-class> 2array <and-class> foo <primitive-class> t answer ] unit-test +[ f ] [ foo <primitive-class> bar <primitive-class> 2array <and-class> foo <primitive-class> f answer ] unit-test +[ f ] [ foo <primitive-class> bar <primitive-class> 2array <and-class> bar <primitive-class> f answer ] unit-test +[ t ] [ foo <primitive-class> bar <primitive-class> 2array <or-class> bar <primitive-class> t answer ] unit-test +[ T{ primitive-class f foo } ] [ foo <primitive-class> bar <primitive-class> 2array <or-class> bar <primitive-class> f answer ] unit-test diff --git a/basis/regexp/classes/classes.factor b/basis/regexp/classes/classes.factor index 4a807fa51b..d26ff7f69c 100644 --- a/basis/regexp/classes/classes.factor +++ b/basis/regexp/classes/classes.factor @@ -1,7 +1,8 @@ -! Copyright (C) 2008 Doug Coleman. +! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel math math.order words regexp.utils -unicode.categories combinators.short-circuit ; +USING: accessors kernel math math.order words combinators locals +ascii unicode.categories combinators.short-circuit sequences +fry macros arrays assocs sets classes mirrors ; IN: regexp.classes SINGLETONS: any-char any-char-no-nl @@ -11,19 +12,18 @@ ascii-class punctuation-class java-printable-class blank-class control-character-class hex-digit-class java-blank-class c-identifier-class unmatchable-class terminator-class word-boundary-class ; -SINGLETONS: beginning-of-input beginning-of-line -end-of-input end-of-line ; +SINGLETONS: beginning-of-input ^ end-of-input $ end-of-file word-break ; -MIXIN: node -TUPLE: character-class-range from to ; INSTANCE: character-class-range node +TUPLE: range from to ; +C: <range> range GENERIC: class-member? ( obj class -- ? ) -M: t class-member? ( obj class -- ? ) 2drop f ; +M: t class-member? ( obj class -- ? ) 2drop t ; -M: integer class-member? ( obj class -- ? ) 2drop f ; +M: integer class-member? ( obj class -- ? ) = ; -M: character-class-range class-member? ( obj class -- ? ) +M: range class-member? ( obj class -- ? ) [ from>> ] [ to>> ] bi between? ; M: any-char class-member? ( obj class -- ? ) @@ -47,16 +47,24 @@ M: ascii-class class-member? ( obj class -- ? ) M: digit-class class-member? ( obj class -- ? ) drop digit? ; +: c-identifier-char? ( ch -- ? ) + { [ alpha? ] [ CHAR: _ = ] } 1|| ; + M: c-identifier-class class-member? ( obj class -- ? ) - drop - { [ digit? ] [ Letter? ] [ CHAR: _ = ] } 1|| ; + drop c-identifier-char? ; M: alpha-class class-member? ( obj class -- ? ) drop alpha? ; +: punct? ( ch -- ? ) + "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" member? ; + M: punctuation-class class-member? ( obj class -- ? ) drop punct? ; +: java-printable? ( ch -- ? ) + { [ alpha? ] [ punct? ] } 1|| ; + M: java-printable-class class-member? ( obj class -- ? ) drop java-printable? ; @@ -64,11 +72,24 @@ M: non-newline-blank-class class-member? ( obj class -- ? ) drop { [ blank? ] [ CHAR: \n = not ] } 1&& ; M: control-character-class class-member? ( obj class -- ? ) - drop control-char? ; + drop control? ; + +: hex-digit? ( ch -- ? ) + { + [ CHAR: A CHAR: F between? ] + [ CHAR: a CHAR: f between? ] + [ CHAR: 0 CHAR: 9 between? ] + } 1|| ; M: hex-digit-class class-member? ( obj class -- ? ) drop hex-digit? ; +: java-blank? ( ch -- ? ) + { + CHAR: \s CHAR: \t CHAR: \n + HEX: b HEX: 7 CHAR: \r + } member? ; + M: java-blank-class class-member? ( obj class -- ? ) drop java-blank? ; @@ -76,16 +97,219 @@ M: unmatchable-class class-member? ( obj class -- ? ) 2drop f ; M: terminator-class class-member? ( obj class -- ? ) - drop { - [ CHAR: \r = ] - [ CHAR: \n = ] - [ CHAR: \u000085 = ] - [ CHAR: \u002028 = ] - [ CHAR: \u002029 = ] + drop "\r\n\u000085\u002029\u002028" member? ; + +M: ^ class-member? ( obj class -- ? ) + 2drop f ; + +M: $ class-member? ( obj class -- ? ) + 2drop f ; + +M: f class-member? 2drop f ; + +TUPLE: primitive-class class ; +C: <primitive-class> primitive-class + +TUPLE: not-class class ; + +PREDICATE: not-integer < not-class class>> integer? ; +PREDICATE: not-primitive < not-class class>> primitive-class? ; + +M: not-class class-member? + class>> class-member? not ; + +TUPLE: or-class seq ; + +M: or-class class-member? + seq>> [ class-member? ] with any? ; + +TUPLE: and-class seq ; + +M: and-class class-member? + seq>> [ class-member? ] with all? ; + +DEFER: substitute + +: flatten ( seq class -- newseq ) + '[ dup _ instance? [ seq>> ] [ 1array ] if ] map concat ; inline + +:: seq>instance ( seq empty class -- instance ) + seq length { + { 0 [ empty ] } + { 1 [ seq first ] } + [ drop class new seq { } like >>seq ] + } case ; inline + +TUPLE: class-partition integers not-integers primitives not-primitives and or other ; + +: partition-classes ( seq -- class-partition ) + prune + [ integer? ] partition + [ not-integer? ] partition + [ primitive-class? ] partition ! extend primitive-class to epsilon tags + [ not-primitive? ] partition + [ and-class? ] partition + [ or-class? ] partition + class-partition boa ; + +: class-partition>seq ( class-partition -- seq ) + make-mirror values concat ; + +: repartition ( partition -- partition' ) + ! This could be made more efficient; only and and or are effected + class-partition>seq partition-classes ; + +: filter-not-integers ( partition -- partition' ) + dup + [ primitives>> ] [ not-primitives>> ] [ or>> ] tri + 3append and-class boa + '[ [ class>> _ class-member? ] filter ] change-not-integers ; + +: answer-ors ( partition -- partition' ) + dup [ not-integers>> ] [ not-primitives>> ] [ primitives>> ] tri 3append + '[ [ _ [ t substitute ] each ] map ] change-or ; + +: contradiction? ( partition -- ? ) + { + [ [ primitives>> ] [ not-primitives>> ] bi intersects? ] + [ other>> f swap member? ] } 1|| ; -M: beginning-of-line class-member? ( obj class -- ? ) - 2drop f ; +: make-and-class ( partition -- and-class ) + answer-ors repartition + [ t swap remove ] change-other + dup contradiction? + [ drop f ] + [ filter-not-integers class-partition>seq prune t and-class seq>instance ] if ; -M: end-of-line class-member? ( obj class -- ? ) - 2drop f ; +: <and-class> ( seq -- class ) + dup and-class flatten partition-classes + dup integers>> length { + { 0 [ nip make-and-class ] } + { 1 [ integers>> first [ '[ _ swap class-member? ] all? ] keep and ] } + [ 3drop f ] + } case ; + +: filter-integers ( partition -- partition' ) + dup + [ primitives>> ] [ not-primitives>> ] [ and>> ] tri + 3append or-class boa + '[ [ _ class-member? not ] filter ] change-integers ; + +: answer-ands ( partition -- partition' ) + dup [ integers>> ] [ not-primitives>> ] [ primitives>> ] tri 3append + '[ [ _ [ f substitute ] each ] map ] change-and ; + +: tautology? ( partition -- ? ) + { + [ [ primitives>> ] [ not-primitives>> ] bi intersects? ] + [ other>> t swap member? ] + } 1|| ; + +: make-or-class ( partition -- and-class ) + answer-ands repartition + [ f swap remove ] change-other + dup tautology? + [ drop t ] + [ filter-integers class-partition>seq prune f or-class seq>instance ] if ; + +: <or-class> ( seq -- class ) + dup or-class flatten partition-classes + dup not-integers>> length { + { 0 [ nip make-or-class ] } + { 1 [ not-integers>> first [ class>> '[ _ swap class-member? ] any? ] keep or ] } + [ 3drop t ] + } case ; + +GENERIC: <not-class> ( class -- inverse ) + +M: object <not-class> + not-class boa ; + +M: not-class <not-class> + class>> ; + +M: and-class <not-class> + seq>> [ <not-class> ] map <or-class> ; + +M: or-class <not-class> + seq>> [ <not-class> ] map <and-class> ; + +M: t <not-class> drop f ; +M: f <not-class> drop t ; + +M: primitive-class class-member? + class>> class-member? ; + +UNION: class primitive-class not-class or-class and-class range ; + +TUPLE: condition question yes no ; +C: <condition> condition + +GENERIC# answer 2 ( class from to -- new-class ) + +M:: object answer ( class from to -- new-class ) + class from = to class ? ; + +: replace-compound ( class from to -- seq ) + [ seq>> ] 2dip '[ _ _ answer ] map ; + +M: and-class answer + replace-compound <and-class> ; + +M: or-class answer + replace-compound <or-class> ; + +M: not-class answer + [ class>> ] 2dip answer <not-class> ; + +GENERIC# substitute 1 ( class from to -- new-class ) +M: object substitute answer ; +M: not-class substitute [ <not-class> ] bi@ answer ; + +: assoc-answer ( table question answer -- new-table ) + '[ _ _ substitute ] assoc-map + [ nip ] assoc-filter ; + +: assoc-answers ( table questions answer -- new-table ) + '[ _ assoc-answer ] each ; + +DEFER: make-condition + +: (make-condition) ( table questions question -- condition ) + [ 2nip ] + [ swap [ t assoc-answer ] dip make-condition ] + [ swap [ f assoc-answer ] dip make-condition ] 3tri + 2dup = [ 2nip ] [ <condition> ] if ; + +: make-condition ( table questions -- condition ) + [ keys ] [ unclip (make-condition) ] if-empty ; + +GENERIC: class>questions ( class -- questions ) +: compound-questions ( class -- questions ) seq>> [ class>questions ] gather ; +M: or-class class>questions compound-questions ; +M: and-class class>questions compound-questions ; +M: not-class class>questions class>> class>questions ; +M: object class>questions 1array ; + +: table>questions ( table -- questions ) + values [ class>questions ] gather >array t swap remove ; + +: table>condition ( table -- condition ) + ! input table is state => class + >alist dup table>questions make-condition ; + +: condition-map ( condition quot: ( obj -- obj' ) -- new-condition ) + over condition? [ + [ [ question>> ] [ yes>> ] [ no>> ] tri ] dip + '[ _ condition-map ] bi@ <condition> + ] [ call ] if ; inline recursive + +: condition-states ( condition -- states ) + dup condition? [ + [ yes>> ] [ no>> ] bi + [ condition-states ] bi@ append prune + ] [ 1array ] if ; + +: condition-at ( condition assoc -- new-condition ) + '[ _ at ] condition-map ; diff --git a/unmaintained/bitfields/authors.txt b/basis/regexp/combinators/authors.txt similarity index 100% rename from unmaintained/bitfields/authors.txt rename to basis/regexp/combinators/authors.txt diff --git a/basis/regexp/combinators/combinators-docs.factor b/basis/regexp/combinators/combinators-docs.factor new file mode 100644 index 0000000000..7cb214f42b --- /dev/null +++ b/basis/regexp/combinators/combinators-docs.factor @@ -0,0 +1,54 @@ +! Copyright (C) 2009 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: help.syntax help.markup regexp strings ; +IN: regexp.combinators + +ABOUT: "regexp.combinators" + +ARTICLE: "regexp.combinators" "Regular expression combinators" +"The " { $vocab-link "regexp.combinators" } " vocabulary defines combinators which can be used to build up regular expressions to match strings. This is in addition to the traditional syntax defined in the " { $vocab-link "regexp" } " vocabulary." +{ $subsection <literal> } +{ $subsection <nothing> } +{ $subsection <or> } +{ $subsection <and> } +{ $subsection <not> } +{ $subsection <sequence> } +{ $subsection <zero-or-more> } +{ $subsection <one-or-more> } +{ $subsection <option> } ; + +HELP: <literal> +{ $values { "string" string } { "regexp" regexp } } +{ $description "Creates a regular expression which matches the given literal string." } ; + +HELP: <nothing> +{ $values { "value" regexp } } +{ $description "The empty regular language." } ; + +HELP: <or> +{ $values { "regexps" "a sequence of regular expressions" } { "disjunction" regexp } } +{ $description "Creates a new regular expression which matches the union of what elements of the sequence match." } ; + +HELP: <and> +{ $values { "regexps" "a sequence of regular expressions" } { "conjunction" regexp } } +{ $description "Creates a new regular expression which matches the intersection of what elements of the sequence match." } ; + +HELP: <sequence> +{ $values { "regexps" "a sequence of regular expressions" } { "regexp" regexp } } +{ $description "Creates a new regular expression which matches strings that match each element of the sequence in order." } ; + +HELP: <not> +{ $values { "regexp" regexp } { "not-regexp" regexp } } +{ $description "Creates a new regular expression which matches everything that the given regexp does not match." } ; + +HELP: <one-or-more> +{ $values { "regexp" regexp } { "regexp+" regexp } } +{ $description "Creates a new regular expression which matches one or more copies of the given regexp." } ; + +HELP: <option> +{ $values { "regexp" regexp } { "regexp?" regexp } } +{ $description "Creates a new regular expression which matches zero or one copies of the given regexp." } ; + +HELP: <zero-or-more> +{ $values { "regexp" regexp } { "regexp*" regexp } } +{ $description "Creates a new regular expression which matches zero or more copies of the given regexp." } ; diff --git a/basis/regexp/combinators/combinators-tests.factor b/basis/regexp/combinators/combinators-tests.factor new file mode 100644 index 0000000000..85fa190bfe --- /dev/null +++ b/basis/regexp/combinators/combinators-tests.factor @@ -0,0 +1,28 @@ +! Copyright (C) 2009 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: regexp.combinators tools.test regexp kernel sequences ; +IN: regexp.combinators.tests + +: strings ( -- regexp ) + { "foo" "bar" "baz" } <any-of> ; + +[ t t t ] [ "foo" "bar" "baz" [ strings matches? ] tri@ ] unit-test +[ f f f ] [ "food" "ibar" "ba" [ strings matches? ] tri@ ] unit-test + +: conj ( -- regexp ) + { R' .*a' R' b.*' } <and> ; + +[ t ] [ "bljhasflsda" conj matches? ] unit-test +[ f ] [ "bsdfdfs" conj matches? ] unit-test +[ f ] [ "fsfa" conj matches? ] unit-test + +[ f ] [ "bljhasflsda" conj <not> matches? ] unit-test +[ t ] [ "bsdfdfs" conj <not> matches? ] unit-test +[ t ] [ "fsfa" conj <not> matches? ] unit-test + +[ f f ] [ "" "hi" [ <nothing> matches? ] bi@ ] unit-test +[ t t ] [ "" "hi" [ <nothing> <not> matches? ] bi@ ] unit-test + +[ { t t t f } ] [ { "" "a" "aaaaa" "aab" } [ "a" <literal> <zero-or-more> matches? ] map ] unit-test +[ { f t t f } ] [ { "" "a" "aaaaa" "aab" } [ "a" <literal> <one-or-more> matches? ] map ] unit-test +[ { t t f f } ] [ { "" "a" "aaaaa" "aab" } [ "a" <literal> <option> matches? ] map ] unit-test diff --git a/basis/regexp/combinators/combinators.factor b/basis/regexp/combinators/combinators.factor new file mode 100644 index 0000000000..2941afd99e --- /dev/null +++ b/basis/regexp/combinators/combinators.factor @@ -0,0 +1,56 @@ +! Copyright (C) 2009 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: regexp sequences kernel regexp.negation regexp.ast +accessors fry regexp.classes ; +IN: regexp.combinators + +<PRIVATE + +: modify-regexp ( regexp raw-quot tree-quot -- new-regexp ) + [ '[ raw>> @ ] ] + [ '[ parse-tree>> @ ] ] bi* bi + make-regexp ; inline + +PRIVATE> + +CONSTANT: <nothing> R/ (?~.*)/ + +: <literal> ( string -- regexp ) + [ "\\Q" "\\E" surround ] [ <concatenation> ] bi make-regexp ; foldable + +: <char-range> ( char1 char2 -- regexp ) + [ [ "[" "-" surround ] [ "]" append ] bi* append ] + [ <range> ] + 2bi make-regexp ; + +: <or> ( regexps -- disjunction ) + [ [ raw>> "(" ")" surround ] map "|" join ] + [ [ parse-tree>> ] map <alternation> ] bi + make-regexp ; foldable + +: <any-of> ( strings -- regexp ) + [ <literal> ] map <or> ; foldable + +: <sequence> ( regexps -- regexp ) + [ [ raw>> ] map concat ] + [ [ parse-tree>> ] map <concatenation> ] bi + make-regexp ; foldable + +: <not> ( regexp -- not-regexp ) + [ "(?~" ")" surround ] + [ <negation> ] modify-regexp ; foldable + +: <and> ( regexps -- conjunction ) + [ <not> ] map <or> <not> ; foldable + +: <zero-or-more> ( regexp -- regexp* ) + [ "(" ")*" surround ] + [ <star> ] modify-regexp ; foldable + +: <one-or-more> ( regexp -- regexp+ ) + [ "(" ")+" surround ] + [ <plus> ] modify-regexp ; foldable + +: <option> ( regexp -- regexp? ) + [ "(" ")?" surround ] + [ <maybe> ] modify-regexp ; foldable diff --git a/basis/regexp/combinators/summary.txt b/basis/regexp/combinators/summary.txt new file mode 100644 index 0000000000..1b3fb6c188 --- /dev/null +++ b/basis/regexp/combinators/summary.txt @@ -0,0 +1 @@ +Combinators for creating regular expressions diff --git a/unmaintained/lisp/parser/tags.txt b/basis/regexp/combinators/tags.txt similarity index 61% rename from unmaintained/lisp/parser/tags.txt rename to basis/regexp/combinators/tags.txt index d1f6fa1ef3..9da56880c0 100644 --- a/unmaintained/lisp/parser/tags.txt +++ b/basis/regexp/combinators/tags.txt @@ -1,2 +1 @@ -lisp parsing diff --git a/basis/regexp/compiler/compiler.factor b/basis/regexp/compiler/compiler.factor new file mode 100644 index 0000000000..186d683f82 --- /dev/null +++ b/basis/regexp/compiler/compiler.factor @@ -0,0 +1,142 @@ +! Copyright (C) 2009 Daniel Ehrenberg. +! See http://factorcode.org/license.txt for BSD license. +USING: regexp.classes kernel sequences regexp.negation +quotations assocs fry math locals combinators +accessors words compiler.units kernel.private strings +sequences.private arrays call namespaces unicode.breaks +regexp.transition-tables combinators.short-circuit ; +IN: regexp.compiler + +GENERIC: question>quot ( question -- quot ) + +SYMBOL: shortest? +SYMBOL: backwards? + +<PRIVATE + +M: t question>quot drop [ 2drop t ] ; +M: f question>quot drop [ 2drop f ] ; + +M: not-class question>quot + class>> question>quot [ not ] compose ; + +M: beginning-of-input question>quot + drop [ drop zero? ] ; + +M: end-of-input question>quot + drop [ length = ] ; + +M: end-of-file question>quot + drop [ + { + [ length swap - 2 <= ] + [ swap tail { "\n" "\r\n" "\r" "" } member? ] + } 2&& + ] ; + +M: $ question>quot + drop [ { [ length = ] [ ?nth "\r\n" member? ] } 2|| ] ; + +M: ^ question>quot + drop [ { [ drop zero? ] [ [ 1- ] dip ?nth "\r\n" member? ] } 2|| ] ; + +M: word-break question>quot + drop [ word-break-at? ] ; + +: (execution-quot) ( next-state -- quot ) + ! The conditions here are for lookaround and anchors, etc + dup condition? [ + [ question>> question>quot ] [ yes>> ] [ no>> ] tri + [ (execution-quot) ] bi@ + '[ 2dup @ _ _ if ] + ] [ '[ _ execute ] ] if ; + +: execution-quot ( next-state -- quot ) + dup sequence? [ first ] when + (execution-quot) ; + +TUPLE: box contents ; +C: <box> box + +: condition>quot ( condition -- quot ) + ! Conditions here are for different classes + dup condition? [ + [ question>> ] [ yes>> ] [ no>> ] tri + [ condition>quot ] bi@ + '[ dup _ class-member? _ _ if ] + ] [ + contents>> + [ [ 3drop ] ] [ execution-quot '[ drop @ ] ] if-empty + ] if ; + +: non-literals>dispatch ( literals non-literals -- quot ) + [ swap ] assoc-map ! we want state => predicate, and get the opposite as input + swap keys f assoc-answers + table>condition [ <box> ] condition-map condition>quot ; + +: literals>cases ( literal-transitions -- case-body ) + [ execution-quot ] assoc-map ; + +: split-literals ( transitions -- case default ) + { } assoc-like [ first integer? ] partition + [ [ literals>cases ] keep ] dip non-literals>dispatch ; + +:: step ( last-match index str quot final? direction -- last-index/f ) + final? index last-match ? + index str bounds-check? [ + index direction + str + index str nth-unsafe + quot call + ] when ; inline + +: direction ( -- n ) + backwards? get -1 1 ? ; + +: transitions>quot ( transitions final-state? -- quot ) + dup shortest? get and [ 2drop [ drop nip ] ] [ + [ split-literals swap case>quot ] dip direction + '[ { array-capacity string } declare _ _ _ step ] + ] if ; + +: word>quot ( word dfa -- quot ) + [ transitions>> at ] + [ final-states>> key? ] 2bi + transitions>quot ; + +: states>code ( words dfa -- ) + [ ! with-compilation-unit doesn't compile, so we need call( -- ) + [ + '[ + dup _ word>quot + (( last-match index string -- ? )) + define-declared + ] each + ] with-compilation-unit + ] call( words dfa -- ) ; + +: states>words ( dfa -- words dfa ) + dup transitions>> keys [ gensym ] H{ } map>assoc + [ transitions-at ] + [ values ] + bi swap ; + +: dfa>main-word ( dfa -- word ) + states>words [ states>code ] keep start-state>> ; + +PRIVATE> + +: simple-define-temp ( quot effect -- word ) + [ [ define-temp ] with-compilation-unit ] call( quot effect -- word ) ; + +: dfa>word ( dfa -- quot ) + dfa>main-word execution-quot '[ drop [ f ] 2dip @ ] + (( start-index string regexp -- i/f )) simple-define-temp ; + +: dfa>shortest-word ( dfa -- word ) + t shortest? [ dfa>word ] with-variable ; + +: dfa>reverse-word ( dfa -- word ) + t backwards? [ dfa>word ] with-variable ; + +: dfa>reverse-shortest-word ( dfa -- word ) + t backwards? [ dfa>shortest-word ] with-variable ; diff --git a/basis/regexp/dfa/dfa-tests.factor b/basis/regexp/dfa/dfa-tests.factor new file mode 100644 index 0000000000..129a639929 --- /dev/null +++ b/basis/regexp/dfa/dfa-tests.factor @@ -0,0 +1,3 @@ +USING: regexp.dfa tools.test ; +IN: regexp.dfa.tests + diff --git a/basis/regexp/dfa/dfa.factor b/basis/regexp/dfa/dfa.factor index 549669cab7..d137ee3e4f 100644 --- a/basis/regexp/dfa/dfa.factor +++ b/basis/regexp/dfa/dfa.factor @@ -1,84 +1,84 @@ -! Copyright (C) 2008 Doug Coleman. +! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs combinators fry kernel locals math math.order regexp.nfa regexp.transition-tables sequences -sets sorting vectors regexp.utils sequences.deep ; -USING: io prettyprint threads ; +sets sorting vectors regexp.ast regexp.classes ; IN: regexp.dfa -: find-delta ( states transition regexp -- new-states ) - nfa-table>> transitions>> - rot [ swap at at ] with with gather sift ; +: find-delta ( states transition nfa -- new-states ) + transitions>> '[ _ swap _ at at ] gather sift ; -: (find-epsilon-closure) ( states regexp -- new-states ) - eps swap find-delta ; +:: epsilon-loop ( state table nfa question -- ) + state table at :> old-value + old-value question 2array <or-class> :> new-question + new-question old-value = [ + new-question state table set-at + state nfa transitions>> at + [ drop tagged-epsilon? ] assoc-filter + [| trans to | + to [ + table nfa + trans tag>> new-question 2array <and-class> + epsilon-loop + ] each + ] assoc-each + ] unless ; -: find-epsilon-closure ( states regexp -- new-states ) - '[ dup _ (find-epsilon-closure) union ] [ length ] while-changes - natural-sort ; +: epsilon-table ( states nfa -- table ) + [ H{ } clone tuck ] dip + '[ _ _ t epsilon-loop ] each ; -: find-closure ( states transition regexp -- new-states ) - [ find-delta ] 2keep nip find-epsilon-closure ; +: find-epsilon-closure ( states nfa -- dfa-state ) + epsilon-table table>condition ; -: find-start-state ( regexp -- state ) - [ nfa-table>> start-state>> 1vector ] keep find-epsilon-closure ; +: find-closure ( states transition nfa -- new-states ) + [ find-delta ] keep find-epsilon-closure ; -: find-transitions ( seq1 regexp -- seq2 ) - nfa-table>> transitions>> - [ at keys ] curry gather - eps swap remove ; +: find-start-state ( nfa -- state ) + [ start-state>> 1array ] keep find-epsilon-closure ; -: add-todo-state ( state regexp -- ) - 2dup visited-states>> key? [ - 2drop - ] [ - [ visited-states>> conjoin ] - [ new-states>> push ] 2bi +: find-transitions ( dfa-state nfa -- next-dfa-state ) + transitions>> + '[ _ at keys [ condition-states ] map concat ] gather + [ tagged-epsilon? not ] filter ; + +: add-todo-state ( state visited-states new-states -- ) + 3dup drop key? [ 3drop ] [ + [ conjoin ] [ push ] bi-curry* bi ] if ; -: new-transitions ( regexp -- ) - dup new-states>> [ - drop - ] [ - dupd pop dup pick find-transitions rot - [ - [ [ find-closure ] 2keep nip dupd add-todo-state ] 3keep - [ swapd transition make-transition ] dip - dfa-table>> add-transition - ] curry with each - new-transitions +: add-todo-states ( state/condition visited-states new-states -- ) + [ condition-states ] 2dip + '[ _ _ add-todo-state ] each ; + +:: new-transitions ( nfa dfa new-states visited-states -- nfa dfa ) + new-states [ nfa dfa ] [ + pop :> state + state dfa transitions>> maybe-initialize-key + state nfa find-transitions + [| trans | + state trans nfa find-closure :> new-state + new-state visited-states new-states add-todo-states + state new-state trans dfa set-transition + ] each + nfa dfa new-states visited-states new-transitions ] if-empty ; -: states ( hashtable -- array ) - [ keys ] - [ values [ values concat ] map concat append ] bi ; +: set-final-states ( nfa dfa -- ) + [ + [ final-states>> keys ] + [ transitions>> keys ] bi* + [ intersects? ] with filter + unique + ] keep (>>final-states) ; -: set-final-states ( regexp -- ) - dup - [ nfa-table>> final-states>> keys ] - [ dfa-table>> transitions>> states ] bi - [ intersects? ] with filter +: initialize-dfa ( nfa -- dfa ) + <transition-table> + swap find-start-state >>start-state ; - swap dfa-table>> final-states>> - [ conjoin ] curry each ; - -: set-initial-state ( regexp -- ) - dup - [ dfa-table>> ] [ find-start-state ] bi - [ >>start-state drop ] keep - 1vector >>new-states drop ; - -: set-traversal-flags ( regexp -- ) - dup - [ nfa-traversal-flags>> ] - [ dfa-table>> transitions>> keys ] bi - [ [ nip ] [ [ swap at ] with map concat ] 2bi ] with H{ } map>assoc - >>dfa-traversal-flags drop ; - -: construct-dfa ( regexp -- ) - { - [ set-initial-state ] - [ new-transitions ] - [ set-final-states ] - [ set-traversal-flags ] - } cleave ; +: construct-dfa ( nfa -- dfa ) + dup initialize-dfa + dup start-state>> condition-states >vector + H{ } clone + new-transitions + [ set-final-states ] keep ; diff --git a/basis/regexp/disambiguate/disambiguate.factor b/basis/regexp/disambiguate/disambiguate.factor new file mode 100644 index 0000000000..67b1503f9b --- /dev/null +++ b/basis/regexp/disambiguate/disambiguate.factor @@ -0,0 +1,43 @@ +! Copyright (C) 2009 Daniel Ehrenberg. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel accessors regexp.classes math.bits assocs sequences +arrays sets regexp.dfa math fry regexp.minimize regexp.ast regexp.transition-tables ; +IN: regexp.disambiguate + +TUPLE: parts in out ; + +: make-partition ( choices classes -- partition ) + zip [ first ] partition [ values ] bi@ parts boa ; + +: powerset-partition ( classes -- partitions ) + [ length [ 2^ ] keep ] keep '[ + _ <bits> _ make-partition + ] map rest ; + +: partition>class ( parts -- class ) + [ out>> [ <not-class> ] map ] + [ in>> <and-class> ] bi + prefix <and-class> ; + +: get-transitions ( partition state-transitions -- next-states ) + [ in>> ] dip '[ _ at ] gather sift ; + +: new-transitions ( transitions -- assoc ) ! assoc is class, partition + values [ keys ] gather + [ tagged-epsilon? not ] filter + powerset-partition + [ [ partition>class ] keep ] { } map>assoc + [ drop ] assoc-filter ; + +: preserving-epsilon ( state-transitions quot -- new-state-transitions ) + [ [ drop tagged-epsilon? ] assoc-filter ] bi + assoc-union H{ } assoc-like ; inline +: disambiguate ( nfa -- nfa ) + expand-ors [ + dup new-transitions '[ + [ + _ swap '[ _ get-transitions ] assoc-map + [ nip empty? not ] assoc-filter + ] preserving-epsilon + ] assoc-map + ] change-transitions ; diff --git a/basis/regexp/minimize/minimize-tests.factor b/basis/regexp/minimize/minimize-tests.factor new file mode 100644 index 0000000000..17a1d51b88 --- /dev/null +++ b/basis/regexp/minimize/minimize-tests.factor @@ -0,0 +1,58 @@ +! Copyright (C) 2009 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: tools.test regexp.minimize assocs regexp +accessors regexp.transition-tables regexp.parser +regexp.classes regexp.negation ; +IN: regexp.minimize.tests + +[ t ] [ 1 2 H{ { { 1 2 } t } } same-partition? ] unit-test +[ t ] [ 2 1 H{ { { 1 2 } t } } same-partition? ] unit-test +[ f ] [ 2 3 H{ { { 1 2 } t } } same-partition? ] unit-test + +[ H{ { 1 1 } { 2 1 } { 3 3 } { 4 3 } } ] +[ { { 1 1 } { 1 2 } { 2 2 } { 3 3 } { 3 4 } { 4 4 } } [ t ] H{ } map>assoc partition>classes ] unit-test + +[ { { 1 2 } { 3 4 } } ] [ H{ { "elephant" 1 } { "tiger" 3 } } H{ { "elephant" 2 } { "tiger" 4 } } assemble-values ] unit-test + +: regexp-states ( string -- n ) + parse-regexp ast>dfa transitions>> assoc-size ; + +[ 3 ] [ "ab|ac" regexp-states ] unit-test +[ 3 ] [ "a(b|c)" regexp-states ] unit-test +[ 1 ] [ "((aa*)*)*" regexp-states ] unit-test +[ 1 ] [ "a|((aa*)*)*" regexp-states ] unit-test +[ 2 ] [ "ab|((aa*)*)*b" regexp-states ] unit-test +[ 4 ] [ "ab|cd" regexp-states ] unit-test +[ 1 ] [ "(?i:[a-z]*|[A-Z]*)" regexp-states ] unit-test + +[ + T{ transition-table + { transitions H{ + { 0 H{ { CHAR: a 1 } { CHAR: b 1 } } } + { 1 H{ { CHAR: a 2 } { CHAR: b 2 } } } + { 2 H{ { CHAR: c 3 } } } + { 3 H{ } } + } } + { start-state 0 } + { final-states H{ { 3 3 } } } + } +] [ + T{ transition-table + { transitions H{ + { 0 H{ { CHAR: a 1 } { CHAR: b 4 } } } + { 1 H{ { CHAR: a 2 } { CHAR: b 5 } } } + { 2 H{ { CHAR: c 3 } } } + { 3 H{ } } + { 4 H{ { CHAR: a 2 } { CHAR: b 5 } } } + { 5 H{ { CHAR: c 6 } } } + { 6 H{ } } + } } + { start-state 0 } + { final-states H{ { 3 3 } { 6 6 } } } + } combine-states +] unit-test + +[ [ ] [ ] while-changes ] must-infer + +[ H{ { T{ or-class f { 2 1 } } 3 } { 4 5 } } ] +[ H{ { 1 3 } { 2 3 } { 4 5 } } combine-state-transitions ] unit-test diff --git a/basis/regexp/minimize/minimize.factor b/basis/regexp/minimize/minimize.factor new file mode 100644 index 0000000000..1885144e6c --- /dev/null +++ b/basis/regexp/minimize/minimize.factor @@ -0,0 +1,100 @@ +! Copyright (C) 2009 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: kernel sequences regexp.transition-tables fry assocs +accessors locals math sorting arrays sets hashtables regexp.dfa +combinators.short-circuit regexp.classes ; +IN: regexp.minimize + +: table>state-numbers ( table -- assoc ) + transitions>> keys <enum> [ swap ] H{ } assoc-map-as ; + +: number-states ( table -- newtable ) + dup table>state-numbers transitions-at ; + +: has-conditions? ( assoc -- ? ) + values [ condition? ] any? ; + +: initially-same? ( s1 s2 transition-table -- ? ) + { + [ drop <= ] + [ transitions>> '[ _ at keys ] bi@ set= ] + [ final-states>> '[ _ key? ] bi@ = ] + } 3&& ; + +:: initialize-partitions ( transition-table -- partitions ) + ! Partition table is sorted-array => ? + H{ } clone :> out + transition-table transitions>> keys :> states + states [| s1 | + states [| s2 | + s1 s2 transition-table initially-same? + [ s1 s2 2array out conjoin ] when + ] each + ] each out ; + +: same-partition? ( s1 s2 partitions -- ? ) + { [ [ 2array natural-sort ] dip key? ] [ drop = ] } 3|| ; + +: assemble-values ( assoc1 assoc2 -- values ) + dup keys '[ _ swap [ at ] curry map ] bi@ zip ; + +: stay-same? ( s1 s2 transition partitions -- ? ) + [ '[ _ transitions>> at ] bi@ assemble-values ] dip + '[ _ same-partition? ] assoc-all? ; + +: partition-more ( partitions transition-table -- partitions ) + over '[ drop first2 _ _ stay-same? ] assoc-filter ; + +: partition>classes ( partitions -- synonyms ) ! old-state => new-state + >alist sort-keys + [ drop first2 swap ] assoc-map + <reversed> + >hashtable ; + +:: (while-changes) ( obj quot: ( obj -- obj' ) comp: ( obj -- key ) old-key -- obj ) + obj quot call :> new-obj + new-obj comp call :> new-key + new-key old-key = + [ new-obj ] + [ new-obj quot comp new-key (while-changes) ] + if ; inline recursive + +: while-changes ( obj quot pred -- obj' ) + 3dup nip call (while-changes) ; inline + +: (state-classes) ( transition-table -- partition ) + [ initialize-partitions ] keep + '[ _ partition-more ] [ assoc-size ] while-changes ; + +: assoc>set ( assoc -- keys-set ) + [ drop dup ] assoc-map ; + +: state-classes ( transition-table -- synonyms ) + clone [ [ nip has-conditions? ] assoc-partition ] change-transitions + [ assoc>set ] [ (state-classes) partition>classes ] bi* assoc-union ; + +: canonical-state? ( state transitions state-classes -- ? ) + '[ dup _ at = ] swap '[ _ at has-conditions? ] bi or ; + +: delete-duplicates ( transitions state-classes -- new-transitions ) + dupd '[ drop _ _ canonical-state? ] assoc-filter ; + +: combine-states ( table -- smaller-table ) + dup state-classes + [ transitions-at ] keep + '[ _ delete-duplicates ] change-transitions ; + +: combine-state-transitions ( hash -- hash ) + H{ } clone tuck '[ + _ [ 2array <or-class> ] change-at + ] assoc-each [ swap ] assoc-map ; + +: combine-transitions ( table -- table ) + [ [ combine-state-transitions ] assoc-map ] change-transitions ; + +: minimize ( table -- minimal-table ) + clone + number-states + combine-states + combine-transitions + expand-ors ; diff --git a/basis/regexp/negation/negation-tests.factor b/basis/regexp/negation/negation-tests.factor new file mode 100644 index 0000000000..41dfe7f493 --- /dev/null +++ b/basis/regexp/negation/negation-tests.factor @@ -0,0 +1,27 @@ +! Copyright (C) 2009 Daniel Ehrenberg. +! See http://factorcode.org/license.txt for BSD license. +USING: tools.test regexp.negation regexp.transition-tables regexp.classes ; +IN: regexp.negation.tests + +[ + ! R/ |[^a]|.+/ + T{ transition-table + { transitions H{ + { 0 H{ { CHAR: a 1 } { T{ not-class f CHAR: a } -1 } } } + { 1 H{ { t -1 } } } + { -1 H{ { t -1 } } } + } } + { start-state 0 } + { final-states H{ { 0 0 } { -1 -1 } } } + } +] [ + ! R/ a/ + T{ transition-table + { transitions H{ + { 0 H{ { CHAR: a 1 } } } + { 1 H{ } } + } } + { start-state 0 } + { final-states H{ { 1 1 } } } + } negate-table +] unit-test diff --git a/basis/regexp/negation/negation.factor b/basis/regexp/negation/negation.factor new file mode 100644 index 0000000000..8b0a2f6edf --- /dev/null +++ b/basis/regexp/negation/negation.factor @@ -0,0 +1,53 @@ +! Copyright (C) 2009 Daniel Ehrenberg. +! See http://factorcode.org/license.txt for BSD license. +USING: regexp.nfa regexp.disambiguate kernel sequences +assocs regexp.classes hashtables accessors fry vectors +regexp.ast regexp.transition-tables regexp.minimize +regexp.dfa namespaces ; +IN: regexp.negation + +CONSTANT: fail-state -1 + +: add-default-transition ( state's-transitions -- new-state's-transitions ) + clone dup + [ [ fail-state ] dip keys [ <not-class> ] map <and-class> ] keep set-at ; + +: fail-state-recurses ( transitions -- new-transitions ) + clone dup + [ fail-state t associate fail-state ] dip set-at ; + +: add-fail-state ( transitions -- new-transitions ) + [ add-default-transition ] assoc-map + fail-state-recurses ; + +: inverse-final-states ( transition-table -- final-states ) + [ transitions>> assoc>set ] [ final-states>> ] bi assoc-diff ; + +: negate-table ( transition-table -- transition-table ) + clone + [ add-fail-state ] change-transitions + dup inverse-final-states >>final-states ; + +: renumber-states ( transition-table -- transition-table ) + dup transitions>> keys [ next-state ] H{ } map>assoc + transitions-at ; + +: box-transitions ( transition-table -- transition-table ) + [ [ [ 1vector ] assoc-map ] assoc-map ] change-transitions ; + +: unify-final-state ( transition-table -- transition-table ) + dup [ final-states>> keys ] keep + '[ -2 epsilon _ set-transition ] each + H{ { -2 -2 } } >>final-states ; + +: adjoin-dfa ( transition-table -- start end ) + unify-final-state renumber-states box-transitions + [ start-state>> ] + [ final-states>> keys first ] + [ nfa-table get [ transitions>> ] bi@ swap update ] tri ; + +: ast>dfa ( parse-tree -- minimal-dfa ) + construct-nfa disambiguate construct-dfa minimize ; + +M: negation nfa-node ( node -- start end ) + term>> ast>dfa negate-table adjoin-dfa ; diff --git a/basis/regexp/nfa/nfa.factor b/basis/regexp/nfa/nfa.factor index 537c85c2d3..2dc2c1798b 100644 --- a/basis/regexp/nfa/nfa.factor +++ b/basis/regexp/nfa/nfa.factor @@ -1,235 +1,153 @@ -! Copyright (C) 2008 Doug Coleman. +! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays assocs grouping kernel regexp.backend -locals math namespaces regexp.parser sequences fry quotations -math.order math.ranges vectors unicode.categories regexp.utils -regexp.transition-tables words sets regexp.classes unicode.case.private ; +USING: accessors arrays assocs grouping kernel +locals math namespaces sequences fry quotations +math.order math.ranges vectors unicode.categories +regexp.transition-tables words sets hashtables combinators.short-circuit +unicode.case.private regexp.ast regexp.classes ; +IN: regexp.nfa + ! This uses unicode.case.private for ch>upper and ch>lower ! but case-insensitive matching should be done by case-folding everything ! before processing starts -IN: regexp.nfa -ERROR: feature-is-broken feature ; +SYMBOL: option-stack -SYMBOL: negation-mode -: negated? ( -- ? ) negation-mode get 0 or odd? ; +SYMBOL: state -SINGLETON: eps +: next-state ( -- state ) + state [ get ] [ inc ] bi ; -MIXIN: traversal-flag -SINGLETON: lookahead-on INSTANCE: lookahead-on traversal-flag -SINGLETON: lookahead-off INSTANCE: lookahead-off traversal-flag -SINGLETON: lookbehind-on INSTANCE: lookbehind-on traversal-flag -SINGLETON: lookbehind-off INSTANCE: lookbehind-off traversal-flag -SINGLETON: capture-group-on INSTANCE: capture-group-on traversal-flag -SINGLETON: capture-group-off INSTANCE: capture-group-off traversal-flag -SINGLETON: front-anchor INSTANCE: front-anchor traversal-flag -SINGLETON: back-anchor INSTANCE: back-anchor traversal-flag -SINGLETON: word-boundary INSTANCE: word-boundary traversal-flag +SYMBOL: nfa-table -: options ( -- obj ) current-regexp get options>> ; +: set-each ( keys value hashtable -- ) + '[ _ swap _ set-at ] each ; -: option? ( obj -- ? ) options key? ; +: options>hash ( options -- hashtable ) + H{ } clone [ + [ [ on>> t ] dip set-each ] + [ [ off>> f ] dip set-each ] 2bi + ] keep ; -: option-on ( obj -- ) options conjoin ; +: using-options ( options quot -- ) + [ options>hash option-stack [ ?push ] change ] dip + call option-stack get pop* ; inline -: option-off ( obj -- ) options delete-at ; +: option? ( obj -- ? ) + option-stack get assoc-stack ; -: next-state ( regexp -- state ) - [ state>> ] [ [ 1+ ] change-state drop ] bi ; +GENERIC: nfa-node ( node -- start-state end-state ) -: set-start-state ( regexp -- ) - dup stack>> [ - drop - ] [ - [ nfa-table>> ] [ pop first ] bi* >>start-state drop - ] if-empty ; +: add-simple-entry ( obj -- start-state end-state ) + [ next-state next-state 2dup ] dip + nfa-table get add-transition ; -GENERIC: nfa-node ( node -- ) +: epsilon-transition ( source target -- ) + epsilon nfa-table get add-transition ; -:: add-simple-entry ( obj class -- ) - [let* | regexp [ current-regexp get ] - s0 [ regexp next-state ] - s1 [ regexp next-state ] - stack [ regexp stack>> ] - table [ regexp nfa-table>> ] | - negated? [ - s0 f obj class make-transition table add-transition - s0 s1 <default-transition> table add-transition - ] [ - s0 s1 obj class make-transition table add-transition - ] if - s0 s1 2array stack push - t s1 table final-states>> set-at ] ; +M:: star nfa-node ( node -- start end ) + node term>> nfa-node :> s1 :> s0 + next-state :> s2 + next-state :> s3 + s1 s0 epsilon-transition + s2 s0 epsilon-transition + s2 s3 epsilon-transition + s1 s3 epsilon-transition + s2 s3 ; -: add-traversal-flag ( flag -- ) - stack peek second - current-regexp get nfa-traversal-flags>> push-at ; +GENERIC: modify-epsilon ( tag -- newtag ) +! Potential off-by-one errors when lookaround nested in lookbehind -:: concatenate-nodes ( -- ) - [let* | regexp [ current-regexp get ] - stack [ regexp stack>> ] - table [ regexp nfa-table>> ] - s2 [ stack peek first ] - s3 [ stack pop second ] - s0 [ stack peek first ] - s1 [ stack pop second ] | - s1 s2 eps <literal-transition> table add-transition - s1 table final-states>> delete-at - s0 s3 2array stack push ] ; +M: object modify-epsilon ; -:: alternate-nodes ( -- ) - [let* | regexp [ current-regexp get ] - stack [ regexp stack>> ] - table [ regexp nfa-table>> ] - s2 [ stack peek first ] - s3 [ stack pop second ] - s0 [ stack peek first ] - s1 [ stack pop second ] - s4 [ regexp next-state ] - s5 [ regexp next-state ] | - s4 s0 eps <literal-transition> table add-transition - s4 s2 eps <literal-transition> table add-transition - s1 s5 eps <literal-transition> table add-transition - s3 s5 eps <literal-transition> table add-transition - s1 table final-states>> delete-at - s3 table final-states>> delete-at - t s5 table final-states>> set-at - s4 s5 2array stack push ] ; +M: $ modify-epsilon + multiline option? [ drop end-of-input ] unless ; -M: kleene-star nfa-node ( node -- ) - term>> nfa-node - [let* | regexp [ current-regexp get ] - stack [ regexp stack>> ] - s0 [ stack peek first ] - s1 [ stack pop second ] - s2 [ regexp next-state ] - s3 [ regexp next-state ] - table [ regexp nfa-table>> ] | - s1 table final-states>> delete-at - t s3 table final-states>> set-at - s1 s0 eps <literal-transition> table add-transition - s2 s0 eps <literal-transition> table add-transition - s2 s3 eps <literal-transition> table add-transition - s1 s3 eps <literal-transition> table add-transition - s2 s3 2array stack push ] ; +M: ^ modify-epsilon + multiline option? [ drop beginning-of-input ] unless ; -M: concatenation nfa-node ( node -- ) - seq>> - reversed-regexp option? [ <reversed> ] when - [ [ nfa-node ] each ] - [ length 1- [ concatenate-nodes ] times ] bi ; +M: tagged-epsilon nfa-node + clone [ modify-epsilon ] change-tag add-simple-entry ; -M: alternation nfa-node ( node -- ) - seq>> - [ [ nfa-node ] each ] - [ length 1- [ alternate-nodes ] times ] bi ; +M: concatenation nfa-node ( node -- start end ) + [ first>> ] [ second>> ] bi + reversed-regexp option? [ swap ] when + [ nfa-node ] bi@ + [ epsilon-transition ] dip ; -M: constant nfa-node ( node -- ) +:: alternate-nodes ( s0 s1 s2 s3 -- start end ) + next-state :> s4 + next-state :> s5 + s4 s0 epsilon-transition + s4 s2 epsilon-transition + s1 s5 epsilon-transition + s3 s5 epsilon-transition + s4 s5 ; + +M: alternation nfa-node ( node -- start end ) + [ first>> ] [ second>> ] bi + [ nfa-node ] bi@ + alternate-nodes ; + +GENERIC: modify-class ( char-class -- char-class' ) + +M: object modify-class ; + +M: integer modify-class case-insensitive option? [ - dup char>> [ ch>lower ] [ ch>upper ] bi - 2dup = [ - 2drop - char>> literal-transition add-simple-entry - ] [ - [ literal-transition add-simple-entry ] bi@ - alternate-nodes drop - ] if - ] [ - char>> literal-transition add-simple-entry - ] if ; + dup Letter? [ + [ ch>lower ] [ ch>upper ] bi 2array <or-class> + ] when + ] when ; -M: epsilon nfa-node ( node -- ) - drop eps literal-transition add-simple-entry ; +M: integer nfa-node ( node -- start end ) + modify-class add-simple-entry ; -M: word nfa-node ( node -- ) class-transition add-simple-entry ; +M: primitive-class modify-class + class>> modify-class <primitive-class> ; -M: any-char nfa-node ( node -- ) - [ dotall option? ] dip any-char-no-nl ? - class-transition add-simple-entry ; +M: or-class modify-class + seq>> [ modify-class ] map <or-class> ; -! M: beginning-of-text nfa-node ( node -- ) ; +M: not-class modify-class + class>> modify-class <not-class> ; -M: beginning-of-line nfa-node ( node -- ) class-transition add-simple-entry ; +M: any-char modify-class + drop dotall option? t any-char-no-nl ? ; -M: end-of-line nfa-node ( node -- ) class-transition add-simple-entry ; +: modify-letter-class ( class -- newclass ) + case-insensitive option? [ drop Letter-class ] when ; +M: letter-class modify-class modify-letter-class ; +M: LETTER-class modify-class modify-letter-class ; -: choose-letter-class ( node -- node' ) - case-insensitive option? Letter-class rot ? ; +: cased-range? ( range -- ? ) + [ from>> ] [ to>> ] bi { + [ [ letter? ] bi@ and ] + [ [ LETTER? ] bi@ and ] + } 2|| ; -M: letter-class nfa-node ( node -- ) - choose-letter-class class-transition add-simple-entry ; - -M: LETTER-class nfa-node ( node -- ) - choose-letter-class class-transition add-simple-entry ; - -M: character-class-range nfa-node ( node -- ) +M: range modify-class case-insensitive option? [ - ! This should be implemented for Unicode by case-folding - ! the input and all strings in the regexp. - dup [ from>> ] [ to>> ] bi - 2dup [ Letter? ] bi@ and [ - rot drop - [ [ ch>lower ] bi@ character-class-range boa ] - [ [ ch>upper ] bi@ character-class-range boa ] 2bi - [ class-transition add-simple-entry ] bi@ - alternate-nodes - ] [ - 2drop - class-transition add-simple-entry - ] if - ] [ - class-transition add-simple-entry - ] if ; + dup cased-range? [ + [ from>> ] [ to>> ] bi + [ [ ch>lower ] bi@ <range> ] + [ [ ch>upper ] bi@ <range> ] 2bi + 2array <or-class> + ] when + ] when ; -M: capture-group nfa-node ( node -- ) - "capture-groups" feature-is-broken - eps literal-transition add-simple-entry - capture-group-on add-traversal-flag - term>> nfa-node - eps literal-transition add-simple-entry - capture-group-off add-traversal-flag - 2 [ concatenate-nodes ] times ; +M: class nfa-node + modify-class add-simple-entry ; -! xyzzy -M: non-capture-group nfa-node ( node -- ) - term>> nfa-node ; +M: with-options nfa-node ( node -- start end ) + dup options>> [ tree>> nfa-node ] using-options ; -M: reluctant-kleene-star nfa-node ( node -- ) - term>> <kleene-star> nfa-node ; - -M: negation nfa-node ( node -- ) - negation-mode inc - term>> nfa-node - negation-mode dec ; - -M: lookahead nfa-node ( node -- ) - "lookahead" feature-is-broken - eps literal-transition add-simple-entry - lookahead-on add-traversal-flag - term>> nfa-node - eps literal-transition add-simple-entry - lookahead-off add-traversal-flag - 2 [ concatenate-nodes ] times ; - -M: lookbehind nfa-node ( node -- ) - "lookbehind" feature-is-broken - eps literal-transition add-simple-entry - lookbehind-on add-traversal-flag - term>> nfa-node - eps literal-transition add-simple-entry - lookbehind-off add-traversal-flag - 2 [ concatenate-nodes ] times ; - -M: option nfa-node ( node -- ) - [ option>> ] [ on?>> ] bi [ option-on ] [ option-off ] if - eps literal-transition add-simple-entry ; - -: construct-nfa ( regexp -- ) +: construct-nfa ( ast -- nfa-table ) [ - reset-regexp - negation-mode off - [ current-regexp set ] - [ parse-tree>> nfa-node ] - [ set-start-state ] tri + 0 state set + <transition-table> nfa-table set + nfa-node + nfa-table get + swap dup associate >>final-states + swap >>start-state ] with-scope ; diff --git a/basis/regexp/parser/parser-tests.factor b/basis/regexp/parser/parser-tests.factor index fe4d2f1d1a..d606015f61 100644 --- a/basis/regexp/parser/parser-tests.factor +++ b/basis/regexp/parser/parser-tests.factor @@ -1,34 +1,24 @@ -USING: kernel tools.test regexp.backend regexp ; -IN: regexp.parser +USING: kernel tools.test regexp.parser fry sequences ; +IN: regexp.parser.tests -: test-regexp ( string -- ) - default-regexp parse-regexp ; +: regexp-parses ( string -- ) + [ [ ] ] dip '[ _ parse-regexp drop ] unit-test ; -! [ "(" ] [ unmatched-parentheses? ] must-fail-with +: regexp-fails ( string -- ) + '[ _ parse-regexp ] must-fail ; -[ ] [ "a|b" test-regexp ] unit-test -[ ] [ "a.b" test-regexp ] unit-test -[ ] [ "a|b|c" test-regexp ] unit-test -[ ] [ "abc|b" test-regexp ] unit-test -[ ] [ "a|bcd" test-regexp ] unit-test -[ ] [ "a|(b)" test-regexp ] unit-test -[ ] [ "(a)|b" test-regexp ] unit-test -[ ] [ "(a|b)" test-regexp ] unit-test -[ ] [ "((a)|(b))" test-regexp ] unit-test +{ + "a|b" "a.b" "a|b|c" "abc|b" "a|bcd" "a|(b)" "(?-i:a)" "||" + "(a)|b" "(a|b)" "((a)|(b))" "(?:a)" "(?i:a)" "|b" "b|" + "[abc]" "[a-c]" "[^a-c]" "[^]]" "[]a]" "[[]" "[]-a]" "[a-]" "[-]" + "[--a]" "foo*" "(foo)*" "(a|b)|c" "(foo){2,3}" "(foo){2,}" + "(foo){2}" "{2,3}" "{," "{,}" "}" "foo}" "[^]-a]" "[^-]a]" + "[a-]" "[^a-]" "[^a-]" "a{,2}" "(?#foobar)" + "\\p{Space}" "\\t" "\\[" "[\\]]" "\\P{Space}" + "\\ueeee" "\\0333" "\\xff" "\\\\" "\\w" +} [ regexp-parses ] each -[ ] [ "(?:a)" test-regexp ] unit-test -[ ] [ "(?i:a)" test-regexp ] unit-test -[ ] [ "(?-i:a)" test-regexp ] unit-test -[ "(?z:a)" test-regexp ] [ unknown-regexp-option? ] must-fail-with -[ "(?-z:a)" test-regexp ] [ unknown-regexp-option? ] must-fail-with - -[ ] [ "(?=a)" test-regexp ] unit-test - -[ ] [ "[abc]" test-regexp ] unit-test -[ ] [ "[a-c]" test-regexp ] unit-test -[ ] [ "[^a-c]" test-regexp ] unit-test -[ "[^]" test-regexp ] must-fail - -[ ] [ "|b" test-regexp ] unit-test -[ ] [ "b|" test-regexp ] unit-test -[ ] [ "||" test-regexp ] unit-test +{ + "[^]" "[]" "a{foo}" "a{,}" "a{}" "(?)" "\\p{foo}" "\\P{foo}" + "\\ueeeg" "\\0339" "\\xfg" +} [ regexp-fails ] each diff --git a/basis/regexp/parser/parser.factor b/basis/regexp/parser/parser.factor index 377535eccd..c6a69f2508 100644 --- a/basis/regexp/parser/parser.factor +++ b/basis/regexp/parser/parser.factor @@ -1,437 +1,179 @@ -! Copyright (C) 2008 Doug Coleman. +! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays assocs combinators io io.streams.string -kernel math math.parser namespaces sets -quotations sequences splitting vectors math.order -strings regexp.backend regexp.utils -unicode.case unicode.categories words locals regexp.classes ; +USING: peg.ebnf kernel math.parser sequences assocs arrays fry math +combinators regexp.classes strings splitting peg locals accessors +regexp.ast ; IN: regexp.parser -FROM: math.ranges => [a,b] ; +: allowed-char? ( ch -- ? ) + ".()|[*+?$^" member? not ; -TUPLE: concatenation seq ; INSTANCE: concatenation node -TUPLE: alternation seq ; INSTANCE: alternation node -TUPLE: kleene-star term ; INSTANCE: kleene-star node +ERROR: bad-number ; -! !!!!!!!! -TUPLE: possessive-question term ; INSTANCE: possessive-question node -TUPLE: possessive-kleene-star term ; INSTANCE: possessive-kleene-star node +: ensure-number ( n -- n ) + [ bad-number ] unless* ; -! !!!!!!!! -TUPLE: reluctant-question term ; INSTANCE: reluctant-question node -TUPLE: reluctant-kleene-star term ; INSTANCE: reluctant-kleene-star node +:: at-error ( key assoc quot: ( key -- replacement ) -- value ) + key assoc at* [ drop key quot call ] unless ; inline -TUPLE: negation term ; INSTANCE: negation node -TUPLE: constant char ; INSTANCE: constant node -TUPLE: range from to ; INSTANCE: range node +ERROR: bad-class name ; -MIXIN: parentheses-group -TUPLE: lookahead term ; INSTANCE: lookahead node -INSTANCE: lookahead parentheses-group -TUPLE: lookbehind term ; INSTANCE: lookbehind node -INSTANCE: lookbehind parentheses-group -TUPLE: capture-group term ; INSTANCE: capture-group node -INSTANCE: capture-group parentheses-group -TUPLE: non-capture-group term ; INSTANCE: non-capture-group node -INSTANCE: non-capture-group parentheses-group -TUPLE: independent-group term ; INSTANCE: independent-group node ! atomic group -INSTANCE: independent-group parentheses-group -TUPLE: comment-group term ; INSTANCE: comment-group node -INSTANCE: comment-group parentheses-group +: name>class ( name -- class ) + { + { "Lower" letter-class } + { "Upper" LETTER-class } + { "Alpha" Letter-class } + { "ASCII" ascii-class } + { "Digit" digit-class } + { "Alnum" alpha-class } + { "Punct" punctuation-class } + { "Graph" java-printable-class } + { "Print" java-printable-class } + { "Blank" non-newline-blank-class } + { "Cntrl" control-character-class } + { "XDigit" hex-digit-class } + { "Space" java-blank-class } + ! TODO: unicode-character-class + } [ bad-class ] at-error ; -SINGLETON: epsilon INSTANCE: epsilon node +: lookup-escape ( char -- ast ) + { + { CHAR: t [ CHAR: \t ] } + { CHAR: n [ CHAR: \n ] } + { CHAR: r [ CHAR: \r ] } + { CHAR: f [ HEX: c ] } + { CHAR: a [ HEX: 7 ] } + { CHAR: e [ HEX: 1b ] } + { CHAR: \\ [ CHAR: \\ ] } -TUPLE: option option on? ; INSTANCE: option node + { CHAR: w [ c-identifier-class <primitive-class> ] } + { CHAR: W [ c-identifier-class <primitive-class> <not-class> ] } + { CHAR: s [ java-blank-class <primitive-class> ] } + { CHAR: S [ java-blank-class <primitive-class> <not-class> ] } + { CHAR: d [ digit-class <primitive-class> ] } + { CHAR: D [ digit-class <primitive-class> <not-class> ] } -SINGLETONS: unix-lines dotall multiline comments case-insensitive -unicode-case reversed-regexp ; + { CHAR: z [ end-of-input <tagged-epsilon> ] } + { CHAR: Z [ end-of-file <tagged-epsilon> ] } + { CHAR: A [ beginning-of-input <tagged-epsilon> ] } + { CHAR: b [ word-break <tagged-epsilon> ] } + { CHAR: B [ word-break <not-class> <tagged-epsilon> ] } + [ ] + } case ; -SINGLETONS: beginning-of-character-class end-of-character-class -left-parenthesis pipe caret dash ; - -: push1 ( obj -- ) input-stream get stream>> push ; -: peek1 ( -- obj ) input-stream get stream>> [ f ] [ peek ] if-empty ; -: pop3 ( seq -- obj1 obj2 obj3 ) [ pop ] [ pop ] [ pop ] tri spin ; -: drop1 ( -- ) read1 drop ; - -: stack ( -- obj ) current-regexp get stack>> ; -: change-whole-stack ( quot -- ) - current-regexp get - [ stack>> swap call ] keep (>>stack) ; inline -: push-stack ( obj -- ) stack push ; -: pop-stack ( -- obj ) stack pop ; -: cut-out ( vector n -- vector' vector ) cut rest ; -ERROR: cut-stack-error ; -: cut-stack ( obj vector -- vector' vector ) - [ nip ] [ last-index ] 2bi [ cut-stack-error ] unless* cut-out swap ; - -: <possessive-kleene-star> ( obj -- kleene ) possessive-kleene-star boa ; -: <reluctant-kleene-star> ( obj -- kleene ) reluctant-kleene-star boa ; -: <possessive-question> ( obj -- kleene ) possessive-question boa ; -: <reluctant-question> ( obj -- kleene ) reluctant-question boa ; - -: <negation> ( obj -- negation ) negation boa ; -: <concatenation> ( seq -- concatenation ) - >vector [ epsilon ] [ concatenation boa ] if-empty ; -: <alternation> ( seq -- alternation ) >vector alternation boa ; -: <capture-group> ( obj -- capture-group ) capture-group boa ; -: <kleene-star> ( obj -- kleene-star ) kleene-star boa ; -: <constant> ( obj -- constant ) constant boa ; - -: first|concatenation ( seq -- first/concatenation ) - dup length 1 = [ first ] [ <concatenation> ] if ; - -: first|alternation ( seq -- first/alternation ) - dup length 1 = [ first ] [ <alternation> ] if ; - -: <character-class-range> ( from to -- obj ) - 2dup < - [ character-class-range boa ] [ 2drop unmatchable-class ] if ; - -ERROR: unmatched-parentheses ; - -ERROR: unknown-regexp-option option ; +: options-assoc ( -- assoc ) + H{ + { CHAR: i case-insensitive } + { CHAR: d unix-lines } + { CHAR: m multiline } + { CHAR: n multiline } + { CHAR: r reversed-regexp } + { CHAR: s dotall } + { CHAR: u unicode-case } + { CHAR: x comments } + } ; : ch>option ( ch -- singleton ) - { - { CHAR: i [ case-insensitive ] } - { CHAR: d [ unix-lines ] } - { CHAR: m [ multiline ] } - { CHAR: n [ multiline ] } - { CHAR: r [ reversed-regexp ] } - { CHAR: s [ dotall ] } - { CHAR: u [ unicode-case ] } - { CHAR: x [ comments ] } - [ unknown-regexp-option ] - } case ; + options-assoc at ; : option>ch ( option -- string ) - { - { case-insensitive [ CHAR: i ] } - { multiline [ CHAR: m ] } - { reversed-regexp [ CHAR: r ] } - { dotall [ CHAR: s ] } - [ unknown-regexp-option ] - } case ; + options-assoc value-at ; -: toggle-option ( ch ? -- ) - [ ch>option ] dip option boa push-stack ; +: parse-options ( on off -- options ) + [ [ ch>option ] { } map-as ] bi@ <options> ; -: (parse-options) ( string ? -- ) [ toggle-option ] curry each ; +: string>options ( string -- options ) + "-" split1 parse-options ; + +: options>string ( options -- string ) + [ on>> ] [ off>> ] bi + [ [ option>ch ] map ] bi@ + [ "-" glue ] unless-empty + "" like ; -: parse-options ( string -- ) - "-" split1 [ t (parse-options) ] [ f (parse-options) ] bi* ; +! TODO: add syntax for various parenthized things, +! add greedy and nongreedy forms of matching +! (once it's all implemented) -ERROR: bad-special-group string ; +EBNF: parse-regexp -DEFER: (parse-regexp) -: nested-parse-regexp ( token ? -- ) - [ push-stack (parse-regexp) pop-stack ] dip - [ <negation> ] when pop-stack new swap >>term push-stack ; +CharacterInBracket = !("}") Character -! non-capturing groups -: (parse-special-group) ( -- ) - read1 { - { [ dup CHAR: # = ] ! comment - [ drop comment-group f nested-parse-regexp pop-stack drop ] } - { [ dup CHAR: : = ] - [ drop non-capture-group f nested-parse-regexp ] } - { [ dup CHAR: = = ] - [ drop lookahead f nested-parse-regexp ] } - { [ dup CHAR: ! = ] - [ drop lookahead t nested-parse-regexp ] } - { [ dup CHAR: > = ] - [ drop non-capture-group f nested-parse-regexp ] } - { [ dup CHAR: < = peek1 CHAR: = = and ] - [ drop drop1 lookbehind f nested-parse-regexp ] } - { [ dup CHAR: < = peek1 CHAR: ! = and ] - [ drop drop1 lookbehind t nested-parse-regexp ] } - [ - ":)" read-until - [ swap prefix ] dip - { - { CHAR: : [ parse-options non-capture-group f nested-parse-regexp ] } - { CHAR: ) [ parse-options ] } - [ drop bad-special-group ] - } case - ] - } cond ; +QuotedCharacter = !("\\E") . -: handle-left-parenthesis ( -- ) - peek1 CHAR: ? = - [ drop1 (parse-special-group) ] - [ capture-group f nested-parse-regexp ] if ; +Escape = "p{" CharacterInBracket*:s "}" => [[ s >string name>class <primitive-class> ]] + | "P{" CharacterInBracket*:s "}" => [[ s >string name>class <primitive-class> <negation> ]] + | "Q" QuotedCharacter*:s "\\E" => [[ s <concatenation> ]] + | "u" Character:a Character:b Character:c Character:d + => [[ { a b c d } hex> ensure-number ]] + | "x" Character:a Character:b + => [[ { a b } hex> ensure-number ]] + | "0" Character:a Character:b Character:c + => [[ { a b c } oct> ensure-number ]] + | . => [[ lookup-escape ]] -: handle-dot ( -- ) any-char push-stack ; -: handle-pipe ( -- ) pipe push-stack ; -: (handle-star) ( obj -- kleene-star ) - peek1 { - { CHAR: + [ drop1 <possessive-kleene-star> ] } - { CHAR: ? [ drop1 <reluctant-kleene-star> ] } - [ drop <kleene-star> ] - } case ; -: handle-star ( -- ) stack pop (handle-star) push-stack ; -: handle-question ( -- ) - stack pop peek1 { - { CHAR: + [ drop1 <possessive-question> ] } - { CHAR: ? [ drop1 <reluctant-question> ] } - [ drop epsilon 2array <alternation> ] - } case push-stack ; -: handle-plus ( -- ) - stack pop dup (handle-star) - 2array <concatenation> push-stack ; +EscapeSequence = "\\" Escape:e => [[ e ]] -ERROR: unmatched-brace ; -: parse-repetition ( -- start finish ? ) - "}" read-until [ unmatched-brace ] unless - [ "," split1 [ string>number ] bi@ ] - [ CHAR: , swap index >boolean ] bi ; +Character = EscapeSequence + | "$" => [[ $ <tagged-epsilon> ]] + | "^" => [[ ^ <tagged-epsilon> ]] + | . ?[ allowed-char? ]? -: replicate/concatenate ( n obj -- obj' ) - over zero? [ 2drop epsilon ] - [ <repetition> first|concatenation ] if ; +AnyRangeCharacter = EscapeSequence | . -: exactly-n ( n -- ) - stack pop replicate/concatenate push-stack ; +RangeCharacter = !("]") AnyRangeCharacter -: at-least-n ( n -- ) - stack pop - [ replicate/concatenate ] keep - <kleene-star> 2array <concatenation> push-stack ; +Range = RangeCharacter:a "-" RangeCharacter:b => [[ a b <range> ]] + | RangeCharacter -: at-most-n ( n -- ) - 1+ - stack pop - [ replicate/concatenate ] curry map <alternation> push-stack ; +StartRange = AnyRangeCharacter:a "-" RangeCharacter:b => [[ a b <range> ]] + | AnyRangeCharacter -: from-m-to-n ( m n -- ) - [a,b] - stack pop - [ replicate/concatenate ] curry map - <alternation> push-stack ; +Ranges = StartRange:s Range*:r => [[ r s prefix ]] -ERROR: invalid-range a b ; +CharClass = "^"?:n Ranges:e => [[ e n char-class ]] -: handle-left-brace ( -- ) - parse-repetition - [ 2dup [ [ 0 < [ invalid-range ] when ] when* ] bi@ ] dip - [ - 2dup and [ from-m-to-n ] - [ [ nip at-most-n ] [ at-least-n ] if* ] if - ] [ drop 0 max exactly-n ] if ; +Options = [idmsux]* -: handle-front-anchor ( -- ) beginning-of-line push-stack ; -: handle-back-anchor ( -- ) end-of-line push-stack ; +Parenthized = "?:" Alternation:a => [[ a ]] + | "?" Options:on "-"? Options:off ":" Alternation:a + => [[ a on off parse-options <with-options> ]] + | "?#" [^)]* => [[ f ]] + | "?~" Alternation:a => [[ a <negation> ]] + | "?=" Alternation:a => [[ a <lookahead> <tagged-epsilon> ]] + | "?!" Alternation:a => [[ a <lookahead> <not-class> <tagged-epsilon> ]] + | "?<=" Alternation:a => [[ a <lookbehind> <tagged-epsilon> ]] + | "?<!" Alternation:a => [[ a <lookbehind> <not-class> <tagged-epsilon> ]] + | Alternation -ERROR: bad-character-class obj ; -ERROR: expected-posix-class ; +Element = "(" Parenthized:p ")" => [[ p ]] + | "[" CharClass:r "]" => [[ r ]] + | ".":d => [[ any-char <primitive-class> ]] + | Character -: parse-posix-class ( -- obj ) - read1 CHAR: { = [ expected-posix-class ] unless - "}" read-until [ bad-character-class ] unless - { - { "Lower" [ letter-class ] } - { "Upper" [ LETTER-class ] } - { "Alpha" [ Letter-class ] } - { "ASCII" [ ascii-class ] } - { "Digit" [ digit-class ] } - { "Alnum" [ alpha-class ] } - { "Punct" [ punctuation-class ] } - { "Graph" [ java-printable-class ] } - { "Print" [ java-printable-class ] } - { "Blank" [ non-newline-blank-class ] } - { "Cntrl" [ control-character-class ] } - { "XDigit" [ hex-digit-class ] } - { "Space" [ java-blank-class ] } - ! TODO: unicode-character-class, fallthrough in unicode is bad-char-clss - [ bad-character-class ] - } case ; +Number = (!(","|"}").)* => [[ string>number ensure-number ]] -: parse-octal ( -- n ) 3 read oct> check-octal ; -: parse-short-hex ( -- n ) 2 read hex> check-hex ; -: parse-long-hex ( -- n ) 6 read hex> check-hex ; -: parse-control-character ( -- n ) read1 ; +Times = "," Number:n "}" => [[ 0 n <from-to> ]] + | Number:n ",}" => [[ n <at-least> ]] + | Number:n "}" => [[ n n <from-to> ]] + | "}" => [[ bad-number ]] + | Number:n "," Number:m "}" => [[ n m <from-to> ]] -ERROR: bad-escaped-literals seq ; +Repeated = Element:e "{" Times:t => [[ e t <times> ]] + | Element:e "??" => [[ e <maybe> ]] + | Element:e "*?" => [[ e <star> ]] + | Element:e "+?" => [[ e <plus> ]] + | Element:e "?" => [[ e <maybe> ]] + | Element:e "*" => [[ e <star> ]] + | Element:e "+" => [[ e <plus> ]] + | Element -: parse-til-E ( -- obj ) - "\\E" read-until [ bad-escaped-literals ] unless ; - -:: (parse-escaped-literals) ( quot: ( obj -- obj' ) -- obj ) - parse-til-E - drop1 - [ epsilon ] [ - quot call [ <constant> ] V{ } map-as - first|concatenation - ] if-empty ; inline +Concatenation = Repeated*:r => [[ r sift <concatenation> ]] -: parse-escaped-literals ( -- obj ) - [ ] (parse-escaped-literals) ; +Alternation = Concatenation:c ("|" Concatenation)*:a + => [[ a empty? [ c ] [ a values c prefix <alternation> ] if ]] -: lower-case-literals ( -- obj ) - [ >lower ] (parse-escaped-literals) ; +End = !(.) -: upper-case-literals ( -- obj ) - [ >upper ] (parse-escaped-literals) ; - -: parse-escaped ( -- obj ) - read1 - { - { CHAR: t [ CHAR: \t <constant> ] } - { CHAR: n [ CHAR: \n <constant> ] } - { CHAR: r [ CHAR: \r <constant> ] } - { CHAR: f [ HEX: c <constant> ] } - { CHAR: a [ HEX: 7 <constant> ] } - { CHAR: e [ HEX: 1b <constant> ] } - - { CHAR: w [ c-identifier-class ] } - { CHAR: W [ c-identifier-class <negation> ] } - { CHAR: s [ java-blank-class ] } - { CHAR: S [ java-blank-class <negation> ] } - { CHAR: d [ digit-class ] } - { CHAR: D [ digit-class <negation> ] } - - { CHAR: p [ parse-posix-class ] } - { CHAR: P [ parse-posix-class <negation> ] } - { CHAR: x [ parse-short-hex <constant> ] } - { CHAR: u [ parse-long-hex <constant> ] } - { CHAR: 0 [ parse-octal <constant> ] } - { CHAR: c [ parse-control-character ] } - - { CHAR: Q [ parse-escaped-literals ] } - - ! { CHAR: b [ word-boundary-class ] } - ! { CHAR: B [ word-boundary-class <negation> ] } - ! { CHAR: A [ handle-beginning-of-input ] } - ! { CHAR: z [ handle-end-of-input ] } - - ! { CHAR: Z [ handle-end-of-input ] } ! plus a final terminator - - ! m//g mode - ! { CHAR: G [ end of previous match ] } - - ! Group capture - ! { CHAR: 1 [ CHAR: 1 <constant> ] } - ! { CHAR: 2 [ CHAR: 2 <constant> ] } - ! { CHAR: 3 [ CHAR: 3 <constant> ] } - ! { CHAR: 4 [ CHAR: 4 <constant> ] } - ! { CHAR: 5 [ CHAR: 5 <constant> ] } - ! { CHAR: 6 [ CHAR: 6 <constant> ] } - ! { CHAR: 7 [ CHAR: 7 <constant> ] } - ! { CHAR: 8 [ CHAR: 8 <constant> ] } - ! { CHAR: 9 [ CHAR: 9 <constant> ] } - - ! Perl extensions - ! can't do \l and \u because \u is already a 4-hex - { CHAR: L [ lower-case-literals ] } - { CHAR: U [ upper-case-literals ] } - - [ <constant> ] - } case ; - -: handle-escape ( -- ) parse-escaped push-stack ; - -: handle-dash ( vector -- vector' ) - H{ { dash CHAR: - } } substitute ; - -: character-class>alternation ( seq -- alternation ) - [ dup number? [ <constant> ] when ] map first|alternation ; - -: handle-caret ( vector -- vector' ) - dup [ length 2 >= ] [ first caret eq? ] bi and [ - rest-slice character-class>alternation <negation> - ] [ - character-class>alternation - ] if ; - -: make-character-class ( -- character-class ) - [ beginning-of-character-class swap cut-stack ] change-whole-stack - handle-dash handle-caret ; - -: apply-dash ( -- ) - stack [ pop3 nip <character-class-range> ] keep push ; - -: apply-dash? ( -- ? ) - stack dup length 3 >= - [ [ length 2 - ] keep nth dash eq? ] [ drop f ] if ; - -ERROR: empty-negated-character-class ; -DEFER: handle-left-bracket -: (parse-character-class) ( -- ) - read1 [ empty-negated-character-class ] unless* { - { CHAR: [ [ handle-left-bracket t ] } - { CHAR: ] [ make-character-class push-stack f ] } - { CHAR: - [ dash push-stack t ] } - { CHAR: \ [ parse-escaped push-stack t ] } - [ push-stack apply-dash? [ apply-dash ] when t ] - } case - [ (parse-character-class) ] when ; - -: push-constant ( ch -- ) <constant> push-stack ; - -: parse-character-class-second ( -- ) - read1 { - { CHAR: [ [ CHAR: [ push-constant ] } - { CHAR: ] [ CHAR: ] push-constant ] } - { CHAR: - [ CHAR: - push-constant ] } - [ push1 ] - } case ; - -: parse-character-class-first ( -- ) - read1 { - { CHAR: ^ [ caret push-stack parse-character-class-second ] } - { CHAR: [ [ CHAR: [ push-constant ] } - { CHAR: ] [ CHAR: ] push-constant ] } - { CHAR: - [ CHAR: - push-constant ] } - [ push1 ] - } case ; - -: handle-left-bracket ( -- ) - beginning-of-character-class push-stack - parse-character-class-first (parse-character-class) ; - -: finish-regexp-parse ( stack -- obj ) - { pipe } split - [ first|concatenation ] map first|alternation ; - -: handle-right-parenthesis ( -- ) - stack dup [ parentheses-group "members" word-prop member? ] find-last - -rot cut rest - [ [ push ] keep current-regexp get (>>stack) ] - [ finish-regexp-parse push-stack ] bi* ; - -: parse-regexp-token ( token -- ? ) - { - { CHAR: ( [ handle-left-parenthesis t ] } ! handle (?..) at beginning? - { CHAR: ) [ handle-right-parenthesis f ] } - { CHAR: . [ handle-dot t ] } - { CHAR: | [ handle-pipe t ] } - { CHAR: ? [ handle-question t ] } - { CHAR: * [ handle-star t ] } - { CHAR: + [ handle-plus t ] } - { CHAR: { [ handle-left-brace t ] } - { CHAR: [ [ handle-left-bracket t ] } - { CHAR: \ [ handle-escape t ] } - [ - dup CHAR: $ = peek1 f = and - [ drop handle-back-anchor f ] - [ push-constant t ] if - ] - } case ; - -: (parse-regexp) ( -- ) - read1 [ parse-regexp-token [ (parse-regexp) ] when ] when* ; - -: parse-regexp-beginning ( -- ) - peek1 CHAR: ^ = [ drop1 handle-front-anchor ] when ; - -: parse-regexp ( regexp -- ) - dup current-regexp [ - raw>> [ - <string-reader> [ - parse-regexp-beginning (parse-regexp) - ] with-input-stream - ] unless-empty - current-regexp get [ finish-regexp-parse ] change-stack - dup stack>> >>parse-tree drop - ] with-variable ; +Main = Alternation End +;EBNF diff --git a/basis/regexp/regexp-docs.factor b/basis/regexp/regexp-docs.factor index 378ae503ce..adbeb341bb 100644 --- a/basis/regexp/regexp-docs.factor +++ b/basis/regexp/regexp-docs.factor @@ -1,8 +1,92 @@ -! Copyright (C) 2008 Doug Coleman. +! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel strings help.markup help.syntax regexp.backend ; +USING: kernel strings help.markup help.syntax math ; IN: regexp +ABOUT: "regexp" + +ARTICLE: "regexp" "Regular expressions" +"The " { $vocab-link "regexp" } " vocabulary provides word for creating and using regular expressions." +{ $subsection { "regexp" "syntax" } } +{ $subsection { "regexp" "construction" } } +{ $vocab-subsection "regexp.combinators" "Regular expression combinators" } +{ $subsection { "regexp" "operations" } } +{ $subsection regexp } +{ $subsection { "regexp" "theory" } } ; + +ARTICLE: { "regexp" "construction" } "Constructing regular expressions" +"Words which are useful for creating regular expressions:" +{ $subsection POSTPONE: R/ } +{ $subsection <regexp> } +{ $subsection <optioned-regexp> } +{ $heading "See also" } +{ $vocab-link "regexp.combinators" } ; + +ARTICLE: { "regexp" "syntax" } "Regular expression syntax" +"Regexp syntax is largely compatible with Perl, Java and extended POSIX regexps, but not completely." $nl +"A new addition is the inclusion of a negation operator, with the syntax " { $snippet "(?~foo)" } " to match everything that does not match " { $snippet "foo" } "." $nl +"One missing feature is backreferences. This is because of a design decision to allow only regular expressions following the formal theory of regular languages. For more information, see " { $link { "regexp" "theory" } } ". You can create a new regular expression to match a particular string using " { $vocab-link "regexp.combinators" } " and group capture is available to extract parts of a regular expression match." $nl +"A distinction from Perl is that " { $snippet "\\G" } ", which references the previous match, is not included. This is because that sequence is inherently stateful, and Factor regexps don't hold state." $nl +"Additionally, none of the operations which embed code into a regexp are supported, as this would require the inclusion of the Factor parser and compiler in any application which wants to expose regexps to the user. None of the casing operations are included, for simplicity." ; ! Also describe syntax, from the beginning + +ARTICLE: { "regexp" "theory" } "The theory of regular expressions" +"Far from being just a practical tool invented by Unix hackers, regular expressions were studied formally before computer programs were written to process them." $nl +"A regular language is a set of strings that is matched by a regular expression, which is defined to have characters and the empty string, along with the operations concatenation, disjunction and Kleene star. Another way to define the class of regular languages is as the class of languages which can be recognized with constant space overhead, ie with a DFA. These two definitions are provably equivalent." $nl +"One basic result in the theory of regular language is that the complement of a regular language is regular. In other words, for any regular expression, there exists another regular expression which matches exactly the strings that the first one doesn't match." $nl +"This implies, by DeMorgan's law, that, if you have two regular languages, their intersection is also regular. That is, for any two regular expressions, there exists a regular expression which matches strings that match both inputs." $nl +"Traditionally, regular expressions on computer support an additional operation: backreferences. For example, the Perl regexp " { $snippet "/(.*)$1/" } " matches a string repated twice. If a backreference refers to a string with a predetermined maximum length, then the resulting language is still regular." $nl +"But, if not, the language is not regular. There is strong evidence that there is no efficient way to parse with backreferences in the general case. Perl uses a naive backtracking algorithm which has pathological behavior in some cases, taking exponential time to match even if backreferences aren't used. Additionally, expressions with backreferences don't have the properties with negation and intersection described above." $nl +"The Factor regular expression engine was built with the design decision to support negation and intersection at the expense of backreferences. This lets us have a guaranteed linear-time matching algorithm. Systems like Ragel and Lex also use this algorithm, but in the Factor regular expression engine, all other features of regexps are still present." ; + +ARTICLE: { "regexp" "operations" } "Matching operations with regular expressions" +{ $subsection matches? } +{ $subsection re-contains? } +{ $subsection first-match } +{ $subsection all-matching-slices } +{ $subsection all-matching-subseqs } +{ $subsection re-split } +{ $subsection re-replace } +{ $subsection count-matches } ; + HELP: <regexp> { $values { "string" string } { "regexp" regexp } } -{ $description "Compiles a regular expression into a DFA and returns this object. Regular expressions only have to be compiled once and can then be used multiple times to match input strings." } ; +{ $description "Creates a regular expression object, given a string in regular expression syntax. When it is first used for matching, a DFA is compiled, and this DFA is stored for reuse so it is only compiled once." } ; + +HELP: <optioned-regexp> +{ $values { "string" string } { "options" string } { "regexp" regexp } } +{ $description "Given a string in regular expression syntax, and a string of options, creates a regular expression object. When it is first used for matching, a DFA is compiled, and this DFA is stored for reuse so it is only compiled once." } ; + +HELP: R/ +{ $syntax "R/ foo.*|[a-zA-Z]bar/i" } +{ $description "Literal syntax for a regular expression. When this syntax is used, the DFA is compiled at compile-time, rather than on first use." } ; + +HELP: regexp +{ $class-description "The class of regular expressions. To construct these, see " { $link { "regexp" "construction" } } "." } ; + +HELP: matches? +{ $values { "string" string } { "regexp" regexp } { "?" "a boolean" } } +{ $description "Tests if the string as a whole matches the given regular expression." } ; + +HELP: all-matching-slices +{ $values { "string" string } { "regexp" regexp } { "seq" "a sequence of slices of the input" } } +{ $description "Finds a sequence of disjoint substrings which each match the pattern. It chooses this by finding the leftmost longest match, and then the leftmost longest match which starts after the end of the previous match, and so on." } ; + +HELP: count-matches +{ $values { "string" string } { "regexp" regexp } { "n" integer } } +{ $description "Counts how many disjoint matches the regexp has in the string, as made unambiguous by " { $link all-matching-slices } "." } ; + +HELP: re-split +{ $values { "string" string } { "regexp" regexp } { "seq" "a sequence of slices of the input" } } +{ $description "Splits the input string into chunks separated by the regular expression. Each chunk contains no match of the regexp. The chunks are chosen by the strategy of " { $link all-matching-slices } "." } ; + +HELP: re-replace +{ $values { "string" string } { "regexp" regexp } { "replacement" string } { "result" string } } +{ $description "Replaces substrings which match the input regexp with the given replacement text. The boundaries of the substring are chosen by the strategy used by " { $link all-matching-slices } "." } ; + +HELP: first-match +{ $values { "string" string } { "regexp" regexp } { "slice/f" "the match, if one exists" } } +{ $description "Finds the first match of the regular expression in the string, and returns it as a slice. If there is no match, then " { $link f } " is returned." } ; + +HELP: re-contains? +{ $values { "string" string } { "regexp" regexp } { "?" "a boolean" } } +{ $description "Determines whether the string has a substring which matches the regular expression given." } ; diff --git a/basis/regexp/regexp-tests.factor b/basis/regexp/regexp-tests.factor index 1cd9a2392e..a449b3e2f0 100644 --- a/basis/regexp/regexp-tests.factor +++ b/basis/regexp/regexp-tests.factor @@ -1,8 +1,11 @@ -USING: regexp tools.test kernel sequences regexp.parser -regexp.traversal eval strings multiline ; +! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: regexp tools.test kernel sequences regexp.parser regexp.private +eval strings multiline accessors ; IN: regexp-tests \ <regexp> must-infer +\ compile-regexp must-infer \ matches? must-infer [ f ] [ "b" "a*" <regexp> matches? ] unit-test @@ -21,8 +24,8 @@ IN: regexp-tests [ t ] [ "b" "b|" <regexp> matches? ] unit-test [ t ] [ "" "b|" <regexp> matches? ] unit-test [ t ] [ "" "b|" <regexp> matches? ] unit-test -[ f ] [ "" "|" <regexp> matches? ] unit-test -[ f ] [ "" "|||||||" <regexp> matches? ] unit-test +[ t ] [ "" "|" <regexp> matches? ] unit-test +[ t ] [ "" "|||||||" <regexp> matches? ] unit-test [ f ] [ "aa" "a|b|c" <regexp> matches? ] unit-test [ f ] [ "bb" "a|b|c" <regexp> matches? ] unit-test @@ -44,9 +47,9 @@ IN: regexp-tests ! Dotall mode -- when on, . matches newlines. ! Off by default. [ f ] [ "\n" "." <regexp> matches? ] unit-test -[ t ] [ "\n" "(?s)." <regexp> matches? ] unit-test +[ t ] [ "\n" "(?s:.)" <regexp> matches? ] unit-test [ t ] [ "\n" R/ ./s matches? ] unit-test -[ f ] [ "\n\n" "(?s).(?-s)." <regexp> matches? ] unit-test +[ f ] [ "\n\n" "(?s:.)." <regexp> matches? ] unit-test [ f ] [ "" ".+" <regexp> matches? ] unit-test [ t ] [ "a" ".+" <regexp> matches? ] unit-test @@ -76,8 +79,6 @@ IN: regexp-tests [ t ] [ "bar" "foo|bar" <regexp> matches? ] unit-test [ f ] [ "foobar" "foo|bar" <regexp> matches? ] unit-test -/* -! FIXME [ f ] [ "" "(a)" <regexp> matches? ] unit-test [ t ] [ "a" "(a)" <regexp> matches? ] unit-test [ f ] [ "aa" "(a)" <regexp> matches? ] unit-test @@ -85,7 +86,6 @@ IN: regexp-tests [ f ] [ "aababaaabbac" "(a|b)+" <regexp> matches? ] unit-test [ t ] [ "ababaaabba" "(a|b)+" <regexp> matches? ] unit-test -*/ [ f ] [ "" "a{1}" <regexp> matches? ] unit-test [ t ] [ "a" "a{1}" <regexp> matches? ] unit-test @@ -168,12 +168,9 @@ IN: regexp-tests [ f ] [ "0" "[^\\d]" <regexp> matches? ] unit-test [ t ] [ "a" "[^\\d]" <regexp> matches? ] unit-test -/* -! FIXME [ t ] [ "a" "[a-z]{1,}|[A-Z]{2,4}|b*|c|(f|g)*" <regexp> matches? ] unit-test [ t ] [ "a" "[a-z]{1,2}|[A-Z]{3,3}|b*|c|(f|g)*" <regexp> matches? ] unit-test [ t ] [ "a" "[a-z]{1,2}|[A-Z]{3,3}" <regexp> matches? ] unit-test -*/ [ t ] [ "1000" "\\d{4,6}" <regexp> matches? ] unit-test [ t ] [ "1000" "[0-9]{4,6}" <regexp> matches? ] unit-test @@ -185,7 +182,7 @@ IN: regexp-tests [ f ] [ "abc" "[\\p{Upper}]{3}" <regexp> matches? ] unit-test [ t ] [ "ABC" "[\\p{Upper}]{3}" <regexp> matches? ] unit-test -[ f ] [ "" "\\Q\\E" <regexp> matches? ] unit-test +[ t ] [ "" "\\Q\\E" <regexp> matches? ] unit-test [ f ] [ "a" "\\Q\\E" <regexp> matches? ] unit-test [ t ] [ "|*+" "\\Q|*+\\E" <regexp> matches? ] unit-test [ f ] [ "abc" "\\Q|*+\\E" <regexp> matches? ] unit-test @@ -195,8 +192,8 @@ IN: regexp-tests [ t ] [ "SXY" "\\0123XY" <regexp> matches? ] unit-test [ t ] [ "x" "\\x78" <regexp> matches? ] unit-test [ f ] [ "y" "\\x78" <regexp> matches? ] unit-test -[ t ] [ "x" "\\u000078" <regexp> matches? ] unit-test -[ f ] [ "y" "\\u000078" <regexp> matches? ] unit-test +[ t ] [ "x" "\\u0078" <regexp> matches? ] unit-test +[ f ] [ "y" "\\u0078" <regexp> matches? ] unit-test [ t ] [ "ab" "a+b" <regexp> matches? ] unit-test [ f ] [ "b" "a+b" <regexp> matches? ] unit-test @@ -214,8 +211,8 @@ IN: regexp-tests [ f ] [ "aaaxb" "a+ab" <regexp> matches? ] unit-test [ t ] [ "aaacb" "a+cb" <regexp> matches? ] unit-test -[ 3 ] [ "aaacb" "a*" <regexp> match-head ] unit-test -[ 2 ] [ "aaacb" "aa?" <regexp> match-head ] unit-test +[ "aaa" ] [ "aaacb" "a*" <regexp> first-match >string ] unit-test +[ "aa" ] [ "aaacb" "aa?" <regexp> first-match >string ] unit-test [ t ] [ "aaa" R/ AAA/i matches? ] unit-test [ f ] [ "aax" R/ AAA/i matches? ] unit-test @@ -226,15 +223,15 @@ IN: regexp-tests [ t ] [ "c" R/ [A-Z]/i matches? ] unit-test [ f ] [ "3" R/ [A-Z]/i matches? ] unit-test -[ t ] [ "a" "(?i)a" <regexp> matches? ] unit-test -[ t ] [ "a" "(?i)a" <regexp> matches? ] unit-test -[ t ] [ "A" "(?i)a" <regexp> matches? ] unit-test -[ t ] [ "A" "(?i)a" <regexp> matches? ] unit-test +[ t ] [ "a" "(?i:a)" <regexp> matches? ] unit-test +[ t ] [ "a" "(?i:a)" <regexp> matches? ] unit-test +[ t ] [ "A" "(?i:a)" <regexp> matches? ] unit-test +[ t ] [ "A" "(?i:a)" <regexp> matches? ] unit-test -[ t ] [ "a" R/ (?-i)a/i matches? ] unit-test -[ t ] [ "a" R/ (?-i)a/i matches? ] unit-test -[ f ] [ "A" R/ (?-i)a/i matches? ] unit-test -[ f ] [ "A" R/ (?-i)a/i matches? ] unit-test +[ t ] [ "a" R/ (?-i:a)/i matches? ] unit-test +[ t ] [ "a" R/ (?-i:a)/i matches? ] unit-test +[ f ] [ "A" R/ (?-i:a)/i matches? ] unit-test +[ f ] [ "A" R/ (?-i:a)/i matches? ] unit-test [ f ] [ "A" "[a-z]" <regexp> matches? ] unit-test [ t ] [ "A" R/ [a-z]/i matches? ] unit-test @@ -242,9 +239,11 @@ IN: regexp-tests [ f ] [ "A" "\\p{Lower}" <regexp> matches? ] unit-test [ t ] [ "A" R/ \p{Lower}/i matches? ] unit-test -[ t ] [ "abc" <reversed> R/ abc/r matches? ] unit-test -[ t ] [ "abc" <reversed> R/ a[bB][cC]/r matches? ] unit-test -! [ t ] [ "adcbe" R/ a(?r)(bcd)(?-r)e/ matches? ] unit-test ! FIXME +[ t ] [ "abc" R/ abc/r matches? ] unit-test +[ t ] [ "abc" R/ a[bB][cC]/r matches? ] unit-test + +[ t ] [ 3 "xabc" R/ abc/r match-index-from >boolean ] unit-test +[ t ] [ 3 "xabc" R/ a[bB][cC]/r match-index-from >boolean ] unit-test [ t ] [ "s@f" "[a-z.-]@[a-z]" <regexp> matches? ] unit-test [ f ] [ "a" "[a-z.-]@[a-z]" <regexp> matches? ] unit-test @@ -253,8 +252,6 @@ IN: regexp-tests [ t ] [ "abc*" "[^\\*]*\\*" <regexp> matches? ] unit-test [ t ] [ "bca" "[^a]*a" <regexp> matches? ] unit-test -/* -! FIXME [ ] [ "(0[lL]?|[1-9]\\d{0,9}(\\d{0,9}[lL])?|0[xX]\\p{XDigit}{1,8}(\\p{XDigit}{0,8}[lL])?|0[0-7]{1,11}([0-7]{0,11}[lL])?|([0-9]+\\.[0-9]*|\\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?|[0-9]+([eE][+-]?[0-9]+[fFdD]?|([eE][+-]?[0-9]+)?[fFdD]))" <regexp> drop @@ -278,11 +275,6 @@ IN: regexp-tests [ "abc" ] [ "abc" "(ab|a)(bc)?" <regexp> first-match >string ] unit-test [ "b" ] [ "aaaaaaaaaaaaaaaaaaaaaaab" "((a*)*b)*b" <regexp> first-match >string ] unit-test -*/ - -! [ t ] [ "a:b" ".+:?" <regexp> matches? ] unit-test - -! [ 1 ] [ "hello" ".+?" <regexp> match length ] unit-test [ { "1" "2" "3" "4" } ] [ "1ABC2DEF3GHI4" R/ [A-Z]+/ re-split [ >string ] map ] unit-test @@ -295,7 +287,7 @@ IN: regexp-tests [ { "a" "" } ] [ "a=" R/ =/ re-split [ >string ] map ] unit-test [ { "ABC" "DEF" "GHI" } ] -[ "1ABC2DEF3GHI4" R/ [A-Z]+/ all-matches [ >string ] map ] unit-test +[ "1ABC2DEF3GHI4" R/ [A-Z]+/ all-matching-subseqs ] unit-test [ 3 ] [ "1ABC2DEF3GHI4" R/ [A-Z]+/ count-matches ] unit-test @@ -308,127 +300,173 @@ IN: regexp-tests [ "-- title --" ] [ "== title ==" R/ =/ "-" re-replace ] unit-test -/* -! FIXME -[ f ] [ "ab" "a(?!b)" <regexp> first-match ] unit-test +[ "" ] [ "ab" "a(?!b)" <regexp> first-match >string ] unit-test [ "a" ] [ "ac" "a(?!b)" <regexp> first-match >string ] unit-test +[ t ] [ "fxxbar" ".{3}(?!foo)bar" <regexp> matches? ] unit-test +[ t ] [ "foobar" ".{3}(?!foo)bar" <regexp> matches? ] unit-test [ t ] [ "fxxbar" "(?!foo).{3}bar" <regexp> matches? ] unit-test [ f ] [ "foobar" "(?!foo).{3}bar" <regexp> matches? ] unit-test [ "a" ] [ "ab" "a(?=b)(?=b)" <regexp> first-match >string ] unit-test -[ "a" ] [ "ba" "a(?<=b)(?<=b)" <regexp> first-match >string ] unit-test -[ "a" ] [ "cab" "a(?=b)(?<=c)" <regexp> first-match >string ] unit-test +[ "a" ] [ "ba" "(?<=b)(?<=b)a" <regexp> first-match >string ] unit-test +[ "a" ] [ "cab" "(?<=c)a(?=b)" <regexp> first-match >string ] unit-test -[ 3 ] [ "foobar" "foo(?=bar)" <regexp> match-head ] unit-test -[ f ] [ "foobxr" "foo(?=bar)" <regexp> match-head ] unit-test -*/ +[ 3 ] [ "foobar" "foo(?=bar)" <regexp> first-match length ] unit-test +[ f ] [ "foobxr" "foo(?=bar)" <regexp> first-match ] unit-test ! Bug in parsing word [ t ] [ "a" R' a' matches? ] unit-test -! Convert to lowercase until E -[ f ] [ "AA" R/ \LAA\E/ matches? ] unit-test -[ t ] [ "aa" R/ \LAA\E/ matches? ] unit-test +! Testing negation +[ f ] [ "a" R/ (?~a)/ matches? ] unit-test +[ t ] [ "aa" R/ (?~a)/ matches? ] unit-test +[ t ] [ "bb" R/ (?~a)/ matches? ] unit-test +[ t ] [ "" R/ (?~a)/ matches? ] unit-test -! Convert to uppercase until E -[ t ] [ "AA" R/ \Uaa\E/ matches? ] unit-test -[ f ] [ "aa" R/ \Uaa\E/ matches? ] unit-test +[ f ] [ "a" R/ (?~a+|b)/ matches? ] unit-test +[ f ] [ "aa" R/ (?~a+|b)/ matches? ] unit-test +[ t ] [ "bb" R/ (?~a+|b)/ matches? ] unit-test +[ f ] [ "b" R/ (?~a+|b)/ matches? ] unit-test +[ t ] [ "" R/ (?~a+|b)/ matches? ] unit-test -! [ "{Lower}" <regexp> ] [ invalid-range? ] must-fail-with +! Intersecting classes +[ t ] [ "ab" R/ ac|\p{Lower}b/ matches? ] unit-test +[ t ] [ "ab" R/ ac|[a-z]b/ matches? ] unit-test +[ t ] [ "ac" R/ ac|\p{Lower}b/ matches? ] unit-test +[ t ] [ "ac" R/ ac|[a-z]b/ matches? ] unit-test +[ t ] [ "ac" R/ [a-zA-Z]c|\p{Lower}b/ matches? ] unit-test +[ t ] [ "ab" R/ [a-zA-Z]c|\p{Lower}b/ matches? ] unit-test +[ t ] [ "Ï€b" R/ [a-zA-Z]c|\p{Lower}b/ matches? ] unit-test +[ f ] [ "Ï€c" R/ [a-zA-Z]c|\p{Lower}b/ matches? ] unit-test +[ f ] [ "Ab" R/ [a-zA-Z]c|\p{Lower}b/ matches? ] unit-test -! [ t ] [ "a" R/ ^a/ matches? ] unit-test -! [ f ] [ "\na" R/ ^a/ matches? ] unit-test -! [ f ] [ "\r\na" R/ ^a/ matches? ] unit-test -! [ f ] [ "\ra" R/ ^a/ matches? ] unit-test +[ t ] [ "aaaa" R/ .*a./ matches? ] unit-test -! [ t ] [ "a" R/ a$/ matches? ] unit-test -! [ f ] [ "a\n" R/ a$/ matches? ] unit-test -! [ f ] [ "a\r" R/ a$/ matches? ] unit-test -! [ f ] [ "a\r\n" R/ a$/ matches? ] unit-test +[ f ] [ "ab" R/ (?~ac|\p{Lower}b)/ matches? ] unit-test +[ f ] [ "ab" R/ (?~ac|[a-z]b)/ matches? ] unit-test +[ f ] [ "ac" R/ (?~ac|\p{Lower}b)/ matches? ] unit-test +[ f ] [ "ac" R/ (?~ac|[a-z]b)/ matches? ] unit-test +[ f ] [ "ac" R/ (?~[a-zA-Z]c|\p{Lower}b)/ matches? ] unit-test +[ f ] [ "ab" R/ (?~[a-zA-Z]c|\p{Lower}b)/ matches? ] unit-test +[ f ] [ "Ï€b" R/ (?~[a-zA-Z]c|\p{Lower}b)/ matches? ] unit-test +[ t ] [ "Ï€c" R/ (?~[a-zA-Z]c|\p{Lower}b)/ matches? ] unit-test +[ t ] [ "Ab" R/ (?~[a-zA-Z]c|\p{Lower}b)/ matches? ] unit-test -! [ t ] [ "a" R/ a$|b$/ matches? ] unit-test -! [ t ] [ "b" R/ a$|b$/ matches? ] unit-test -! [ t ] [ "ab" R/ a$|b$/ matches? ] unit-test -! [ t ] [ "ba" R/ ba$|b$/ matches? ] unit-test +! DFA is compiled when needed, or when literal +[ regexp-initial-word ] [ "foo" <regexp> dfa>> ] unit-test +[ f ] [ R/ foo/ dfa>> \ regexp-initial-word = ] unit-test -! [ t ] [ "a" R/ \Aa/ matches? ] unit-test -! [ f ] [ "\na" R/ \Aaa/ matches? ] unit-test -! [ f ] [ "\r\na" R/ \Aa/ matches? ] unit-test -! [ f ] [ "\ra" R/ \Aa/ matches? ] unit-test +[ t ] [ "a" R/ ^a/ matches? ] unit-test +[ f ] [ "\na" R/ ^a/ matches? ] unit-test +[ f ] [ "\r\na" R/ ^a/ matches? ] unit-test +[ f ] [ "\ra" R/ ^a/ matches? ] unit-test -! [ t ] [ "a" R/ \Aa/m matches? ] unit-test -! [ f ] [ "\na" R/ \Aaa/m matches? ] unit-test -! [ f ] [ "\r\na" R/ \Aa/m matches? ] unit-test -! [ f ] [ "\ra" R/ \Aa/m matches? ] unit-test +[ 1 ] [ "a" R/ ^a/ count-matches ] unit-test +[ 0 ] [ "\na" R/ ^a/ count-matches ] unit-test +[ 0 ] [ "\r\na" R/ ^a/ count-matches ] unit-test +[ 0 ] [ "\ra" R/ ^a/ count-matches ] unit-test -! [ t ] [ "\r\n\n\n\nam" R/ ^am/m matches? ] unit-test +[ t ] [ "a" R/ a$/ matches? ] unit-test +[ f ] [ "a\n" R/ a$/ matches? ] unit-test +[ f ] [ "a\r" R/ a$/ matches? ] unit-test +[ f ] [ "a\r\n" R/ a$/ matches? ] unit-test -! [ t ] [ "a" R/ \Aa\z/m matches? ] unit-test -! [ f ] [ "a\n" R/ \Aa\z/m matches? ] unit-test +[ 1 ] [ "a" R/ a$/ count-matches ] unit-test +[ 0 ] [ "a\n" R/ a$/ count-matches ] unit-test +[ 0 ] [ "a\r" R/ a$/ count-matches ] unit-test +[ 0 ] [ "a\r\n" R/ a$/ count-matches ] unit-test -! [ t ] [ "a\r\n" R/ \Aa\Z/m matches? ] unit-test -! [ t ] [ "a\n" R/ \Aa\Z/m matches? ] unit-test +[ t ] [ "a" R/ a$|b$/ matches? ] unit-test +[ t ] [ "b" R/ a$|b$/ matches? ] unit-test +[ f ] [ "ab" R/ a$|b$/ matches? ] unit-test +[ t ] [ "ba" R/ ba$|b$/ matches? ] unit-test -! [ t ] [ "a" R/ \Aa\Z/m matches? ] unit-test -! [ f ] [ "\na" R/ \Aaa\Z/m matches? ] unit-test -! [ f ] [ "\r\na" R/ \Aa\Z/m matches? ] unit-test -! [ f ] [ "\ra" R/ \Aa\Z/m matches? ] unit-test +[ t ] [ "a" R/ \Aa/ matches? ] unit-test +[ f ] [ "\na" R/ \Aaa/ matches? ] unit-test +[ f ] [ "\r\na" R/ \Aa/ matches? ] unit-test +[ f ] [ "\ra" R/ \Aa/ matches? ] unit-test -! [ t ] [ "a" R/ ^a/m matches? ] unit-test -! [ t ] [ "\na" R/ ^a/m matches? ] unit-test -! [ t ] [ "\r\na" R/ ^a/m matches? ] unit-test -! [ t ] [ "\ra" R/ ^a/m matches? ] unit-test +[ t ] [ "a" R/ \Aa/m matches? ] unit-test +[ f ] [ "\na" R/ \Aaa/m matches? ] unit-test +[ f ] [ "\r\na" R/ \Aa/m matches? ] unit-test +[ f ] [ "\ra" R/ \Aa/m matches? ] unit-test +[ 0 ] [ "\ra" R/ \Aa/m count-matches ] unit-test -! [ t ] [ "a" "a$" R/ a$/m matches? ] unit-test -! [ t ] [ "a\n" "a$" R/ a$/m matches? ] unit-test -! [ t ] [ "a\r" "a$" R/ a$/m matches? ] unit-test -! [ t ] [ "a\r\n" "a$" R/ a$/m matches? ] unit-test +[ f ] [ "\r\n\n\n\nam" R/ ^am/m matches? ] unit-test +[ 1 ] [ "\r\n\n\n\nam" R/ ^am/m count-matches ] unit-test -! [ f ] [ "foobxr" "foo\\z" <regexp> match-head ] unit-test -! [ 3 ] [ "foo" "foo\\z" <regexp> match-head ] unit-test +[ t ] [ "a" R/ \Aa\z/m matches? ] unit-test +[ f ] [ "a\n" R/ \Aa\z/m matches? ] unit-test -! [ t ] [ "foo" "\\bfoo\\b" <regexp> matches? ] unit-test -! [ t ] [ "afoob" "\\Bfoo\\B" <regexp> matches? ] unit-test -! [ t ] [ "afoob" "\\bfoo\\b" <regexp> matches? ] unit-test -! [ f ] [ "foo" "\\Bfoo\\B" <regexp> matches? ] unit-test +[ f ] [ "a\r\n" R/ \Aa\Z/m matches? ] unit-test +[ f ] [ "a\n" R/ \Aa\Z/m matches? ] unit-test +[ 1 ] [ "a\r\n" R/ \Aa\Z/m count-matches ] unit-test +[ 1 ] [ "a\n" R/ \Aa\Z/m count-matches ] unit-test -! [ 3 ] [ "foo bar" "foo\\b" <regexp> match-head ] unit-test -! [ f ] [ "fooxbar" "foo\\b" <regexp> matches? ] unit-test -! [ t ] [ "foo" "foo\\b" <regexp> matches? ] unit-test -! [ t ] [ "foo bar" "foo\\b bar" <regexp> matches? ] unit-test -! [ f ] [ "fooxbar" "foo\\bxbar" <regexp> matches? ] unit-test -! [ f ] [ "foo" "foo\\bbar" <regexp> matches? ] unit-test +[ t ] [ "a" R/ \Aa\Z/m matches? ] unit-test +[ f ] [ "\na" R/ \Aaa\Z/m matches? ] unit-test +[ f ] [ "\r\na" R/ \Aa\Z/m matches? ] unit-test +[ f ] [ "\ra" R/ \Aa\Z/m matches? ] unit-test -! [ f ] [ "foo bar" "foo\\B" <regexp> matches? ] unit-test -! [ 3 ] [ "fooxbar" "foo\\B" <regexp> match-head ] unit-test -! [ t ] [ "foo" "foo\\B" <regexp> matches? ] unit-test -! [ f ] [ "foo bar" "foo\\B bar" <regexp> matches? ] unit-test -! [ t ] [ "fooxbar" "foo\\Bxbar" <regexp> matches? ] unit-test -! [ f ] [ "foo" "foo\\Bbar" <regexp> matches? ] unit-test +[ 1 ] [ "a" R/ \Aa\Z/m count-matches ] unit-test +[ 0 ] [ "\na" R/ \Aaa\Z/m count-matches ] unit-test +[ 0 ] [ "\r\na" R/ \Aa\Z/m count-matches ] unit-test +[ 0 ] [ "\ra" R/ \Aa\Z/m count-matches ] unit-test -! [ 1 ] [ "aaacb" "a+?" <regexp> match-head ] unit-test -! [ 1 ] [ "aaacb" "aa??" <regexp> match-head ] unit-test -! [ f ] [ "aaaab" "a++ab" <regexp> matches? ] unit-test -! [ t ] [ "aaacb" "a++cb" <regexp> matches? ] unit-test -! [ 3 ] [ "aacb" "aa?c" <regexp> match-head ] unit-test -! [ 3 ] [ "aacb" "aa??c" <regexp> match-head ] unit-test +[ t ] [ "a" R/ ^a/m matches? ] unit-test +[ f ] [ "\na" R/ ^a/m matches? ] unit-test +[ 1 ] [ "\na" R/ ^a/m count-matches ] unit-test +[ 1 ] [ "\r\na" R/ ^a/m count-matches ] unit-test +[ 1 ] [ "\ra" R/ ^a/m count-matches ] unit-test -! "ab" "a(?=b*)" <regexp> match -! "abbbbbc" "a(?=b*c)" <regexp> match -! "ab" "a(?=b*)" <regexp> match +[ t ] [ "a" R/ a$/m matches? ] unit-test +[ f ] [ "a\n" R/ a$/m matches? ] unit-test +[ 1 ] [ "a\n" R/ a$/m count-matches ] unit-test +[ 1 ] [ "a\r" R/ a$/m count-matches ] unit-test +[ 1 ] [ "a\r\n" R/ a$/m count-matches ] unit-test -! "baz" "(az)(?<=b)" <regexp> first-match -! "cbaz" "a(?<=b*)" <regexp> first-match -! "baz" "a(?<=b)" <regexp> first-match +[ f ] [ "foobxr" "foo\\z" <regexp> first-match ] unit-test +[ 3 ] [ "foo" "foo\\z" <regexp> first-match length ] unit-test -! "baz" "a(?<!b)" <regexp> first-match -! "caz" "a(?<!b)" <regexp> first-match +[ t ] [ "a foo b" R/ foo/ re-contains? ] unit-test +[ f ] [ "a bar b" R/ foo/ re-contains? ] unit-test +[ t ] [ "foo" R/ foo/ re-contains? ] unit-test -! "abcdefg" "a(?=bcdefg)bcd" <regexp> first-match -! "abcdefg" "a(?#bcdefg)bcd" <regexp> first-match -! "abcdefg" "a(?:bcdefg)" <regexp> first-match +[ { "foo" "fxx" "fab" } ] [ "fab fxx foo" R/ f../r all-matching-subseqs ] unit-test -! "caba" "a(?<=b)" <regexp> first-match +[ t ] [ "foo" "\\bfoo\\b" <regexp> re-contains? ] unit-test +[ t ] [ "afoob" "\\Bfoo\\B" <regexp> re-contains? ] unit-test +[ f ] [ "afoob" "\\bfoo\\b" <regexp> re-contains? ] unit-test +[ f ] [ "foo" "\\Bfoo\\B" <regexp> re-contains? ] unit-test -! capture group 1: "aaaa" 2: "" -! "aaaa" "(a*)(a*)" <regexp> match* -! "aaaa" "(a*)(a+)" <regexp> match* +[ 3 ] [ "foo bar" "foo\\b" <regexp> first-match length ] unit-test +[ f ] [ "fooxbar" "foo\\b" <regexp> re-contains? ] unit-test +[ t ] [ "foo" "foo\\b" <regexp> re-contains? ] unit-test +[ t ] [ "foo bar" "foo\\b bar" <regexp> matches? ] unit-test +[ f ] [ "fooxbar" "foo\\bxbar" <regexp> matches? ] unit-test +[ f ] [ "foo" "foo\\bbar" <regexp> matches? ] unit-test + +[ f ] [ "foo bar" "foo\\B" <regexp> re-contains? ] unit-test +[ 3 ] [ "fooxbar" "foo\\B" <regexp> first-match length ] unit-test +[ f ] [ "foo" "foo\\B" <regexp> re-contains? ] unit-test +[ f ] [ "foo bar" "foo\\B bar" <regexp> matches? ] unit-test +[ t ] [ "fooxbar" "foo\\Bxbar" <regexp> matches? ] unit-test +[ f ] [ "foo" "foo\\Bbar" <regexp> matches? ] unit-test + +[ t ] [ "ab" "a(?=b*)" <regexp> re-contains? ] unit-test +[ t ] [ "abbbbbc" "a(?=b*c)" <regexp> re-contains? ] unit-test +[ f ] [ "abbbbb" "a(?=b*c)" <regexp> re-contains? ] unit-test +[ t ] [ "ab" "a(?=b*)" <regexp> re-contains? ] unit-test + +[ "az" ] [ "baz" "(?<=b)(az)" <regexp> first-match >string ] unit-test +[ f ] [ "chaz" "(?<=b)(az)" <regexp> re-contains? ] unit-test +[ "a" ] [ "cbaz" "(?<=b*)a" <regexp> first-match >string ] unit-test +[ f ] [ "baz" "a(?<=b)" <regexp> re-contains? ] unit-test + +[ f ] [ "baz" "(?<!b)a" <regexp> re-contains? ] unit-test +[ t ] [ "caz" "(?<!b)a" <regexp> re-contains? ] unit-test + +[ "abcd" ] [ "abcdefg" "a(?=bcdefg)bcd" <regexp> first-match >string ] unit-test +[ t ] [ "abcdefg" "a(?#bcdefg)bcd" <regexp> re-contains? ] unit-test +[ t ] [ "abcdefg" "a(?:bcdefg)" <regexp> matches? ] unit-test + +[ 3 ] [ "caba" "(?<=b)a" <regexp> first-match from>> ] unit-test diff --git a/basis/regexp/regexp.factor b/basis/regexp/regexp.factor index 11d257b6b2..29f7e3e84e 100644 --- a/basis/regexp/regexp.factor +++ b/basis/regexp/regexp.factor @@ -1,87 +1,182 @@ -! Copyright (C) 2008 Doug Coleman. +! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors combinators kernel math sequences strings sets -assocs prettyprint.backend prettyprint.custom make lexer -namespaces parser arrays fry regexp.backend regexp.utils -regexp.parser regexp.nfa regexp.dfa regexp.traversal -regexp.transition-tables splitting sorting ; +USING: accessors combinators kernel kernel.private math sequences +sequences.private strings sets assocs prettyprint.backend +prettyprint.custom make lexer namespaces parser arrays fry locals +regexp.parser splitting sorting regexp.ast regexp.negation +regexp.compiler words call call.private math.ranges ; IN: regexp -: default-regexp ( string -- regexp ) - regexp new - swap >>raw - <transition-table> >>nfa-table - <transition-table> >>dfa-table - <transition-table> >>minimized-table - H{ } clone >>nfa-traversal-flags - H{ } clone >>dfa-traversal-flags - H{ } clone >>options - H{ } clone >>matchers - reset-regexp ; +TUPLE: regexp + { raw read-only } + { parse-tree read-only } + { options read-only } + dfa next-match ; -: construct-regexp ( regexp -- regexp' ) - { - [ parse-regexp ] - [ construct-nfa ] - [ construct-dfa ] - [ ] - } cleave ; - -: (match) ( string regexp -- dfa-traverser ) - <dfa-traverser> do-match ; inline - -: match ( string regexp -- slice/f ) - (match) return-match ; - -: match* ( string regexp -- slice/f captured-groups ) - (match) [ return-match ] [ captured-groups>> ] bi ; - -: matches? ( string regexp -- ? ) - dupd match - [ [ length ] bi@ = ] [ drop f ] if* ; - -: match-head ( string regexp -- end/f ) match [ length ] [ f ] if* ; - -: match-at ( string m regexp -- n/f finished? ) - [ - 2dup swap length > [ 2drop f f ] [ tail-slice t ] if - ] dip swap [ match-head f ] [ 2drop f t ] if ; - -: match-range ( string m regexp -- a/f b/f ) - 3dup match-at over [ - drop nip rot drop dupd + - ] [ - [ 3drop drop f f ] [ drop [ 1+ ] dip match-range ] if - ] if ; - -: first-match ( string regexp -- slice/f ) - dupd 0 swap match-range rot over [ <slice> ] [ 3drop f ] if ; - -: re-cut ( string regexp -- end/f start ) - dupd first-match - [ split1-slice swap ] [ "" like f swap ] if* ; - -: (re-split) ( string regexp -- ) - over [ [ re-cut , ] keep (re-split) ] [ 2drop ] if ; - -: re-split ( string regexp -- seq ) - [ (re-split) ] { } make ; - -: re-replace ( string regexp replacement -- result ) - [ re-split ] dip join ; - -: next-match ( string regexp -- end/f match/f ) - dupd first-match dup - [ [ split1-slice nip ] keep ] [ 2drop f f ] if ; - -: all-matches ( string regexp -- seq ) - [ dup ] swap '[ _ next-match ] produce nip harvest ; - -: count-matches ( string regexp -- n ) - all-matches length ; +TUPLE: reverse-regexp < regexp ; <PRIVATE +M: lookahead question>quot ! Returns ( index string -- ? ) + term>> ast>dfa dfa>shortest-word '[ f _ execute ] ; + +: <reversed-option> ( ast -- reversed ) + "r" string>options <with-options> ; + +M: lookbehind question>quot ! Returns ( index string -- ? ) + term>> <reversed-option> + ast>dfa dfa>reverse-shortest-word + '[ [ 1- ] dip f _ execute ] ; + +: check-string ( string -- string ) + ! Make this configurable + dup string? [ "String required" throw ] unless ; + +: match-index-from ( i string regexp -- index/f ) + ! This word is unsafe. It assumes that i is a fixnum + ! and that string is a string. + dup dfa>> execute-unsafe( index string regexp -- i/f ) ; + +GENERIC: end/start ( string regexp -- end start ) +M: regexp end/start drop length 0 ; +M: reverse-regexp end/start drop length 1- -1 swap ; + +PRIVATE> + +: matches? ( string regexp -- ? ) + [ check-string ] dip + [ end/start ] 2keep + match-index-from + [ = ] [ drop f ] if* ; + +<PRIVATE + +:: (next-match) ( i string regexp quot: ( i string regexp -- j ) reverse? -- i start end ? ) + i string regexp quot call dup [| j | + j i j + reverse? [ swap [ 1+ ] bi@ ] when + string + ] [ drop f f f f ] if ; inline + +: search-range ( i string reverse? -- seq ) + [ drop dup 1+ -1 ] [ length 1 ] if range boa ; inline + +:: next-match ( i string regexp quot: ( i string regexp -- j ) reverse? -- i start end ? ) + f f f f + i string reverse? search-range + [ [ 2drop 2drop ] dip string regexp quot reverse? (next-match) dup ] find 2drop ; inline + +: do-next-match ( i string regexp -- i start end ? ) + dup next-match>> + execute-unsafe( i string regexp -- i start end ? ) ; inline + +:: (each-match) ( i string regexp quot: ( start end string -- ) -- ) + i string regexp do-next-match [| i' start end | + start end string quot call + i' string regexp quot (each-match) + ] [ 3drop ] if ; inline recursive + +: prepare-match-iterator ( string regexp -- i string regexp ) + [ check-string ] dip [ end/start nip ] 2keep ; inline + +PRIVATE> + +: each-match ( string regexp quot: ( start end string -- ) -- ) + [ prepare-match-iterator ] dip (each-match) ; inline + +: map-matches ( string regexp quot: ( start end string -- obj ) -- seq ) + accumulator [ each-match ] dip >array ; inline + +: all-matching-slices ( string regexp -- seq ) + [ slice boa ] map-matches ; + +: all-matching-subseqs ( string regexp -- seq ) + [ subseq ] map-matches ; + +: count-matches ( string regexp -- n ) + [ 0 ] 2dip [ 3drop 1+ ] each-match ; + +<PRIVATE + +:: (re-split) ( string regexp quot -- new-slices ) + 0 string regexp [| end start end' string | + end' ! leave it on the stack for the next iteration + end start string quot call + ] map-matches + ! Final chunk + swap string length string quot call suffix ; inline + +PRIVATE> + +: first-match ( string regexp -- slice/f ) + [ prepare-match-iterator do-next-match ] [ drop ] 2bi + '[ _ slice boa nip ] [ 3drop f ] if ; + +: re-contains? ( string regexp -- ? ) + prepare-match-iterator do-next-match [ 3drop ] dip >boolean ; + +: re-split ( string regexp -- seq ) + [ slice boa ] (re-split) ; + +: re-replace ( string regexp replacement -- result ) + [ [ subseq ] (re-split) ] dip join ; + +<PRIVATE + +: get-ast ( regexp -- ast ) + [ parse-tree>> ] [ options>> ] bi <with-options> ; + +GENERIC: compile-regexp ( regex -- regexp ) + +: regexp-initial-word ( i string regexp -- i/f ) + compile-regexp match-index-from ; + +: do-compile-regexp ( regexp -- regexp ) + dup '[ + dup \ regexp-initial-word = + [ drop _ get-ast ast>dfa dfa>word ] when + ] change-dfa ; + +M: regexp compile-regexp ( regexp -- regexp ) + do-compile-regexp ; + +M: reverse-regexp compile-regexp ( regexp -- regexp ) + t backwards? [ do-compile-regexp ] with-variable ; + +DEFER: compile-next-match + +: next-initial-word ( i string regexp -- i start end string ) + compile-next-match do-next-match ; + +: compile-next-match ( regexp -- regexp ) + dup '[ + dup \ next-initial-word = [ + drop _ [ compile-regexp dfa>> def>> ] [ reverse-regexp? ] bi + '[ { array-capacity string regexp } declare _ _ next-match ] + (( i string regexp -- i start end string )) simple-define-temp + ] when + ] change-next-match ; + +PRIVATE> + +: new-regexp ( string ast options class -- regexp ) + [ \ regexp-initial-word \ next-initial-word ] dip boa ; inline + +: make-regexp ( string ast -- regexp ) + f f <options> regexp new-regexp ; + +: <optioned-regexp> ( string options -- regexp ) + [ dup parse-regexp ] [ string>options ] bi* + dup on>> reversed-regexp swap member? + [ reverse-regexp new-regexp ] + [ regexp new-regexp ] if ; + +: <regexp> ( string -- regexp ) "" <optioned-regexp> ; + +<PRIVATE + +! The following two should do some caching + : find-regexp-syntax ( string -- prefix suffix ) { { "R/ " "/" } @@ -97,28 +192,19 @@ IN: regexp { "R| " "|" } } swap [ subseq? not nip ] curry assoc-find drop ; -: string>options ( string -- options ) - [ ch>option dup ] H{ } map>assoc ; +: take-until ( end lexer -- string ) + dup skip-blank [ + [ index-from ] 2keep + [ swapd subseq ] + [ 2drop 1+ ] 3bi + ] change-lexer-column ; -: options>string ( options -- string ) - keys [ option>ch ] map natural-sort >string ; - -PRIVATE> - -: <optioned-regexp> ( string option-string -- regexp ) - [ default-regexp ] [ string>options ] bi* >>options - construct-regexp ; - -: <regexp> ( string -- regexp ) "" <optioned-regexp> ; - -<PRIVATE +: parse-noblank-token ( lexer -- str/f ) + dup still-parsing-line? [ (parse-token) ] [ drop f ] if ; : parsing-regexp ( accum end -- accum ) - lexer get dup skip-blank - [ [ index-from dup 1+ swap ] 2keep swapd subseq swap ] change-lexer-column - lexer get dup still-parsing-line? - [ (parse-token) ] [ drop f ] if - <optioned-regexp> parsed ; + lexer get [ take-until ] [ parse-noblank-token ] bi + <optioned-regexp> compile-next-match parsed ; PRIVATE> @@ -141,3 +227,4 @@ M: regexp pprint* [ options>> options>string % ] bi ] "" make ] keep present-text ; + diff --git a/basis/regexp/transition-tables/transition-tables.factor b/basis/regexp/transition-tables/transition-tables.factor index e5c31a54e0..3c33ae8846 100644 --- a/basis/regexp/transition-tables/transition-tables.factor +++ b/basis/regexp/transition-tables/transition-tables.factor @@ -1,32 +1,9 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs fry hashtables kernel sequences -vectors regexp.utils ; +vectors locals regexp.classes ; IN: regexp.transition-tables -TUPLE: transition from to obj ; -TUPLE: literal-transition < transition ; -TUPLE: class-transition < transition ; -TUPLE: default-transition < transition ; - -TUPLE: literal obj ; -TUPLE: class obj ; -TUPLE: default ; -: make-transition ( from to obj class -- obj ) - new - swap >>obj - swap >>to - swap >>from ; - -: <literal-transition> ( from to obj -- transition ) - literal-transition make-transition ; - -: <class-transition> ( from to obj -- transition ) - class-transition make-transition ; - -: <default-transition> ( from to -- transition ) - t default-transition make-transition ; - TUPLE: transition-table transitions start-state final-states ; : <transition-table> ( -- transition-table ) @@ -35,14 +12,50 @@ TUPLE: transition-table transitions start-state final-states ; H{ } clone >>final-states ; : maybe-initialize-key ( key hashtable -- ) + ! Why do we have to do this? 2dup key? [ 2drop ] [ [ H{ } clone ] 2dip set-at ] if ; -: set-transition ( transition hash -- ) - #! set the state as a key - 2dup [ to>> ] dip maybe-initialize-key - [ [ to>> ] [ obj>> ] [ from>> ] tri ] dip - 2dup at* [ 2nip insert-at ] - [ drop [ H{ } clone [ insert-at ] keep ] 2dip set-at ] if ; +:: (set-transition) ( from to obj hash -- ) + to condition? [ to hash maybe-initialize-key ] unless + from hash at + [ [ to obj ] dip set-at ] + [ to obj associate from hash set-at ] if* ; -: add-transition ( transition transition-table -- ) - transitions>> set-transition ; +: set-transition ( from to obj transition-table -- ) + transitions>> (set-transition) ; + +:: (add-transition) ( from to obj hash -- ) + to hash maybe-initialize-key + from hash at + [ [ to obj ] dip push-at ] + [ to 1vector obj associate from hash set-at ] if* ; + +: add-transition ( from to obj transition-table -- ) + transitions>> (add-transition) ; + +: map-set ( assoc quot -- new-assoc ) + '[ drop @ dup ] assoc-map ; inline + +: number-transitions ( transitions numbering -- new-transitions ) + dup '[ + [ _ at ] + [ [ _ condition-at ] assoc-map ] bi* + ] assoc-map ; + +: transitions-at ( transition-table assoc -- transition-table ) + [ clone ] dip + [ '[ _ condition-at ] change-start-state ] + [ '[ [ _ at ] map-set ] change-final-states ] + [ '[ _ number-transitions ] change-transitions ] tri ; + +: expand-one-or ( or-class transition -- alist ) + [ seq>> ] dip '[ _ 2array ] map ; + +: expand-or ( state-transitions -- new-transitions ) + >alist [ + first2 over or-class? + [ expand-one-or ] [ 2array 1array ] if + ] map concat >hashtable ; + +: expand-ors ( transition-table -- transition-table ) + [ [ expand-or ] assoc-map ] change-transitions ; diff --git a/basis/regexp/traversal/traversal.factor b/basis/regexp/traversal/traversal.factor deleted file mode 100644 index 104a6c2ce1..0000000000 --- a/basis/regexp/traversal/traversal.factor +++ /dev/null @@ -1,195 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs combinators kernel math -quotations sequences regexp.parser regexp.classes fry arrays -combinators.short-circuit regexp.utils prettyprint regexp.nfa ; -IN: regexp.traversal - -TUPLE: dfa-traverser - dfa-table - traversal-flags - traverse-forward - lookahead-counters - lookbehind-counters - capture-counters - captured-groups - capture-group-index - last-state current-state - text - match-failed? - start-index current-index - matches ; - -: <dfa-traverser> ( text regexp -- match ) - [ dfa-table>> ] [ dfa-traversal-flags>> ] bi - dfa-traverser new - swap >>traversal-flags - swap [ start-state>> >>current-state ] [ >>dfa-table ] bi - swap >>text - t >>traverse-forward - 0 >>start-index - 0 >>current-index - 0 >>capture-group-index - V{ } clone >>matches - V{ } clone >>capture-counters - V{ } clone >>lookbehind-counters - V{ } clone >>lookahead-counters - H{ } clone >>captured-groups ; - -: final-state? ( dfa-traverser -- ? ) - [ current-state>> ] - [ dfa-table>> final-states>> ] bi key? ; - -: beginning-of-text? ( dfa-traverser -- ? ) - current-index>> 0 <= ; inline - -: end-of-text? ( dfa-traverser -- ? ) - [ current-index>> ] [ text>> length ] bi >= ; inline - -: text-finished? ( dfa-traverser -- ? ) - { - [ current-state>> empty? ] - [ end-of-text? ] - [ match-failed?>> ] - } 1|| ; - -: save-final-state ( dfa-straverser -- ) - [ current-index>> ] [ matches>> ] bi push ; - -: match-done? ( dfa-traverser -- ? ) - dup final-state? [ - dup save-final-state - ] when text-finished? ; - -: previous-text-character ( dfa-traverser -- ch ) - [ text>> ] [ current-index>> 1- ] bi nth ; - -: current-text-character ( dfa-traverser -- ch ) - [ text>> ] [ current-index>> ] bi nth ; - -: next-text-character ( dfa-traverser -- ch ) - [ text>> ] [ current-index>> 1+ ] bi nth ; - -GENERIC: flag-action ( dfa-traverser flag -- ) - - -M: beginning-of-input flag-action ( dfa-traverser flag -- ) - drop - dup beginning-of-text? [ t >>match-failed? ] unless drop ; - -M: end-of-input flag-action ( dfa-traverser flag -- ) - drop - dup end-of-text? [ t >>match-failed? ] unless drop ; - - -M: beginning-of-line flag-action ( dfa-traverser flag -- ) - drop - dup { - [ beginning-of-text? ] - [ previous-text-character terminator-class class-member? ] - } 1|| [ t >>match-failed? ] unless drop ; - -M: end-of-line flag-action ( dfa-traverser flag -- ) - drop - dup { - [ end-of-text? ] - [ next-text-character terminator-class class-member? ] - } 1|| [ t >>match-failed? ] unless drop ; - - -M: word-boundary flag-action ( dfa-traverser flag -- ) - drop - dup { - [ end-of-text? ] - [ current-text-character terminator-class class-member? ] - } 1|| [ t >>match-failed? ] unless drop ; - - -M: lookahead-on flag-action ( dfa-traverser flag -- ) - drop - lookahead-counters>> 0 swap push ; - -M: lookahead-off flag-action ( dfa-traverser flag -- ) - drop - dup lookahead-counters>> - [ drop ] [ pop '[ _ - ] change-current-index drop ] if-empty ; - -M: lookbehind-on flag-action ( dfa-traverser flag -- ) - drop - f >>traverse-forward - [ 2 - ] change-current-index - lookbehind-counters>> 0 swap push ; - -M: lookbehind-off flag-action ( dfa-traverser flag -- ) - drop - t >>traverse-forward - dup lookbehind-counters>> - [ drop ] [ pop '[ _ + 2 + ] change-current-index drop ] if-empty ; - -M: capture-group-on flag-action ( dfa-traverser flag -- ) - drop - [ current-index>> 0 2array ] - [ capture-counters>> ] bi push ; - -M: capture-group-off flag-action ( dfa-traverser flag -- ) - drop - dup capture-counters>> empty? [ - drop - ] [ - { - [ capture-counters>> pop first2 dupd + ] - [ text>> <slice> ] - [ [ 1+ ] change-capture-group-index capture-group-index>> ] - [ captured-groups>> set-at ] - } cleave - ] if ; - -: process-flags ( dfa-traverser -- ) - [ [ 1+ ] map ] change-lookahead-counters - [ [ 1+ ] map ] change-lookbehind-counters - [ [ first2 1+ 2array ] map ] change-capture-counters - ! dup current-state>> . - dup [ current-state>> ] [ traversal-flags>> ] bi - at [ flag-action ] with each ; - -: increment-state ( dfa-traverser state -- dfa-traverser ) - [ - dup traverse-forward>> - [ [ 1+ ] change-current-index ] - [ [ 1- ] change-current-index ] if - dup current-state>> >>last-state - ] [ first ] bi* >>current-state ; - -: match-literal ( transition from-state table -- to-state/f ) - transitions>> at at ; - -: match-class ( transition from-state table -- to-state/f ) - transitions>> at* [ - [ drop class-member? ] assoc-with assoc-find [ nip ] [ drop ] if - ] [ drop ] if ; - -: match-default ( transition from-state table -- to-state/f ) - [ drop ] 2dip transitions>> at t swap at ; - -: match-transition ( obj from-state dfa -- to-state/f ) - { [ match-literal ] [ match-class ] [ match-default ] } 3|| ; - -: setup-match ( match -- obj state dfa-table ) - [ [ current-index>> ] [ text>> ] bi nth ] - [ current-state>> ] - [ dfa-table>> ] tri ; - -: do-match ( dfa-traverser -- dfa-traverser ) - dup process-flags - dup match-done? [ - dup setup-match match-transition - [ increment-state do-match ] when* - ] unless ; - -: return-match ( dfa-traverser -- slice/f ) - dup matches>> - [ drop f ] - [ - [ [ text>> ] [ start-index>> ] bi ] - [ peek ] bi* rot <slice> - ] if-empty ; diff --git a/basis/regexp/utils/utils-tests.factor b/basis/regexp/utils/utils-tests.factor deleted file mode 100644 index d048ad4be1..0000000000 --- a/basis/regexp/utils/utils-tests.factor +++ /dev/null @@ -1,4 +0,0 @@ -USING: regexp.utils tools.test ; -IN: regexp.utils.tests - -[ [ ] [ ] while-changes ] must-infer diff --git a/basis/regexp/utils/utils.factor b/basis/regexp/utils/utils.factor deleted file mode 100644 index af1b2fa1fb..0000000000 --- a/basis/regexp/utils/utils.factor +++ /dev/null @@ -1,64 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays assocs io kernel math math.order -namespaces regexp.backend sequences unicode.categories -math.ranges fry combinators.short-circuit vectors ; -IN: regexp.utils - -: (while-changes) ( obj quot: ( obj -- obj' ) pred: ( obj -- <=> ) pred-ret -- obj ) - [ [ dup slip ] dip pick over call ] dip dupd = - [ 3drop ] [ (while-changes) ] if ; inline recursive - -: while-changes ( obj quot pred -- obj' ) - pick over call (while-changes) ; inline - -: assoc-with ( param assoc quot -- assoc curry ) - swapd [ [ -rot ] dip call ] 2curry ; inline - -: insert-at ( value key hash -- ) - 2dup at* [ - 2nip push - ] [ - drop - [ dup vector? [ 1vector ] unless ] 2dip set-at - ] if ; - -: ?insert-at ( value key hash/f -- hash ) - [ H{ } clone ] unless* [ insert-at ] keep ; - -ERROR: bad-octal number ; -ERROR: bad-hex number ; -: check-octal ( octal -- octal ) dup 255 > [ bad-octal ] when ; -: check-hex ( hex -- hex ) dup number? [ bad-hex ] unless ; - -: ascii? ( n -- ? ) 0 HEX: 7f between? ; -: octal-digit? ( n -- ? ) CHAR: 0 CHAR: 7 between? ; -: decimal-digit? ( n -- ? ) CHAR: 0 CHAR: 9 between? ; - -: hex-digit? ( n -- ? ) - [ - [ decimal-digit? ] - [ CHAR: a CHAR: f between? ] - [ CHAR: A CHAR: F between? ] - ] 1|| ; - -: control-char? ( n -- ? ) - [ - [ 0 HEX: 1f between? ] - [ HEX: 7f = ] - ] 1|| ; - -: punct? ( n -- ? ) - "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" member? ; - -: c-identifier-char? ( ch -- ? ) - [ [ alpha? ] [ CHAR: _ = ] ] 1|| ; - -: java-blank? ( n -- ? ) - { - CHAR: \s CHAR: \t CHAR: \n - HEX: b HEX: 7 CHAR: \r - } member? ; - -: java-printable? ( n -- ? ) - [ [ alpha? ] [ punct? ] ] 1|| ; diff --git a/basis/see/authors.txt b/basis/see/authors.txt new file mode 100644 index 0000000000..d4f5d6b3ae --- /dev/null +++ b/basis/see/authors.txt @@ -0,0 +1 @@ +Slava Pestov \ No newline at end of file diff --git a/basis/see/see-docs.factor b/basis/see/see-docs.factor new file mode 100644 index 0000000000..755d4ac9bc --- /dev/null +++ b/basis/see/see-docs.factor @@ -0,0 +1,55 @@ +IN: see +USING: help.markup help.syntax strings prettyprint.private +definitions generic words classes ; + +HELP: synopsis +{ $values { "defspec" "a definition specifier" } { "str" string } } +{ $contract "Prettyprints the prologue of a definition." } ; + +HELP: synopsis* +{ $values { "defspec" "a definition specifier" } } +{ $contract "Adds sections to the current block corresponding to a the prologue of a definition, in source code-like form." } +{ $notes "This word should only be called from inside the " { $link with-pprint } " combinator. Client code should call " { $link synopsis } " instead." } ; + +HELP: see +{ $values { "defspec" "a definition specifier" } } +{ $contract "Prettyprints a definition." } ; + +HELP: see-methods +{ $values { "word" "a " { $link generic } " or a " { $link class } } } +{ $contract "Prettyprints the methods defined on a generic word or class." } ; + +HELP: definer +{ $values { "defspec" "a definition specifier" } { "start" word } { "end" "a word or " { $link f } } } +{ $contract "Outputs the parsing words which delimit the definition." } +{ $examples + { $example "USING: definitions prettyprint ;" + "IN: scratchpad" + ": foo ; \\ foo definer . ." + ";\nPOSTPONE: :" + } + { $example "USING: definitions prettyprint ;" + "IN: scratchpad" + "SYMBOL: foo \\ foo definer . ." + "f\nPOSTPONE: SYMBOL:" + } +} +{ $notes "This word is used in the implementation of " { $link see } "." } ; + +HELP: definition +{ $values { "defspec" "a definition specifier" } { "seq" "a sequence" } } +{ $contract "Outputs the body of a definition." } +{ $examples + { $example "USING: definitions math prettyprint ;" "\\ sq definition ." "[ dup * ]" } +} +{ $notes "This word is used in the implementation of " { $link see } "." } ; + +ARTICLE: "see" "Printing definitions" +"The " { $vocab-link "see" } " vocabulary implements support for printing out " { $link "definitions" } " in the image." +$nl +"Printing a definition:" +{ $subsection see } +"Printing the methods defined on a generic word or class (see " { $link "objects" } "):" +{ $subsection see-methods } ; + +ABOUT: "see" \ No newline at end of file diff --git a/basis/see/see.factor b/basis/see/see.factor new file mode 100644 index 0000000000..ab9fa2006f --- /dev/null +++ b/basis/see/see.factor @@ -0,0 +1,227 @@ +! Copyright (C) 2009 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors arrays assocs classes classes.builtin +classes.intersection classes.mixin classes.predicate +classes.singleton classes.tuple classes.union combinators +definitions effects generic generic.standard io io.pathnames +io.streams.string io.styles kernel make namespaces prettyprint +prettyprint.backend prettyprint.config prettyprint.custom +prettyprint.sections sequences sets sorting strings summary +words words.symbol ; +IN: see + +GENERIC: see* ( defspec -- ) + +: see ( defspec -- ) see* nl ; + +: synopsis ( defspec -- str ) + [ + 0 margin set + 1 line-limit set + [ synopsis* ] with-in + ] with-string-writer ; + +: definer. ( defspec -- ) + definer drop pprint-word ; + +: comment. ( text -- ) + H{ { font-style italic } } styled-text ; + +: stack-effect. ( word -- ) + [ [ parsing-word? ] [ symbol? ] bi or not ] [ stack-effect ] bi and + [ effect>string comment. ] when* ; + +<PRIVATE + +: seeing-word ( word -- ) + vocabulary>> pprinter-in set ; + +: word-synopsis ( word -- ) + { + [ seeing-word ] + [ definer. ] + [ pprint-word ] + [ stack-effect. ] + } cleave ; + +M: word synopsis* word-synopsis ; + +M: simple-generic synopsis* word-synopsis ; + +M: standard-generic synopsis* + { + [ definer. ] + [ seeing-word ] + [ pprint-word ] + [ dispatch# pprint* ] + [ stack-effect. ] + } cleave ; + +M: hook-generic synopsis* + { + [ definer. ] + [ seeing-word ] + [ pprint-word ] + [ "combination" word-prop var>> pprint* ] + [ stack-effect. ] + } cleave ; + +M: method-spec synopsis* + first2 method synopsis* ; + +M: method-body synopsis* + [ definer. ] + [ "method-class" word-prop pprint-word ] + [ "method-generic" word-prop pprint-word ] tri ; + +M: mixin-instance synopsis* + [ definer. ] + [ class>> pprint-word ] + [ mixin>> pprint-word ] tri ; + +M: pathname synopsis* pprint* ; + +M: word summary synopsis ; + +GENERIC: declarations. ( obj -- ) + +M: object declarations. drop ; + +: declaration. ( word prop -- ) + [ nip ] [ name>> word-prop ] 2bi + [ pprint-word ] [ drop ] if ; + +M: word declarations. + { + POSTPONE: parsing + POSTPONE: delimiter + POSTPONE: inline + POSTPONE: recursive + POSTPONE: foldable + POSTPONE: flushable + } [ declaration. ] with each ; + +: pprint-; ( -- ) \ ; pprint-word ; + +M: object see* + [ + 12 nesting-limit set + 100 length-limit set + <colon dup synopsis* + <block dup definition pprint-elements block> + dup definer nip [ pprint-word ] when* declarations. + block> + ] with-use ; + +M: method-spec see* + first2 method see* ; + +GENERIC: see-class* ( word -- ) + +M: union-class see-class* + <colon \ UNION: pprint-word + dup pprint-word + members pprint-elements pprint-; block> ; + +M: intersection-class see-class* + <colon \ INTERSECTION: pprint-word + dup pprint-word + participants pprint-elements pprint-; block> ; + +M: mixin-class see-class* + <block \ MIXIN: pprint-word + dup pprint-word <block + dup members [ + hard line-break + \ INSTANCE: pprint-word pprint-word pprint-word + ] with each block> block> ; + +M: predicate-class see-class* + <colon \ PREDICATE: pprint-word + dup pprint-word + "<" text + dup superclass pprint-word + <block + "predicate-definition" word-prop pprint-elements + pprint-; block> block> ; + +M: singleton-class see-class* ( class -- ) + \ SINGLETON: pprint-word pprint-word ; + +GENERIC: pprint-slot-name ( object -- ) + +M: string pprint-slot-name text ; + +M: array pprint-slot-name + <flow \ { pprint-word + f <inset unclip text pprint-elements block> + \ } pprint-word block> ; + +: unparse-slot ( slot-spec -- array ) + [ + dup name>> , + dup class>> object eq? [ + dup class>> , + initial: , + dup initial>> , + ] unless + dup read-only>> [ + read-only , + ] when + drop + ] { } make ; + +: pprint-slot ( slot-spec -- ) + unparse-slot + dup length 1 = [ first ] when + pprint-slot-name ; + +M: tuple-class see-class* + <colon \ TUPLE: pprint-word + dup pprint-word + dup superclass tuple eq? [ + "<" text dup superclass pprint-word + ] unless + <block "slots" word-prop [ pprint-slot ] each block> + pprint-; block> ; + +M: word see-class* drop ; + +M: builtin-class see-class* + drop "! Built-in class" comment. ; + +: see-class ( class -- ) + dup class? [ + [ + [ seeing-word ] [ see-class* ] bi + ] with-use + ] [ drop ] if ; + +M: word see* + [ see-class ] + [ [ class? ] [ symbol? not ] bi and [ nl nl ] when ] + [ + dup [ class? ] [ symbol? ] bi and + [ drop ] [ call-next-method ] if + ] tri ; + +: seeing-implementors ( class -- seq ) + dup implementors [ method ] with map natural-sort ; + +: seeing-methods ( generic -- seq ) + "methods" word-prop values natural-sort ; + +PRIVATE> + +: see-all ( seq -- ) + natural-sort [ nl nl ] [ see* ] interleave ; + +: methods ( word -- seq ) + [ + dup class? [ dup seeing-implementors % ] when + dup generic? [ dup seeing-methods % ] when + drop + ] { } make prune ; + +: see-methods ( word -- ) + methods see-all nl ; \ No newline at end of file diff --git a/basis/see/summary.txt b/basis/see/summary.txt new file mode 100644 index 0000000000..a6274bcfe2 --- /dev/null +++ b/basis/see/summary.txt @@ -0,0 +1 @@ +Printing loaded definitions as source code diff --git a/basis/simple-flat-file/simple-flat-file-tests.factor b/basis/simple-flat-file/simple-flat-file-tests.factor index 5b58f569cb..33b6d4ac2a 100644 --- a/basis/simple-flat-file/simple-flat-file-tests.factor +++ b/basis/simple-flat-file/simple-flat-file-tests.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Yun, Jonghyouk. ! See http://factorcode.org/license.txt for BSD license. -USING: simple-flat-file tools.test memoize ; +USING: simple-flat-file tools.test memoize assocs ; IN: simple-flat-file.tests diff --git a/basis/simple-flat-file/simple-flat-file.factor b/basis/simple-flat-file/simple-flat-file.factor index 53f5f16425..403fc4d14b 100644 --- a/basis/simple-flat-file/simple-flat-file.factor +++ b/basis/simple-flat-file/simple-flat-file.factor @@ -7,10 +7,13 @@ IN: simple-flat-file [ "#" split1 drop ] map harvest ; : split-column ( line -- columns ) - "\t" split 2 head ; + " \t" split harvest 2 short head 2 f pad-tail ; : parse-hex ( s -- n ) - 2 short tail hex> ; + dup [ + "0x" ?head [ "U+" ?head [ "Missing 0x or U+" throw ] unless ] unless + hex> + ] when ; : parse-line ( line -- code-unicode ) split-column [ parse-hex ] map ; diff --git a/basis/simple-flat-file/test1.txt b/basis/simple-flat-file/test1.txt new file mode 100644 index 0000000000..3437a61c38 --- /dev/null +++ b/basis/simple-flat-file/test1.txt @@ -0,0 +1,15 @@ +# +# Name: cp949 to Unicode table (for testing, partial) +# +0x00 0x0000 #NULL +0x01 0x0001 #START OF HEADING +0x02 0x0002 #START OF TEXT +0x03 0x0003 #END OF TEXT +0x04 0x0004 #END OF TRANSMISSION +0x8253 0xAD2A #HANGUL SYLLABLE KIYEOK WAE PIEUPSIOS +0x8254 0xAD2B #HANGUL SYLLABLE KIYEOK WAE SIOS +0x8255 0xAD2E #HANGUL SYLLABLE KIYEOK WAE CIEUC +0x8256 0xAD2F #HANGUL SYLLABLE KIYEOK WAE CHIEUCH +0x8257 0xAD30 #HANGUL SYLLABLE KIYEOK WAE KHIEUKH +0x8258 0xAD31 #HANGUL SYLLABLE KIYEOK WAE THIEUTH +0x8259 0xAD32 #HANGUL SYLLABLE KIYEOK WAE PHIEUPH diff --git a/basis/stack-checker/backend/backend.factor b/basis/stack-checker/backend/backend.factor index 78f357b1cb..9e867f4fbb 100755 --- a/basis/stack-checker/backend/backend.factor +++ b/basis/stack-checker/backend/backend.factor @@ -155,7 +155,7 @@ M: object apply-object push-literal ; "cannot-infer" word-prop rethrow ; : maybe-cannot-infer ( word quot -- ) - [ [ "cannot-infer" set-word-prop ] keep throw ] recover ; inline + [ [ "cannot-infer" set-word-prop ] keep rethrow ] recover ; inline : infer-word ( word -- effect ) [ diff --git a/basis/stack-checker/stack-checker-tests.factor b/basis/stack-checker/stack-checker-tests.factor index 6e7774aba1..c881ccee11 100644 --- a/basis/stack-checker/stack-checker-tests.factor +++ b/basis/stack-checker/stack-checker-tests.factor @@ -288,7 +288,7 @@ DEFER: bar [ [ [ dup call ] dup call ] infer ] [ inference-error? ] must-fail-with -: m dup call ; inline +: m ( q -- ) dup call ; inline [ [ [ m ] m ] infer ] [ inference-error? ] must-fail-with @@ -296,13 +296,13 @@ DEFER: bar [ [ [ m' ] m' ] infer ] [ inference-error? ] must-fail-with -: m'' [ dup curry ] ; inline +: m'' ( -- q ) [ dup curry ] ; inline -: m''' m'' call call ; inline +: m''' ( -- ) m'' call call ; inline [ [ [ m''' ] m''' ] infer ] [ inference-error? ] must-fail-with -: m-if t over if ; inline +: m-if ( a b c -- ) t over if ; inline [ [ [ m-if ] m-if ] infer ] [ inference-error? ] must-fail-with @@ -488,7 +488,7 @@ ERROR: custom-error ; [ custom-error ] infer ] unit-test -: funny-throw throw ; inline +: funny-throw ( a -- * ) throw ; inline [ T{ effect f 0 0 t } ] [ [ 3 funny-throw ] infer @@ -502,12 +502,8 @@ ERROR: custom-error ; [ dup [ 3 throw ] dip ] infer ] unit-test -! This was a false trigger of the undecidable quotation -! recursion bug -{ 2 1 } [ find-last-sep ] must-infer-as - ! Regression -: missing->r-check 1 load-locals ; +: missing->r-check ( a -- ) 1 load-locals ; [ [ missing->r-check ] infer ] must-fail @@ -516,7 +512,7 @@ ERROR: custom-error ; [ [ [ f dup ] [ ] while ] infer ] must-fail -: erg's-inference-bug ( -- ) f dup [ erg's-inference-bug ] when ; inline +: erg's-inference-bug ( -- ) f dup [ erg's-inference-bug ] when ; inline recursive [ [ erg's-inference-bug ] infer ] must-fail @@ -544,10 +540,10 @@ M: object inference-invalidation-d inference-invalidation-c 2drop ; [ [ inference-invalidation-d ] infer ] must-fail -: bad-recursion-3 ( -- ) dup [ [ bad-recursion-3 ] dip ] when ; inline +: bad-recursion-3 ( -- ) dup [ [ bad-recursion-3 ] dip ] when ; inline recursive [ [ bad-recursion-3 ] infer ] must-fail -: bad-recursion-4 ( -- ) 4 [ dup call roll ] times ; inline +: bad-recursion-4 ( -- ) 4 [ dup call roll ] times ; inline recursive [ [ [ ] [ 1 2 3 ] over dup bad-recursion-4 ] infer ] must-fail : bad-recursion-5 ( obj quot: ( -- ) -- ) dup call swap bad-recursion-5 ; inline recursive diff --git a/basis/tools/annotations/annotations-tests.factor b/basis/tools/annotations/annotations-tests.factor index 2a65ea5236..7e377aedd9 100644 --- a/basis/tools/annotations/annotations-tests.factor +++ b/basis/tools/annotations/annotations-tests.factor @@ -1,5 +1,5 @@ USING: tools.test tools.annotations tools.time math parser eval -io.streams.string kernel ; +io.streams.string kernel strings ; IN: tools.annotations.tests : foo ; @@ -45,4 +45,4 @@ M: string blah-generic ; { string blah-generic } watch -[ ] [ "hi" blah-generic ] unit-test \ No newline at end of file +[ "hi" ] [ "hi" blah-generic ] unit-test diff --git a/basis/tools/crossref/crossref-docs.factor b/basis/tools/crossref/crossref-docs.factor index 820c957cbc..f49ac7ea76 100644 --- a/basis/tools/crossref/crossref-docs.factor +++ b/basis/tools/crossref/crossref-docs.factor @@ -3,7 +3,7 @@ IN: tools.crossref ARTICLE: "tools.crossref" "Cross-referencing tools" { $subsection usage. } -{ $see-also "definitions" "words" see see-methods } ; +{ $see-also "definitions" "words" "see" } ; ABOUT: "tools.crossref" diff --git a/basis/tools/crossref/crossref.factor b/basis/tools/crossref/crossref.factor index 494e022243..36ccaadc98 100644 --- a/basis/tools/crossref/crossref.factor +++ b/basis/tools/crossref/crossref.factor @@ -1,11 +1,11 @@ -! Copyright (C) 2005, 2008 Slava Pestov. +! Copyright (C) 2005, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: assocs definitions io io.styles kernel prettyprint -sorting ; +sorting see ; IN: tools.crossref : synopsis-alist ( definitions -- alist ) - [ dup synopsis swap ] { } map>assoc ; + [ [ synopsis ] keep ] { } map>assoc ; : definitions. ( alist -- ) [ write-object nl ] assoc-each ; diff --git a/basis/tools/deploy/backend/backend.factor b/basis/tools/deploy/backend/backend.factor index 7d8f357240..28a32790dc 100755 --- a/basis/tools/deploy/backend/backend.factor +++ b/basis/tools/deploy/backend/backend.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2007, 2008 Slava Pestov. +! Copyright (C) 2007, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: namespaces make continuations.private kernel.private init assocs kernel vocabs words sequences memory io system arrays @@ -14,9 +14,14 @@ IN: tools.deploy.backend : copy-vm ( executable bundle-name -- vm ) prepend-path vm over copy-file ; -: copy-fonts ( name dir -- ) +CONSTANT: theme-path "basis/ui/gadgets/theme/" + +: copy-theme ( name dir -- ) deploy-ui? get [ - append-path "resource:fonts/" swap copy-tree-into + append-path + theme-path append-path + [ make-directories ] + [ theme-path "resource:" prepend swap copy-tree ] bi ] [ 2drop ] if ; : image-name ( vocab bundle-name -- str ) diff --git a/basis/tools/deploy/unix/unix.factor b/basis/tools/deploy/unix/unix.factor index c9bf308357..f88cf06ef7 100755 --- a/basis/tools/deploy/unix/unix.factor +++ b/basis/tools/deploy/unix/unix.factor @@ -7,7 +7,7 @@ tools.deploy.config.editor assocs hashtables prettyprint ; IN: tools.deploy.unix : create-app-dir ( vocab bundle-name -- vm ) - dup "" copy-fonts + dup "" copy-theme copy-vm dup OCT: 755 set-file-permissions ; diff --git a/basis/tools/deploy/windows/windows.factor b/basis/tools/deploy/windows/windows.factor index 0e9146b26e..bfa096ad2f 100755 --- a/basis/tools/deploy/windows/windows.factor +++ b/basis/tools/deploy/windows/windows.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2007, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: io io.files io.pathnames io.directories kernel namespaces +USING: io io.files io.pathnames io.directories io.encodings.ascii kernel namespaces sequences locals system splitting tools.deploy.backend tools.deploy.config tools.deploy.config.editor assocs hashtables prettyprint combinators windows.shell32 windows.user32 ; @@ -9,11 +9,10 @@ IN: tools.deploy.windows : copy-dll ( bundle-name -- ) "resource:factor.dll" swap copy-file-into ; -: copy-freetype ( bundle-name -- ) - { - "resource:freetype6.dll" - "resource:zlib1.dll" - } swap copy-files-into ; +: copy-pango ( bundle-name -- ) + "resource:build-support/dlls.txt" ascii file-lines + [ "resource:" prepend-path ] map + swap copy-files-into ; :: copy-vm ( executable bundle-name extension -- vm ) vm "." split1-last drop extension append @@ -23,8 +22,8 @@ IN: tools.deploy.windows : create-exe-dir ( vocab bundle-name -- vm ) dup copy-dll deploy-ui? get [ - [ copy-freetype ] - [ "" copy-fonts ] + [ copy-pango ] + [ "" copy-theme ] [ ".exe" copy-vm ] tri ] [ ".com" copy-vm ] if ; diff --git a/basis/tools/memory/memory.factor b/basis/tools/memory/memory.factor index 9b727b48de..3d9166aafa 100644 --- a/basis/tools/memory/memory.factor +++ b/basis/tools/memory/memory.factor @@ -63,11 +63,12 @@ PRIVATE> { "" "Total" "Used" "Free" } write-headings (data-room.) ] tabular-output - nl + nl nl "==== CODE HEAP" print standard-table-style [ (code-room.) - ] tabular-output ; + ] tabular-output + nl ; : heap-stats ( -- counts sizes ) [ ] instances H{ } clone H{ } clone @@ -83,4 +84,4 @@ PRIVATE> pick at pprint-cell ] with-row ] each 2drop - ] tabular-output ; + ] tabular-output nl ; diff --git a/basis/tools/profiler/profiler.factor b/basis/tools/profiler/profiler.factor index 19646e55c2..864a637096 100644 --- a/basis/tools/profiler/profiler.factor +++ b/basis/tools/profiler/profiler.factor @@ -46,9 +46,7 @@ IN: tools.profiler profiler-usage counters ; : counters. ( assoc -- ) - standard-table-style [ - sort-values simple-table. - ] tabular-output ; + sort-values simple-table. ; : profile. ( -- ) "Call counts for all words:" print diff --git a/basis/tools/threads/threads.factor b/basis/tools/threads/threads.factor index fc4ba1f6b2..18dd8ce2b7 100644 --- a/basis/tools/threads/threads.factor +++ b/basis/tools/threads/threads.factor @@ -29,4 +29,4 @@ IN: tools.threads threads >alist sort-keys values [ [ thread. ] with-row ] each - ] tabular-output ; + ] tabular-output nl ; diff --git a/basis/tools/vocabs/browser/browser.factor b/basis/tools/vocabs/browser/browser.factor index 3550424b83..6a3f2df8a3 100644 --- a/basis/tools/vocabs/browser/browser.factor +++ b/basis/tools/vocabs/browser/browser.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2007, 2008 Slava Pestov. +! Copyright (C) 2007, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs classes classes.builtin classes.intersection classes.mixin classes.predicate @@ -66,15 +66,18 @@ C: <vocab-author> vocab-author : describe-children ( vocab -- ) vocab-name all-child-vocabs $vocab-roots ; +: files. ( seq -- ) + snippet-style get [ + code-style get [ + [ nl ] [ [ string>> ] keep write-object ] interleave + ] with-nesting + ] with-style ; + : describe-files ( vocab -- ) vocab-files [ <pathname> ] map [ "Files" $heading [ - snippet-style get [ - code-style get [ - stack. - ] with-nesting - ] with-style + files. ] ($block) ] unless-empty ; @@ -221,7 +224,7 @@ C: <vocab-author> vocab-author : words. ( vocab -- ) last-element off - [ require ] [ words $words ] bi ; + [ require ] [ words $words ] bi nl ; : describe-metadata ( vocab -- ) [ @@ -288,7 +291,7 @@ M: vocab-tag article-name name>> ; M: vocab-tag article-content \ $tagged-vocabs swap name>> 2array ; -M: vocab-tag article-parent drop "vocab-index" ; +M: vocab-tag article-parent drop "vocab-tags" ; M: vocab-tag summary article-title ; @@ -302,6 +305,6 @@ M: vocab-author article-name name>> ; M: vocab-author article-content \ $authored-vocabs swap name>> 2array ; -M: vocab-author article-parent drop "vocab-index" ; +M: vocab-author article-parent drop "vocab-authors" ; M: vocab-author summary article-title ; diff --git a/basis/ui/gadgets/canvas/canvas.factor b/basis/ui/gadgets/canvas/canvas.factor index 1c36f4f9fd..710a9fb492 100644 --- a/basis/ui/gadgets/canvas/canvas.factor +++ b/basis/ui/gadgets/canvas/canvas.factor @@ -1,14 +1,14 @@ -! Copyright (C) 2007 Slava Pestov. +! Copyright (C) 2007, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: ui.backend ui.gadgets -ui.gadgets.worlds ui.render opengl opengl.gl kernel namespaces -classes.tuple colors accessors ; +USING: ui.backend ui.gadgets ui.gadgets.worlds ui.pens.solid opengl +opengl.gl kernel namespaces classes.tuple colors colors.constants +accessors ; IN: ui.gadgets.canvas TUPLE: canvas < gadget dlist ; : new-canvas ( class -- canvas ) - new black <solid> >>interior ; inline + new COLOR: black <solid> >>interior ; inline : delete-canvas-dlist ( canvas -- ) [ find-gl-context ] @@ -23,8 +23,6 @@ TUPLE: canvas < gadget dlist ; [ 2nip ] [ drop make-canvas-dlist ] if ; inline : draw-canvas ( canvas quot -- ) - origin get [ - cache-canvas-dlist glCallList - ] with-translation ; inline + cache-canvas-dlist glCallList ; inline M: canvas ungraft* delete-canvas-dlist ; diff --git a/basis/ui/gadgets/glass/glass-docs.factor b/basis/ui/gadgets/glass/glass-docs.factor new file mode 100644 index 0000000000..bd9028d414 --- /dev/null +++ b/basis/ui/gadgets/glass/glass-docs.factor @@ -0,0 +1,55 @@ +IN: ui.gadgets.glass +USING: help.markup help.syntax ui.gadgets math.rectangles ; + +HELP: show-glass +{ $values { "owner" gadget } { "child" gadget } { "visible-rect" rect } } +{ $description "Displays " { $snippet "child" } " in the glass layer of the window containing " { $snippet "owner" } "." + $nl + "The child's position is calculated with a heuristic:" + { $list + "The child must fit inside the window" + { "The child must not obscure " { $snippet "visible-rect" } ", which is a rectangle whose origin is relative to " { $snippet "owner" } } + { "The child must otherwise be as close as possible to the edges of " { $snippet "visible-rect" } } + } + "For example, when displaying a menu, " { $snippet "visible-rect" } " is a single point at the mouse location, and when displaying a completion popup, " { $snippet "visible-rect" } " contains the bounds of the text element being completed." +} ; + +HELP: hide-glass +{ $values { "child" gadget } } +{ $description "Hides a gadget displayed in a glass layer." } ; + +HELP: hide-glass-hook +{ $values { "gadget" gadget } } +{ $description "Called when a gadget displayed in a glass layer is hidden. The gadget can perform cleanup tasks here." } ; + +HELP: pass-to-popup +{ $values { "gesture" "a gesture" } { "owner" "the popup's owner" } { "?" "a boolean" } } +{ $description "Resends the gesture to the popup displayed by " { $snippet "owner" } ". The owner must have a " { $slot "popup" } " slot. Outputs " { $link f } " if the gesture was handled, " { $link t } " otherwise." } ; + +HELP: show-popup +{ $values { "owner" gadget } { "popup" gadget } { "visible-rect" rect } } +{ $description "Displays " { $snippet "popup" } " in the glass layer of the window containing " { $snippet "owner" } " as a popup." + $nl + "This word differs from " { $link show-glass } " in two respects:" + { $list + { "The popup is stored in the owner's " { $slot "popup" } " slot; the owner can call " { $link pass-to-popup } " to pass keyboard gestures to the popup" } + { "Pressing " { $snippet "ESC" } " with the popup visible will hide it" } + } +} ; + +ARTICLE: "ui.gadgets.glass" "Glass layers" +"The " { $vocab-link "ui.gadgets.glass" } " vocabulary implements support for displaying gadgets in the glass layer of a window. The gadget can be positioned arbitrarily within the glass layer, and while it is visible, mouse clicks outside of the glass layer are intercepted to hide the glass layer. Multiple glass layers can be active at a time; they behave as if stacked on top of each other." +$nl +"This feature is used for completion popups and " { $link "ui.gadgets.menus" } " in the " { $link "ui-tools" } "." +$nl +"Displaying a gadget in a glass layer:" +{ $subsection show-glass } +"Hiding a gadget in a glass layer:" +{ $subsection hide-glass } +"Callback generic invoked on the gadget when its glass layer is hidden:" +{ $subsection hide-glass-hook } +"Popup gadgets add support for forwarding keyboard gestures from an owner gadget to the glass layer:" +{ $subsection show-popup } +{ $subsection pass-to-popup } ; + +ABOUT: "ui.gadgets.glass" \ No newline at end of file diff --git a/basis/ui/gadgets/glass/glass.factor b/basis/ui/gadgets/glass/glass.factor index a8f438c85e..af169235b4 100644 --- a/basis/ui/gadgets/glass/glass.factor +++ b/basis/ui/gadgets/glass/glass.factor @@ -71,7 +71,7 @@ popup H{ { T{ key-down f f "ESC" } [ hide-glass ] } } set-gestures -: pass-to-popup ( gesture interactor -- ? ) +: pass-to-popup ( gesture owner -- ? ) popup>> focusable-child resend-gesture ; : show-popup ( owner popup visible-rect -- ) diff --git a/basis/ui/gadgets/menus/menus-docs.factor b/basis/ui/gadgets/menus/menus-docs.factor index d7297217ed..ad0881a382 100644 --- a/basis/ui/gadgets/menus/menus-docs.factor +++ b/basis/ui/gadgets/menus/menus-docs.factor @@ -16,7 +16,7 @@ HELP: show-commands-menu { $notes "Useful for right-click context menus." } ; ARTICLE: "ui.gadgets.menus" "Popup menus" -"The " { $vocab-link "ui.gadgets.menus" } " vocabulary implements popup menus." +"The " { $vocab-link "ui.gadgets.menus" } " vocabulary displays popup menus in " { $link "ui.gadgets.glass" } "." { $subsection <commands-menu> } { $subsection show-menu } { $subsection show-commands-menu } ; diff --git a/basis/ui/gadgets/panes/panes-docs.factor b/basis/ui/gadgets/panes/panes-docs.factor index afb2307b1e..cb747bf84d 100644 --- a/basis/ui/gadgets/panes/panes-docs.factor +++ b/basis/ui/gadgets/panes/panes-docs.factor @@ -26,10 +26,6 @@ HELP: gadget. { $description "Writes a gadget followed by a newline to " { $link output-stream } "." } { $notes "Not all streams support this operation." } ; -HELP: ?nl -{ $values { "stream" pane-stream } } -{ $description "Inserts a line break in the pane unless the current line is empty." } ; - HELP: with-pane { $values { "pane" pane } { "quot" quotation } } { $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." } ; diff --git a/basis/ui/gadgets/panes/panes-tests.factor b/basis/ui/gadgets/panes/panes-tests.factor index 680b6fe57f..2947ce242d 100644 --- a/basis/ui/gadgets/panes/panes-tests.factor +++ b/basis/ui/gadgets/panes/panes-tests.factor @@ -2,7 +2,7 @@ USING: alien ui.gadgets.panes ui.gadgets namespaces kernel sequences io io.styles io.streams.string tools.test prettyprint definitions help help.syntax help.markup help.stylesheet splitting tools.test.ui models math summary -inspector accessors help.topics ; +inspector accessors help.topics see ; IN: ui.gadgets.panes.tests : #children "pane" get children>> length ; @@ -19,7 +19,7 @@ IN: ui.gadgets.panes.tests : test-gadget-text ( quot -- ? ) dup make-pane gadget-text dup print "======" print - swap with-string-writer dup print "\n" ?tail drop "\n" ?tail drop = ; + swap with-string-writer dup print = ; [ t ] [ [ "hello" write ] test-gadget-text ] unit-test [ t ] [ [ "hello" pprint ] test-gadget-text ] unit-test @@ -87,6 +87,28 @@ IN: ui.gadgets.panes.tests ] test-gadget-text ] unit-test +[ t ] [ + [ + last-element off + \ = >link title-style get [ + $navigation-table + ] with-nesting + "Hello world" print-content + ] test-gadget-text +] unit-test + +[ t ] [ + [ { { "a\n" } } simple-table. ] test-gadget-text +] unit-test + +[ t ] [ + [ { { "a" } } simple-table. "x" write ] test-gadget-text +] unit-test + +[ t ] [ + [ H{ } [ { { "a" } } simple-table. ] with-nesting "x" write ] test-gadget-text +] unit-test + ARTICLE: "test-article-1" "This is a test article" "Hello world, how are you today." ; diff --git a/basis/ui/gadgets/panes/panes.factor b/basis/ui/gadgets/panes/panes.factor index aef8fda066..28dc7e3ead 100644 --- a/basis/ui/gadgets/panes/panes.factor +++ b/basis/ui/gadgets/panes/panes.factor @@ -17,6 +17,12 @@ TUPLE: pane < track output current input last-line prototype scrolls? selection-color caret mark selecting? ; +TUPLE: pane-stream pane ; + +C: <pane-stream> pane-stream + +<PRIVATE + : clear-selection ( pane -- pane ) f >>caret f >>mark ; inline @@ -29,11 +35,14 @@ selection-color caret mark selecting? ; : init-current ( pane -- pane ) dup prototype>> clone >>current ; inline +: focus-input ( pane -- ) + input>> [ request-focus ] when* ; + : next-line ( pane -- ) clear-selection [ input>> unparent ] [ init-current prepare-last-line ] - [ input>> [ request-focus ] when* ] tri ; + [ focus-input ] tri ; : pane-caret&mark ( pane -- caret mark ) [ caret>> ] [ mark>> ] bi ; inline @@ -46,12 +55,6 @@ M: pane gadget-selection? pane-caret&mark and ; M: pane gadget-selection ( pane -- string/f ) selected-children gadget-text ; -: pane-clear ( pane -- ) - clear-selection - [ output>> clear-incremental ] - [ current>> clear-gadget ] - bi ; - : init-prototype ( pane -- pane ) <shelf> +baseline+ >>align >>prototype ; inline @@ -63,21 +66,10 @@ M: pane gadget-selection ( pane -- string/f ) selection-color >>selection-color ; inline : init-last-line ( pane -- pane ) - horizontal <track> + horizontal <track> 0 >>fill +baseline+ >>align [ >>last-line ] [ 1 track-add ] bi dup prepare-last-line ; inline -: new-pane ( input class -- pane ) - [ vertical ] dip new-track - swap >>input - pane-theme - init-prototype - init-output - init-current - init-last-line ; inline - -: <pane> ( -- pane ) f pane new-pane ; - GENERIC: draw-selection ( loc obj -- ) : if-fits ( rect quot -- ) @@ -101,7 +93,7 @@ M: pane draw-gadget* dup gadget-selection? [ [ selection-color>> gl-color ] [ - [ [ origin get ] dip loc>> v- ] keep selected-children + [ loc>> vneg ] keep selected-children [ draw-selection ] with each ] bi ] [ drop ] if ; @@ -109,10 +101,6 @@ M: pane draw-gadget* : scroll-pane ( pane -- ) dup scrolls?>> [ scroll>bottom ] [ drop ] if ; -TUPLE: pane-stream pane ; - -C: <pane-stream> pane-stream - : smash-line ( current -- gadget ) dup children>> { { [ dup empty? ] [ 2drop "" <label> ] } @@ -120,14 +108,18 @@ C: <pane-stream> pane-stream [ drop ] } cond ; -: smash-pane ( pane -- gadget ) output>> smash-line ; - : pane-nl ( pane -- ) [ [ current>> [ unparent ] [ smash-line ] bi ] [ output>> ] bi add-incremental ] [ next-line ] bi ; +: ?pane-nl ( pane -- ) + [ dup current>> children>> empty? [ pane-nl ] [ drop ] if ] + [ pane-nl ] bi ; + +: smash-pane ( pane -- gadget ) [ pane-nl ] [ output>> smash-line ] bi ; + : pane-write ( seq pane -- ) [ pane-nl ] [ current>> stream-write ] bi-curry interleave ; @@ -136,43 +128,6 @@ C: <pane-stream> pane-stream [ nip pane-nl ] [ current>> stream-format ] bi-curry bi-curry interleave ; -GENERIC: write-gadget ( gadget stream -- ) - -M: pane-stream write-gadget ( gadget pane-stream -- ) - pane>> current>> swap add-gadget drop ; - -M: style-stream write-gadget - stream>> write-gadget ; - -: print-gadget ( gadget stream -- ) - [ write-gadget ] [ nip stream-nl ] 2bi ; - -: gadget. ( gadget -- ) - output-stream get print-gadget ; - -: ?nl ( stream -- ) - dup pane>> current>> children>> empty? - [ dup stream-nl ] unless drop ; - -: with-pane ( pane quot -- ) - over scroll>top - over pane-clear [ <pane-stream> ] dip - over [ with-output-stream* ] dip ?nl ; inline - -: make-pane ( quot -- gadget ) - <pane> [ swap with-pane ] keep smash-pane ; inline - -TUPLE: pane-control < pane quot ; - -M: pane-control model-changed ( model pane-control -- ) - [ value>> ] [ dup quot>> ] bi* - '[ _ call( value -- ) ] with-pane ; - -: <pane-control> ( model quot -- pane ) - f pane-control new-pane - swap >>quot - swap >>model ; - : do-pane-stream ( pane-stream quot -- ) [ pane>> ] dip keep scroll-pane ; inline @@ -195,7 +150,59 @@ M: pane-stream stream-flush drop ; M: pane-stream make-span-stream swap <style-stream> <ignore-close-stream> ; +PRIVATE> + +: new-pane ( input class -- pane ) + [ vertical ] dip new-track + swap >>input + pane-theme + init-prototype + init-output + init-current + init-last-line ; inline + +: <pane> ( -- pane ) f pane new-pane ; + +GENERIC: write-gadget ( gadget stream -- ) + +M: pane-stream write-gadget ( gadget pane-stream -- ) + pane>> current>> swap add-gadget drop ; + +M: style-stream write-gadget + stream>> write-gadget ; + +: print-gadget ( gadget stream -- ) + [ write-gadget ] [ nip stream-nl ] 2bi ; + +: gadget. ( gadget -- ) + output-stream get print-gadget ; + +: pane-clear ( pane -- ) + clear-selection + [ output>> clear-incremental ] + [ current>> clear-gadget ] + bi ; + +: with-pane ( pane quot -- ) + [ [ scroll>top ] [ pane-clear ] [ <pane-stream> ] tri ] dip + with-output-stream* ; inline + +: make-pane ( quot -- gadget ) + [ <pane> ] dip [ with-pane ] [ drop smash-pane ] 2bi ; inline + +TUPLE: pane-control < pane quot ; + +M: pane-control model-changed ( model pane-control -- ) + [ value>> ] [ dup quot>> ] bi* + '[ _ call( value -- ) ] with-pane ; + +: <pane-control> ( model quot -- pane ) + f pane-control new-pane + swap >>quot + swap >>model ; + ! Character styles +<PRIVATE MEMO: specified-font ( assoc -- font ) #! We memoize here to avoid creating lots of duplicate font objects. @@ -276,10 +283,7 @@ TUPLE: nested-pane-stream < pane-stream style parent ; inline : unnest-pane-stream ( stream -- child parent ) - dup ?nl - dup style>> - over pane>> smash-pane style-pane - swap parent>> ; + [ [ style>> ] [ pane>> smash-pane ] bi style-pane ] [ parent>> ] bi ; TUPLE: pane-block-stream < nested-pane-stream ; @@ -306,7 +310,7 @@ M: pane-stream make-block-stream TUPLE: pane-cell-stream < nested-pane-stream ; -M: pane-cell-stream dispose ?nl ; +M: pane-cell-stream dispose drop ; M: pane-stream make-cell-stream pane-cell-stream new-nested-pane-stream ; @@ -315,7 +319,7 @@ M: pane-stream stream-write-table [ swap [ [ pane>> smash-pane ] map ] map styled-grid - ] dip print-gadget ; + ] dip write-gadget ; ! Stream utilities M: pack dispose drop ; @@ -364,9 +368,8 @@ M: paragraph stream-format interleave ] if ; -: caret>mark ( pane -- pane ) - dup caret>> >>mark - dup relayout-1 ; +: caret>mark ( pane -- ) + dup caret>> >>mark relayout-1 ; GENERIC: sloppy-pick-up* ( loc gadget -- n ) @@ -388,48 +391,51 @@ M: f sloppy-pick-up* [ 3drop { } ] if ; -: move-caret ( pane loc -- pane ) +: move-caret ( pane loc -- ) over screen-loc v- over sloppy-pick-up >>caret - dup relayout-1 ; + relayout-1 ; : begin-selection ( pane -- ) f >>selecting? - hand-loc get move-caret + dup hand-loc get move-caret f >>mark drop ; : extend-selection ( pane -- ) hand-moved? [ - dup selecting?>> [ - hand-loc get move-caret - ] [ - dup hand-clicked get child? [ - t >>selecting? - dup hand-clicked set-global - hand-click-loc get move-caret - caret>mark - ] when - ] if - dup dup caret>> gadget-at-path scroll>gadget - ] when drop ; + [ + dup selecting?>> [ + hand-loc get move-caret + ] [ + dup hand-clicked get child? [ + t >>selecting? + [ hand-clicked set-global ] + [ hand-click-loc get move-caret ] + [ caret>mark ] + tri + ] [ drop ] if + ] if + ] [ dup caret>> gadget-at-path scroll>gadget ] bi + ] [ drop ] if ; : end-selection ( pane -- ) f >>selecting? - hand-moved? [ - [ com-copy-selection ] [ request-focus ] bi - ] [ - relayout-1 - ] if ; + hand-moved? + [ [ com-copy-selection ] [ request-focus ] bi ] + [ [ relayout-1 ] [ focus-input ] bi ] + if ; : select-to-caret ( pane -- ) t >>selecting? - dup mark>> [ caret>mark ] unless - hand-loc get move-caret - dup request-focus - com-copy-selection ; + [ dup mark>> [ dup caret>mark ] unless hand-loc get move-caret ] + [ com-copy-selection ] + [ request-focus ] + tri ; : pane-menu ( pane -- ) { com-copy } show-commands-menu ; +PRIVATE> + pane H{ { T{ button-down } [ begin-selection ] } { T{ button-down f { S+ } 1 } [ select-to-caret ] } diff --git a/basis/ui/gadgets/status-bar/status-bar-docs.factor b/basis/ui/gadgets/status-bar/status-bar-docs.factor index f5a6409fca..57c69c2a66 100644 --- a/basis/ui/gadgets/status-bar/status-bar-docs.factor +++ b/basis/ui/gadgets/status-bar/status-bar-docs.factor @@ -3,7 +3,7 @@ ui.gadgets ui.gadgets.worlds ui ; IN: ui.gadgets.status-bar HELP: show-status -{ $values { "string" string } { "gadget" gadget } } +{ $values { "string/f" string } { "gadget" gadget } } { $description "Displays a status message in the gadget's world." } { $notes "The status message will only be visible if the window was opened with " { $link open-status-window } ", and not " { $link open-window } "." } ; diff --git a/basis/ui/gestures/gestures.factor b/basis/ui/gestures/gestures.factor index 744cb1dc50..2e52a2fe1e 100644 --- a/basis/ui/gestures/gestures.factor +++ b/basis/ui/gestures/gestures.factor @@ -306,12 +306,18 @@ M: macosx modifiers>string M: object modifiers>string [ name>> ] map "" join ; +HOOK: keysym>string os ( keysym -- string ) + +M: macosx keysym>string >upper ; + +M: object keysym>string ; + M: key-down gesture>string [ mods>> ] [ sym>> ] bi { { [ dup { [ length 1 = ] [ first LETTER? ] } 1&& ] [ [ S+ prefix ] dip ] } { [ dup " " = ] [ drop "SPACE" ] } - [ >upper ] + [ keysym>string ] } cond [ modifiers>string ] dip append ; diff --git a/basis/ui/pens/gradient/gradient.factor b/basis/ui/pens/gradient/gradient.factor index a137ae022b..485015b898 100644 --- a/basis/ui/pens/gradient/gradient.factor +++ b/basis/ui/pens/gradient/gradient.factor @@ -41,4 +41,6 @@ M: gradient draw-interior [ last-vertices>> gl-vertex-pointer ] [ last-colors>> gl-color-pointer ] [ colors>> draw-gradient ] - } cleave ; \ No newline at end of file + } cleave ; + +M: gradient pen-background 2drop transparent ; \ No newline at end of file diff --git a/basis/ui/pens/polygon/polygon-docs.factor b/basis/ui/pens/polygon/polygon-docs.factor index 706c1449a6..dfe687f398 100644 --- a/basis/ui/pens/polygon/polygon-docs.factor +++ b/basis/ui/pens/polygon/polygon-docs.factor @@ -1,5 +1,5 @@ +USING: colors help.markup help.syntax ui.pens ; IN: ui.pens.polygon -USING: help.markup help.syntax ; HELP: polygon { $class-description "A class implementing the " { $link draw-boundary } " and " { $link draw-interior } " generic words to draw a solid outline or a solid filled polygon, respectively. Instances of " { $link polygon } " have two slots:" diff --git a/basis/ui/pens/polygon/polygon.factor b/basis/ui/pens/polygon/polygon.factor index 4fc05c468b..d244cc71d2 100644 --- a/basis/ui/pens/polygon/polygon.factor +++ b/basis/ui/pens/polygon/polygon.factor @@ -1,6 +1,8 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: ; +USING: accessors colors help.markup help.syntax kernel opengl +opengl.gl sequences specialized-arrays.float math.vectors +ui.gadgets ui.pens ; IN: ui.pens.polygon ! Polygon pen @@ -29,4 +31,8 @@ M: polygon draw-interior [ color>> gl-color ] [ interior-vertices>> gl-vertex-pointer ] [ [ GL_POLYGON 0 ] dip interior-count>> glDrawArrays ] - tri ; \ No newline at end of file + tri ; + +: <polygon-gadget> ( color points -- gadget ) + [ <polygon> ] [ { 0 0 } [ vmax ] reduce ] bi + [ <gadget> ] 2dip [ >>interior ] [ >>dim ] bi* ; \ No newline at end of file diff --git a/basis/ui/pens/solid/solid.factor b/basis/ui/pens/solid/solid.factor index 32d400463e..950035e773 100644 --- a/basis/ui/pens/solid/solid.factor +++ b/basis/ui/pens/solid/solid.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel accessors opengl ui.pens ui.pens.caching ; +USING: kernel accessors opengl math colors ui.pens ui.pens.caching ; IN: ui.pens.solid TUPLE: solid < caching-pen color interior-vertices boundary-vertices ; @@ -29,4 +29,4 @@ M: solid draw-boundary (gl-rect) ; M: solid pen-background - nip color>> ; \ No newline at end of file + nip color>> dup alpha>> 1 number= [ drop transparent ] unless ; \ No newline at end of file diff --git a/unmaintained/fs/tags.txt b/basis/ui/text/pango/tags.txt similarity index 100% rename from unmaintained/fs/tags.txt rename to basis/ui/text/pango/tags.txt diff --git a/basis/ui/tools/browser/browser.factor b/basis/ui/tools/browser/browser.factor index 8fcd14c95f..078ece6546 100644 --- a/basis/ui/tools/browser/browser.factor +++ b/basis/ui/tools/browser/browser.factor @@ -86,7 +86,9 @@ M: browser-gadget focusable-child* search-field>> ; [ [ raise-window ] [ gadget-child show-help ] bi ] [ (browser-window) ] if* ; -: show-browser ( -- ) "handbook" com-browse ; +: show-browser ( -- ) + [ browser-gadget? ] find-window + [ raise-window ] [ browser-window ] if* ; \ show-browser H{ { +nullary+ t } } define-command diff --git a/basis/ui/tools/inspector/inspector.factor b/basis/ui/tools/inspector/inspector.factor index 17ffc9ee18..35fa5e3c17 100644 --- a/basis/ui/tools/inspector/inspector.factor +++ b/basis/ui/tools/inspector/inspector.factor @@ -33,19 +33,19 @@ M: inspector-renderer column-titles [ [ [ "Class:" write ] with-cell - [ class . ] with-cell + [ class pprint ] with-cell ] with-row ] [ [ [ "Object:" write ] with-cell - [ short. ] with-cell + [ pprint-short ] with-cell ] with-row ] [ [ [ "Summary:" write ] with-cell - [ summary. ] with-cell + [ print-summary ] with-cell ] with-row ] tri ] tabular-output diff --git a/basis/ui/tools/listener/listener-docs.factor b/basis/ui/tools/listener/listener-docs.factor index d03995988c..caff45e40e 100644 --- a/basis/ui/tools/listener/listener-docs.factor +++ b/basis/ui/tools/listener/listener-docs.factor @@ -24,7 +24,7 @@ ARTICLE: "ui-listener" "UI listener" { $operations \ word } { $command-map interactor "quotation" } { $heading "Editing commands" } -"The text editing commands are standard; see " { $link "ui.gadgets.editors" } "." +"The text editing commands are standard; see " { $link "gadgets-editors-commands" } "." { $heading "Implementation" } "Listeners are instances of " { $link listener-gadget } ". The listener consists of an output area (instance of " { $link pane } ") and an input area (instance of " { $link interactor } "). Clickable presentations can also be printed to the listener; see " { $link "ui-presentations" } "." ; diff --git a/basis/ui/tools/listener/listener-tests.factor b/basis/ui/tools/listener/listener-tests.factor index 337921a00c..cd56dd876e 100644 --- a/basis/ui/tools/listener/listener-tests.factor +++ b/basis/ui/tools/listener/listener-tests.factor @@ -25,7 +25,7 @@ IN: ui.tools.listener.tests ! This should not throw an exception [ ] [ "interactor" get evaluate-input ] unit-test - [ ] [ [ "interactor" get interactor-busy? ] [ yield ] [ ] while ] unit-test + [ ] [ [ "interactor" get interactor-busy? ] [ yield ] while ] unit-test [ ] [ "[ 1 2 3 ]" "interactor" get set-editor-string ] unit-test @@ -48,7 +48,7 @@ IN: ui.tools.listener.tests [ ] [ "hi" "interactor" get set-editor-string ] unit-test - [ ] [ [ "interactor" get interactor-busy? ] [ yield ] [ ] while ] unit-test + [ ] [ [ "interactor" get interactor-busy? ] [ yield ] while ] unit-test [ ] [ "interactor" get evaluate-input ] unit-test diff --git a/basis/ui/tools/listener/listener.factor b/basis/ui/tools/listener/listener.factor index ebf2db79bf..4429f058f1 100644 --- a/basis/ui/tools/listener/listener.factor +++ b/basis/ui/tools/listener/listener.factor @@ -175,7 +175,7 @@ TUPLE: listener-gadget < tool input output scroller ; [ listener-gadget? ] find-parent ; : listener-streams ( listener -- input output ) - [ input>> ] [ output>> ] bi <pane-stream> ; + [ input>> ] [ output>> <pane-stream> ] bi ; : init-listener ( listener -- listener ) <interactor> diff --git a/basis/ui/tools/profiler/profiler.factor b/basis/ui/tools/profiler/profiler.factor index 0ab1519cd7..bbd9237c87 100644 --- a/basis/ui/tools/profiler/profiler.factor +++ b/basis/ui/tools/profiler/profiler.factor @@ -3,7 +3,7 @@ USING: kernel quotations accessors fry assocs present math.order math.vectors arrays locals models.search models.sort models sequences vocabs tools.profiler words prettyprint combinators.smart -definitions.icons ui ui.commands ui.gadgets ui.gadgets.panes +definitions.icons see ui ui.commands ui.gadgets ui.gadgets.panes ui.gadgets.scrollers ui.gadgets.tracks ui.gestures ui.gadgets.buttons ui.gadgets.tables ui.gadgets.search-tables ui.gadgets.labeled ui.gadgets.buttons ui.gadgets.packs ui.gadgets.labels diff --git a/basis/ui/tools/tools-docs.factor b/basis/ui/tools/tools-docs.factor index 9e63be09ab..d3078cc178 100644 --- a/basis/ui/tools/tools-docs.factor +++ b/basis/ui/tools/tools-docs.factor @@ -1,7 +1,7 @@ USING: editors help.markup help.syntax summary inspector io io.styles listener parser prettyprint tools.profiler tools.walker ui.commands ui.gadgets.panes ui.gadgets.presentations ui.operations -ui.tools.operations ui.tools.profiler ui.tools.common vocabs ; +ui.tools.operations ui.tools.profiler ui.tools.common vocabs see ; IN: ui.tools ARTICLE: "starting-ui-tools" "Starting the UI tools" diff --git a/basis/ui/ui-docs.factor b/basis/ui/ui-docs.factor index d08dea299e..f2b6154745 100644 --- a/basis/ui/ui-docs.factor +++ b/basis/ui/ui-docs.factor @@ -171,6 +171,7 @@ ARTICLE: "ui-layouts" "Gadget hierarchy and layouts" { $subsection "ui-frame-layout" } { $subsection "ui-book-layout" } "Advanced topics:" +{ $subsection "ui.gadgets.glass" } { $subsection "ui-null-layout" } { $subsection "ui-incremental-layout" } { $subsection "ui-layout-impl" } diff --git a/basis/ui/windows/summary.txt b/basis/ui/windows/summary.txt deleted file mode 100644 index 9a0a894850..0000000000 --- a/basis/ui/windows/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Windows UI backend diff --git a/basis/ui/x11/summary.txt b/basis/ui/x11/summary.txt deleted file mode 100644 index 046c83ad89..0000000000 --- a/basis/ui/x11/summary.txt +++ /dev/null @@ -1 +0,0 @@ -X11 UI backend diff --git a/basis/ui/x11/x11.factor b/basis/ui/x11/x11.factor deleted file mode 100755 index 2a622a6985..0000000000 --- a/basis/ui/x11/x11.factor +++ /dev/null @@ -1,297 +0,0 @@ -! Copyright (C) 2005, 2008 Eduardo Cavazos and Slava Pestov -! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien alien.c-types arrays ui ui.gadgets -ui.gestures ui.backend ui.clipboards ui.gadgets.worlds ui.render -ui.event-loop assocs kernel math namespaces opengl sequences -strings x11.xlib x11.events x11.xim x11.glx x11.clipboard -x11.constants x11.windows io.encodings.string io.encodings.ascii -io.encodings.utf8 combinators combinators.short-circuit command-line -math.vectors classes.tuple opengl.gl threads math.geometry.rect -environment ascii ; -IN: ui.x11 - -SINGLETON: x11-ui-backend - -: XA_NET_WM_NAME ( -- atom ) "_NET_WM_NAME" x-atom ; - -TUPLE: x11-handle-base glx ; -TUPLE: x11-handle < x11-handle-base xic window ; -TUPLE: x11-pixmap-handle < x11-handle-base pixmap glx-pixmap ; - -C: <x11-handle> x11-handle -C: <x11-pixmap-handle> x11-pixmap-handle - -M: world expose-event nip relayout ; - -M: world configure-event - over configured-loc >>window-loc - swap configured-dim >>dim - ! In case dimensions didn't change - relayout-1 ; - -CONSTANT: modifiers - { - { S+ HEX: 1 } - { C+ HEX: 4 } - { A+ HEX: 8 } - } - -CONSTANT: key-codes - H{ - { HEX: FF08 "BACKSPACE" } - { HEX: FF09 "TAB" } - { HEX: FF0D "RET" } - { HEX: FF8D "ENTER" } - { HEX: FF1B "ESC" } - { HEX: FFFF "DELETE" } - { HEX: FF50 "HOME" } - { HEX: FF51 "LEFT" } - { HEX: FF52 "UP" } - { HEX: FF53 "RIGHT" } - { HEX: FF54 "DOWN" } - { HEX: FF55 "PAGE_UP" } - { HEX: FF56 "PAGE_DOWN" } - { HEX: FF57 "END" } - { HEX: FF58 "BEGIN" } - { HEX: FFBE "F1" } - { HEX: FFBF "F2" } - { HEX: FFC0 "F3" } - { HEX: FFC1 "F4" } - { HEX: FFC2 "F5" } - { HEX: FFC3 "F6" } - { HEX: FFC4 "F7" } - { HEX: FFC5 "F8" } - { HEX: FFC6 "F9" } - } - -: key-code ( keysym -- keycode action? ) - dup key-codes at [ t ] [ 1string f ] ?if ; - -: event-modifiers ( event -- seq ) - XKeyEvent-state modifiers modifier ; - -: valid-input? ( string gesture -- ? ) - over empty? [ 2drop f ] [ - mods>> { f { S+ } } member? [ - [ { [ 127 = not ] [ CHAR: \s >= ] } 1&& ] all? - ] [ - [ { [ 127 = not ] [ CHAR: \s >= ] [ alpha? not ] } 1&& ] all? - ] if - ] if ; - -: key-down-event>gesture ( event world -- string gesture ) - dupd - handle>> xic>> lookup-string - [ swap event-modifiers ] dip key-code <key-down> ; - -M: world key-down-event - [ key-down-event>gesture ] keep - [ propagate-key-gesture drop ] - [ 2over valid-input? [ nip user-input ] [ 3drop ] if ] - 3bi ; - -: key-up-event>gesture ( event -- gesture ) - dup event-modifiers swap 0 XLookupKeysym key-code <key-up> ; - -M: world key-up-event - [ key-up-event>gesture ] dip propagate-key-gesture ; - -: mouse-event>gesture ( event -- modifiers button loc ) - [ event-modifiers ] - [ XButtonEvent-button ] - [ mouse-event-loc ] - tri ; - -M: world button-down-event - [ mouse-event>gesture [ <button-down> ] dip ] dip - send-button-down ; - -M: world button-up-event - [ mouse-event>gesture [ <button-up> ] dip ] dip - send-button-up ; - -: mouse-event>scroll-direction ( event -- pair ) - XButtonEvent-button { - { 4 { 0 -1 } } - { 5 { 0 1 } } - { 6 { -1 0 } } - { 7 { 1 0 } } - } at ; - -M: world wheel-event - [ [ mouse-event>scroll-direction ] [ mouse-event-loc ] bi ] dip - send-wheel ; - -M: world enter-event motion-event ; - -M: world leave-event 2drop forget-rollover ; - -M: world motion-event - [ [ XMotionEvent-x ] [ XMotionEvent-y ] bi 2array ] dip - move-hand fire-motion ; - -M: world focus-in-event - nip - dup handle>> xic>> XSetICFocus focus-world ; - -M: world focus-out-event - nip - dup handle>> xic>> XUnsetICFocus unfocus-world ; - -M: world selection-notify-event - [ handle>> window>> selection-from-event ] keep - user-input ; - -: supported-type? ( atom -- ? ) - { "UTF8_STRING" "STRING" "TEXT" } - [ x-atom = ] with any? ; - -: clipboard-for-atom ( atom -- clipboard ) - { - { XA_PRIMARY [ selection get ] } - { XA_CLIPBOARD [ clipboard get ] } - [ drop <clipboard> ] - } case ; - -: encode-clipboard ( string type -- bytes ) - XSelectionRequestEvent-target - XA_UTF8_STRING = utf8 ascii ? encode ; - -: set-selection-prop ( evt -- ) - dpy get swap - [ XSelectionRequestEvent-requestor ] keep - [ XSelectionRequestEvent-property ] keep - [ XSelectionRequestEvent-target ] keep - [ 8 PropModeReplace ] dip - [ - XSelectionRequestEvent-selection - clipboard-for-atom contents>> - ] keep encode-clipboard dup length XChangeProperty drop ; - -M: world selection-request-event - drop dup XSelectionRequestEvent-target { - { [ dup supported-type? ] [ drop dup set-selection-prop send-notify-success ] } - { [ dup "TARGETS" x-atom = ] [ drop dup set-targets-prop send-notify-success ] } - { [ dup "TIMESTAMP" x-atom = ] [ drop dup set-timestamp-prop send-notify-success ] } - [ drop send-notify-failure ] - } cond ; - -M: x11-ui-backend (close-window) ( handle -- ) - dup xic>> XDestroyIC - dup glx>> destroy-glx - window>> dup unregister-window - destroy-window ; - -M: world client-event - swap close-box? [ ungraft ] [ drop ] if ; - -: gadget-window ( world -- ) - dup window-loc>> over rect-dim glx-window - over "Factor" create-xic rot <x11-handle> - 2dup window>> register-window - >>handle drop ; - -: wait-event ( -- event ) - QueuedAfterFlush events-queued 0 > [ - next-event dup - None XFilterEvent zero? [ drop wait-event ] unless - ] [ - ui-wait wait-event - ] if ; - -M: x11-ui-backend do-events - wait-event dup XAnyEvent-window window dup - [ handle-event ] [ 2drop ] if ; - -: x-clipboard@ ( gadget clipboard -- prop win ) - atom>> swap - find-world handle>> window>> ; - -M: x-clipboard copy-clipboard - [ x-clipboard@ own-selection ] keep - (>>contents) ; - -M: x-clipboard paste-clipboard - [ find-world handle>> window>> ] dip atom>> convert-selection ; - -: init-clipboard ( -- ) - XA_PRIMARY <x-clipboard> selection set-global - XA_CLIPBOARD <x-clipboard> clipboard set-global ; - -: set-title-old ( dpy window string -- ) - dup [ 127 <= ] all? [ XStoreName drop ] [ 3drop ] if ; - -: set-title-new ( dpy window string -- ) - [ XA_NET_WM_NAME XA_UTF8_STRING 8 PropModeReplace ] dip - utf8 encode dup length XChangeProperty drop ; - -M: x11-ui-backend set-title ( string world -- ) - handle>> window>> swap - [ dpy get ] 2dip [ set-title-old ] [ set-title-new ] 3bi ; - -M: x11-ui-backend set-fullscreen* ( ? world -- ) - handle>> window>> "XClientMessageEvent" <c-object> - tuck set-XClientMessageEvent-window - swap _NET_WM_STATE_ADD _NET_WM_STATE_REMOVE ? - over set-XClientMessageEvent-data0 - ClientMessage over set-XClientMessageEvent-type - dpy get over set-XClientMessageEvent-display - "_NET_WM_STATE" x-atom over set-XClientMessageEvent-message_type - 32 over set-XClientMessageEvent-format - "_NET_WM_STATE_FULLSCREEN" x-atom over set-XClientMessageEvent-data1 - [ dpy get root get 0 SubstructureNotifyMask ] dip XSendEvent drop ; - -M: x11-ui-backend (open-window) ( world -- ) - dup gadget-window - handle>> window>> dup set-closable map-window ; - -M: x11-ui-backend raise-window* ( world -- ) - handle>> [ - dpy get swap window>> XRaiseWindow drop - ] when* ; - -M: x11-handle select-gl-context ( handle -- ) - dpy get swap - [ window>> ] [ glx>> ] bi glXMakeCurrent - [ "Failed to set current GLX context" throw ] unless ; - -M: x11-handle flush-gl-context ( handle -- ) - dpy get swap window>> glXSwapBuffers ; - -M: x11-pixmap-handle select-gl-context ( handle -- ) - dpy get swap - [ glx-pixmap>> ] [ glx>> ] bi glXMakeCurrent - [ "Failed to set current GLX context" throw ] unless ; - -M: x11-pixmap-handle flush-gl-context ( handle -- ) - drop ; - -M: x11-ui-backend (open-offscreen-buffer) ( world -- ) - dup dim>> glx-pixmap <x11-pixmap-handle> >>handle drop ; -M: x11-ui-backend (close-offscreen-buffer) ( handle -- ) - dpy get swap - [ glx-pixmap>> glXDestroyGLXPixmap ] - [ pixmap>> XFreePixmap drop ] - [ glx>> glXDestroyContext ] 2tri ; - -M: x11-ui-backend offscreen-pixels ( world -- alien w h ) - [ [ dim>> ] [ handle>> pixmap>> ] bi pixmap-bits ] [ dim>> first2 ] bi ; - -M: x11-ui-backend ui ( -- ) - [ - f [ - [ - init-clipboard - start-ui - event-loop - ] with-xim - ] with-x - ] ui-running ; - -M: x11-ui-backend beep ( -- ) - dpy get 100 XBell drop ; - -x11-ui-backend ui-backend set-global - -[ "DISPLAY" os-env "ui" "listener" ? ] -main-vocab-hook set-global diff --git a/basis/unicode/breaks/breaks-tests.factor b/basis/unicode/breaks/breaks-tests.factor index d8e220cf18..493c2db0c2 100644 --- a/basis/unicode/breaks/breaks-tests.factor +++ b/basis/unicode/breaks/breaks-tests.factor @@ -37,3 +37,5 @@ IN: unicode.breaks.tests grapheme-break-test parse-test-file [ >graphemes ] test word-break-test parse-test-file [ >words ] test + +[ { t f t t f t } ] [ 6 [ "as df" word-break-at? ] map ] unit-test diff --git a/basis/unicode/breaks/breaks.factor b/basis/unicode/breaks/breaks.factor index ddcb99b829..f2e9454545 100644 --- a/basis/unicode/breaks/breaks.factor +++ b/basis/unicode/breaks/breaks.factor @@ -228,3 +228,20 @@ PRIVATE> : >words ( str -- words ) [ first-word ] >pieces ; + +<PRIVATE + +: nth-next ( i str -- str[i-1] str[i] ) + [ [ 1- ] keep ] dip '[ _ nth ] bi@ ; + +PRIVATE> + +: word-break-at? ( i str -- ? ) + { + [ drop zero? ] + [ length = ] + [ + [ nth-next [ word-break-prop ] dip ] 2keep + word-break-next nip + ] + } 2|| ; diff --git a/basis/unix/bsd/freebsd/freebsd.factor b/basis/unix/bsd/freebsd/freebsd.factor index 4536c532bf..05642b5065 100644 --- a/basis/unix/bsd/freebsd/freebsd.factor +++ b/basis/unix/bsd/freebsd/freebsd.factor @@ -1,7 +1,7 @@ USING: alien.syntax ; IN: unix -: FD_SETSIZE 1024 ; +CONSTANT: FD_SETSIZE 1024 C-STRUCT: addrinfo { "int" "flags" } diff --git a/basis/validators/validators-docs.factor b/basis/validators/validators-docs.factor index 8f5a587569..45444889de 100644 --- a/basis/validators/validators-docs.factor +++ b/basis/validators/validators-docs.factor @@ -1,5 +1,5 @@ USING: help.markup help.syntax io.streams.string quotations -strings math regexp regexp.backend ; +strings math regexp ; IN: validators HELP: v-checkbox diff --git a/basis/windows/com/com-docs.factor b/basis/windows/com/com-docs.factor index 8c7584828f..3a7b7272d7 100644 --- a/basis/windows/com/com-docs.factor +++ b/basis/windows/com/com-docs.factor @@ -15,11 +15,11 @@ HELP: com-release { $description "A small wrapper around " { $link IUnknown::Release } ". Decrements the reference count on " { $snippet "interface" } ", releasing the underlying object if the reference count has reached zero." } ; HELP: &com-release -{ $values { "interface" "Pointer to a COM interface implementing " { $snippet "IUnknown" } } } +{ $values { "alien" "pointer to a COM interface implementing " { $snippet "IUnknown" } } } { $description "Marks the given COM interface for unconditional release via " { $link com-release } " at the end of the enclosing " { $link with-destructors } " scope." } ; HELP: |com-release -{ $values { "interface" "Pointer to a COM interface implementing " { $snippet "IUnknown" } } } +{ $values { "alien" "pointer to a COM interface implementing " { $snippet "IUnknown" } } } { $description "Marks the given COM interface for release via " { $link com-release } " in the event of an error at the end of the enclosing " { $link with-destructors } " scope." } ; { com-release &com-release |com-release } related-words diff --git a/basis/xmode/catalog/catalog.factor b/basis/xmode/catalog/catalog.factor index 7a935d31a4..894ec264ab 100644 --- a/basis/xmode/catalog/catalog.factor +++ b/basis/xmode/catalog/catalog.factor @@ -1,13 +1,14 @@ USING: xmode.loader xmode.utilities xmode.rules namespaces strings splitting assocs sequences kernel io.files xml memoize -words globs combinators io.encodings.utf8 sorting accessors xml.data ; +words globs combinators io.encodings.utf8 sorting accessors xml.data +xml.traversal xml.syntax ; IN: xmode.catalog TUPLE: mode file file-name-glob first-line-glob ; -<TAGS: parse-mode-tag ( modes tag -- ) +TAGS: parse-mode-tag ( modes tag -- ) -TAG: MODE +TAG: MODE parse-mode-tag dup "NAME" attr [ mode new { { "FILE" f (>>file) } @@ -17,11 +18,9 @@ TAG: MODE ] dip rot set-at ; -TAGS> - : parse-modes-tag ( tag -- modes ) H{ } clone [ - swap child-tags [ parse-mode-tag ] with each + swap children-tags [ parse-mode-tag ] with each ] keep ; MEMO: modes ( -- modes ) @@ -97,8 +96,8 @@ ERROR: mutually-recursive-rulesets ruleset ; ] if ; : finalize-mode ( rulesets -- ) - rule-sets [ - dup [ nip finalize-rule-set ] assoc-each + dup rule-sets [ + [ nip finalize-rule-set ] assoc-each ] with-variable ; : load-mode ( name -- rule-sets ) diff --git a/basis/xmode/code2html/code2html-tests.factor b/basis/xmode/code2html/code2html-tests.factor index c0b8a1b560..241ab7ff75 100644 --- a/basis/xmode/code2html/code2html-tests.factor +++ b/basis/xmode/code2html/code2html-tests.factor @@ -3,6 +3,8 @@ USING: xmode.code2html xmode.catalog tools.test multiline splitting memoize kernel io.streams.string xml.writer ; +\ htmlize-file must-infer + [ ] [ \ (load-mode) reset-memoized ] unit-test [ ] [ diff --git a/basis/xmode/loader/loader.factor b/basis/xmode/loader/loader.factor index ef1defc4da..e5d5112a27 100644 --- a/basis/xmode/loader/loader.factor +++ b/basis/xmode/loader/loader.factor @@ -1,56 +1,54 @@ USING: xmode.loader.syntax xmode.tokens xmode.rules xmode.keyword-map xml.data xml.traversal xml assocs kernel combinators sequences math.parser namespaces parser -xmode.utilities parser-combinators.regexp io.files accessors ; +xmode.utilities regexp io.files accessors xml.syntax ; IN: xmode.loader ! Based on org.gjt.sp.jedit.XModeHandler ! RULES and its children -<TAGS: parse-rule-tag ( rule-set tag -- ) +TAGS: parse-rule-tag ( rule-set tag -- ) -TAG: PROPS +TAG: PROPS parse-rule-tag parse-props-tag >>props drop ; -TAG: IMPORT +TAG: IMPORT parse-rule-tag "DELEGATE" attr swap import-rule-set ; -TAG: TERMINATE +TAG: TERMINATE parse-rule-tag "AT_CHAR" attr string>number >>terminate-char drop ; -RULE: SEQ seq-rule +RULE: SEQ seq-rule parse-rule-tag shared-tag-attrs delegate-attr literal-start ; -RULE: SEQ_REGEXP seq-rule +RULE: SEQ_REGEXP seq-rule parse-rule-tag shared-tag-attrs delegate-attr regexp-attr regexp-start ; -RULE: SPAN span-rule +RULE: SPAN span-rule parse-rule-tag shared-tag-attrs delegate-attr match-type-attr span-attrs parse-begin/end-tags init-span-tag ; -RULE: SPAN_REGEXP span-rule +RULE: SPAN_REGEXP span-rule parse-rule-tag shared-tag-attrs delegate-attr match-type-attr span-attrs regexp-attr parse-begin/end-tags init-span-tag ; -RULE: EOL_SPAN eol-span-rule +RULE: EOL_SPAN eol-span-rule parse-rule-tag shared-tag-attrs delegate-attr match-type-attr literal-start init-eol-span-tag ; -RULE: EOL_SPAN_REGEXP eol-span-rule +RULE: EOL_SPAN_REGEXP eol-span-rule parse-rule-tag shared-tag-attrs delegate-attr match-type-attr regexp-attr regexp-start init-eol-span-tag ; -RULE: MARK_FOLLOWING mark-following-rule +RULE: MARK_FOLLOWING mark-following-rule parse-rule-tag shared-tag-attrs match-type-attr literal-start ; -RULE: MARK_PREVIOUS mark-previous-rule +RULE: MARK_PREVIOUS mark-previous-rule parse-rule-tag shared-tag-attrs match-type-attr literal-start ; -TAG: KEYWORDS ( rule-set tag -- key value ) +TAG: KEYWORDS parse-rule-tag rule-set get ignore-case?>> <keyword-map> - swap child-tags [ over parse-keyword-tag ] each + swap children-tags [ over parse-keyword-tag ] each swap (>>keywords) ; -TAGS> - : ?<regexp> ( string/f -- regexp/f ) - dup [ rule-set get ignore-case?>> <regexp> ] when ; + dup [ rule-set get ignore-case?>> <?insensitive-regexp> ] when ; : (parse-rules-tag) ( tag -- rule-set ) <rule-set> dup rule-set set @@ -66,7 +64,7 @@ TAGS> : parse-rules-tag ( tag -- rule-set ) [ - [ (parse-rules-tag) ] [ child-tags ] bi + [ (parse-rules-tag) ] [ children-tags ] bi [ parse-rule-tag ] with each rule-set get ] with-scope ; diff --git a/basis/xmode/loader/syntax/syntax.factor b/basis/xmode/loader/syntax/syntax.factor index 0e7293da97..60318e669e 100644 --- a/basis/xmode/loader/syntax/syntax.factor +++ b/basis/xmode/loader/syntax/syntax.factor @@ -3,7 +3,7 @@ USING: accessors xmode.tokens xmode.rules xmode.keyword-map xml.data xml.traversal xml assocs kernel combinators sequences math.parser namespaces make parser lexer xmode.utilities -parser-combinators.regexp io.files splitting arrays ; +regexp io.files splitting arrays xml.syntax xml.syntax.private ; IN: xmode.loader.syntax ! Rule tag parsing utilities @@ -11,9 +11,10 @@ IN: xmode.loader.syntax new swap init-from-tag swap add-rule ; inline : RULE: - scan scan-word - parse-definition { } make - swap [ (parse-rule-tag) ] 2curry (TAG:) ; parsing + scan scan-word scan-word [ + parse-definition { } make + swap [ (parse-rule-tag) ] 2curry + ] dip swap define-tag ; parsing ! Attribute utilities : string>boolean ( string -- ? ) "TRUE" = ; @@ -32,7 +33,7 @@ IN: xmode.loader.syntax [ "NAME" attr ] [ "VALUE" attr ] bi ; : parse-props-tag ( tag -- assoc ) - child-tags + children-tags [ parse-prop-tag ] H{ } map>assoc ; : position-attrs ( tag -- at-line-start? at-whitespace-end? at-word-start? ) @@ -46,7 +47,8 @@ IN: xmode.loader.syntax swap position-attrs <matcher> ; : parse-regexp-matcher ( tag -- matcher ) - dup children>string rule-set get ignore-case?>> <regexp> + dup children>string + rule-set get ignore-case?>> <?insensitive-regexp> swap position-attrs <matcher> ; : shared-tag-attrs ( -- ) @@ -79,22 +81,20 @@ IN: xmode.loader.syntax [ parse-literal-matcher >>end drop ] , ; ! SPAN's children -<TAGS: parse-begin/end-tag ( rule tag -- ) +TAGS: parse-begin/end-tag ( rule tag -- ) -TAG: BEGIN +TAG: BEGIN parse-begin/end-tag ! XXX parse-literal-matcher >>start drop ; -TAG: END +TAG: END parse-begin/end-tag ! XXX parse-literal-matcher >>end drop ; -TAGS> - : parse-begin/end-tags ( -- ) [ ! XXX: handle position attrs on span tag itself - child-tags [ parse-begin/end-tag ] with each + children-tags [ parse-begin/end-tag ] with each ] , ; : init-span-tag ( -- ) [ drop init-span ] , ; diff --git a/basis/xmode/marker/marker.factor b/basis/xmode/marker/marker.factor index cff0af2a98..f584756f33 100755 --- a/basis/xmode/marker/marker.factor +++ b/basis/xmode/marker/marker.factor @@ -1,11 +1,26 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -IN: xmode.marker USING: kernel namespaces make xmode.rules xmode.tokens xmode.marker.state xmode.marker.context xmode.utilities xmode.catalog sequences math assocs combinators strings -parser-combinators.regexp splitting parser-combinators ascii -ascii combinators.short-circuit accessors ; +regexp splitting unicode.case ascii +combinators.short-circuit accessors ; +IN: xmode.marker + +! Next two words copied from parser-combinators +! Just like head?, but they optionally ignore case + +: string= ( str1 str2 ignore-case -- ? ) + [ [ >upper ] bi@ ] when sequence= ; + +: string-head? ( str1 str2 ignore-case -- ? ) + 2over shorter? + [ 3drop f ] [ + [ + [ nip ] + [ length head-slice ] 2bi + ] dip string= + ] if ; ! Based on org.gjt.sp.jedit.syntax.TokenMarker @@ -69,7 +84,7 @@ M: string-matcher text-matches? ] keep string>> length and ; M: regexp text-matches? - [ >string ] dip match-head ; + [ >string ] dip re-contains? ; : rule-start-matches? ( rule -- match-count/f ) dup start>> tuck swap can-match-here? [ @@ -150,7 +165,7 @@ M: escape-rule handle-rule-start process-escape? get [ escaped? [ not ] change position [ + ] change - ] [ 2drop ] if ; + ] [ drop ] if ; M: seq-rule handle-rule-start ?end-rule diff --git a/basis/xmode/rules/rules.factor b/basis/xmode/rules/rules.factor index adc43d7bb6..51f216fa44 100644 --- a/basis/xmode/rules/rules.factor +++ b/basis/xmode/rules/rules.factor @@ -1,6 +1,8 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. USING: accessors xmode.tokens xmode.keyword-map kernel sequences vectors assocs strings memoize unicode.case -parser-combinators.regexp ; +regexp ; IN: xmode.rules TUPLE: string-matcher string ignore-case? ; diff --git a/basis/xmode/utilities/utilities-tests.factor b/basis/xmode/utilities/utilities-tests.factor index 538c8cef6b..338878942b 100644 --- a/basis/xmode/utilities/utilities-tests.factor +++ b/basis/xmode/utilities/utilities-tests.factor @@ -1,45 +1,2 @@ +USING: assocs xmode.utilities tools.test ; IN: xmode.utilities.tests -USING: accessors xmode.utilities tools.test xml xml.data kernel -strings vectors sequences io.files prettyprint assocs -unicode.case ; - -TUPLE: company employees type ; - -: <company> V{ } clone f company boa ; - -: add-employee employees>> push ; - -<TAGS: parse-employee-tag - -TUPLE: employee name description ; - -TAG: employee - employee new - { { "name" f (>>name) } { f (>>description) } } - init-from-tag swap add-employee ; - -TAGS> - -\ parse-employee-tag see - -: parse-company-tag - [ - <company> - { { "type" >upper (>>type) } } - init-from-tag dup - ] keep - children>> [ tag? ] filter - [ parse-employee-tag ] with each ; - -[ - T{ company f - V{ - T{ employee f "Joe" "VP Sales" } - T{ employee f "Jane" "CFO" } - } - "PUBLIC" - } -] [ - "vocab:xmode/utilities/test.xml" - file>xml parse-company-tag -] unit-test diff --git a/basis/xmode/utilities/utilities.factor b/basis/xmode/utilities/utilities.factor index f3e28bd4da..a7e42877aa 100644 --- a/basis/xmode/utilities/utilities.factor +++ b/basis/xmode/utilities/utilities.factor @@ -1,11 +1,10 @@ USING: accessors sequences assocs kernel quotations namespaces -xml.data xml.traversal combinators macros parser lexer words fry ; +xml.data xml.traversal combinators macros parser lexer words fry +regexp ; IN: xmode.utilities : implies ( x y -- z ) [ not ] dip or ; inline -: child-tags ( tag -- seq ) children>> [ tag? ] filter ; - : tag-init-form ( spec -- quot ) { { [ dup quotation? ] [ [ object get tag get ] prepose ] } @@ -33,20 +32,5 @@ MACRO: (init-from-tag) ( specs -- ) : init-from-tag ( tag tuple specs -- tuple ) over [ (init-from-tag) ] dip ; inline -SYMBOL: tag-handlers -SYMBOL: tag-handler-word - -: <TAGS: - CREATE tag-handler-word set - H{ } clone tag-handlers set ; parsing - -: (TAG:) ( name quot -- ) swap tag-handlers get set-at ; - -: TAG: - scan parse-definition - (TAG:) ; parsing - -: TAGS> - tag-handler-word get - tag-handlers get >alist [ [ dup main>> ] dip case ] curry - define ; parsing +: <?insensitive-regexp> ( string ? -- regexp ) + "i" "" ? <optioned-regexp> ; diff --git a/build-support/dlls.txt b/build-support/dlls.txt new file mode 100644 index 0000000000..97d0cf6e9c --- /dev/null +++ b/build-support/dlls.txt @@ -0,0 +1,12 @@ +libcairo-2.dll +libgio-2.0-0.dll +libglib-2.0-0.dll +libgmodule-2.0-0.dll +libgobject-2.0-0.dll +libgthread-2.0-0.dll +libpango-1.0-0.dll +libpangocairo-1.0-0.dll +libpangowin32-1.0-0.dll +libpng12-0.dll +libtiff3.dll +zlib1.dll diff --git a/build-support/factor.sh b/build-support/factor.sh index 3517d8f4ba..cf6aacb84f 100755 --- a/build-support/factor.sh +++ b/build-support/factor.sh @@ -447,31 +447,11 @@ get_url() { maybe_download_dlls() { if [[ $OS == winnt ]] ; then - get_url http://factorcode.org/dlls/freetype6.dll - get_url http://factorcode.org/dlls/zlib1.dll - get_url http://factorcode.org/dlls/OpenAL32.dll - get_url http://factorcode.org/dlls/alut.dll - get_url http://factorcode.org/dlls/comerr32.dll - get_url http://factorcode.org/dlls/gssapi32.dll - get_url http://factorcode.org/dlls/iconv.dll - get_url http://factorcode.org/dlls/k5sprt32.dll - get_url http://factorcode.org/dlls/krb5_32.dll - get_url http://factorcode.org/dlls/libcairo-2.dll - get_url http://factorcode.org/dlls/libeay32.dll - get_url http://factorcode.org/dlls/libiconv2.dll - get_url http://factorcode.org/dlls/libintl3.dll - get_url http://factorcode.org/dlls/libpq.dll - get_url http://factorcode.org/dlls/libxml2.dll - get_url http://factorcode.org/dlls/libxslt.dll - get_url http://factorcode.org/dlls/msvcr71.dll - get_url http://factorcode.org/dlls/ogg.dll - get_url http://factorcode.org/dlls/pgaevent.dll - get_url http://factorcode.org/dlls/sqlite3.dll - get_url http://factorcode.org/dlls/ssleay32.dll - get_url http://factorcode.org/dlls/theora.dll - get_url http://factorcode.org/dlls/vorbis.dll - chmod 777 *.dll - check_ret chmod + for file in `cat build-support/dlls.txt`; do + get_url http://factorcode.org/dlls/$file + chmod 777 *.dll + check_ret chmod + done fi } @@ -522,7 +502,7 @@ make_boot_image() { } install_build_system_apt() { - sudo apt-get --yes install libc6-dev libfreetype6-dev libx11-dev xorg-dev glutg3-dev wget git-core git-doc rlwrap gcc make + sudo apt-get --yes install libc6-dev libpango-1.0-dev libx11-dev xorg-dev glutg3-dev wget git-core git-doc rlwrap gcc make check_ret sudo } diff --git a/core/assocs/assocs.factor b/core/assocs/assocs.factor index c4deddae39..ec56cffff7 100755 --- a/core/assocs/assocs.factor +++ b/core/assocs/assocs.factor @@ -20,7 +20,7 @@ GENERIC: >alist ( assoc -- newassoc ) M: assoc assoc-like drop ; : ?at ( key assoc -- value/key ? ) - dupd at* [ [ nip ] [ drop ] if ] keep ; inline + 2dup at* [ 2nip t ] [ 2drop f ] if ; inline <PRIVATE @@ -41,7 +41,7 @@ M: assoc assoc-like drop ; : substituter ( assoc -- quot ) [ ?at drop ] curry ; inline -: with-assoc ( assoc quot: ( value key -- assoc ) -- quot: ( key value -- ) ) +: with-assoc ( assoc quot: ( value key assoc -- ) -- quot: ( key value -- ) ) curry [ swap ] prepose ; inline PRIVATE> diff --git a/core/classes/singleton/singleton-tests.factor b/core/classes/singleton/singleton-tests.factor index 10ddde75ae..d9011ad776 100644 --- a/core/classes/singleton/singleton-tests.factor +++ b/core/classes/singleton/singleton-tests.factor @@ -1,4 +1,4 @@ -USING: kernel classes.singleton tools.test prettyprint io.streams.string ; +USING: kernel classes.singleton tools.test prettyprint io.streams.string see ; IN: classes.singleton.tests [ ] [ SINGLETON: bzzt ] unit-test diff --git a/core/classes/tuple/tuple-tests.factor b/core/classes/tuple/tuple-tests.factor index 8d2610ccd7..f27d24e39d 100644 --- a/core/classes/tuple/tuple-tests.factor +++ b/core/classes/tuple/tuple-tests.factor @@ -4,7 +4,7 @@ namespaces quotations sequences.private classes continuations generic.standard effects classes.tuple classes.tuple.private arrays vectors strings compiler.units accessors classes.algebra calendar prettyprint io.streams.string splitting summary -columns math.order classes.private slots slots.private eval ; +columns math.order classes.private slots slots.private eval see ; IN: classes.tuple.tests TUPLE: rect x y w h ; @@ -703,3 +703,31 @@ TUPLE: bogus-hashcode-2 x ; M: bogus-hashcode-1 hashcode* 2drop 0 >bignum ; [ ] [ T{ bogus-hashcode-2 f T{ bogus-hashcode-1 } } hashcode drop ] unit-test + +DEFER: change-slot-test +SLOT: kex + +[ ] [ + "IN: classes.tuple.tests USING: kernel accessors ; TUPLE: change-slot-test ; SLOT: kex M: change-slot-test kex>> drop 3 ;" + <string-reader> "change-slot-test" parse-stream + drop +] unit-test + +[ t ] [ \ change-slot-test \ kex>> method >boolean ] unit-test + +[ ] [ + "IN: classes.tuple.tests USING: kernel accessors ; TUPLE: change-slot-test kex ;" + <string-reader> "change-slot-test" parse-stream + drop +] unit-test + +[ t ] [ \ change-slot-test \ kex>> method >boolean ] unit-test + +[ ] [ + "IN: classes.tuple.tests USING: kernel accessors ; TUPLE: change-slot-test ; SLOT: kex M: change-slot-test kex>> drop 3 ;" + <string-reader> "change-slot-test" parse-stream + drop +] unit-test + +[ t ] [ \ change-slot-test \ kex>> method >boolean ] unit-test +[ f ] [ \ change-slot-test \ kex>> method "reading" word-prop ] unit-test \ No newline at end of file diff --git a/core/classes/union/union-tests.factor b/core/classes/union/union-tests.factor index 97baf08874..0802c0a2d9 100644 --- a/core/classes/union/union-tests.factor +++ b/core/classes/union/union-tests.factor @@ -4,7 +4,7 @@ tools.test vectors words quotations classes classes.private classes.union classes.mixin classes.predicate classes.algebra vectors definitions source-files compiler.units kernel.private sorting vocabs io.streams.string -eval ; +eval see ; IN: classes.union.tests ! DEFER: bah diff --git a/core/compiler/units/units.factor b/core/compiler/units/units.factor index 0577f8b83c..178e29fd93 100644 --- a/core/compiler/units/units.factor +++ b/core/compiler/units/units.factor @@ -23,6 +23,9 @@ TUPLE: redefine-error def ; : remember-definition ( definition loc -- ) new-definitions get first (remember-definition) ; +: fake-definition ( definition -- ) + old-definitions get [ delete-at ] with each ; + : remember-class ( class loc -- ) [ dup new-definitions get first key? [ dup redefine-error ] when ] dip new-definitions get second (remember-definition) ; @@ -72,14 +75,12 @@ SYMBOL: outdated-tuples SYMBOL: update-tuples-hook SYMBOL: remake-generics-hook +: index>= ( obj1 obj2 seq -- ? ) + [ index ] curry bi@ >= ; + : dependency>= ( how1 how2 -- ? ) - [ - { - called-dependency - flushed-dependency - inlined-dependency - } index - ] bi@ >= ; + { called-dependency flushed-dependency inlined-dependency } + index>= ; : strongest-dependency ( how1 how2 -- how ) [ called-dependency or ] bi@ [ dependency>= ] most ; diff --git a/core/definitions/definitions-docs.factor b/core/definitions/definitions-docs.factor index d43c61ff70..80da7daa31 100644 --- a/core/definitions/definitions-docs.factor +++ b/core/definitions/definitions-docs.factor @@ -56,12 +56,12 @@ $nl { $subsection redefine-error } ; ARTICLE: "definitions" "Definitions" -"A " { $emphasis "definition" } " is an artifact read from a source file. This includes words, methods, and help articles. Words for working with definitions are found in the " { $vocab-link "definitions" } " vocabulary. Implementations of the definition protocol include pathnames, words, methods, and help articles." +"A " { $emphasis "definition" } " is an artifact read from a source file. This includes words, methods, help articles, and path names (which represent the source file at that location). Words for working with definitions are found in the " { $vocab-link "definitions" } " vocabulary." { $subsection "definition-protocol" } { $subsection "definition-crossref" } { $subsection "definition-checking" } { $subsection "compilation-units" } -{ $see-also "parser" "source-files" "words" "generic" "help-impl" } ; +{ $see-also "see" "parser" "source-files" "words" "generic" "help-impl" } ; ABOUT: "definitions" diff --git a/core/definitions/definitions.factor b/core/definitions/definitions.factor index 726116909f..db99d7e3a3 100644 --- a/core/definitions/definitions.factor +++ b/core/definitions/definitions.factor @@ -9,13 +9,9 @@ SYMBOL: inlined-dependency SYMBOL: flushed-dependency SYMBOL: called-dependency -<PRIVATE - : set-in-unit ( value key assoc -- ) [ set-at ] [ no-compilation-unit ] if* ; -PRIVATE> - SYMBOL: changed-definitions : changed-definition ( defspec -- ) @@ -23,14 +19,8 @@ SYMBOL: changed-definitions SYMBOL: changed-generics -: changed-generic ( class generic -- ) - changed-generics get set-in-unit ; - SYMBOL: remake-generics -: remake-generic ( generic -- ) - dup remake-generics get set-in-unit ; - SYMBOL: new-classes : new-class ( word -- ) @@ -52,11 +42,9 @@ M: object forget* drop ; SYMBOL: forgotten-definitions : forgotten-definition ( defspec -- ) - dup forgotten-definitions get - [ no-compilation-unit ] unless* - set-at ; + dup forgotten-definitions get set-in-unit ; -: forget ( defspec -- ) dup forgotten-definition forget* ; +: forget ( defspec -- ) [ forgotten-definition ] [ forget* ] bi ; : forget-all ( definitions -- ) [ forget ] each ; diff --git a/core/generic/generic-docs.factor b/core/generic/generic-docs.factor index 429e272647..613dbf72a4 100644 --- a/core/generic/generic-docs.factor +++ b/core/generic/generic-docs.factor @@ -47,7 +47,7 @@ $nl { $subsection <method> } "A " { $emphasis "method specifier" } " refers to a method and implements the " { $link "definition-protocol" } ":" { $subsection method-spec } -{ $see-also see see-methods } ; +{ $see-also "see" } ; ARTICLE: "method-combination" "Custom method combination" "Abstractly, a generic word can be thought of as a big chain of type conditional tests applied to the top of the stack, with methods as the bodies of each test. The " { $emphasis "method combination" } " is this control flow glue between the set of methods, and several aspects of it can be customized:" diff --git a/core/generic/generic.factor b/core/generic/generic.factor index c520b4aaac..351a8f98fd 100644 --- a/core/generic/generic.factor +++ b/core/generic/generic.factor @@ -71,6 +71,13 @@ TUPLE: check-method class generic ; \ check-method boa throw ] unless ; inline +: changed-generic ( class generic -- ) + changed-generics get + [ [ [ class-or ] when* ] change-at ] [ no-compilation-unit ] if* ; + +: remake-generic ( generic -- ) + dup remake-generics get set-in-unit ; + : with-methods ( class generic quot -- ) [ drop changed-generic ] [ [ "methods" word-prop ] dip call ] @@ -113,7 +120,7 @@ M: method-body crossref? 2bi ; : create-method ( class generic -- method ) - 2dup method dup [ 2nip ] [ + 2dup method dup [ 2nip dup reset-generic ] [ drop [ <method> dup ] 2keep reveal-method diff --git a/core/generic/standard/standard-tests.factor b/core/generic/standard/standard-tests.factor index 516d408933..2cd64ac9f4 100644 --- a/core/generic/standard/standard-tests.factor +++ b/core/generic/standard/standard-tests.factor @@ -5,7 +5,7 @@ specialized-arrays.double byte-arrays bit-arrays parser namespaces make quotations stack-checker vectors growable hashtables sbufs prettyprint byte-vectors bit-vectors specialized-vectors.double definitions generic sets graphs assocs -grouping ; +grouping see ; GENERIC: lo-tag-test ( obj -- obj' ) diff --git a/core/kernel/kernel-docs.factor b/core/kernel/kernel-docs.factor index 9c5d6f56ea..c178573a0a 100644 --- a/core/kernel/kernel-docs.factor +++ b/core/kernel/kernel-docs.factor @@ -684,7 +684,7 @@ $nl "This operation is efficient and does not copy the quotation." } { $examples { $example "USING: kernel prettyprint ;" "5 [ . ] curry ." "[ 5 . ]" } - { $example "USING: kernel prettyprint ;" "\\ = [ see ] curry ." "[ \\ = see ]" } + { $example "USING: kernel prettyprint see ;" "\\ = [ see ] curry ." "[ \\ = see ]" } { $example "USING: kernel math prettyprint sequences ;" "{ 1 2 3 } 2 [ - ] curry map ." "{ -1 0 1 }" } } ; diff --git a/core/parser/parser-tests.factor b/core/parser/parser-tests.factor index 3fcf489413..5ec9ea9b3c 100644 --- a/core/parser/parser-tests.factor +++ b/core/parser/parser-tests.factor @@ -556,3 +556,37 @@ EXCLUDE: qualified.tests.bar => x ; [ "IN: qualified.tests RENAME: doesnotexist qualified.tests => blahx" eval ] [ error>> no-word-error? ] must-fail-with + +! Two similar bugs + +! Replace : def with something in << >> +[ [ ] ] [ + "IN: parser.tests : was-once-a-word-bug ( -- ) ;" + <string-reader> "was-once-a-word-test" parse-stream +] unit-test + +[ t ] [ "was-once-a-word-bug" "parser.tests" lookup >boolean ] unit-test + +[ [ ] ] [ + "IN: parser.tests USE: words << \"was-once-a-word-bug\" \"parser.tests\" create [ ] (( -- )) define-declared >>" + <string-reader> "was-once-a-word-test" parse-stream +] unit-test + +[ t ] [ "was-once-a-word-bug" "parser.tests" lookup >boolean ] unit-test + +! Replace : def with DEFER: +[ [ ] ] [ + "IN: parser.tests : is-not-deferred ( -- ) ;" + <string-reader> "is-not-deferred" parse-stream +] unit-test + +[ t ] [ "is-not-deferred" "parser.tests" lookup >boolean ] unit-test +[ f ] [ "is-not-deferred" "parser.tests" lookup deferred? ] unit-test + +[ [ ] ] [ + "IN: parser.tests DEFER: is-not-deferred" + <string-reader> "is-not-deferred" parse-stream +] unit-test + +[ t ] [ "is-not-deferred" "parser.tests" lookup >boolean ] unit-test +[ t ] [ "is-not-deferred" "parser.tests" lookup deferred? ] unit-test diff --git a/core/parser/parser.factor b/core/parser/parser.factor index cbf8754821..c68d453b15 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -5,7 +5,7 @@ sequences strings vectors words words.symbol quotations io combinators sorting splitting math.parser effects continuations io.files vocabs io.encodings.utf8 source-files classes hashtables compiler.errors compiler.units accessors sets -lexer vocabs.parser ; +lexer vocabs.parser slots ; IN: parser : location ( -- loc ) @@ -113,12 +113,16 @@ ERROR: staging-violation word ; : parse-until ( end -- vec ) 100 <vector> swap (parse-until) ; +SYMBOL: quotation-parser + +HOOK: parse-quotation quotation-parser ( -- quot ) + +M: f parse-quotation \ ] parse-until >quotation ; + : parsed ( accum obj -- accum ) over push ; : (parse-lines) ( lexer -- quot ) - [ - f parse-until >quotation - ] with-lexer ; + [ f parse-until >quotation ] with-lexer ; : parse-lines ( lines -- quot ) lexer-factory get call (parse-lines) ; @@ -172,6 +176,7 @@ SYMBOL: interactive-vocabs "memory" "namespaces" "prettyprint" + "see" "sequences" "slicing" "sorting" @@ -216,10 +221,14 @@ print-use-hook [ [ ] ] initialize "quiet" get [ drop ] [ "Loading " write print flush ] if ; : filter-moved ( assoc1 assoc2 -- seq ) - swap assoc-diff [ - drop where dup [ first ] when - file get path>> = - ] assoc-filter keys ; + swap assoc-diff keys [ + { + { [ dup where dup [ first ] when file get path>> = not ] [ f ] } + { [ dup reader-method? ] [ f ] } + { [ dup writer-method? ] [ f ] } + [ t ] + } cond nip + ] filter ; : removed-definitions ( -- assoc1 assoc2 ) new-definitions old-definitions diff --git a/core/sequences/sequences-tests.factor b/core/sequences/sequences-tests.factor index dbbf49ef36..da495f410f 100644 --- a/core/sequences/sequences-tests.factor +++ b/core/sequences/sequences-tests.factor @@ -13,6 +13,10 @@ IN: sequences.tests [ V{ 4 5 } ] [ { 1 2 3 4 5 } 2 tail-slice* >vector ] unit-test [ V{ 3 4 } ] [ 2 4 1 10 dup <slice> subseq >vector ] unit-test [ V{ 3 4 } ] [ 0 2 2 4 1 10 dup <slice> <slice> subseq >vector ] unit-test +[ 0 10 "hello" <slice> ] must-fail +[ -10 3 "hello" <slice> ] must-fail +[ 2 1 "hello" <slice> ] must-fail + [ "cba" ] [ "abcdef" 3 head-slice reverse ] unit-test [ 5040 ] [ [ 1 2 3 4 5 6 7 ] 1 [ * ] reduce ] unit-test diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index fb05d331e1..144b417f04 100755 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -213,12 +213,17 @@ TUPLE: slice : collapse-slice ( m n slice -- m' n' seq ) [ from>> ] [ seq>> ] bi [ [ + ] curry bi@ ] dip ; inline -ERROR: slice-error from to seq reason ; +TUPLE: slice-error from to seq reason ; + +: slice-error ( from to seq ? string -- from to seq ) + [ \ slice-error boa throw ] curry when ; inline : check-slice ( from to seq -- from to seq ) - pick 0 < [ "start < 0" slice-error ] when - dup length pick < [ "end > sequence" slice-error ] when - 2over > [ "start > end" slice-error ] when ; inline + 3dup + [ 2drop 0 < "start < 0" slice-error ] + [ [ drop ] 2dip length > "end > sequence" slice-error ] + [ drop > "start > end" slice-error ] + 3tri ; inline : <slice> ( from to seq -- slice ) dup slice? [ collapse-slice ] when @@ -326,8 +331,8 @@ PRIVATE> [ (append) ] new-like ; inline : 3append-as ( seq1 seq2 seq3 exemplar -- newseq ) - [ pick length pick length pick length + + ] dip [ - [ [ pick length pick length + ] dip copy ] + [ 3dup [ length ] tri@ + + ] dip [ + [ [ 2over [ length ] bi@ + ] dip copy ] [ (append) ] bi ] new-like ; inline diff --git a/core/slots/slots.factor b/core/slots/slots.factor index ea020c5c55..71c2bdcc90 100755 --- a/core/slots/slots.factor +++ b/core/slots/slots.factor @@ -10,8 +10,12 @@ TUPLE: slot-spec name offset class initial read-only ; PREDICATE: reader < word "reader" word-prop ; +PREDICATE: reader-method < method-body "reading" word-prop ; + PREDICATE: writer < word "writer" word-prop ; +PREDICATE: writer-method < method-body "writing" word-prop ; + : <slot-spec> ( -- slot-spec ) slot-spec new object bootstrap-word >>class ; diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index af5fa38aeb..de3be98ceb 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -94,7 +94,7 @@ IN: bootstrap.syntax lexer get skip-blank parse-string <pathname> parsed ] define-syntax - "[" [ \ ] [ >quotation ] parse-literal ] define-syntax + "[" [ parse-quotation parsed ] define-syntax "{" [ \ } [ >array ] parse-literal ] define-syntax "V{" [ \ } [ >vector ] parse-literal ] define-syntax "B{" [ \ } [ >byte-array ] parse-literal ] define-syntax @@ -135,8 +135,7 @@ IN: bootstrap.syntax "DEFER:" [ scan current-vocab create - dup old-definitions get [ delete-at ] with each - set-word + [ fake-definition ] [ set-word ] [ [ undefined ] define ] tri ] define-syntax ":" [ diff --git a/core/words/words-docs.factor b/core/words/words-docs.factor index f5990c295e..9c32a8094e 100644 --- a/core/words/words-docs.factor +++ b/core/words/words-docs.factor @@ -161,7 +161,7 @@ $nl { $subsection "word-definition" } { $subsection "word-props" } { $subsection "word.private" } -{ $see-also "vocabularies" "vocabs.loader" "definitions" } ; +{ $see-also "vocabularies" "vocabs.loader" "definitions" "see" } ; ABOUT: "words" diff --git a/extra/4DNav/4DNav.factor b/extra/4DNav/4DNav.factor index 91c1c94b35..8ddbff96d9 100755 --- a/extra/4DNav/4DNav.factor +++ b/extra/4DNav/4DNav.factor @@ -3,6 +3,7 @@ USING: kernel namespaces accessors +assocs make math math.functions @@ -13,8 +14,10 @@ sequences combinators continuations colors +colors.constants prettyprint vars +call quotations io io.directories @@ -26,25 +29,19 @@ ui.gadgets.panes ui.gadgets ui.traverse ui.gadgets.borders - ui.gadgets.handler - ui.gadgets.slate - ui.gadgets.theme ui.gadgets.frames ui.gadgets.tracks ui.gadgets.labels - ui.gadgets.labelled + ui.gadgets.labeled ui.gadgets.lists ui.gadgets.buttons ui.gadgets.packs ui.gadgets.grids ui.gestures - ui.tools.workspace ui.gadgets.scrollers splitting vectors math.vectors -rewrite-closures -self values 4DNav.turtle 4DNav.window3D @@ -55,6 +52,9 @@ fry adsoda adsoda.tools ; +QUALIFIED-WITH: ui.pens.solid s +QUALIFIED-WITH: ui.gadgets.wrappers w + IN: 4DNav VALUE: selected-file @@ -74,10 +74,13 @@ VAR: present-space ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! replacement of namespaces.lib +! namespace utilities : make* ( seq -- seq ) [ dup quotation? [ call ] [ ] if ] map ; +: closed-quot ( quot -- quot ) + namestack swap '[ namestack [ _ set-namestack @ ] dip set-namestack ] ; + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! waiting for deep-cleave-quots @@ -131,11 +134,11 @@ VAR: present-space : model-projection-chooser ( -- gadget ) observer3d> projection-mode>> { { 1 "perspective" } { 0 "orthogonal" } } - <toggle-buttons> ; + <radio-buttons> ; : collision-detection-chooser ( -- gadget ) observer3d> collision-mode>> - { { t "on" } { f "off" } } <toggle-buttons> ; + { { t "on" } { f "off" } } <radio-buttons> ; : model-projection ( x -- space ) present-space> swap space-project ; @@ -184,8 +187,11 @@ VAR: present-space ! menu ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +USE: ui.gadgets.labeled.private + : menu-rotations-4D ( -- gadget ) - <frame> + 3 3 <frame> + { 1 1 } >>filled-cell <pile> 1 >>fill "XY +" [ drop rotation-step 4D-Rxy rotation-4D ] button* add-gadget @@ -225,7 +231,8 @@ VAR: present-space ; : menu-translations-4D ( -- gadget ) - <frame> + 3 3 <frame> + { 1 1 } >>filled-cell <pile> 1 >>fill <shelf> 1 >>fill "X+" [ drop { 1 0 0 0 } translation-step v*n @@ -325,12 +332,13 @@ VAR: present-space [ ".xml" tail? ] filter [ append-path ] with map [ <run-file-button> add-gadget ] each - swap <labelled-gadget> ; + swap <labeled-gadget> ; ! ----------------------------------------------------- : menu-rotations-3D ( -- gadget ) - <frame> + 3 3 <frame> + { 1 1 } >>filled-cell "Turn\n left" [ rotation-step turn-left ] camera-button @left grid-add "Turn\n right" [ rotation-step turn-right ] @@ -348,7 +356,8 @@ VAR: present-space ; : menu-translations-3D ( -- gadget ) - <frame> + 3 3 <frame> + { 1 1 } >>filled-cell "left\n(alt)" [ translation-step strafe-left ] camera-button @left grid-add "right\n(alt)" [ translation-step strafe-right ] @@ -384,6 +393,13 @@ VAR: present-space add-gadget menu-quick-views add-gadget ; +TUPLE: handler < w:wrapper table ; + +: <handler> ( child -- handler ) handler w:new-wrapper ; + +M: handler handle-gesture ( gesture gadget -- ? ) + tuck table>> at dup [ call( gadget -- ) f ] [ 2drop t ] if ; + : add-keyboard-delegate ( obj -- obj ) <handler> { @@ -477,8 +493,7 @@ M: space adsoda-display-model { 0 1 } <track> menu-bar f track-add <list-runner> - <limited-scroller> - { 200 400 } >>max-dim + <scroller> f track-add <shelf> "Projection mode : " <label> add-gadget @@ -492,17 +507,17 @@ M: space adsoda-display-model <pile> 0.5 >>align menu-4D add-gadget - light-purple solid-interior - "4D movements" <labelled-gadget> + COLOR: purple s:<solid> >>interior + "4D movements" <labeled-gadget> f track-add <pile> 0.5 >>align { 2 2 } >>gap menu-3D add-gadget - light-purple solid-interior - "Camera 3D" <labelled-gadget> + COLOR: purple s:<solid> >>interior + "Camera 3D" <labeled-gadget> f track-add - gray solid-interior + COLOR: gray s:<solid> >>interior ; : viewer-windows* ( -- ) diff --git a/extra/4DNav/camera/camera.factor b/extra/4DNav/camera/camera.factor index 1e492fe8d9..1f36a46275 100755 --- a/extra/4DNav/camera/camera.factor +++ b/extra/4DNav/camera/camera.factor @@ -1,5 +1,4 @@ -USING: kernel namespaces math.vectors opengl 4DNav.turtle -self ; +USING: kernel namespaces math.vectors opengl 4DNav.turtle ; IN: 4DNav.camera diff --git a/extra/4DNav/file-chooser/file-chooser.factor b/extra/4DNav/file-chooser/file-chooser.factor index d7c869ce2f..9bd0e9c011 100755 --- a/extra/4DNav/file-chooser/file-chooser.factor +++ b/extra/4DNav/file-chooser/file-chooser.factor @@ -24,7 +24,6 @@ ui.gadgets.panes ui.gadgets.scrollers prettyprint combinators -rewrite-closures accessors values tools.walker @@ -67,7 +66,7 @@ file-chooser H{ [ directory? ] bi or ] filter ; -: update-filelist-model ( file-chooser -- file-chooser ) +: update-filelist-model ( file-chooser -- ) [ list-of-files ] [ model>> ] bi set-model ; : init-filelist-model ( file-chooser -- file-chooser ) @@ -86,7 +85,7 @@ file-chooser H{ : fc-go-home ( file-chooser -- ) [ home ] (fc-go) ; -: fc-change-directory ( file-chooser file -- file-chooser ) +: fc-change-directory ( file-chooser file -- ) dupd [ path>> value>> normalize-path ] [ name>> ] bi* append-path over path>> set-model update-filelist-model @@ -139,9 +138,9 @@ file-chooser H{ f track-add <shelf> over [ swap fc-go-parent ] curry "go up" - swap <bevel-button> add-gadget + swap <border-button> add-gadget over [ swap fc-go-home ] curry "go home" - swap <bevel-button> add-gadget + swap <border-button> add-gadget ! over [ swap fc-ok-action ] curry "OK" ! swap <bevel-button> add-gadget ! [ drop ] "Cancel" swap <bevel-button> add-gadget diff --git a/extra/4DNav/turtle/turtle.factor b/extra/4DNav/turtle/turtle.factor index 62c25c4344..664645c466 100755 --- a/extra/4DNav/turtle/turtle.factor +++ b/extra/4DNav/turtle/turtle.factor @@ -2,10 +2,18 @@ USING: kernel math arrays math.vectors math.matrices namespaces make math.constants math.functions math.vectors -splitting grouping self math.trig - sequences accessors 4DNav.deep models ; +splitting grouping math.trig + sequences accessors 4DNav.deep models vars ; IN: 4DNav.turtle +! replacement of self + +VAR: self + +: with-self ( quot obj -- ) [ >self call ] with-scope ; inline + +: save-self ( quot -- ) self> [ self> clone >self call ] dip >self ; inline + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! TUPLE: turtle pos ori ; diff --git a/extra/4DNav/window3D/window3D.factor b/extra/4DNav/window3D/window3D.factor index a5ca5f2a9a..6bb57cf940 100755 --- a/extra/4DNav/window3D/window3D.factor +++ b/extra/4DNav/window3D/window3D.factor @@ -28,7 +28,7 @@ IN: 4DNav.window3D TUPLE: window3D < gadget observer ; : <window3D> ( model observer -- gadget ) - window3D new-gadget + window3D new swap 2dup projection-mode>> add-connection 2dup diff --git a/extra/annotations/annotations.factor b/extra/annotations/annotations.factor index 6685e4e036..b3eccad6a3 100644 --- a/extra/annotations/annotations.factor +++ b/extra/annotations/annotations.factor @@ -1,6 +1,7 @@ ! (c)2009 Joe Groff, Doug Coleman. see BSD license USING: accessors combinators.short-circuit definitions functors -kernel lexer namespaces parser prettyprint sequences words ; +kernel lexer namespaces parser prettyprint tools.crossref +sequences words ; IN: annotations << diff --git a/extra/benchmark/regex-dna/regex-dna.factor b/extra/benchmark/regex-dna/regex-dna.factor index 8c0aee596d..5c11be357f 100644 --- a/extra/benchmark/regex-dna/regex-dna.factor +++ b/extra/benchmark/regex-dna/regex-dna.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors regexp prettyprint io io.encodings.ascii -io.files kernel sequences assocs namespaces ; +USING: accessors prettyprint io io.encodings.ascii +io.files kernel sequences assocs namespaces regexp ; IN: benchmark.regex-dna ! Based on http://shootout.alioth.debian.org/gp4/benchmark.php?test=regexdna&lang=ruby&id=1 diff --git a/extra/bunny/outlined/outlined.factor b/extra/bunny/outlined/outlined.factor index c91a895ce1..7491ed8bcb 100755 --- a/extra/bunny/outlined/outlined.factor +++ b/extra/bunny/outlined/outlined.factor @@ -1,6 +1,6 @@ USING: arrays bunny.model bunny.cel-shaded continuations destructors kernel math multiline opengl opengl.shaders -opengl.framebuffers opengl.gl opengl.demo-support fry +opengl.framebuffers opengl.gl opengl.textures opengl.demo-support fry opengl.capabilities sequences ui.gadgets combinators accessors macros locals ; IN: bunny.outlined diff --git a/extra/cap/cap.factor b/extra/cap/cap.factor index 1f62441028..64696759bb 100644 --- a/extra/cap/cap.factor +++ b/extra/cap/cap.factor @@ -1,30 +1,31 @@ ! Copyright (C) 2008 Doug Coleman, Joe Groff. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays byte-arrays kernel math namespaces -opengl.gl sequences math.vectors ui images.bitmap images.viewer +opengl.gl sequences math.vectors ui images images.viewer models ui.gadgets.worlds ui.gadgets fry alien.syntax ; IN: cap : screenshot-array ( world -- byte-array ) - dim>> [ first 3 * 4 align ] [ second ] bi * <byte-array> ; + dim>> [ first 4 * ] [ second ] bi * <byte-array> ; : gl-screenshot ( gadget -- byte-array ) [ - GL_BACK glReadBuffer - GL_PACK_ALIGNMENT 4 glPixelStorei - 0 0 - ] dip - [ dim>> first2 GL_BGR GL_UNSIGNED_BYTE ] + [ + GL_BACK glReadBuffer + GL_PACK_ALIGNMENT 4 glPixelStorei + 0 0 + ] dip + dim>> first2 GL_RGBA GL_UNSIGNED_BYTE + ] [ screenshot-array ] bi [ glReadPixels ] keep ; : screenshot ( window -- bitmap ) - [ gl-screenshot ] - [ dim>> first2 ] bi - bgr>bitmap ; - -: save-screenshot ( window path -- ) - [ screenshot ] dip save-bitmap ; + [ <image> ] dip + [ gl-screenshot >>bitmap ] [ dim>> >>dim ] bi + RGBA >>component-order + t >>upside-down? + normalize-image ; : screenshot. ( window -- ) [ screenshot <image-gadget> ] [ title>> ] bi open-window ; diff --git a/extra/color-picker/color-picker.factor b/extra/color-picker/color-picker.factor index 69c21b10f7..d7919aafd1 100755 --- a/extra/color-picker/color-picker.factor +++ b/extra/color-picker/color-picker.factor @@ -2,8 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel math math.functions math.parser models models.arrow models.range models.product sequences ui -ui.gadgets ui.gadgets.frames ui.gadgets.labels ui.gadgets.packs -ui.gadgets.sliders ui.render math.rectangles accessors +ui.gadgets ui.gadgets.tracks ui.gadgets.labels ui.gadgets.packs +ui.gadgets.sliders ui.pens.solid ui.render math.rectangles accessors ui.gadgets.grids colors ; IN: color-picker @@ -12,7 +12,7 @@ IN: color-picker TUPLE: color-preview < gadget ; : <color-preview> ( model -- gadget ) - color-preview new-gadget + color-preview new swap >>model { 100 100 } >>dim ; @@ -32,16 +32,16 @@ M: color-preview model-changed bi ; : <color-picker> ( -- gadget ) - <frame> + vertical <track> { 5 5 } >>gap <color-sliders> - [ @top grid-add ] + [ f track-add ] [ - [ <color-model> <color-preview> @center grid-add ] + [ <color-model> <color-preview> 1 track-add ] [ [ [ truncate number>string ] map " " join ] <arrow> <label-control> - @bottom grid-add + f track-add ] bi ] bi* ; diff --git a/extra/demos/demos.factor b/extra/demos/demos.factor index b411df1e30..fd7aafb601 100644 --- a/extra/demos/demos.factor +++ b/extra/demos/demos.factor @@ -10,7 +10,7 @@ IN: demos : demo-vocabs ( -- seq ) "demos" tagged [ second ] map concat [ name>> ] map ; : <run-vocab-button> ( vocab-name -- button ) - dup '[ drop [ _ run ] call-listener ] <bevel-button> { 0 0 } >>align ; + dup '[ drop [ _ run ] call-listener ] <border-button> ; : <demo-runner> ( -- gadget ) <pile> 1 >>fill demo-vocabs [ <run-vocab-button> add-gadget ] each ; diff --git a/extra/descriptive/descriptive-tests.factor b/extra/descriptive/descriptive-tests.factor index 1582ca895d..755c57ceda 100755 --- a/extra/descriptive/descriptive-tests.factor +++ b/extra/descriptive/descriptive-tests.factor @@ -1,4 +1,4 @@ -USING: descriptive kernel math tools.test continuations prettyprint io.streams.string ; +USING: descriptive kernel math tools.test continuations prettyprint io.streams.string see ; IN: descriptive.tests DESCRIPTIVE: divide ( num denom -- fraction ) / ; diff --git a/extra/dns/cache/rr/rr.factor b/extra/dns/cache/rr/rr.factor index 77d787ff27..cb80190452 100644 --- a/extra/dns/cache/rr/rr.factor +++ b/extra/dns/cache/rr/rr.factor @@ -1,7 +1,7 @@ USING: kernel sequences assocs sets locals combinators accessors system math math.functions unicode.case prettyprint - combinators.cleave dns ; + combinators.smart dns ; IN: dns.cache.rr @@ -16,7 +16,7 @@ TUPLE: <entry> time data ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! : make-cache-key ( obj -- key ) - { [ name>> >lower ] [ type>> unparse ] [ class>> unparse ] } 1arr " " join ; + [ [ name>> >lower ] [ type>> ] [ class>> ] tri ] output>array ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/extra/dns/dns.factor b/extra/dns/dns.factor index ca37691ba7..cf98154e7a 100644 --- a/extra/dns/dns.factor +++ b/extra/dns/dns.factor @@ -5,7 +5,7 @@ USING: kernel byte-arrays combinators strings arrays sequences splitting destructors io io.binary io.sockets io.encodings.binary accessors - combinators.cleave + combinators.smart newfx ; @@ -145,12 +145,13 @@ SYMBOLS: NO-ERROR FORMAT-ERROR SERVER-FAILURE NAME-ERROR NOT-IMPLEMENTED ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! : query->ba ( query -- ba ) + [ { [ name>> dn->ba ] [ type>> type-table of uint16->ba ] [ class>> class-table of uint16->ba ] - } - <arr> concat ; + } cleave + ] output>array concat ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -169,6 +170,7 @@ SYMBOLS: NO-ERROR FORMAT-ERROR SERVER-FAILURE NAME-ERROR NOT-IMPLEMENTED ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! : soa->ba ( rdata -- ba ) + [ { [ mname>> dn->ba ] [ rname>> dn->ba ] @@ -177,8 +179,8 @@ SYMBOLS: NO-ERROR FORMAT-ERROR SERVER-FAILURE NAME-ERROR NOT-IMPLEMENTED [ retry>> uint32->ba ] [ expire>> uint32->ba ] [ minimum>> uint32->ba ] - } - <arr> concat ; + } cleave + ] output>array concat ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -198,6 +200,7 @@ SYMBOLS: NO-ERROR FORMAT-ERROR SERVER-FAILURE NAME-ERROR NOT-IMPLEMENTED ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! : rr->ba ( rr -- ba ) + [ { [ name>> dn->ba ] [ type>> type-table of uint16->ba ] @@ -207,12 +210,13 @@ SYMBOLS: NO-ERROR FORMAT-ERROR SERVER-FAILURE NAME-ERROR NOT-IMPLEMENTED [ type>> ] [ rdata>> ] bi rdata->ba [ length uint16->ba ] [ ] bi append ] - } - <arr> concat ; + } cleave + ] output>array concat ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! : header-bits-ba ( message -- ba ) + [ { [ qr>> 15 shift ] [ opcode>> opcode-table of 11 shift ] @@ -222,10 +226,11 @@ SYMBOLS: NO-ERROR FORMAT-ERROR SERVER-FAILURE NAME-ERROR NOT-IMPLEMENTED [ ra>> 7 shift ] [ z>> 4 shift ] [ rcode>> rcode-table of 0 shift ] - } - <arr> sum uint16->ba ; + } cleave + ] sum-outputs uint16->ba ; : message->ba ( message -- ba ) + [ { [ id>> uint16->ba ] [ header-bits-ba ] @@ -237,8 +242,8 @@ SYMBOLS: NO-ERROR FORMAT-ERROR SERVER-FAILURE NAME-ERROR NOT-IMPLEMENTED [ answer-section>> [ rr->ba ] map concat ] [ authority-section>> [ rr->ba ] map concat ] [ additional-section>> [ rr->ba ] map concat ] - } - <arr> concat ; + } cleave + ] output>array concat ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -475,7 +480,7 @@ SYMBOLS: NO-ERROR FORMAT-ERROR SERVER-FAILURE NAME-ERROR NOT-IMPLEMENTED : ask ( message -- message ) dns-server ask-server ; -: query->message ( query -- message ) <message> swap {1} >>question-section ; +: query->message ( query -- message ) <message> swap 1array >>question-section ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/extra/dns/server/server.factor b/extra/dns/server/server.factor index d8a8adc88e..b14d765e8d 100644 --- a/extra/dns/server/server.factor +++ b/extra/dns/server/server.factor @@ -1,8 +1,8 @@ USING: kernel combinators sequences sets math threads namespaces continuations debugger io io.sockets unicode.case accessors destructors - combinators.cleave combinators.short-circuit - newfx fry + combinators.short-circuit combinators.smart + newfx fry arrays dns dns.util dns.misc ; IN: dns.server @@ -16,7 +16,7 @@ SYMBOL: records-var ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! : {name-type-class} ( obj -- array ) - { [ name>> >lower ] [ type>> ] [ class>> ] } <arr> ; + [ [ name>> >lower ] [ type>> ] [ class>> ] tri ] output>array ; : rr=query? ( obj obj -- ? ) [ {name-type-class} ] bi@ = ; @@ -52,9 +52,9 @@ SYMBOL: records-var : rr->rdata-names ( rr -- names/f ) { - { [ dup type>> NS = ] [ rdata>> {1} ] } - { [ dup type>> MX = ] [ rdata>> exchange>> {1} ] } - { [ dup type>> CNAME = ] [ rdata>> {1} ] } + { [ dup type>> NS = ] [ rdata>> 1array ] } + { [ dup type>> MX = ] [ rdata>> exchange>> 1array ] } + { [ dup type>> CNAME = ] [ rdata>> 1array ] } { [ t ] [ drop f ] } } cond ; diff --git a/extra/fuel/help/help.factor b/extra/fuel/help/help.factor index 64d77566b5..6368e542a7 100644 --- a/extra/fuel/help/help.factor +++ b/extra/fuel/help/help.factor @@ -4,7 +4,7 @@ USING: accessors arrays assocs combinators help help.crossref help.markup help.topics io io.streams.string kernel make namespaces parser prettyprint sequences summary tools.vocabs tools.vocabs.browser -vocabs vocabs.loader words ; +vocabs vocabs.loader words see ; IN: fuel.help @@ -31,6 +31,8 @@ IN: fuel.help : fuel-parent-topics ( word -- seq ) help-path [ dup article-title swap 2array ] map ; inline +SYMBOL: $doc-path + : (fuel-word-element) ( word -- element ) \ article swap dup article-title swap [ @@ -46,12 +48,13 @@ IN: fuel.help ] { } make 3array ; : fuel-vocab-help-row ( vocab -- element ) - [ vocab-status-string ] [ vocab-name ] [ summary ] tri 3array ; + [ vocab-name ] [ summary ] bi 2array ; : fuel-vocab-help-root-heading ( root -- element ) [ "Children from " prepend ] [ "Other children" ] if* \ $heading swap 2array ; SYMBOL: vocab-list +SYMBOL: describe-words : fuel-vocab-help-table ( vocabs -- element ) [ fuel-vocab-help-row ] map vocab-list prefix ; @@ -69,7 +72,7 @@ SYMBOL: vocab-list all-child-vocabs fuel-vocab-list ; inline : fuel-vocab-describe-words ( name -- element ) - [ describe-words ] with-string-writer \ describe-words swap 2array ; inline + [ words. ] with-string-writer \ describe-words swap 2array ; inline : (fuel-vocab-element) ( name -- element ) dup require \ article swap dup >vocab-link diff --git a/extra/fuel/xref/xref.factor b/extra/fuel/xref/xref.factor index 5f5e28d1d2..ec06b9892e 100644 --- a/extra/fuel/xref/xref.factor +++ b/extra/fuel/xref/xref.factor @@ -3,7 +3,8 @@ USING: accessors arrays assocs definitions help.topics io.pathnames kernel math math.order memoize namespaces sequences sets sorting -tools.crossref tools.vocabs vocabs vocabs.parser words ; +tools.completion tools.crossref tools.vocabs vocabs vocabs.parser +words ; IN: fuel.xref diff --git a/extra/game-input/game-input-tests.factor b/extra/game-input/game-input-tests.factor new file mode 100644 index 0000000000..a5c79e0268 --- /dev/null +++ b/extra/game-input/game-input-tests.factor @@ -0,0 +1,7 @@ +IN: game-input.tests +USING: game-input tools.test kernel system ; + +os windows? os macosx? or [ + [ ] [ open-game-input ] unit-test + [ ] [ close-game-input ] unit-test +] when \ No newline at end of file diff --git a/extra/images/viewer/viewer.factor b/extra/images/viewer/viewer.factor index faed31a0e5..4eaa984953 100644 --- a/extra/images/viewer/viewer.factor +++ b/extra/images/viewer/viewer.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors images images.loader io.pathnames kernel -namespaces opengl opengl.gl sequences strings ui ui.gadgets +USING: accessors images images.loader io.pathnames kernel namespaces +opengl opengl.gl opengl.textures sequences strings ui ui.gadgets ui.gadgets.panes ui.render ; IN: images.viewer @@ -12,14 +12,14 @@ M: image-gadget pref-dim* : draw-image ( image -- ) 0 0 glRasterPos2i 1.0 -1.0 glPixelZoom - [ dim>> first2 GL_RGBA GL_UNSIGNED_BYTE ] - [ bitmap>> ] bi glDrawPixels ; + [ dim>> first2 ] [ component-order>> component-order>format ] [ bitmap>> ] tri + glDrawPixels ; M: image-gadget draw-gadget* ( gadget -- ) image>> draw-image ; : <image-gadget> ( image -- gadget ) - \ image-gadget new-gadget + \ image-gadget new swap >>image ; : image-window ( path -- gadget ) diff --git a/extra/infix/infix.factor b/extra/infix/infix.factor index d39c0b3c2d..87080683b2 100644 --- a/extra/infix/infix.factor +++ b/extra/infix/infix.factor @@ -95,4 +95,4 @@ PRIVATE> : [infix| "|" parse-bindings "infix]" parse-infix-locals <let> - parsed-lambda ; parsing + ?rewrite-closures over push-all ; parsing diff --git a/extra/irc/client/client.factor b/extra/irc/client/client.factor index 2770471093..c82f2e292c 100755 --- a/extra/irc/client/client.factor +++ b/extra/irc/client/client.factor @@ -152,8 +152,6 @@ M: irc-chat to-chat in-messages>> mailbox-put ; [ (>>nick) ] [ (>>parameter) ] [ +mode+ >>action ] tri ] dip to-chat ] 3bi ; ! FIXME -DEFER: me? - ! ====================================== ! IRC client messages ! ====================================== diff --git a/extra/joystick-demo/joystick-demo.factor b/extra/joystick-demo/joystick-demo.factor index c7a774af31..3f24a5bb39 100755 --- a/extra/joystick-demo/joystick-demo.factor +++ b/extra/joystick-demo/joystick-demo.factor @@ -1,7 +1,7 @@ USING: ui ui.gadgets sequences kernel arrays math colors -ui.render math.vectors accessors fry ui.gadgets.packs game-input -ui.gadgets.labels ui.gadgets.borders alarms -calendar locals strings ui.gadgets.buttons +colors.constants ui.render ui.pens.polygon ui.pens.solid math.vectors +accessors fry ui.gadgets.packs game-input ui.gadgets.labels +ui.gadgets.borders alarms calendar locals strings ui.gadgets.buttons combinators math.parser assocs threads ; IN: joystick-demo @@ -56,11 +56,11 @@ CONSTANT: pov-polygons [ z-indicator>> (>>loc) ] 2bi* ; : move-pov ( gadget pov -- ) - swap pov>> [ interior>> -rot = [ gray ] [ white ] if >>color drop ] + swap pov>> [ interior>> -rot = COLOR: gray COLOR: white ? >>color drop ] with assoc-each ; :: add-pov-gadget ( gadget direction polygon -- gadget direction gadget ) - gadget white polygon <polygon-gadget> [ add-gadget ] keep + gadget COLOR: white polygon <polygon-gadget> [ add-gadget ] keep direction swap ; : add-pov-gadgets ( gadget -- gadget ) @@ -69,14 +69,14 @@ CONSTANT: pov-polygons : <axis-gadget> ( -- gadget ) axis-gadget new add-pov-gadgets - black <indicator-gadget> [ >>z-indicator ] [ add-gadget ] bi - red <indicator-gadget> [ >>indicator ] [ add-gadget ] bi + COLOR: black <indicator-gadget> [ >>z-indicator ] [ add-gadget ] bi + COLOR: red <indicator-gadget> [ >>indicator ] [ add-gadget ] bi dup [ 0.0 0.0 0.0 move-axis ] [ f move-pov ] bi ; TUPLE: joystick-demo-gadget < pack axis raxis controller buttons alarm ; : add-gadget-with-border ( parent child -- parent ) - { 2 2 } <border> gray <solid> >>boundary add-gadget ; + { 2 2 } <border> COLOR: gray <solid> >>boundary add-gadget ; : add-controller-label ( gadget controller -- gadget ) [ >>controller ] [ product-string <label> add-gadget ] bi ; @@ -89,7 +89,7 @@ TUPLE: joystick-demo-gadget < pack axis raxis controller buttons alarm ; :: (add-button-gadgets) ( gadget shelf -- ) gadget controller>> read-controller buttons>> length [ - number>string [ ] <bevel-button> + number>string [ drop ] <border-button> shelf over add-gadget drop ] map gadget (>>buttons) ; @@ -107,7 +107,7 @@ TUPLE: joystick-demo-gadget < pack axis raxis controller buttons alarm ; [ >>selected? drop ] 2each ; : kill-update-axes ( gadget -- ) - gray <solid> >>interior + COLOR: gray <solid> >>interior [ [ cancel-alarm ] when* f ] change-alarm relayout-1 ; diff --git a/extra/key-caps/key-caps.factor b/extra/key-caps/key-caps.factor index 8b97fc54b5..02f5ce8b21 100755 --- a/extra/key-caps/key-caps.factor +++ b/extra/key-caps/key-caps.factor @@ -139,7 +139,7 @@ TUPLE: key-caps-gadget < gadget keys alarm ; : make-key-gadget ( scancode dim array -- ) [ swap [ - " " [ drop ] <bevel-button> + " " [ drop ] <border-button> swap [ first >>loc ] [ second >>dim ] bi ] [ execute ] bi* ] dip set-nth ; diff --git a/extra/lcd/lcd.factor b/extra/lcd/lcd.factor index b7a3235ea8..1801ee2170 100755 --- a/extra/lcd/lcd.factor +++ b/extra/lcd/lcd.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors sequences kernel math io calendar grouping -calendar.format calendar.model arrays models models.arrow -namespaces ui.gadgets ui.gadgets.labels ui.gadgets.theme ui ; +calendar.format calendar.model fonts arrays models models.arrow +namespaces ui.gadgets ui.gadgets.labels ui ; IN: lcd : lcd-digit ( row digit -- str ) diff --git a/extra/literals/literals-tests.factor b/extra/literals/literals-tests.factor index 0e933d5209..024c94e4f2 100644 --- a/extra/literals/literals-tests.factor +++ b/extra/literals/literals-tests.factor @@ -2,11 +2,11 @@ USING: kernel literals math tools.test ; IN: literals.tests << -: six-six-six 6 6 6 ; +: six-six-six ( -- a b c ) 6 6 6 ; >> -: five 5 ; -: seven-eleven 7 11 ; +: five ( -- a ) 5 ; +: seven-eleven ( -- b c ) 7 11 ; [ { 5 } ] [ { $ five } ] unit-test [ { 7 11 } ] [ { $ seven-eleven } ] unit-test diff --git a/extra/literals/literals.factor b/extra/literals/literals.factor index d3cfcaae23..6bff666f07 100644 --- a/extra/literals/literals.factor +++ b/extra/literals/literals.factor @@ -3,4 +3,4 @@ USING: accessors continuations kernel parser words quotations vectors ; IN: literals : $ scan-word [ def>> call ] curry with-datastack >vector ; parsing -: $[ \ ] parse-until >quotation with-datastack >vector ; parsing +: $[ parse-quotation with-datastack >vector ; parsing diff --git a/extra/literals/tags.txt b/extra/literals/tags.txt index 71c0ff7282..4f4a20b1cb 100644 --- a/extra/literals/tags.txt +++ b/extra/literals/tags.txt @@ -1 +1,2 @@ +extensions syntax diff --git a/extra/mason/child/child.factor b/extra/mason/child/child.factor index 087ed2c3cb..1999c76d83 100644 --- a/extra/mason/child/child.factor +++ b/extra/mason/child/child.factor @@ -1,21 +1,22 @@ -! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. +! Copyright (C) 2008, 2009 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays calendar combinators.short-circuit -continuations debugger http.client io.directories io.files -io.launcher io.pathnames kernel make mason.common mason.config +continuations debugger http.client io.directories io.files io.launcher +io.pathnames io.encodings.ascii kernel make mason.common mason.config mason.platform mason.report mason.email namespaces sequences ; IN: mason.child : make-cmd ( -- args ) gnu-make platform 2array ; +: dll-url ( -- url ) + "http://factorcode.org/dlls/" + target-cpu get "x86.64" = [ "64/" append ] when ; + : download-dlls ( -- ) target-os get "winnt" = [ - "http://factorcode.org/dlls/" - target-cpu get "x86.64" = [ "64/" append ] when - [ "freetype6.dll" append ] - [ "zlib1.dll" append ] bi - [ download ] bi@ + dll-url "build-support/dlls.txt" ascii file-lines + [ append download ] with each ] when ; : make-vm ( -- ) diff --git a/extra/maze/maze.factor b/extra/maze/maze.factor index 14bbc5822e..c0623d96b6 100644 --- a/extra/maze/maze.factor +++ b/extra/maze/maze.factor @@ -1,7 +1,7 @@ ! From http://www.ffconsultancy.com/ocaml/maze/index.html USING: sequences namespaces math math.vectors opengl opengl.gl arrays kernel random ui ui.gadgets ui.gadgets.canvas ui.render -math.order math.rectangles ; +math.order math.rectangles accessors ; IN: maze CONSTANT: line-width 8 diff --git a/extra/multi-methods/multi-methods.factor b/extra/multi-methods/multi-methods.factor index 3370ab7f86..7c5d5fb431 100755 --- a/extra/multi-methods/multi-methods.factor +++ b/extra/multi-methods/multi-methods.factor @@ -5,7 +5,7 @@ combinators arrays words assocs parser namespaces make definitions prettyprint prettyprint.backend prettyprint.custom quotations generalizations debugger io compiler.units kernel.private effects accessors hashtables sorting shuffle -math.order sets ; +math.order sets see ; IN: multi-methods ! PART I: Converting hook specializers diff --git a/extra/multi-methods/tests/syntax.factor b/extra/multi-methods/tests/syntax.factor index 597a1cebeb..9d9c80b214 100644 --- a/extra/multi-methods/tests/syntax.factor +++ b/extra/multi-methods/tests/syntax.factor @@ -1,7 +1,7 @@ IN: multi-methods.tests USING: multi-methods tools.test math sequences namespaces system kernel strings definitions prettyprint debugger arrays -hashtables continuations classes assocs accessors ; +hashtables continuations classes assocs accessors see ; GENERIC: first-test diff --git a/extra/nehe/nehe.factor b/extra/nehe/nehe.factor index a96c024683..70ab0f0f5d 100644 --- a/extra/nehe/nehe.factor +++ b/extra/nehe/nehe.factor @@ -5,10 +5,10 @@ IN: nehe : nehe-window ( -- ) [ <filled-pile> - "Nehe 2" [ drop run2 ] <bevel-button> add-gadget - "Nehe 3" [ drop run3 ] <bevel-button> add-gadget - "Nehe 4" [ drop run4 ] <bevel-button> add-gadget - "Nehe 5" [ drop run5 ] <bevel-button> add-gadget + "Nehe 2" [ drop run2 ] <border-button> add-gadget + "Nehe 3" [ drop run3 ] <border-button> add-gadget + "Nehe 4" [ drop run4 ] <border-button> add-gadget + "Nehe 5" [ drop run5 ] <border-button> add-gadget "Nehe examples" open-window ] with-ui ; diff --git a/extra/opengl/demo-support/demo-support.factor b/extra/opengl/demo-support/demo-support.factor index 845c39ab75..5973766c8e 100755 --- a/extra/opengl/demo-support/demo-support.factor +++ b/extra/opengl/demo-support/demo-support.factor @@ -15,7 +15,7 @@ TUPLE: demo-gadget < gadget yaw pitch distance ; new swap >>distance swap >>pitch - swap >>yaw ; + swap >>yaw ; inline GENERIC: far-plane ( gadget -- z ) GENERIC: near-plane ( gadget -- z ) @@ -104,6 +104,6 @@ demo-gadget H{ { T{ button-down f f 1 } [ drop reset-last-drag-rel ] } { T{ drag f 1 } [ drag-yaw-pitch rot [ pitch-demo-gadget ] keep yaw-demo-gadget ] } - { T{ mouse-scroll } [ scroll-direction get second over distance-step * swap zoom-demo-gadget ] } + { mouse-scroll [ scroll-direction get second over distance-step * swap zoom-demo-gadget ] } } set-gestures diff --git a/extra/otug-talk/2bi.png b/extra/otug-talk/2bi.png deleted file mode 100644 index 8f431f87ce..0000000000 Binary files a/extra/otug-talk/2bi.png and /dev/null differ diff --git a/extra/otug-talk/2bi.tiff b/extra/otug-talk/2bi.tiff new file mode 100644 index 0000000000..16c0777254 Binary files /dev/null and b/extra/otug-talk/2bi.tiff differ diff --git a/extra/otug-talk/2bi_at.png b/extra/otug-talk/2bi_at.png deleted file mode 100644 index 55d42c2a4c..0000000000 Binary files a/extra/otug-talk/2bi_at.png and /dev/null differ diff --git a/extra/otug-talk/2bi_at.tiff b/extra/otug-talk/2bi_at.tiff new file mode 100644 index 0000000000..e41ab98eeb Binary files /dev/null and b/extra/otug-talk/2bi_at.tiff differ diff --git a/extra/otug-talk/2bi_star.png b/extra/otug-talk/2bi_star.png deleted file mode 100644 index 0fff37624b..0000000000 Binary files a/extra/otug-talk/2bi_star.png and /dev/null differ diff --git a/extra/otug-talk/2bi_star.tiff b/extra/otug-talk/2bi_star.tiff new file mode 100644 index 0000000000..f457ce5481 Binary files /dev/null and b/extra/otug-talk/2bi_star.tiff differ diff --git a/extra/otug-talk/bi.png b/extra/otug-talk/bi.png deleted file mode 100644 index 2470c9fab1..0000000000 Binary files a/extra/otug-talk/bi.png and /dev/null differ diff --git a/extra/otug-talk/bi.tiff b/extra/otug-talk/bi.tiff new file mode 100644 index 0000000000..ad0ce97cc0 Binary files /dev/null and b/extra/otug-talk/bi.tiff differ diff --git a/extra/otug-talk/bi_at.png b/extra/otug-talk/bi_at.png deleted file mode 100644 index 282f2f118d..0000000000 Binary files a/extra/otug-talk/bi_at.png and /dev/null differ diff --git a/extra/otug-talk/bi_at.tiff b/extra/otug-talk/bi_at.tiff new file mode 100644 index 0000000000..07d25bcd01 Binary files /dev/null and b/extra/otug-talk/bi_at.tiff differ diff --git a/extra/otug-talk/bi_star.png b/extra/otug-talk/bi_star.png deleted file mode 100644 index e94e3710cf..0000000000 Binary files a/extra/otug-talk/bi_star.png and /dev/null differ diff --git a/extra/otug-talk/bi_star.tiff b/extra/otug-talk/bi_star.tiff new file mode 100644 index 0000000000..17f3350b51 Binary files /dev/null and b/extra/otug-talk/bi_star.tiff differ diff --git a/extra/otug-talk/otug-talk.factor b/extra/otug-talk/otug-talk.factor index 16ee2b740b..2ce307ce20 100644 --- a/extra/otug-talk/otug-talk.factor +++ b/extra/otug-talk/otug-talk.factor @@ -1,41 +1,14 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: slides help.markup math arrays hashtables namespaces -sequences kernel sequences parser memoize io.encodings.binary -locals kernel.private tools.vocabs.browser assocs quotations - tools.vocabs tools.annotations tools.crossref -help.topics math.functions compiler.tree.optimizer -compiler.cfg.optimizer fry -ui.gadgets.panes tetris tetris.game combinators generalizations -multiline sequences.private ; +USING: slides help.markup math arrays hashtables namespaces sequences +kernel sequences parser memoize io.encodings.binary locals +kernel.private tools.vocabs.browser assocs quotations tools.vocabs +tools.annotations tools.crossref help.topics math.functions +compiler.tree.optimizer compiler.cfg.optimizer fry ui.gadgets.panes +tetris tetris.game combinators generalizations multiline +sequences.private ; IN: otug-talk -USING: cairo cairo.ffi cairo.gadgets accessors -io.backend ui.gadgets ; - -TUPLE: png-gadget < cairo-gadget surface ; - -: <png-gadget> ( file -- gadget ) - png-gadget new-gadget - swap normalize-path - cairo_image_surface_create_from_png >>surface ; inline - -M: png-gadget pref-dim* ( gadget -- ) - surface>> - [ cairo_image_surface_get_width ] - [ cairo_image_surface_get_height ] - bi 2array ; - -M: png-gadget render-cairo* ( gadget -- ) - cr swap surface>> 0 0 cairo_set_source_surface - cr cairo_paint ; - -M: png-gadget ungraft* ( gadget -- ) - surface>> cairo_surface_destroy ; - -: $bitmap ( element -- ) - [ first <png-gadget> gadget. ] ($block) ; - : $tetris ( element -- ) drop [ <default-tetris> <tetris-gadget> gadget. ] ($block) ; @@ -105,11 +78,11 @@ CONSTANT: otug-slides } { $slide "Data flow combinators - cleave family" { { $link bi } ", " { $link tri } ", " { $link cleave } } - { $bitmap "resource:extra/otug-talk/bi.png" } + { $image "resource:extra/otug-talk/bi.tiff" } } { $slide "Data flow combinators - cleave family" { { $link 2bi } ", " { $link 2tri } ", " { $link 2cleave } } - { $bitmap "resource:extra/otug-talk/2bi.png" } + { $image "resource:extra/otug-talk/2bi.tiff" } } { $slide "Data flow combinators" "First, let's define a data type:" @@ -128,19 +101,19 @@ CONSTANT: otug-slides } { $slide "Data flow combinators - spread family" { { $link bi* } ", " { $link tri* } ", " { $link spread } } - { $bitmap "resource:extra/otug-talk/bi_star.png" } + { $image "resource:extra/otug-talk/bi_star.tiff" } } { $slide "Data flow combinators - spread family" { { $link 2bi* } } - { $bitmap "resource:extra/otug-talk/2bi_star.png" } + { $image "resource:extra/otug-talk/2bi_star.tiff" } } { $slide "Data flow combinators - apply family" { { $link bi@ } ", " { $link tri@ } ", " { $link napply } } - { $bitmap "resource:extra/otug-talk/bi_at.png" } + { $image "resource:extra/otug-talk/bi_at.tiff" } } { $slide "Data flow combinators - apply family" { { $link 2bi@ } } - { $bitmap "resource:extra/otug-talk/2bi_at.png" } + { $image "resource:extra/otug-talk/2bi_at.tiff" } } { $slide "Shuffle words" "When data flow combinators are not enough" diff --git a/extra/rewrite-closures/rewrite-closures.factor b/extra/rewrite-closures/rewrite-closures.factor deleted file mode 100644 index 41e3d36c61..0000000000 --- a/extra/rewrite-closures/rewrite-closures.factor +++ /dev/null @@ -1,27 +0,0 @@ - -USING: kernel parser math quotations namespaces sequences macros fry ; - -IN: rewrite-closures - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: [set-parameters] ( seq -- quot ) reverse [ [ set ] curry ] map concat ; - -MACRO: set-parameters ( seq -- quot ) [set-parameters] ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: parametric-quot ( parameters quot -- quot ) '[ _ set-parameters _ call ] ; - -: scoped-quot ( quot -- quot ) '[ _ with-scope ] ; - -: closed-quot ( quot -- quot ) - namestack swap '[ namestack [ _ set-namestack @ ] dip set-namestack ] ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: lambda ( parameters quot -- quot ) parametric-quot scoped-quot closed-quot ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: C[ \ ] [ >quotation ] parse-literal \ closed-quot parsed ; parsing \ No newline at end of file diff --git a/extra/rewrite-closures/summary.txt b/extra/rewrite-closures/summary.txt deleted file mode 100644 index a5209bfe6e..0000000000 --- a/extra/rewrite-closures/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Closures implemented via quotation rewriting diff --git a/extra/self/self.factor b/extra/self/self.factor deleted file mode 100644 index 26f73d4938..0000000000 --- a/extra/self/self.factor +++ /dev/null @@ -1,10 +0,0 @@ - -USING: kernel namespaces vars ; - -IN: self - -VAR: self - -: with-self ( quot obj -- ) [ >self call ] with-scope ; - -: save-self ( quot -- ) self> [ self> clone >self call ] dip >self ; diff --git a/extra/self/slots/slots.factor b/extra/self/slots/slots.factor deleted file mode 100644 index b07641a062..0000000000 --- a/extra/self/slots/slots.factor +++ /dev/null @@ -1,27 +0,0 @@ - -USING: kernel words lexer parser sequences accessors self ; - -IN: self.slots - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: define-self-slot-reader ( slot -- ) - [ "->" append current-vocab create dup set-word ] - [ ">>" append search [ self> ] swap suffix ] bi - (( -- value )) define-declared ; - -: define-self-slot-writer ( slot -- ) - [ "->" prepend current-vocab create dup set-word ] - [ ">>" prepend search [ self> swap ] swap suffix [ drop ] append ] bi - (( value -- )) define-declared ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: define-self-slot-accessors ( class -- ) - "slots" word-prop - [ name>> ] map - [ [ define-self-slot-reader ] [ define-self-slot-writer ] bi ] each ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: SELF-SLOTS: scan-word define-self-slot-accessors ; parsing \ No newline at end of file diff --git a/extra/slides/slides.factor b/extra/slides/slides.factor index 4b2725fd97..752d0b3ffa 100755 --- a/extra/slides/slides.factor +++ b/extra/slides/slides.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays hashtables help.markup help.stylesheet io io.styles kernel math models namespaces sequences ui ui.gadgets -ui.gadgets.books ui.gadgets.panes ui.gestures ui.render +ui.gadgets.books ui.gadgets.panes ui.gestures ui.pens.gradient parser accessors colors ; IN: slides @@ -10,7 +10,7 @@ CONSTANT: stylesheet H{ { default-span-style H{ - { font "sans-serif" } + { font-name "sans-serif" } { font-size 36 } } } @@ -21,14 +21,14 @@ CONSTANT: stylesheet } { code-style H{ - { font "monospace" } + { font-name "monospace" } { font-size 36 } { page-color T{ rgba f 0.4 0.4 0.4 0.3 } } } } { snippet-style H{ - { font "monospace" } + { font-name "monospace" } { font-size 36 } { foreground T{ rgba f 0.1 0.1 0.4 1 } } } @@ -39,11 +39,10 @@ CONSTANT: stylesheet { list-style H{ { table-gap { 10 20 } } } } - { bullet "\u0000b7" } } : $title ( string -- ) - [ H{ { font "sans-serif" } { font-size 48 } } format ] ($block) ; + [ H{ { font-name "sans-serif" } { font-size 48 } } format ] ($block) ; : $divider ( -- ) [ @@ -99,6 +98,7 @@ TUPLE: slides < book ; parse-definition strip-tease [ parsed ] each ; parsing \ slides H{ + { T{ button-down } [ request-focus ] } { T{ key-down f f "DOWN" } [ next-page ] } { T{ key-down f f "UP" } [ prev-page ] } } set-gestures diff --git a/extra/spheres/spheres.factor b/extra/spheres/spheres.factor index f08e08c787..fa666dd776 100755 --- a/extra/spheres/spheres.factor +++ b/extra/spheres/spheres.factor @@ -1,4 +1,4 @@ -USING: kernel opengl opengl.demo-support opengl.gl +USING: kernel opengl opengl.demo-support opengl.gl opengl.textures opengl.shaders opengl.framebuffers opengl.capabilities multiline ui.gadgets accessors sequences ui.render ui math locals arrays generalizations combinators ui.gadgets.worlds ; diff --git a/extra/springies/models/urchin/authors.txt b/extra/springies/models/urchin/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/extra/springies/models/urchin/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/extra/springies/ui/authors.txt b/extra/springies/ui/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/extra/springies/ui/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/extra/tetris/board/board-tests.factor b/extra/tetris/board/board-tests.factor index 518b5544e9..81ee65bcb8 100644 --- a/extra/tetris/board/board-tests.factor +++ b/extra/tetris/board/board-tests.factor @@ -1,23 +1,23 @@ -USING: accessors arrays colors kernel tetris.board tetris.piece tools.test ; +USING: accessors arrays colors colors.constants kernel tetris.board tetris.piece tools.test ; [ { { f f } { f f } { f f } } ] [ 2 3 make-rows ] unit-test [ { { f f } { f f } { f f } } ] [ 2 3 <board> rows>> ] unit-test [ 1 { f f } ] [ 2 3 <board> { 1 1 } board@block ] unit-test [ f ] [ 2 3 <board> { 1 1 } block ] unit-test [ 2 3 <board> { 2 3 } block ] must-fail -red 1array [ 2 3 <board> dup { 1 1 } red set-block { 1 1 } block ] unit-test +COLOR: red 1array [ 2 3 <board> dup { 1 1 } COLOR: red set-block { 1 1 } block ] unit-test [ t ] [ 2 3 <board> { 1 1 } block-free? ] unit-test -[ f ] [ 2 3 <board> dup { 1 1 } red set-block { 1 1 } block-free? ] unit-test -[ t ] [ 2 3 <board> dup { 1 1 } red set-block { 1 2 } block-free? ] unit-test -[ t ] [ 2 3 <board> dup { 1 1 } red set-block { 0 1 } block-free? ] unit-test +[ f ] [ 2 3 <board> dup { 1 1 } COLOR: red set-block { 1 1 } block-free? ] unit-test +[ t ] [ 2 3 <board> dup { 1 1 } COLOR: red set-block { 1 2 } block-free? ] unit-test +[ t ] [ 2 3 <board> dup { 1 1 } COLOR: red set-block { 0 1 } block-free? ] unit-test [ t ] [ 2 3 <board> { 0 0 } block-in-bounds? ] unit-test [ f ] [ 2 3 <board> { -1 0 } block-in-bounds? ] unit-test [ t ] [ 2 3 <board> { 1 2 } block-in-bounds? ] unit-test [ f ] [ 2 3 <board> { 2 2 } block-in-bounds? ] unit-test [ t ] [ 2 3 <board> { 1 1 } location-valid? ] unit-test -[ f ] [ 2 3 <board> dup { 1 1 } red set-block { 1 1 } location-valid? ] unit-test +[ f ] [ 2 3 <board> dup { 1 1 } COLOR: red set-block { 1 1 } location-valid? ] unit-test [ t ] [ 10 10 <board> 10 <random-piece> piece-valid? ] unit-test [ f ] [ 2 3 <board> 10 <random-piece> { 1 2 } >>location piece-valid? ] unit-test [ { { f } { f } } ] [ 1 1 <board> add-row rows>> ] unit-test -[ { { f } } ] [ 1 2 <board> dup { 0 1 } red set-block remove-full-rows rows>> ] unit-test -[ { { f } { f } } ] [ 1 2 <board> dup { 0 1 } red set-block dup check-rows drop rows>> ] unit-test +[ { { f } } ] [ 1 2 <board> dup { 0 1 } COLOR: red set-block remove-full-rows rows>> ] unit-test +[ { { f } { f } } ] [ 1 2 <board> dup { 0 1 } COLOR: red set-block dup check-rows drop rows>> ] unit-test diff --git a/extra/tetris/gl/gl.factor b/extra/tetris/gl/gl.factor index e7c01742d5..f8c901ff56 100644 --- a/extra/tetris/gl/gl.factor +++ b/extra/tetris/gl/gl.factor @@ -1,6 +1,8 @@ ! Copyright (C) 2006, 2007, 2008 Alex Chapman ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays combinators kernel math math.vectors namespaces opengl opengl.gl sequences tetris.board tetris.game tetris.piece ui.render tetris.tetromino ui.gadgets ; +USING: accessors arrays combinators kernel math math.vectors +namespaces opengl opengl.gl sequences tetris.board tetris.game +tetris.piece ui.render tetris.tetromino ui.gadgets colors ; IN: tetris.gl #! OpenGL rendering for tetris @@ -16,7 +18,7 @@ IN: tetris.gl : draw-next-piece ( piece -- ) dup tetromino>> colour>> - clone 0.2 >>alpha gl-color draw-piece-blocks ; + >rgba-components drop 0.2 <rgba> gl-color draw-piece-blocks ; ! TODO: move implementation specific stuff into tetris-board : (draw-row) ( x y row -- ) @@ -33,7 +35,7 @@ IN: tetris.gl : scale-board ( width height board -- ) [ width>> ] [ height>> ] bi swapd [ / ] dup 2bi* 1 glScalef ; -: (draw-tetris) ( width height tetris -- ) +: draw-tetris ( width height tetris -- ) #! width and height are in pixels GL_MODELVIEW [ { @@ -42,7 +44,4 @@ IN: tetris.gl [ next-piece draw-next-piece ] [ current-piece draw-piece ] } cleave - ] do-matrix ; - -: draw-tetris ( width height tetris -- ) - origin get [ (draw-tetris) ] with-translation ; + ] do-matrix ; \ No newline at end of file diff --git a/extra/tetris/tetromino/tetromino.factor b/extra/tetris/tetromino/tetromino.factor index 127e4854e0..68f8e85a4a 100644 --- a/extra/tetris/tetromino/tetromino.factor +++ b/extra/tetris/tetromino/tetromino.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2006, 2007, 2008 Alex Chapman ! See http://factorcode.org/license.txt for BSD license. USING: kernel arrays namespaces sequences math math.order -math.vectors colors random ; +math.vectors colors colors.constants random ; IN: tetris.tetromino TUPLE: tetromino states colour ; @@ -20,7 +20,7 @@ SYMBOL: tetrominoes { 0 2 } { 0 3 } } - } cyan + } COLOR: cyan ] [ { { { 1 0 } @@ -37,11 +37,11 @@ SYMBOL: tetrominoes { 0 1 } { 1 1 } { 1 2 } } - } purple + } COLOR: purple ] [ { { { 0 0 } { 1 0 } { 0 1 } { 1 1 } } - } yellow + } COLOR: yellow ] [ { { { 0 0 } { 1 0 } { 2 0 } @@ -58,7 +58,7 @@ SYMBOL: tetrominoes { 0 1 } { 0 2 } { 1 2 } } - } orange + } COLOR: orange ] [ { { { 0 0 } { 1 0 } { 2 0 } @@ -75,7 +75,7 @@ SYMBOL: tetrominoes { 0 1 } { 0 2 } } - } blue + } COLOR: blue ] [ { { { 1 0 } { 2 0 } @@ -85,7 +85,7 @@ SYMBOL: tetrominoes { 0 1 } { 1 1 } { 1 2 } } - } green + } COLOR: green ] [ { { @@ -96,9 +96,9 @@ SYMBOL: tetrominoes { 0 1 } { 1 1 } { 0 2 } } - } red + } COLOR: red ] -} [ call <tetromino> ] map tetrominoes set-global +} [ first2 <tetromino> ] map tetrominoes set-global : random-tetromino ( -- tetromino ) tetrominoes get random ; diff --git a/extra/ui/gadgets/handler/authors.txt b/extra/ui/gadgets/handler/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/extra/ui/gadgets/handler/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/extra/ui/gadgets/handler/handler.factor b/extra/ui/gadgets/handler/handler.factor deleted file mode 100644 index 1c12142593..0000000000 --- a/extra/ui/gadgets/handler/handler.factor +++ /dev/null @@ -1,11 +0,0 @@ - -USING: kernel assocs ui.gestures ui.gadgets.wrappers accessors ; - -IN: ui.gadgets.handler - -TUPLE: handler < wrapper table ; - -: <handler> ( child -- handler ) handler new-wrapper ; - -M: handler handle-gesture ( gesture gadget -- ? ) - tuck table>> at dup [ call f ] [ 2drop t ] if ; \ No newline at end of file diff --git a/extra/ui/gadgets/lists/lists.factor b/extra/ui/gadgets/lists/lists.factor index a22435af20..982aabe2e8 100644 --- a/extra/ui/gadgets/lists/lists.factor +++ b/extra/ui/gadgets/lists/lists.factor @@ -1,11 +1,10 @@ ! Copyright (C) 2006, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors math.vectors classes.tuple math.rectangles colors -kernel sequences models opengl math math.order namespaces -ui.commands ui.gestures ui.render ui.gadgets -ui.gadgets.labels ui.gadgets.scrollers -ui.gadgets.presentations ui.gadgets.viewports ui.gadgets.packs -ui.gadgets.theme ; +kernel sequences models opengl math math.order namespaces call +ui.commands ui.gestures ui.render ui.gadgets ui.gadgets.labels +ui.gadgets.scrollers ui.gadgets.presentations ui.gadgets.viewports +ui.gadgets.packs ; IN: ui.gadgets.lists TUPLE: list < pack index presenter color hook ; @@ -14,7 +13,7 @@ TUPLE: list < pack index presenter color hook ; selection-color >>color ; inline : <list> ( hook presenter model -- gadget ) - list new-gadget + list new { 0 1 } >>orientation 1 >>fill 0 >>index @@ -33,7 +32,7 @@ TUPLE: list < pack index presenter color hook ; hook>> [ [ list? ] find-parent ] prepend ; : <list-presentation> ( hook elt presenter -- gadget ) - keep [ >label text-theme ] dip + [ call( elt -- obj ) ] [ drop ] 2bi [ >label text-theme ] dip <presentation> swap >>hook ; inline diff --git a/extra/ui/gadgets/slate/authors.txt b/extra/ui/gadgets/slate/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/extra/ui/gadgets/slate/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/extra/ui/gadgets/slate/slate-docs.factor b/extra/ui/gadgets/slate/slate-docs.factor deleted file mode 100644 index 0225c20a1e..0000000000 --- a/extra/ui/gadgets/slate/slate-docs.factor +++ /dev/null @@ -1,13 +0,0 @@ -! Copyright (C) 2009 Eduardo Cavazos -! See http://factorcode.org/license.txt for BSD license. -USING: help.markup help.syntax multiline ; -IN: ui.gadgets.slate - -ARTICLE: "ui.gadgets.slate" "Slate gadget" -{ $description "A gadget with an 'action' slot which should be set to a callable."} -{ $heading "Example" } -{ $code <" USING: processing.shapes ui.gadgets.slate ui.gadgets.panes ; -[ { { 10 10 } { 50 30 } { 10 50 } } polygon fill-mode ] <slate> -gadget."> } ; - -ABOUT: "ui.gadgets.slate" diff --git a/extra/ui/gadgets/slate/slate.factor b/extra/ui/gadgets/slate/slate.factor deleted file mode 100644 index 6813388afc..0000000000 --- a/extra/ui/gadgets/slate/slate.factor +++ /dev/null @@ -1,122 +0,0 @@ -! Copyright (C) 2009 Eduardo Cavazos -! See http://factorcode.org/license.txt for BSD license. -USING: kernel namespaces opengl ui.render ui.gadgets accessors ; - -IN: ui.gadgets.slate - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -TUPLE: slate < gadget action pdim graft ungraft ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: init-slate ( slate -- slate ) - init-gadget - [ ] >>action - { 200 200 } >>pdim - [ ] >>graft - [ ] >>ungraft ; - -: <slate> ( action -- slate ) - slate new - init-slate - swap >>action ; - -M: slate pref-dim* ( slate -- dim ) pdim>> ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -USING: combinators arrays sequences math math.geometry - opengl.gl ui.gadgets.worlds ; - -: screen-y* ( gadget -- loc ) - { - [ find-world height ] - [ screen-loc second ] - [ height ] - } - cleave - + - ; - -: screen-loc* ( gadget -- loc ) - { - [ screen-loc first ] - [ screen-y* ] - } - cleave - 2array ; - -: setup-viewport ( gadget -- gadget ) - dup - { - [ screen-loc* ] - [ dim>> ] - } - cleave - gl-viewport ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: default-coordinate-system ( gadget -- gadget ) - dup - { - [ drop 0 ] - [ width 1 - ] - [ height 1 - ] - [ drop 0 ] - } - cleave - -1 1 - glOrtho ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -M: slate graft* ( slate -- ) graft>> call ; -M: slate ungraft* ( slate -- ) ungraft>> call ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -GENERIC: establish-coordinate-system ( gadget -- gadget ) - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -M: slate establish-coordinate-system ( slate -- slate ) - default-coordinate-system ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -GENERIC: draw-slate ( slate -- slate ) - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -M: slate draw-slate ( slate -- slate ) dup action>> call ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -M: slate draw-gadget* ( slate -- ) - - GL_PROJECTION glMatrixMode glPushMatrix glLoadIdentity - - establish-coordinate-system - - GL_MODELVIEW glMatrixMode glPushMatrix glLoadIdentity - - setup-viewport - - draw-slate - - GL_PROJECTION glMatrixMode glPopMatrix glLoadIdentity - GL_MODELVIEW glMatrixMode glPopMatrix glLoadIdentity - - dup - find-world - ! The world coordinate system is a little wacky: - dup { [ drop 0 ] [ width ] [ height ] [ drop 0 ] } cleave -1 1 glOrtho - setup-viewport - drop - drop ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/extra/update/util/util.factor b/extra/update/util/util.factor index b638b61528..beeddc7abb 100644 --- a/extra/update/util/util.factor +++ b/extra/update/util/util.factor @@ -1,6 +1,6 @@ USING: kernel classes strings quotations words math math.parser arrays - combinators.cleave + combinators.smart accessors system prettyprint splitting sequences combinators sequences.deep @@ -58,5 +58,5 @@ DEFER: to-strings : datestamp ( -- string ) now - { year>> month>> day>> hour>> minute>> } <arr> + [ { [ year>> ] [ month>> ] [ day>> ] [ hour>> ] [ minute>> ] } cleave ] output>array [ pad-00 ] map "-" join ; diff --git a/extra/webapps/planet/planet.xml b/extra/webapps/planet/planet.xml index 412f42c64e..08cf07d4ce 100644 --- a/extra/webapps/planet/planet.xml +++ b/extra/webapps/planet/planet.xml @@ -2,6 +2,8 @@ <t:chloe xmlns:t="http://factorcode.org/chloe/1.0"> + <t:atom t:href="$planet/feed.xml">[ planet-factor ]</t:atom> + <t:title>[ planet-factor ]</t:title> <table width="100%" cellpadding="10"> diff --git a/misc/fuel/fuel-markup.el b/misc/fuel/fuel-markup.el index 3a00b70ab1..80fe8e830b 100644 --- a/misc/fuel/fuel-markup.el +++ b/misc/fuel/fuel-markup.el @@ -335,9 +335,8 @@ (defun fuel-markup--vocab-list (e) (let ((rows (mapcar '(lambda (elem) - (list (car elem) - (list '$vocab-link (cadr elem)) - (caddr elem))) + (list (list '$vocab-link (car elem)) + (cadr elem))) (cdr e)))) (fuel-markup--table (cons '$table rows)))) diff --git a/extra/L-system/L-system.factor b/unmaintained/L-system/L-system.factor similarity index 100% rename from extra/L-system/L-system.factor rename to unmaintained/L-system/L-system.factor diff --git a/extra/L-system/models/abop-1/abop-1.factor b/unmaintained/L-system/models/abop-1/abop-1.factor similarity index 100% rename from extra/L-system/models/abop-1/abop-1.factor rename to unmaintained/L-system/models/abop-1/abop-1.factor diff --git a/extra/L-system/models/abop-2/abop-2.factor b/unmaintained/L-system/models/abop-2/abop-2.factor similarity index 100% rename from extra/L-system/models/abop-2/abop-2.factor rename to unmaintained/L-system/models/abop-2/abop-2.factor diff --git a/extra/L-system/models/abop-3/abop-3.factor b/unmaintained/L-system/models/abop-3/abop-3.factor similarity index 100% rename from extra/L-system/models/abop-3/abop-3.factor rename to unmaintained/L-system/models/abop-3/abop-3.factor diff --git a/extra/L-system/models/abop-4/abop-4.factor b/unmaintained/L-system/models/abop-4/abop-4.factor similarity index 100% rename from extra/L-system/models/abop-4/abop-4.factor rename to unmaintained/L-system/models/abop-4/abop-4.factor diff --git a/extra/L-system/models/abop-5-angular/abop-5-angular.factor b/unmaintained/L-system/models/abop-5-angular/abop-5-angular.factor similarity index 100% rename from extra/L-system/models/abop-5-angular/abop-5-angular.factor rename to unmaintained/L-system/models/abop-5-angular/abop-5-angular.factor diff --git a/extra/L-system/models/abop-5/abop-5.factor b/unmaintained/L-system/models/abop-5/abop-5.factor similarity index 100% rename from extra/L-system/models/abop-5/abop-5.factor rename to unmaintained/L-system/models/abop-5/abop-5.factor diff --git a/extra/L-system/models/abop-6/abop-6.factor b/unmaintained/L-system/models/abop-6/abop-6.factor similarity index 100% rename from extra/L-system/models/abop-6/abop-6.factor rename to unmaintained/L-system/models/abop-6/abop-6.factor diff --git a/extra/L-system/models/airhorse/airhorse.factor b/unmaintained/L-system/models/airhorse/airhorse.factor similarity index 100% rename from extra/L-system/models/airhorse/airhorse.factor rename to unmaintained/L-system/models/airhorse/airhorse.factor diff --git a/extra/L-system/models/tree-5/tree-5.factor b/unmaintained/L-system/models/tree-5/tree-5.factor similarity index 100% rename from extra/L-system/models/tree-5/tree-5.factor rename to unmaintained/L-system/models/tree-5/tree-5.factor diff --git a/unmaintained/assocs-lib/authors.txt b/unmaintained/assocs-lib/authors.txt deleted file mode 100644 index 6cfd5da273..0000000000 --- a/unmaintained/assocs-lib/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/assocs-lib/lib-tests.factor b/unmaintained/assocs-lib/lib-tests.factor deleted file mode 100644 index c7e1aa4fbf..0000000000 --- a/unmaintained/assocs-lib/lib-tests.factor +++ /dev/null @@ -1,17 +0,0 @@ -USING: kernel tools.test sequences vectors assocs.lib ; -IN: assocs.lib.tests - -{ 1 1 } [ [ ?push ] histogram ] must-infer-as - -! substitute -[ { 2 } ] [ { 1 } H{ { 1 2 } } [ ?at drop ] curry map ] unit-test -[ { 3 } ] [ { 3 } H{ { 1 2 } } [ ?at drop ] curry map ] unit-test - -[ 2 ] [ 1 H{ { 1 2 } } [ ] [ ] if-at ] unit-test -[ 3 ] [ 3 H{ { 1 2 } } [ ] [ ] if-at ] unit-test - -[ "hi" ] [ 1 H{ { 1 2 } } [ drop "hi" ] when-at ] unit-test -[ 3 ] [ 3 H{ { 1 2 } } [ drop "hi" ] when-at ] unit-test -[ 2 ] [ 1 H{ { 1 2 } } [ drop "hi" ] unless-at ] unit-test -[ "hi" ] [ 3 H{ { 1 2 } } [ drop "hi" ] unless-at ] unit-test - diff --git a/unmaintained/assocs-lib/lib.factor b/unmaintained/assocs-lib/lib.factor deleted file mode 100755 index f1b018f54e..0000000000 --- a/unmaintained/assocs-lib/lib.factor +++ /dev/null @@ -1,49 +0,0 @@ -USING: arrays assocs kernel vectors sequences namespaces - random math.parser math fry ; - -IN: assocs.lib - -: set-assoc-stack ( value key seq -- ) - dupd [ key? ] with find-last nip set-at ; - -: at-default ( key assoc -- value/key ) - dupd at [ nip ] when* ; - -: replace-at ( assoc value key -- assoc ) - [ dupd 1vector ] dip rot set-at ; - -: peek-at* ( assoc key -- obj ? ) - swap at* dup [ [ peek ] dip ] when ; - -: peek-at ( assoc key -- obj ) - peek-at* drop ; - -: >multi-assoc ( assoc -- new-assoc ) - [ 1vector ] assoc-map ; - -: multi-assoc-each ( assoc quot -- ) - [ with each ] curry assoc-each ; inline - -: insert ( value variable -- ) namespace push-at ; - -: generate-key ( assoc -- str ) - [ 32 random-bits >hex ] dip - 2dup key? [ nip generate-key ] [ drop ] if ; - -: set-at-unique ( value assoc -- key ) - dup generate-key [ swap set-at ] keep ; - -: histogram ( assoc quot -- assoc' ) - H{ } clone [ - swap [ change-at ] 2curry assoc-each - ] keep ; inline - -: ?at ( obj assoc -- value/obj ? ) - dupd at* [ [ nip ] [ drop ] if ] keep ; - -: if-at ( obj assoc quot1 quot2 -- ) - [ ?at ] 2dip if ; inline - -: when-at ( obj assoc quot -- ) [ ] if-at ; inline - -: unless-at ( obj assoc quot -- ) [ ] swap if-at ; inline diff --git a/unmaintained/assocs-lib/summary.txt b/unmaintained/assocs-lib/summary.txt deleted file mode 100644 index 24c282540c..0000000000 --- a/unmaintained/assocs-lib/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Non-core assoc words diff --git a/unmaintained/assocs-lib/tags.txt b/unmaintained/assocs-lib/tags.txt deleted file mode 100644 index 42d711b32b..0000000000 --- a/unmaintained/assocs-lib/tags.txt +++ /dev/null @@ -1 +0,0 @@ -collections diff --git a/extra/automata/authors.txt b/unmaintained/automata/authors.txt similarity index 100% rename from extra/automata/authors.txt rename to unmaintained/automata/authors.txt diff --git a/extra/automata/automata.factor b/unmaintained/automata/automata.factor similarity index 100% rename from extra/automata/automata.factor rename to unmaintained/automata/automata.factor diff --git a/extra/automata/summary.txt b/unmaintained/automata/summary.txt similarity index 100% rename from extra/automata/summary.txt rename to unmaintained/automata/summary.txt diff --git a/extra/automata/ui/authors.txt b/unmaintained/automata/ui/authors.txt similarity index 100% rename from extra/automata/ui/authors.txt rename to unmaintained/automata/ui/authors.txt diff --git a/extra/automata/ui/deploy.factor b/unmaintained/automata/ui/deploy.factor similarity index 100% rename from extra/automata/ui/deploy.factor rename to unmaintained/automata/ui/deploy.factor diff --git a/extra/automata/ui/tags.txt b/unmaintained/automata/ui/tags.txt similarity index 100% rename from extra/automata/ui/tags.txt rename to unmaintained/automata/ui/tags.txt diff --git a/extra/automata/ui/ui.factor b/unmaintained/automata/ui/ui.factor similarity index 100% rename from extra/automata/ui/ui.factor rename to unmaintained/automata/ui/ui.factor diff --git a/unmaintained/bake/authors.txt b/unmaintained/bake/authors.txt deleted file mode 100644 index 6cfd5da273..0000000000 --- a/unmaintained/bake/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/bake/bake-tests.factor b/unmaintained/bake/bake-tests.factor deleted file mode 100644 index 64329de92d..0000000000 --- a/unmaintained/bake/bake-tests.factor +++ /dev/null @@ -1,28 +0,0 @@ - -USING: kernel tools.test bake ; - -IN: bake.tests - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: unit-test* ( input output -- ) swap unit-test ; - -: must-be-t ( in -- ) [ t ] swap unit-test ; -: must-be-f ( in -- ) [ f ] swap unit-test ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -[ 10 20 30 `{ , , , } ] [ { 10 20 30 } ] unit-test* - -[ 10 20 30 `{ , { , } , } ] [ { 10 { 20 } 30 } ] unit-test* - -[ 10 { 20 21 22 } 30 `{ , , , } ] [ { 10 { 20 21 22 } 30 } ] unit-test* - -[ 10 { 20 21 22 } 30 `{ , @ , } ] [ { 10 20 21 22 30 } ] unit-test* - -[ { 1 2 3 } `{ @ } ] [ { 1 2 3 } ] unit-test* - -[ { 1 2 3 } { 4 5 6 } { 7 8 9 } `{ @ @ @ } ] -[ { 1 2 3 4 5 6 7 8 9 } ] -unit-test* - diff --git a/unmaintained/bake/bake.factor b/unmaintained/bake/bake.factor deleted file mode 100644 index 25cc0bb289..0000000000 --- a/unmaintained/bake/bake.factor +++ /dev/null @@ -1,97 +0,0 @@ - -USING: kernel parser namespaces sequences quotations arrays vectors splitting - strings words math generalizations - macros combinators.conditional newfx ; - -IN: bake - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYMBOL: , -SYMBOL: @ - -: comma? ( obj -- ? ) , = ; -: atsym? ( obj -- ? ) @ = ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -DEFER: [bake] - -: broil-element ( obj -- quot ) - { - { [ comma? ] [ drop [ >r ] ] } - { [ f = ] [ [ >r ] prefix-on ] } - { [ integer? ] [ [ >r ] prefix-on ] } - { [ string? ] [ [ >r ] prefix-on ] } - { [ sequence? ] [ [bake] [ >r ] append ] } - { [ word? ] [ literalize [ >r ] prefix-on ] } - { [ drop t ] [ [ >r ] prefix-on ] } - } - 1cond ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: constructor ( seq -- quot ) - { - { [ array? ] [ length [ narray ] prefix-on ] } -! { [ quotation? ] [ length [ ncurry ] prefix-on [ ] prefix ] } - { [ quotation? ] [ length [ narray >quotation ] prefix-on ] } - { [ vector? ] [ length [ narray >vector ] prefix-on ] } - } - 1cond ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: [broil] ( seq -- quot ) - [ reverse [ broil-element ] map concat ] - [ length [ drop [ r> ] ] map concat ] - [ constructor ] - tri append append - >quotation ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYMBOL: saved-sequence - -: [connector] ( -- quot ) - saved-sequence get quotation? [ [ compose ] ] [ [ append ] ] if ; - -: [starter] ( -- quot ) - saved-sequence get - { - { [ quotation? ] [ drop [ [ ] ] ] } - { [ array? ] [ drop [ { } ] ] } - { [ vector? ] [ drop [ V{ } ] ] } - } - 1cond ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: [simmer] ( seq -- quot ) - - dup saved-sequence set - - { @ } split reverse - [ [ [bake] [connector] append [ >r ] append ] map concat ] - [ length [ drop [ r> ] [connector] append ] map concat ] - bi - - >r 1 invert-index pluck r> ! remove the last append/compose - - [starter] prepend - - append ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: [bake] ( seq -- quot ) [ @ member? ] [ [simmer] ] [ [broil] ] 1if ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -MACRO: bake ( seq -- quot ) [bake] ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: `{ \ } [ >array ] parse-literal \ bake parsed ; parsing -: `V{ \ } [ >vector ] parse-literal \ bake parsed ; parsing -: `[ \ ] [ >quotation ] parse-literal \ bake parsed ; parsing \ No newline at end of file diff --git a/unmaintained/bake/fry/fry-tests.factor b/unmaintained/bake/fry/fry-tests.factor deleted file mode 100755 index 74408dc9f9..0000000000 --- a/unmaintained/bake/fry/fry-tests.factor +++ /dev/null @@ -1,89 +0,0 @@ - -USING: tools.test math prettyprint kernel io arrays vectors sequences - generalizations bake bake.fry ; - -IN: bake.fry.tests - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: unit-test* ( input output -- ) swap unit-test ; - -: must-be-t ( in -- ) [ t ] swap unit-test ; -: must-be-f ( in -- ) [ f ] swap unit-test ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -[ [ 3 + ] ] [ 3 '[ , + ] ] unit-test - -[ [ 1 3 + ] ] [ 1 3 '[ , , + ] ] unit-test - -[ [ 1 + ] ] [ 1 [ + ] '[ , @ ] ] unit-test - -[ [ 1 + . ] ] [ 1 [ + ] '[ , @ . ] ] unit-test - -[ [ + - ] ] [ [ + ] [ - ] '[ @ @ ] ] unit-test - -[ [ "a" write "b" print ] ] -[ "a" "b" '[ , write , print ] ] unit-test - -[ [ 1 2 + 3 4 - ] ] -[ [ + ] [ - ] '[ 1 2 @ 3 4 @ ] ] unit-test - -[ 1/2 ] [ - 1 '[ , _ / ] 2 swap call -] unit-test - -[ { { 1 "a" "A" } { 1 "b" "B" } { 1 "c" "C" } } ] [ - 1 '[ , _ _ 3array ] - { "a" "b" "c" } { "A" "B" "C" } rot 2map -] unit-test - -[ { { 1 "a" } { 1 "b" } { 1 "c" } } ] [ - '[ 1 _ 2array ] - { "a" "b" "c" } swap map -] unit-test - -[ 1 2 ] [ - 1 2 '[ _ , ] call -] unit-test - -[ { { 1 "a" 2 } { 1 "b" 2 } { 1 "c" 2 } } ] [ - 1 2 '[ , _ , 3array ] - { "a" "b" "c" } swap map -] unit-test - -: funny-dip '[ @ _ ] call ; inline - -[ "hi" 3 ] [ "h" "i" 3 [ append ] funny-dip ] unit-test - -[ { 1 2 3 } ] [ - 3 1 '[ , [ , + ] map ] call -] unit-test - -[ { 1 { 2 { 3 } } } ] [ - 1 2 3 '[ , [ , [ , 1array ] call 2array ] call 2array ] call -] unit-test - -{ 1 1 } [ '[ [ [ , ] ] ] ] must-infer-as - -[ { { { 3 } } } ] [ - 3 '[ [ [ , 1array ] call 1array ] call 1array ] call -] unit-test - -[ { { { 3 } } } ] [ - 3 '[ [ [ , 1array ] call 1array ] call 1array ] call -] unit-test - -! [ 10 20 30 40 '[ , V{ , { , } } , ] ] [ [ 10 V{ 20 { 30 } } 40 ] ] unit-test* - -[ 10 20 30 40 '[ , V{ , { , } } , ] ] -[ [ 10 20 30 >r r> 1 narray >r >r r> r> 2 narray >vector 40 ] ] -unit-test* - -[ { 1 2 3 } { 4 5 6 } { 7 8 9 } '[ , { V{ @ } { , } } ] call ] -[ - { 1 2 3 } - { V{ 4 5 6 } { { 7 8 9 } } } -] -unit-test* - diff --git a/unmaintained/bake/fry/fry.factor b/unmaintained/bake/fry/fry.factor deleted file mode 100644 index d82500edba..0000000000 --- a/unmaintained/bake/fry/fry.factor +++ /dev/null @@ -1,80 +0,0 @@ - -USING: kernel combinators arrays vectors quotations sequences splitting - parser macros sequences.deep - combinators.short-circuit combinators.conditional bake newfx ; - -IN: bake.fry - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYMBOL: _ - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -DEFER: (shallow-fry) -DEFER: shallow-fry - -: ((shallow-fry)) ( accum quot adder -- result ) - >r shallow-fry r> - append swap dup empty? - [ drop ] - [ [ prepose ] curry append ] - if ; inline - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: (shallow-fry) ( accum quot -- result ) - dup empty? - [ drop 1quotation ] - [ - unclip - { - { \ , [ [ curry ] ((shallow-fry)) ] } - { \ @ [ [ compose ] ((shallow-fry)) ] } - [ swap >r suffix r> (shallow-fry) ] - } - case - ] - if ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: shallow-fry ( quot -- quot' ) [ ] swap (shallow-fry) ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: deep-fry ( quot -- quot ) - { _ } split1-last dup - [ - shallow-fry [ >r ] rot - deep-fry [ [ dip ] curry r> compose ] 4array concat - ] - [ drop shallow-fry ] - if ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: bakeable? ( obj -- ? ) { [ array? ] [ vector? ] } 1|| ; - -: fry-specifier? ( obj -- ? ) { , @ } member-of? ; - -: count-inputs ( quot -- n ) flatten [ fry-specifier? ] count ; - -: commas ( n -- seq ) , <repetition> ; - -: [fry] ( quot -- quot' ) - [ - { - { [ callable? ] [ [ count-inputs commas ] [ [fry] ] bi append ] } - { [ bakeable? ] [ [ count-inputs commas ] [ [bake] ] bi append ] } - { [ drop t ] [ 1quotation ] } - } - 1cond - ] - map concat deep-fry ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -MACRO: fry ( seq -- quot ) [fry] ; - -: '[ \ ] [ >quotation ] parse-literal \ fry parsed ; parsing diff --git a/unmaintained/bake/summary.txt b/unmaintained/bake/summary.txt deleted file mode 100644 index cfc944a0b2..0000000000 --- a/unmaintained/bake/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Bake is similar to make but with additional features diff --git a/unmaintained/bitfields/bitfields-docs.factor b/unmaintained/bitfields/bitfields-docs.factor deleted file mode 100644 index ae670237a6..0000000000 --- a/unmaintained/bitfields/bitfields-docs.factor +++ /dev/null @@ -1,17 +0,0 @@ -USING: help.markup help.syntax ; -IN: bitfields - -HELP: BITFIELD: -{ $syntax "BITFIELD: name slot:size... ;" } -{ $values { "name" "name of bitfield" } { "slot" "names of slots" } { "size" "sizes of slots" } } -{ $description "Creates a new bitfield specification, with the constructor <name> and slot accessors of the form name-slot. Slots' values can be changed by words of the form with-name-slot, with the stack effect " { $code "( newvalue bitfield -- newbitfield )" } ". The slots have the amount of space specified, in bits, after the colon. The constructor and setters do not check to make sure there is no overflow, and any inappropriately high value (except in the first field) will corrupt the bitfield. To check overflow, use " { $link POSTPONE: SAFE-BITFIELD: } " instead. Padding can be included by writing the binary number to be used as a pad in the middle of the bitfield specification. The first slot written will have the most significant digits. Note that bitfields do not form a class; they are merely integers. For efficiency across platforms, it is often the best to keep the total size at or below 29, allowing fixnums to be used on all platforms." } -{ $see-also define-bitfield } ; - -HELP: define-bitfield -{ $values { "classname" "a string" } { "slots" "slot specifications" } } -{ $description "Defines a bitfield constructor and slot accessors and setters. The workings of these are described in more detail at " { $link POSTPONE: BITFIELD: } ". The slot specifications should be an assoc. Any key which looks like a binary number will be treated as padding." } ; - -HELP: SAFE-BITFIELD: -{ $syntax "SAFE-BITFIELD: name slot:size... ;" } -{ $values { "name" "name of bitfield" } { "slot" "name of slots" } { "size" "size in bits of slots" } } -{ $description "Defines a bitfield in the same way as " { $link POSTPONE: BITFIELD: } " but the constructor and slot setters check for overflow." } ; diff --git a/unmaintained/bitfields/bitfields-tests.factor b/unmaintained/bitfields/bitfields-tests.factor deleted file mode 100755 index bbd4aa3db0..0000000000 --- a/unmaintained/bitfields/bitfields-tests.factor +++ /dev/null @@ -1,22 +0,0 @@ -USING: tools.test bitfields kernel ; -IN: bitfields.tests - -SAFE-BITFIELD: foo bar:5 baz:10 111 bing:2 ; - -[ 21 ] [ 21 852 3 <foo> foo-bar ] unit-test -[ 852 ] [ 21 852 3 <foo> foo-baz ] unit-test -[ 3 ] [ 21 852 3 <foo> foo-bing ] unit-test - -[ 23 ] [ 21 852 3 <foo> 23 swap with-foo-bar foo-bar ] unit-test -[ 855 ] [ 21 852 3 <foo> 855 swap with-foo-baz foo-baz ] unit-test -[ 1 ] [ 21 852 3 <foo> 1 swap with-foo-bing foo-bing ] unit-test - -[ 100 0 0 <foo> ] must-fail -[ 0 5000 0 <foo> ] must-fail -[ 0 0 10 <foo> ] must-fail - -[ 100 0 with-foo-bar ] must-fail -[ 5000 0 with-foo-baz ] must-fail -[ 10 0 with-foo-bing ] must-fail - -[ BIN: 00101100000000111111 ] [ BIN: 101 BIN: 1000000001 BIN: 11 <foo> ] unit-test diff --git a/unmaintained/bitfields/bitfields.factor b/unmaintained/bitfields/bitfields.factor deleted file mode 100755 index 90e588be48..0000000000 --- a/unmaintained/bitfields/bitfields.factor +++ /dev/null @@ -1,111 +0,0 @@ -USING: parser lexer kernel math sequences namespaces make assocs -summary words splitting math.parser arrays sequences.next -mirrors generalizations compiler.units ; -IN: bitfields - -! Example: -! BITFIELD: blah short:16 char:8 nothing:5 ; -! defines <blah> blah-short blah-char blah-nothing. - -! An efficient bitfield has a sum of 29 bits or less -! so it can fit in a fixnum. -! No class is defined and there is no overflow checking. -! The first field is the most significant. - -: >ranges ( slots/sizes -- slots/ranges ) - ! range is { start length } - reverse 0 swap [ - swap >r tuck >r [ + ] keep r> 2array r> swap - ] assoc-map nip reverse ; - -SYMBOL: safe-bitfields? ! default f; set at parsetime - -TUPLE: check< number bound ; -M: check< summary drop "Number exceeds upper bound" ; - -: check< ( num cmp -- num ) - 2dup < [ drop ] [ \ check< boa throw ] if ; - -: ?check ( length -- ) - safe-bitfields? get [ 2^ , \ check< , ] [ drop ] if ; - -: put-together ( lengths -- ) - ! messy because of bounds checking - dup length 1- [ \ >r , ] times [ 0 swap ] % [ - ?check [ \ bitor , , [ shift r> ] % ] when* - ] each-next \ bitor , ; - -: padding-name? ( string -- ? ) - [ "10" member? ] all? ; - -: pad ( i name -- ) - bin> , , \ -nrot , ; - -: add-padding ( names -- ) - <enum> - [ dup padding-name? [ pad ] [ 2drop ] if ] assoc-each ; - -: [constructor] ( names lengths -- quot ) - [ swap add-padding put-together ] [ ] make ; - -: define-constructor ( classname slots -- ) - [ keys ] keep values [constructor] - >r in get constructor-word dup save-location r> - define ; - -: range>accessor ( range -- quot ) - [ - dup first neg , \ shift , - second 2^ 1- , \ bitand , - ] [ ] make ; - -: [accessors] ( lengths -- accessors ) - [ range>accessor ] map ; - -: clear-range ( range -- num ) - first2 dupd + [ 2^ 1- ] bi@ bitnot bitor ; - -: range>setter ( range -- quot ) - [ - \ >r , dup second ?check \ r> , - dup clear-range , - [ bitand >r ] % - first , [ shift r> bitor ] % - ] [ ] make ; - -: [setters] ( lengths -- setters ) - [ range>setter ] map ; - -: parse-slots ( slotspecs -- slots ) - [ ":" split1 string>number [ dup length ] unless* ] { } map>assoc ; - -: define-slots ( prefix names quots -- ) - >r [ "-" glue create-in ] with map r> - [ define ] 2each ; - -: define-accessors ( classname slots -- ) - dup values [accessors] - >r keys r> define-slots ; - -: define-setters ( classname slots -- ) - >r "with-" prepend r> - dup values [setters] - >r keys r> define-slots ; - -: filter-pad ( slots -- slots ) - [ drop padding-name? not ] assoc-filter ; - -: define-bitfield ( classname slots -- ) - [ - [ define-constructor ] 2keep - >ranges filter-pad [ define-setters ] 2keep define-accessors - ] with-compilation-unit ; - -: parse-bitfield ( -- ) - scan ";" parse-tokens parse-slots define-bitfield ; - -: BITFIELD: - parse-bitfield ; parsing - -: SAFE-BITFIELD: - [ safe-bitfields? on parse-bitfield ] with-scope ; parsing diff --git a/unmaintained/bitfields/summary.txt b/unmaintained/bitfields/summary.txt deleted file mode 100644 index fa2f7ff5c2..0000000000 --- a/unmaintained/bitfields/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Simple system for specifying packed bitfields diff --git a/extra/boids/authors.txt b/unmaintained/boids/authors.txt similarity index 100% rename from extra/boids/authors.txt rename to unmaintained/boids/authors.txt diff --git a/extra/boids/boids.factor b/unmaintained/boids/boids.factor similarity index 100% rename from extra/boids/boids.factor rename to unmaintained/boids/boids.factor diff --git a/extra/boids/summary.txt b/unmaintained/boids/summary.txt similarity index 100% rename from extra/boids/summary.txt rename to unmaintained/boids/summary.txt diff --git a/extra/bubble-chamber/bubble-chamber.factor b/unmaintained/bubble-chamber/bubble-chamber.factor similarity index 100% rename from extra/bubble-chamber/bubble-chamber.factor rename to unmaintained/bubble-chamber/bubble-chamber.factor diff --git a/extra/bubble-chamber/hadron-chamber/hadron-chamber.factor b/unmaintained/bubble-chamber/hadron-chamber/hadron-chamber.factor similarity index 100% rename from extra/bubble-chamber/hadron-chamber/hadron-chamber.factor rename to unmaintained/bubble-chamber/hadron-chamber/hadron-chamber.factor diff --git a/extra/bubble-chamber/hadron-chamber/tags.txt b/unmaintained/bubble-chamber/hadron-chamber/tags.txt similarity index 100% rename from extra/bubble-chamber/hadron-chamber/tags.txt rename to unmaintained/bubble-chamber/hadron-chamber/tags.txt diff --git a/extra/bubble-chamber/large/large.factor b/unmaintained/bubble-chamber/large/large.factor similarity index 100% rename from extra/bubble-chamber/large/large.factor rename to unmaintained/bubble-chamber/large/large.factor diff --git a/extra/bubble-chamber/large/tags.txt b/unmaintained/bubble-chamber/large/tags.txt similarity index 100% rename from extra/bubble-chamber/large/tags.txt rename to unmaintained/bubble-chamber/large/tags.txt diff --git a/extra/bubble-chamber/medium/medium.factor b/unmaintained/bubble-chamber/medium/medium.factor similarity index 100% rename from extra/bubble-chamber/medium/medium.factor rename to unmaintained/bubble-chamber/medium/medium.factor diff --git a/extra/bubble-chamber/medium/tags.txt b/unmaintained/bubble-chamber/medium/tags.txt similarity index 100% rename from extra/bubble-chamber/medium/tags.txt rename to unmaintained/bubble-chamber/medium/tags.txt diff --git a/extra/bubble-chamber/original/original.factor b/unmaintained/bubble-chamber/original/original.factor similarity index 100% rename from extra/bubble-chamber/original/original.factor rename to unmaintained/bubble-chamber/original/original.factor diff --git a/extra/bubble-chamber/original/tags.txt b/unmaintained/bubble-chamber/original/tags.txt similarity index 100% rename from extra/bubble-chamber/original/tags.txt rename to unmaintained/bubble-chamber/original/tags.txt diff --git a/extra/bubble-chamber/quark-chamber/quark-chamber.factor b/unmaintained/bubble-chamber/quark-chamber/quark-chamber.factor similarity index 100% rename from extra/bubble-chamber/quark-chamber/quark-chamber.factor rename to unmaintained/bubble-chamber/quark-chamber/quark-chamber.factor diff --git a/extra/bubble-chamber/quark-chamber/tags.txt b/unmaintained/bubble-chamber/quark-chamber/tags.txt similarity index 100% rename from extra/bubble-chamber/quark-chamber/tags.txt rename to unmaintained/bubble-chamber/quark-chamber/tags.txt diff --git a/extra/bubble-chamber/small/small.factor b/unmaintained/bubble-chamber/small/small.factor similarity index 100% rename from extra/bubble-chamber/small/small.factor rename to unmaintained/bubble-chamber/small/small.factor diff --git a/extra/bubble-chamber/small/tags.txt b/unmaintained/bubble-chamber/small/tags.txt similarity index 100% rename from extra/bubble-chamber/small/tags.txt rename to unmaintained/bubble-chamber/small/tags.txt diff --git a/extra/bubble-chamber/ten-hadrons/tags.txt b/unmaintained/bubble-chamber/ten-hadrons/tags.txt similarity index 100% rename from extra/bubble-chamber/ten-hadrons/tags.txt rename to unmaintained/bubble-chamber/ten-hadrons/tags.txt diff --git a/extra/bubble-chamber/ten-hadrons/ten-hadrons.factor b/unmaintained/bubble-chamber/ten-hadrons/ten-hadrons.factor similarity index 100% rename from extra/bubble-chamber/ten-hadrons/ten-hadrons.factor rename to unmaintained/bubble-chamber/ten-hadrons/ten-hadrons.factor diff --git a/extra/cairo-demo/authors.txt b/unmaintained/cairo-demo/authors.txt similarity index 100% rename from extra/cairo-demo/authors.txt rename to unmaintained/cairo-demo/authors.txt diff --git a/extra/cairo-demo/cairo-demo.factor b/unmaintained/cairo-demo/cairo-demo.factor similarity index 100% rename from extra/cairo-demo/cairo-demo.factor rename to unmaintained/cairo-demo/cairo-demo.factor diff --git a/basis/cairo/gadgets/gadgets.factor b/unmaintained/cairo-gadgets/gadgets.factor similarity index 100% rename from basis/cairo/gadgets/gadgets.factor rename to unmaintained/cairo-gadgets/gadgets.factor diff --git a/basis/cairo/gadgets/summary.txt b/unmaintained/cairo-gadgets/summary.txt similarity index 100% rename from basis/cairo/gadgets/summary.txt rename to unmaintained/cairo-gadgets/summary.txt diff --git a/extra/cairo-samples/cairo-samples.factor b/unmaintained/cairo-samples/cairo-samples.factor similarity index 100% rename from extra/cairo-samples/cairo-samples.factor rename to unmaintained/cairo-samples/cairo-samples.factor diff --git a/unmaintained/camera/authors.txt b/unmaintained/camera/authors.txt deleted file mode 100755 index bbc876e7b6..0000000000 --- a/unmaintained/camera/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Adam Wendt diff --git a/unmaintained/camera/camera.factor b/unmaintained/camera/camera.factor deleted file mode 100644 index c324e53edc..0000000000 --- a/unmaintained/camera/camera.factor +++ /dev/null @@ -1,16 +0,0 @@ - -USING: kernel namespaces math.vectors opengl pos ori turtle self ; - -IN: opengl.camera - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: camera-eye ( -- point ) pos> ; - -: camera-focus ( -- point ) [ 1 step-turtle pos> ] save-self ; - -: camera-up ( -- dirvec ) -[ 90 pitch-up pos> 1 step-turtle pos> swap v- ] save-self ; - -: do-look-at ( camera -- ) -[ >self camera-eye camera-focus camera-up gl-look-at ] with-scope ; diff --git a/extra/ui/gadgets/cartesian/cartesian.factor b/unmaintained/cartesian/cartesian.factor similarity index 100% rename from extra/ui/gadgets/cartesian/cartesian.factor rename to unmaintained/cartesian/cartesian.factor diff --git a/extra/cfdg/authors.txt b/unmaintained/cfdg/authors.txt similarity index 100% rename from extra/cfdg/authors.txt rename to unmaintained/cfdg/authors.txt diff --git a/extra/cfdg/cfdg.factor b/unmaintained/cfdg/cfdg.factor similarity index 100% rename from extra/cfdg/cfdg.factor rename to unmaintained/cfdg/cfdg.factor diff --git a/extra/cfdg/gl/authors.txt b/unmaintained/cfdg/gl/authors.txt similarity index 100% rename from extra/cfdg/gl/authors.txt rename to unmaintained/cfdg/gl/authors.txt diff --git a/extra/cfdg/gl/gl.factor b/unmaintained/cfdg/gl/gl.factor similarity index 100% rename from extra/cfdg/gl/gl.factor rename to unmaintained/cfdg/gl/gl.factor diff --git a/extra/cfdg/models/aqua-star/aqua-star.factor b/unmaintained/cfdg/models/aqua-star/aqua-star.factor similarity index 100% rename from extra/cfdg/models/aqua-star/aqua-star.factor rename to unmaintained/cfdg/models/aqua-star/aqua-star.factor diff --git a/extra/cfdg/models/aqua-star/authors.txt b/unmaintained/cfdg/models/aqua-star/authors.txt similarity index 100% rename from extra/cfdg/models/aqua-star/authors.txt rename to unmaintained/cfdg/models/aqua-star/authors.txt diff --git a/extra/cfdg/models/aqua-star/tags.txt b/unmaintained/cfdg/models/aqua-star/tags.txt similarity index 100% rename from extra/cfdg/models/aqua-star/tags.txt rename to unmaintained/cfdg/models/aqua-star/tags.txt diff --git a/extra/cfdg/models/chiaroscuro/authors.txt b/unmaintained/cfdg/models/chiaroscuro/authors.txt similarity index 100% rename from extra/cfdg/models/chiaroscuro/authors.txt rename to unmaintained/cfdg/models/chiaroscuro/authors.txt diff --git a/extra/cfdg/models/chiaroscuro/chiaroscuro.factor b/unmaintained/cfdg/models/chiaroscuro/chiaroscuro.factor similarity index 100% rename from extra/cfdg/models/chiaroscuro/chiaroscuro.factor rename to unmaintained/cfdg/models/chiaroscuro/chiaroscuro.factor diff --git a/extra/cfdg/models/chiaroscuro/tags.txt b/unmaintained/cfdg/models/chiaroscuro/tags.txt similarity index 100% rename from extra/cfdg/models/chiaroscuro/tags.txt rename to unmaintained/cfdg/models/chiaroscuro/tags.txt diff --git a/extra/cfdg/models/flower6/authors.txt b/unmaintained/cfdg/models/flower6/authors.txt similarity index 100% rename from extra/cfdg/models/flower6/authors.txt rename to unmaintained/cfdg/models/flower6/authors.txt diff --git a/extra/cfdg/models/flower6/deploy.factor b/unmaintained/cfdg/models/flower6/deploy.factor similarity index 100% rename from extra/cfdg/models/flower6/deploy.factor rename to unmaintained/cfdg/models/flower6/deploy.factor diff --git a/extra/cfdg/models/flower6/flower6.factor b/unmaintained/cfdg/models/flower6/flower6.factor similarity index 100% rename from extra/cfdg/models/flower6/flower6.factor rename to unmaintained/cfdg/models/flower6/flower6.factor diff --git a/extra/cfdg/models/flower6/tags.txt b/unmaintained/cfdg/models/flower6/tags.txt similarity index 100% rename from extra/cfdg/models/flower6/tags.txt rename to unmaintained/cfdg/models/flower6/tags.txt diff --git a/extra/cfdg/models/game1-turn6/authors.txt b/unmaintained/cfdg/models/game1-turn6/authors.txt similarity index 100% rename from extra/cfdg/models/game1-turn6/authors.txt rename to unmaintained/cfdg/models/game1-turn6/authors.txt diff --git a/extra/cfdg/models/game1-turn6/game1-turn6.factor b/unmaintained/cfdg/models/game1-turn6/game1-turn6.factor similarity index 100% rename from extra/cfdg/models/game1-turn6/game1-turn6.factor rename to unmaintained/cfdg/models/game1-turn6/game1-turn6.factor diff --git a/extra/cfdg/models/game1-turn6/tags.txt b/unmaintained/cfdg/models/game1-turn6/tags.txt similarity index 100% rename from extra/cfdg/models/game1-turn6/tags.txt rename to unmaintained/cfdg/models/game1-turn6/tags.txt diff --git a/extra/cfdg/models/lesson/authors.txt b/unmaintained/cfdg/models/lesson/authors.txt similarity index 100% rename from extra/cfdg/models/lesson/authors.txt rename to unmaintained/cfdg/models/lesson/authors.txt diff --git a/extra/cfdg/models/lesson/lesson.factor b/unmaintained/cfdg/models/lesson/lesson.factor similarity index 100% rename from extra/cfdg/models/lesson/lesson.factor rename to unmaintained/cfdg/models/lesson/lesson.factor diff --git a/extra/cfdg/models/lesson/tags.txt b/unmaintained/cfdg/models/lesson/tags.txt similarity index 100% rename from extra/cfdg/models/lesson/tags.txt rename to unmaintained/cfdg/models/lesson/tags.txt diff --git a/extra/cfdg/models/rules08/rules08.factor b/unmaintained/cfdg/models/rules08/rules08.factor similarity index 100% rename from extra/cfdg/models/rules08/rules08.factor rename to unmaintained/cfdg/models/rules08/rules08.factor diff --git a/extra/cfdg/models/rules08/tags.txt b/unmaintained/cfdg/models/rules08/tags.txt similarity index 100% rename from extra/cfdg/models/rules08/tags.txt rename to unmaintained/cfdg/models/rules08/tags.txt diff --git a/extra/cfdg/models/sierpinski/authors.txt b/unmaintained/cfdg/models/sierpinski/authors.txt similarity index 100% rename from extra/cfdg/models/sierpinski/authors.txt rename to unmaintained/cfdg/models/sierpinski/authors.txt diff --git a/extra/cfdg/models/sierpinski/sierpinski.factor b/unmaintained/cfdg/models/sierpinski/sierpinski.factor similarity index 100% rename from extra/cfdg/models/sierpinski/sierpinski.factor rename to unmaintained/cfdg/models/sierpinski/sierpinski.factor diff --git a/extra/cfdg/models/sierpinski/tags.txt b/unmaintained/cfdg/models/sierpinski/tags.txt similarity index 100% rename from extra/cfdg/models/sierpinski/tags.txt rename to unmaintained/cfdg/models/sierpinski/tags.txt diff --git a/extra/cfdg/models/snowflake/authors.txt b/unmaintained/cfdg/models/snowflake/authors.txt similarity index 100% rename from extra/cfdg/models/snowflake/authors.txt rename to unmaintained/cfdg/models/snowflake/authors.txt diff --git a/extra/cfdg/models/snowflake/snowflake.factor b/unmaintained/cfdg/models/snowflake/snowflake.factor similarity index 100% rename from extra/cfdg/models/snowflake/snowflake.factor rename to unmaintained/cfdg/models/snowflake/snowflake.factor diff --git a/extra/cfdg/models/snowflake/tags.txt b/unmaintained/cfdg/models/snowflake/tags.txt similarity index 100% rename from extra/cfdg/models/snowflake/tags.txt rename to unmaintained/cfdg/models/snowflake/tags.txt diff --git a/extra/cfdg/models/spirales/spirales.factor b/unmaintained/cfdg/models/spirales/spirales.factor similarity index 100% rename from extra/cfdg/models/spirales/spirales.factor rename to unmaintained/cfdg/models/spirales/spirales.factor diff --git a/extra/cfdg/models/spirales/tags.txt b/unmaintained/cfdg/models/spirales/tags.txt similarity index 100% rename from extra/cfdg/models/spirales/tags.txt rename to unmaintained/cfdg/models/spirales/tags.txt diff --git a/extra/cfdg/summary.txt b/unmaintained/cfdg/summary.txt similarity index 100% rename from extra/cfdg/summary.txt rename to unmaintained/cfdg/summary.txt diff --git a/unmaintained/combinators-lib/authors.txt b/unmaintained/combinators-lib/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/combinators-lib/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/combinators-lib/lib-docs.factor b/unmaintained/combinators-lib/lib-docs.factor deleted file mode 100755 index cde3b4d259..0000000000 --- a/unmaintained/combinators-lib/lib-docs.factor +++ /dev/null @@ -1,22 +0,0 @@ -USING: help.syntax help.markup kernel prettyprint sequences -quotations math ; -IN: combinators.lib - -HELP: generate -{ $values { "generator" quotation } { "predicate" quotation } { "obj" object } } -{ $description "Loop until the generator quotation generates an object that satisfies predicate quotation." } -{ $unchecked-example - "! Generate a random 20-bit prime number congruent to 3 (mod 4)" - "USING: combinators.lib math math.miller-rabin prettyprint ;" - "[ 20 random-prime ] [ 4 mod 3 = ] generate ." - "526367" -} ; - -HELP: %chance -{ $values { "quot" quotation } { "n" integer } } -{ $description "Calls the quotation " { $snippet "n" } " percent of the time." } -{ $unchecked-example - "USING: io ;" - "[ \"hello, world! maybe.\" print ] 50 %chance" - "" -} ; diff --git a/unmaintained/combinators-lib/lib-tests.factor b/unmaintained/combinators-lib/lib-tests.factor deleted file mode 100755 index 9489798b9b..0000000000 --- a/unmaintained/combinators-lib/lib-tests.factor +++ /dev/null @@ -1,24 +0,0 @@ -USING: combinators.lib kernel math random sequences tools.test continuations - arrays vectors ; -IN: combinators.lib.tests - -[ 6 -1 ] [ 5 0 1 [ + ] [ - ] bi, bi* ] unit-test -[ 6 -1 1 ] [ 5 0 1 1 [ + ] [ - ] [ * ] tri, tri* ] unit-test - -[ 5 4 ] [ 5 0 1 [ + ] [ - ] bi*, bi ] unit-test -[ 5 4 5 ] [ 5 0 1 1 [ + ] [ - ] [ * ] tri*, tri ] unit-test - -[ 5 6 ] [ 5 0 1 [ + ] bi@, bi ] unit-test -[ 5 6 7 ] [ 5 0 1 2 [ + ] tri@, tri ] unit-test - -[ 5 ] [ [ 10 random ] [ 5 = ] generate ] unit-test -[ t ] [ [ 10 random ] [ even? ] generate even? ] unit-test - -[ { "foo" "xbarx" } ] -[ - { "oof" "bar" } { [ reverse ] [ "x" dup surround ] } parallel-call -] unit-test - -{ 1 1 } [ - [ even? ] [ drop 1 ] [ drop 2 ] ifte -] must-infer-as diff --git a/unmaintained/combinators-lib/lib.factor b/unmaintained/combinators-lib/lib.factor deleted file mode 100755 index 9b3abe3984..0000000000 --- a/unmaintained/combinators-lib/lib.factor +++ /dev/null @@ -1,138 +0,0 @@ -! Copyright (C) 2007, 2008 Slava Pestov, Chris Double, -! Doug Coleman, Eduardo Cavazos, -! Daniel Ehrenberg. -! See http://factorcode.org/license.txt for BSD license. -USING: kernel combinators fry namespaces make quotations hashtables -sequences assocs arrays stack-checker effects math math.ranges -generalizations macros continuations random locals accessors ; - -IN: combinators.lib - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! Currying cleave combinators -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: bi, ( obj quot quot -- quot' quot' ) - [ [ curry ] curry ] bi@ bi ; inline -: tri, ( obj quot quot quot -- quot' quot' quot' ) - [ [ curry ] curry ] tri@ tri ; inline - -: bi*, ( obj obj quot quot -- quot' quot' ) - [ [ curry ] curry ] bi@ bi* ; inline -: tri*, ( obj obj obj quot quot quot -- quot' quot' quot' ) - [ [ curry ] curry ] tri@ tri* ; inline - -: bi@, ( obj obj quot -- quot' quot' ) - [ curry ] curry bi@ ; inline -: tri@, ( obj obj obj quot -- quot' quot' quot' ) - [ curry ] curry tri@ ; inline - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! Generalized versions of core combinators -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: quad ( x p q r s -- ) [ keep ] 3dip [ keep ] 2dip [ keep ] dip call ; inline - -: 4slip ( quot a b c d -- a b c d ) 4 nslip ; inline - -: 4keep ( w x y z quot -- w x y z ) 4 nkeep ; inline - -: 2with ( param1 param2 obj quot -- obj curry ) - with with ; inline - -: 3with ( param1 param2 param3 obj quot -- obj curry ) - with with with ; inline - -: with* ( obj assoc quot -- assoc curry ) - swapd [ [ -rot ] dip call ] 2curry ; inline - -: 2with* ( obj1 obj2 assoc quot -- assoc curry ) - with* with* ; inline - -: 3with* ( obj1 obj2 obj3 assoc quot -- assoc curry ) - with* with* with* ; inline - -: assoc-each-with ( obj assoc quot -- ) - with* assoc-each ; inline - -: assoc-map-with ( obj assoc quot -- assoc ) - with* assoc-map ; inline - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! ifte -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -MACRO: preserving ( predicate -- quot ) - dup infer in>> - dup 1+ - '[ _ _ nkeep _ nrot ] ; - -MACRO: ifte ( quot quot quot -- ) - '[ _ preserving _ _ if ] ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! switch -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -MACRO: switch ( quot -- ) - [ [ [ preserving ] curry ] dip ] assoc-map - [ cond ] curry ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! Conceptual implementation: - -! : pcall ( seq quots -- seq ) [ call ] 2map ; - -MACRO: parallel-call ( quots -- ) - [ '[ [ unclip @ ] dip [ push ] keep ] ] map concat - '[ V{ } clone @ nip >array ] ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! map-call and friends -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: (make-call-with) ( quots -- quot ) - [ [ keep ] curry ] map concat [ drop ] append ; - -MACRO: map-call-with ( quots -- ) - [ (make-call-with) ] keep length [ narray ] curry compose ; - -: (make-call-with2) ( quots -- quot ) - [ [ 2dup >r >r ] prepend [ r> r> ] append ] map concat - [ 2drop ] append ; - -MACRO: map-call-with2 ( quots -- ) - [ - [ [ 2dup >r >r ] prepend [ r> r> ] append ] map concat - [ 2drop ] append - ] keep length [ narray ] curry append ; - -MACRO: map-exec-with ( words -- ) - [ 1quotation ] map [ map-call-with ] curry ; - -MACRO: construct-slots ( assoc tuple-class -- tuple ) - [ new ] curry swap [ - [ dip ] curry swap 1quotation [ keep ] curry compose - ] { } assoc>map concat compose ; - -: 2quot-with ( obj seq quot1 quot2 -- seq quot1 quot2 ) - >r pick >r with r> r> swapd with ; - -MACRO: multikeep ( word out-indexes -- ... ) - [ - dup >r [ \ npick \ >r 3array % ] each - % - r> [ drop \ r> , ] each - ] [ ] make ; - -: generate ( generator predicate -- obj ) - '[ dup @ dup [ nip ] unless ] - swap do until ; - -MACRO: predicates ( seq -- quot/f ) - dup [ 1quotation [ drop ] prepend ] map - [ [ [ dup ] prepend ] map ] dip zip [ drop f ] suffix - [ cond ] curry ; - -: %chance ( quot n -- ) 100 random > swap when ; inline diff --git a/extra/combinators/cleave/authors.txt b/unmaintained/combinators/cleave/authors.txt similarity index 100% rename from extra/combinators/cleave/authors.txt rename to unmaintained/combinators/cleave/authors.txt diff --git a/extra/combinators/cleave/cleave-tests.factor b/unmaintained/combinators/cleave/cleave-tests.factor similarity index 100% rename from extra/combinators/cleave/cleave-tests.factor rename to unmaintained/combinators/cleave/cleave-tests.factor diff --git a/extra/combinators/cleave/cleave.factor b/unmaintained/combinators/cleave/cleave.factor similarity index 100% rename from extra/combinators/cleave/cleave.factor rename to unmaintained/combinators/cleave/cleave.factor diff --git a/extra/combinators/cleave/enhanced/enhanced.factor b/unmaintained/combinators/cleave/enhanced/enhanced.factor similarity index 100% rename from extra/combinators/cleave/enhanced/enhanced.factor rename to unmaintained/combinators/cleave/enhanced/enhanced.factor diff --git a/extra/combinators/conditional/conditional.factor b/unmaintained/combinators/conditional/conditional.factor similarity index 100% rename from extra/combinators/conditional/conditional.factor rename to unmaintained/combinators/conditional/conditional.factor diff --git a/extra/easy-help/easy-help.factor b/unmaintained/easy-help/easy-help.factor similarity index 100% rename from extra/easy-help/easy-help.factor rename to unmaintained/easy-help/easy-help.factor diff --git a/extra/easy-help/expand-markup/expand-markup.factor b/unmaintained/easy-help/expand-markup/expand-markup.factor similarity index 100% rename from extra/easy-help/expand-markup/expand-markup.factor rename to unmaintained/easy-help/expand-markup/expand-markup.factor diff --git a/unmaintained/factorbot.factor b/unmaintained/factorbot.factor deleted file mode 100644 index 43940d2f79..0000000000 --- a/unmaintained/factorbot.factor +++ /dev/null @@ -1,108 +0,0 @@ -! Simple IRC bot written in Factor. - -REQUIRES: apps/http-server ; - -USING: errors generic hashtables help html http io kernel math -memory namespaces parser prettyprint sequences strings threads -words inspector network ; -IN: factorbot - -SYMBOL: irc-stream -SYMBOL: nickname -SYMBOL: speaker -SYMBOL: receiver - -: irc-write ( s -- ) irc-stream get stream-write ; -: irc-print ( s -- ) - irc-stream get stream-print - irc-stream get stream-flush ; - -: nick ( nick -- ) - dup nickname set "NICK " irc-write irc-print ; - -: login ( nick -- ) - dup nick - "USER " irc-write irc-write - " hostname servername :irc.factor" irc-print ; - -: connect ( server -- ) 6667 <inet> <client> irc-stream set ; - -: disconnect ( -- ) irc-stream get stream-close ; - -: join ( chan -- ) - "JOIN " irc-write irc-print ; - -GENERIC: handle-irc ( line -- ) -PREDICATE: string privmsg " " split1 nip "PRIVMSG" head? ; -PREDICATE: string ping "PING" head? ; - -M: object handle-irc ( line -- ) - drop ; - -: parse-privmsg ( line -- text ) - " " split1 nip - "PRIVMSG " ?head drop - " " split1 swap receiver set - ":" ?head drop ; - -M: privmsg handle-irc ( line -- ) - parse-privmsg - " " split1 swap - "factorbot-commands" lookup dup - [ execute ] [ 2drop ] if ; - -M: ping handle-irc ( line -- ) - "PING " ?head drop "PONG " swap append irc-print ; - -: parse-irc ( line -- ) - ":" ?head [ "!" split1 swap speaker set ] when handle-irc ; - -: say ( line nick -- ) - "PRIVMSG " irc-write irc-write " :" irc-write irc-print ; - -: respond ( line -- ) - receiver get nickname get = speaker receiver ? get say ; - -: irc-loop ( -- ) - irc-stream get stream-readln - [ dup print flush parse-irc irc-loop ] when* ; - -: factorbot - "irc.freenode.net" connect - "factorbot" login - "#concatenative" join - [ irc-loop ] [ irc-stream get stream-close ] cleanup ; - -: factorbot-loop [ factorbot ] try 30000 sleep factorbot-loop ; - -: multiline-respond ( string -- ) - string-lines [ respond ] each ; - -: object-href - "http://factorcode.org" swap browser-link-href append ; - -: not-found ( str -- ) - "Sorry, I couldn't find anything for " swap append respond ; - -IN: factorbot-commands - -: see ( text -- ) - dup words-named dup empty? [ - drop - not-found - ] [ - nip [ - dup summary " -- " - rot object-href 3append respond - ] each - ] if ; - -: memory ( text -- ) - drop [ room. ] with-string-writer multiline-respond ; - -: quit ( text -- ) - drop speaker get "slava" = [ disconnect ] when ; - -PROVIDE: apps/factorbot ; - -MAIN: apps/factorbot factorbot ; diff --git a/unmaintained/factory/authors.txt b/unmaintained/factory/authors.txt deleted file mode 100644 index 6cfd5da273..0000000000 --- a/unmaintained/factory/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/factory/commands/authors.txt b/unmaintained/factory/commands/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/factory/commands/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/factory/commands/commands.factor b/unmaintained/factory/commands/commands.factor deleted file mode 100644 index 6bf5ee8d4f..0000000000 --- a/unmaintained/factory/commands/commands.factor +++ /dev/null @@ -1,73 +0,0 @@ -USING: kernel combinators sequences math math.functions math.vectors mortar - slot-accessors x x.widgets.wm.root x.widgets.wm.frame sequences.lib ; -IN: factory.commands - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: up-till-frame ( window -- wm-frame ) -{ { [ dup <wm-frame> is? ] - [ ] } - { [ dup $dpy $default-root $id over $id = ] - [ drop f ] } - { [ t ] - [ <- parent up-till-frame ] } } cond ; - -: pointer-window ( -- window ) dpy> <- pointer-window ; - -: pointer-frame ( -- wm-frame ) -pointer-window up-till-frame dup <wm-frame> is? [ ] [ drop f ] if ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: maximize ( -- ) pointer-frame wm-frame-maximize drop ; - -: minimize ( -- ) pointer-frame <- unmap drop ; - -: maximize-vertical ( -- ) pointer-frame wm-frame-maximize-vertical drop ; - -: restore ( -- ) pointer-frame <- restore-state drop ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - - -: tile-master ( -- ) - -wm-root> - <- children - [ <- mapped? ] filter - [ check-window-table ] map - reverse - -unclip - { 0 0 } <-- move - wm-root> <- size { 1/2 1 } v* - [ floor ] map <-- resize - <- adjust-child -drop - -dup empty? [ drop ] [ - -wm-root> <- width 2 / floor [ <-- set-width ] curry map -wm-root> <- height over length / floor [ <-- set-height ] curry map - -wm-root> <- width 2 / floor [ <-- set-x ] curry map - -wm-root> <- height over length / over length [ * floor ] map-with -[ <-- set-y <- adjust-child ] 2map - -drop - -] if ; - -! : tile-master ( -- ) - -! wm-root> -! <- children -! [ <- mapped? ] filter -! [ check-window-table ] map -! reverse - -! { { [ dup empty? ] [ drop ] } -! { [ dup length 1 = ] [ drop maximize ] } -! { [ t ] [ tile-master* ] } diff --git a/unmaintained/factory/factory-menus b/unmaintained/factory/factory-menus deleted file mode 100644 index 35ee75e31b..0000000000 --- a/unmaintained/factory/factory-menus +++ /dev/null @@ -1,122 +0,0 @@ -! -*-factor-*- - -USING: kernel unix vars mortar mortar.sugar slot-accessors - x.widgets.wm.menu x.widgets.wm.unmapped-frames-menu - factory.commands factory.load ; - -IN: factory - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! Helper words - -: new-wm-menu ( -- menu ) <wm-menu> new* 1 <-- set-border-width ; - -: shrink-wrap ( menu -- ) dup <- calc-size <-- resize drop ; - -: set-menu-items ( items menu -- ) swap >>items shrink-wrap ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -VAR: apps-menu - -apps-menu> not [ new-wm-menu >apps-menu ] when - -{ { "Emacs" [ "emacs &" system drop ] } - { "KMail" [ "kmail &" system drop ] } - { "Akregator" [ "akregator &" system drop ] } - { "Amarok" [ "amarok &" system drop ] } - { "K3b" [ "k3b &" system drop ] } - { "xchat" [ "xchat &" system drop ] } - { "Nautilus" [ "nautilus --no-desktop &" system drop ] } - { "synaptic" [ "gksudo synaptic &" system drop ] } - { "Volume control" [ "gnome-volume-control &" system drop ] } - { "Azureus" [ "~/azureus/azureus &" system drop ] } - { "Xephyr" [ "Xephyr -host-cursor :1 &" system drop ] } - { "Stop Xephyr" [ "pkill Xephyr &" system drop ] } - { "Stop Firefox" [ "pkill firefox &" system drop ] } -} apps-menu> set-menu-items - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -VAR: emacs-menu - -emacs-menu> not [ new-wm-menu >emacs-menu ] when - -{ { "Start Emacs" [ "emacs &" system drop ] } - { "Small" [ "emacsclient -e '(make-small-frame-command)' &" system drop ] } - { "Large" [ "emacsclient -e '(make-frame-command)' &" system drop ] } - { "Full" [ "emacsclient -e '(make-full-frame-command)' &" system drop ] } - { "Gnus" [ "emacsclient -e '(gnus-other-frame)' &" system drop ] } - { "Factor" [ "emacsclient -e '(run-factor-other-frame)' &" system drop ] } -} emacs-menu> set-menu-items - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -VAR: mail-menu - -mail-menu> not [ new-wm-menu >mail-menu ] when - -{ { "Kmail" [ "kmail &" system drop ] } - { "compose" [ "kmail --composer &" system drop ] } - { "slava" [ "kmail slava@factorcode.org &" system drop ] } - { "erg" [ "kmail doug.coleman@gmail.com &" system drop ] } - { "doublec" [ "kmail chris.double@double.co.nz &" system drop ] } - { "yuuki" [ "kmail matthew.willis@mac.com &" system drop ] } -} mail-menu> set-menu-items - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -VAR: factor-menu - -factor-menu> not [ new-wm-menu >factor-menu ] when - -{ { "Factor" [ "cd /scratch/repos/Factor ; ./factor &" system drop ] } - { "Factor (tty)" - [ "cd /scratch/repos/Factor ; xterm -e ./factor -run=listener &" - system drop ] } - { "Terminal : repos/Factor" - [ "cd /scratch/repos/Factor ; xterm &" system drop ] } - { "darcs whatsnew" - [ "cd /scratch/repos/Factor ; xterm -e 'darcs whatsnew | less' &" - system drop ] } - { "darcs pull" - [ "cd /scratch/repos/Factor ; xterm -e 'darcs pull http://factorcode.org/repos' &" system drop ] } - { "darcs push" - [ "cd /scratch/repos/Factor ; xterm -e 'darcs push dharmatech@onigirihouse.com:doc-root/repos' &" system drop ] } -} factor-menu> set-menu-items - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -VAR: factory-menu - -factory-menu> not [ new-wm-menu >factory-menu ] when - -{ { "Maximize" [ maximize ] } - { "Maximize Vertical" [ maximize-vertical ] } - { "Restore" [ restore ] } - { "Hide" [ minimize ] } - { "Tile Master" [ tile-master ] } -} - -factory-menu> set-menu-items - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! VAR: root-menu - -{ { "xterm" [ "urxvt -bd grey +sb &" system drop ] } - { "Firefox" [ "firefox &" system drop ] } - { "xclock" [ "xclock &" system drop ] } - { "Apps >" [ apps-menu> <- popup ] } - { "Factor >" [ factor-menu> <- popup ] } - { "Unmapped frames >" [ unmapped-frames-menu> <- popup ] } - { "Emacs >" [ emacs-menu> <- popup ] } - { "Mail >" [ mail-menu> <- popup ] } - { "onigirihouse" [ "xterm -e 'ssh dharmatech@onigirihouse.com' &" - system drop ] } - { "Edit menus" [ edit-factory-menus ] } - { "Reload menus" [ load-factory-menus ] } - { "Factory >" [ factory-menu> <- popup ] } -} root-menu> set-menu-items - diff --git a/unmaintained/factory/factory-rc b/unmaintained/factory/factory-rc deleted file mode 100644 index 6d46c07a2a..0000000000 --- a/unmaintained/factory/factory-rc +++ /dev/null @@ -1,26 +0,0 @@ -! -*-factor-*- - -USING: kernel mortar x - x.widgets.wm.root - x.widgets.wm.workspace - x.widgets.wm.unmapped-frames-menu - factory.load - tty-server ; - -IN: factory - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -create-root-menu -create-unmapped-frames-menu -load-factory-menus -6 setup-workspaces - -wm-root> - no-modifiers "F12" [ root-menu> <- popup ] <---- set-key-action - control-alt "LEFT" [ prev-workspace ] <---- set-key-action - control-alt "RIGHT" [ next-workspace ] <---- set-key-action - alt "TAB" [ circulate-focus ] <---- set-key-action -drop - -9010 tty-server diff --git a/unmaintained/factory/factory.factor b/unmaintained/factory/factory.factor deleted file mode 100644 index 6faf334fc3..0000000000 --- a/unmaintained/factory/factory.factor +++ /dev/null @@ -1,37 +0,0 @@ - -USING: kernel parser io io.files namespaces sequences editors threads vars - mortar mortar.sugar slot-accessors - x - x.widgets.wm.root - x.widgets.wm.frame - x.widgets.wm.menu - factory.load - factory.commands ; - -IN: factory - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: manage-windows ( -- ) -dpy get $default-root <- children [ <- mapped? ] filter -[ $id <wm-frame> new* drop ] each ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -VAR: root-menu - -: create-root-menu ( -- ) <wm-menu> new* 1 <-- set-border-width >root-menu ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: start-factory ( display-string -- ) -<display> new* >dpy -install-default-error-handler -create-wm-root -init-atoms -manage-windows -load-factory-rc ; - -: factory ( -- ) f start-factory stop ; - -MAIN: factory \ No newline at end of file diff --git a/unmaintained/factory/load/authors.txt b/unmaintained/factory/load/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/factory/load/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/factory/load/load.factor b/unmaintained/factory/load/load.factor deleted file mode 100644 index 018fe5ea23..0000000000 --- a/unmaintained/factory/load/load.factor +++ /dev/null @@ -1,32 +0,0 @@ - -USING: kernel io.files parser editors sequences ; - -IN: factory.load - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: file-or ( file file -- file ) over exists? [ drop ] [ nip ] if ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: personal-factory-rc ( -- path ) home "/.factory-rc" append ; - -: system-factory-rc ( -- path ) "extra/factory/factory-rc" resource-path ; - -: factory-rc ( -- path ) personal-factory-rc system-factory-rc file-or ; - -: load-factory-rc ( -- ) factory-rc run-file ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: personal-factory-menus ( -- path ) home "/.factory-menus" append ; - -: system-factory-menus ( -- path ) -"extra/factory/factory-menus" resource-path ; - -: factory-menus ( -- path ) -personal-factory-menus system-factory-menus file-or ; - -: load-factory-menus ( -- ) factory-menus run-file ; - -: edit-factory-menus ( -- ) factory-menus 0 edit-location ; diff --git a/unmaintained/factory/summary.txt b/unmaintained/factory/summary.txt deleted file mode 100644 index e3b9c11ffa..0000000000 --- a/unmaintained/factory/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Window manager for the X Window System diff --git a/unmaintained/factory/tags.txt b/unmaintained/factory/tags.txt deleted file mode 100644 index bf31fdbc2e..0000000000 --- a/unmaintained/factory/tags.txt +++ /dev/null @@ -1 +0,0 @@ -applications diff --git a/extra/flatland/flatland.factor b/unmaintained/flatland/flatland.factor similarity index 100% rename from extra/flatland/flatland.factor rename to unmaintained/flatland/flatland.factor diff --git a/extra/frame-buffer/frame-buffer.factor b/unmaintained/frame-buffer/frame-buffer.factor similarity index 100% rename from extra/frame-buffer/frame-buffer.factor rename to unmaintained/frame-buffer/frame-buffer.factor diff --git a/unmaintained/fs/authors.txt b/unmaintained/fs/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/fs/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/fs/fs.factor b/unmaintained/fs/fs.factor deleted file mode 100644 index 6cb9f68934..0000000000 --- a/unmaintained/fs/fs.factor +++ /dev/null @@ -1,23 +0,0 @@ -USING: alien.syntax ; -IN: unix.linux.fs - -: MS_RDONLY 1 ; ! Mount read-only. -: MS_NOSUID 2 ; ! Ignore suid and sgid bits. -: MS_NODEV 4 ; ! Disallow access to device special files. -: MS_NOEXEC 8 ; ! Disallow program execution. -: MS_SYNCHRONOUS 16 ; ! Writes are synced at once. -: MS_REMOUNT 32 ; ! Alter flags of a mounted FS. -: MS_MANDLOCK 64 ; ! Allow mandatory locks on an FS. -: S_WRITE 128 ; ! Write on file/directory/symlink. -: S_APPEND 256 ; ! Append-only file. -: S_IMMUTABLE 512 ; ! Immutable file. -: MS_NOATIME 1024 ; ! Do not update access times. -: MS_NODIRATIME 2048 ; ! Do not update directory access times. -: MS_BIND 4096 ; ! Bind directory at different place. - -FUNCTION: int mount -( char* special_file, char* dir, char* fstype, ulong options, void* data ) ; - -! FUNCTION: int umount2 ( char* file, int flags ) ; - -FUNCTION: int umount ( char* file ) ; diff --git a/unmaintained/gap-buffer/authors.txt b/unmaintained/gap-buffer/authors.txt deleted file mode 100644 index e9c193bac7..0000000000 --- a/unmaintained/gap-buffer/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Alex Chapman diff --git a/unmaintained/gap-buffer/cursortree/authors.txt b/unmaintained/gap-buffer/cursortree/authors.txt deleted file mode 100644 index e9c193bac7..0000000000 --- a/unmaintained/gap-buffer/cursortree/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Alex Chapman diff --git a/unmaintained/gap-buffer/cursortree/cursortree-tests.factor b/unmaintained/gap-buffer/cursortree/cursortree-tests.factor deleted file mode 100644 index 2b3ff69c97..0000000000 --- a/unmaintained/gap-buffer/cursortree/cursortree-tests.factor +++ /dev/null @@ -1,17 +0,0 @@ -USING: assocs kernel gap-buffer.cursortree tools.test sequences trees -arrays strings ; -IN: gap-buffer.cursortree.tests - -[ t ] [ "this is a test string" <cursortree> 0 <left-cursor> at-beginning? ] unit-test -[ t ] [ "this is a test string" <cursortree> dup length <left-cursor> at-end? ] unit-test -[ 3 ] [ "this is a test string" <cursortree> 3 <left-cursor> cursor-pos ] unit-test -[ CHAR: i ] [ "this is a test string" <cursortree> 3 <left-cursor> element< ] unit-test -[ CHAR: s ] [ "this is a test string" <cursortree> 3 <left-cursor> element> ] unit-test -[ t ] [ "this is a test string" <cursortree> 3 <left-cursor> CHAR: a over set-element< CHAR: t over set-element> cursor-tree "that is a test string" sequence= ] unit-test -[ 0 ] [ "this is a test string" <cursortree> dup dup 3 <left-cursor> remove-cursor cursors length ] unit-test -[ t ] [ "this is a test string" <cursortree> 3 <left-cursor> 8 over set-cursor-pos dup 1array swap cursor-tree cursors sequence= ] unit-test -[ "this is no longer a test string" ] [ "this is a test string" <cursortree> 8 <left-cursor> "no longer " over insert cursor-tree >string ] unit-test -[ "refactor" ] [ "factor" <cursortree> 0 <left-cursor> CHAR: e over insert CHAR: r over insert cursor-tree >string ] unit-test -[ "refactor" ] [ "factor" <cursortree> 0 <right-cursor> CHAR: r over insert CHAR: e over insert cursor-tree >string ] unit-test -[ "this a test string" 5 ] [ "this is a test string" <cursortree> 5 <right-cursor> dup delete> dup delete> dup delete> dup cursor-tree >string swap cursor-pos ] unit-test -[ "this a test string" 5 ] [ "this is a test string" <cursortree> 8 <right-cursor> dup delete< dup delete< dup delete< dup cursor-tree >string swap cursor-pos ] unit-test diff --git a/unmaintained/gap-buffer/cursortree/cursortree.factor b/unmaintained/gap-buffer/cursortree/cursortree.factor deleted file mode 100644 index 4249aea2d9..0000000000 --- a/unmaintained/gap-buffer/cursortree/cursortree.factor +++ /dev/null @@ -1,94 +0,0 @@ -! Copyright (C) 2007 Alex Chapman All Rights Reserved. -! See http://factorcode.org/license.txt for BSD license. -USING: assocs kernel gap-buffer generic trees trees.avl math -sequences quotations ; -IN: gap-buffer.cursortree - -TUPLE: cursortree cursors ; - -: <cursortree> ( seq -- cursortree ) - <gb> cursortree new tuck set-delegate <avl> - over set-cursortree-cursors ; - -GENERIC: cursortree-gb ( cursortree -- gb ) -M: cursortree cursortree-gb ( cursortree -- gb ) delegate ; -GENERIC: set-cursortree-gb ( gb cursortree -- ) -M: cursortree set-cursortree-gb ( gb cursortree -- ) set-delegate ; - -TUPLE: cursor i tree ; -TUPLE: left-cursor ; -TUPLE: right-cursor ; - -: cursor-index ( cursor -- i ) cursor-i ; - -: add-cursor ( cursortree cursor -- ) dup cursor-index rot push-at ; - -: remove-cursor ( cursortree cursor -- ) - tuck cursor-index swap cursortree-cursors at* [ delete ] [ 2drop ] if ; - -: set-cursor-index ( index cursor -- ) - dup cursor-tree over remove-cursor tuck set-cursor-i - dup cursor-tree cursortree-cursors swap add-cursor ; - -GENERIC: cursor-pos ( cursor -- n ) -GENERIC: set-cursor-pos ( n cursor -- ) -M: left-cursor cursor-pos ( cursor -- n ) [ cursor-i 1+ ] keep cursor-tree index>position ; -M: right-cursor cursor-pos ( cursor -- n ) [ cursor-i ] keep cursor-tree index>position ; -M: left-cursor set-cursor-pos ( n cursor -- ) >r 1- r> [ cursor-tree position>index ] keep set-cursor-index ; -M: right-cursor set-cursor-pos ( n cursor -- ) [ cursor-tree position>index ] keep set-cursor-index ; - -: <cursor> ( cursortree -- cursor ) - cursor new tuck set-cursor-tree ; - -: make-cursor ( cursortree pos cursor -- cursor ) - >r swap <cursor> r> tuck set-delegate tuck set-cursor-pos ; - -: <left-cursor> ( cursortree pos -- left-cursor ) - left-cursor new make-cursor ; - -: <right-cursor> ( cursortree pos -- right-cursor ) - right-cursor new make-cursor ; - -: cursors ( cursortree -- seq ) - cursortree-cursors values concat ; - -: cursor-positions ( cursortree -- seq ) - cursors [ cursor-pos ] map ; - -M: cursortree move-gap ( n cursortree -- ) - #! Get the position of each cursor before the move, then re-set the - #! position afterwards. This will update any changed cursor indices. - dup cursor-positions >r tuck cursortree-gb move-gap - cursors r> swap [ set-cursor-pos ] 2each ; - -: element@< ( cursor -- pos cursortree ) [ cursor-pos 1- ] keep cursor-tree ; -: element@> ( cursor -- pos cursortree ) [ cursor-pos ] keep cursor-tree ; - -: at-beginning? ( cursor -- ? ) cursor-pos 0 = ; -: at-end? ( cursor -- ? ) element@> length = ; - -: insert ( obj cursor -- ) element@> insert* ; - -: element< ( cursor -- elem ) element@< nth ; -: element> ( cursor -- elem ) element@> nth ; - -: set-element< ( elem cursor -- ) element@< set-nth ; -: set-element> ( elem cursor -- ) element@> set-nth ; - -GENERIC: fix-cursor ( cursortree cursor -- ) - -M: left-cursor fix-cursor ( cursortree cursor -- ) - >r gb-gap-start 1- r> set-cursor-index ; - -M: right-cursor fix-cursor ( cursortree cursor -- ) - >r gb-gap-end r> set-cursor-index ; - -: fix-cursors ( old-gap-end cursortree -- ) - tuck cursortree-cursors at [ fix-cursor ] with each ; - -M: cursortree delete* ( pos cursortree -- ) - tuck move-gap dup gb-gap-end swap dup (delete*) fix-cursors ; - -: delete< ( cursor -- ) element@< delete* ; -: delete> ( cursor -- ) element@> delete* ; - diff --git a/unmaintained/gap-buffer/cursortree/summary.txt b/unmaintained/gap-buffer/cursortree/summary.txt deleted file mode 100644 index e57688fad0..0000000000 --- a/unmaintained/gap-buffer/cursortree/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Collection of 'cursors' representing locations in a gap buffer diff --git a/unmaintained/gap-buffer/gap-buffer-tests.factor b/unmaintained/gap-buffer/gap-buffer-tests.factor deleted file mode 100644 index 85dc7b3c88..0000000000 --- a/unmaintained/gap-buffer/gap-buffer-tests.factor +++ /dev/null @@ -1,40 +0,0 @@ -USING: kernel sequences tools.test gap-buffer strings math ; - -! test copy-elements -[ { 0 3 4 3 4 5 } ] [ { 0 1 2 3 4 5 } dup >r -2 3 5 r> copy-elements ] unit-test -[ { 0 1 2 1 2 5 } ] [ { 0 1 2 3 4 5 } dup >r 2 2 0 r> copy-elements ] unit-test -[ "01234567856" ] [ "01234567890" dup >r 4 6 4 r> copy-elements ] unit-test - -! test sequence protocol (like, length, nth, set-nth) -[ "gap buffers are cool" ] [ "gap buffers are cool" <gb> "" like ] unit-test - -! test move-gap-back-inside -[ t f ] [ 5 "0123456" <gb> move-gap-forward? >r move-gap-back-inside? 2nip r> ] unit-test -[ "0123456" ] [ "0123456" <gb> 5 over move-gap >string ] unit-test -! test move-gap-forward-inside -[ t ] [ "I once ate a spaniel" <gb> 15 over move-gap 17 swap move-gap-forward-inside? 2nip ] unit-test -[ "I once ate a spaniel" ] [ "I once ate a spaniel" <gb> 15 over move-gap 17 over move-gap >string ] unit-test -! test move-gap-back-around -[ f f ] [ 2 "terriers are ok too" <gb> move-gap-forward? >r move-gap-back-inside? 2nip r> ] unit-test -[ "terriers are ok too" ] [ "terriers are ok too" <gb> 2 over move-gap >string ] unit-test -! test move-gap-forward-around -[ f t ] [ "god is nam's best friend" <gb> 2 over move-gap 22 over position>index swap move-gap-forward? >r move-gap-forward-inside? 2nip r> ] unit-test -[ "god is nam's best friend" ] [ "god is nam's best friend" <gb> 2 over move-gap 22 over move-gap >string ] unit-test - -! test changing buffer contents -[ "factory" ] [ "factor" <gb> CHAR: y 6 pick insert* >string ] unit-test -! test inserting multiple elements in different places. buffer should grow -[ "refractory" ] [ "factor" <gb> CHAR: y 6 pick insert* "re" 0 pick insert* CHAR: r 3 pick insert* >string ] unit-test -! test deleting elements. buffer should shrink -[ "for" ] [ "factor" <gb> 3 [ 1 over delete* ] times >string ] unit-test -! more testing of nth and set-nth -[ "raptor" ] [ "factor" <gb> CHAR: p 2 pick set-nth 5 over nth 0 pick set-nth >string ] unit-test - -! test stack/queue operations -[ "slaughter" ] [ "laughter" <gb> CHAR: s over push-start >string ] unit-test -[ "pantonio" ] [ "pant" <gb> "onio" over push-end >string ] unit-test -[ CHAR: f "actor" ] [ "factor" <gb> dup pop-start swap >string ] unit-test -[ CHAR: s "pant" ] [ "pants" <gb> dup pop-end swap >string ] unit-test -[ "end this is the " ] [ "this is the end " <gb> 4 over rotate >string ] unit-test -[ "your jedi training is finished " ] [ "finished your jedi training is " <gb> -9 over rotate >string ] unit-test - diff --git a/unmaintained/gap-buffer/gap-buffer.factor b/unmaintained/gap-buffer/gap-buffer.factor deleted file mode 100644 index 55a1276dd4..0000000000 --- a/unmaintained/gap-buffer/gap-buffer.factor +++ /dev/null @@ -1,294 +0,0 @@ -! Copyright (C) 2007 Alex Chapman All Rights Reserved. -! See http://factorcode.org/license.txt for BSD license. -! -! gap buffer -- largely influenced by Strandh and Villeneuve's Flexichain -! for a good introduction see: -! http://p-cos.net/lisp-ecoop/submissions/StrandhVilleneuveMoore.pdf -USING: kernel arrays sequences sequences.private circular math -math.order math.functions generic ; -IN: gap-buffer - -! gap-start -- the first element of the gap -! gap-end -- the first element after the gap -! expand-factor -- should be > 1 -! min-size -- < 5 is not sensible - -TUPLE: gb - gap-start - gap-end - expand-factor - min-size ; - -GENERIC: gb-seq ( gb -- seq ) -GENERIC: set-gb-seq ( seq gb -- ) -M: gb gb-seq ( gb -- seq ) delegate ; -M: gb set-gb-seq ( seq gb -- ) set-delegate ; - -: required-space ( n gb -- n ) - tuck gb-expand-factor * ceiling >fixnum swap gb-min-size max ; - -: <gb> ( seq -- gb ) - gb new - 5 over set-gb-min-size - 1.5 over set-gb-expand-factor - [ >r length r> set-gb-gap-start ] 2keep - [ swap length over required-space swap set-gb-gap-end ] 2keep - [ - over length over required-space rot { } like resize-array <circular> swap set-gb-seq - ] keep ; - -M: gb like ( seq gb -- seq ) drop <gb> ; - -: gap-length ( gb -- n ) [ gb-gap-end ] keep gb-gap-start - ; - -: buffer-length ( gb -- n ) gb-seq length ; - -M: gb length ( gb -- n ) [ buffer-length ] keep gap-length - ; - -: valid-position? ( pos gb -- ? ) - #! one element past the end of the buffer is a valid position when we're inserting - length -1 swap between? ; - -: valid-index? ( i gb -- ? ) - buffer-length -1 swap between? ; - -TUPLE: position-out-of-bounds position gap-buffer ; -C: <position-out-of-bounds> position-out-of-bounds - -: position>index ( pos gb -- i ) - 2dup valid-position? [ - 2dup gb-gap-start >= [ - gap-length + - ] [ drop ] if - ] [ - <position-out-of-bounds> throw - ] if ; - -TUPLE: index-out-of-bounds index gap-buffer ; -C: <index-out-of-bounds> index-out-of-bounds - -: index>position ( i gb -- pos ) - 2dup valid-index? [ - 2dup gb-gap-end >= [ - gap-length - - ] [ drop ] if - ] [ - <index-out-of-bounds> throw - ] if ; - -M: gb virtual@ ( n gb -- n seq ) [ position>index ] keep gb-seq ; - -M: gb nth ( n gb -- elt ) bounds-check virtual@ nth-unsafe ; - -M: gb nth-unsafe ( n gb -- elt ) virtual@ nth-unsafe ; - -M: gb set-nth ( elt n seq -- ) bounds-check virtual@ set-nth-unsafe ; - -M: gb set-nth-unsafe ( elt n seq -- ) virtual@ set-nth-unsafe ; - -M: gb virtual-seq gb-seq ; - -INSTANCE: gb virtual-sequence - -! ------------- moving the gap ------------------------------- - -: (copy-element) ( to start seq -- ) tuck nth -rot set-nth ; - -: copy-element ( dst start seq -- ) >r [ + ] keep r> (copy-element) ; - -: copy-elements-back ( dst start seq n -- ) - dup 0 > [ - >r [ copy-element ] 3keep >r 1+ r> r> 1- copy-elements-back - ] [ 3drop drop ] if ; - -: copy-elements-forward ( dst start seq n -- ) - dup 0 > [ - >r [ copy-element ] 3keep >r 1- r> r> 1- copy-elements-forward - ] [ 3drop drop ] if ; - -: copy-elements ( dst start end seq -- ) - pick pick > [ - >r dupd - r> swap copy-elements-forward - ] [ - >r over - r> swap copy-elements-back - ] if ; - -! the gap can be moved either forward or back. Moving the gap 'inside' means -! moving elements across the gap. Moving the gap 'around' means changing the -! start of the circular buffer to avoid moving as many elements. - -! We decide which method (inside or around) to pick based on the number of -! elements that will need to be moved. We always try to move as few elements as -! possible. - -: move-gap? ( i gb -- i gb ? ) 2dup gb-gap-end = not ; - -: move-gap-forward? ( i gb -- i gb ? ) 2dup gb-gap-start >= ; - -: move-gap-back-inside? ( i gb -- i gb ? ) - #! is it cheaper to move the gap inside than around? - 2dup [ gb-gap-start swap 2 * - ] keep [ buffer-length ] keep gb-gap-end - <= ; - -: move-gap-forward-inside? ( i gb -- i gb ? ) - #! is it cheaper to move the gap inside than around? - 2dup [ gb-gap-end >r 2 * r> - ] keep [ gb-gap-start ] keep buffer-length + <= ; - -: move-gap-forward-inside ( i gb -- ) - [ dup gap-length neg swap gb-gap-end rot ] keep gb-seq copy-elements ; - -: move-gap-back-inside ( i gb -- ) - [ dup gap-length swap gb-gap-start 1- rot 1- ] keep gb-seq copy-elements ; - -: move-gap-forward-around ( i gb -- ) - 0 over move-gap-back-inside [ - dup buffer-length [ - swap gap-length - neg swap - ] keep - ] keep [ - gb-seq copy-elements - ] keep dup gap-length swap gb-seq change-circular-start ; - -: move-gap-back-around ( i gb -- ) - dup buffer-length over move-gap-forward-inside [ - length swap -1 - ] keep [ - gb-seq copy-elements - ] keep dup length swap gb-seq change-circular-start ; - -: move-gap-forward ( i gb -- ) - move-gap-forward-inside? [ - move-gap-forward-inside - ] [ - move-gap-forward-around - ] if ; - -: move-gap-back ( i gb -- ) - move-gap-back-inside? [ - move-gap-back-inside - ] [ - move-gap-back-around - ] if ; - -: (move-gap) ( i gb -- ) - move-gap? [ - move-gap-forward? [ - move-gap-forward - ] [ - move-gap-back - ] if - ] [ 2drop ] if ; - -: fix-gap ( n gb -- ) - 2dup [ gap-length + ] keep set-gb-gap-end set-gb-gap-start ; - -! moving the gap to position 5 means that the element in position 5 will be immediately after the gap -GENERIC: move-gap ( n gb -- ) - -M: gb move-gap ( n gb -- ) 2dup [ position>index ] keep (move-gap) fix-gap ; - -! ------------ resizing ------------------------------------- - -: enough-room? ( n gb -- ? ) - #! is there enough room to add 'n' elements to gb? - tuck length + swap buffer-length <= ; - -: set-new-gap-end ( array gb -- ) - [ buffer-length swap length swap - ] keep - [ gb-gap-end + ] keep set-gb-gap-end ; - -: after-gap ( gb -- gb ) - dup gb-seq swap gb-gap-end tail ; - -: before-gap ( gb -- gb ) - dup gb-gap-start head ; - -: copy-after-gap ( array gb -- ) - #! copy everything after the gap in 'gb' into the end of 'array', - #! and change 'gb's gap-end to reflect the gap-end in 'array' - dup after-gap >r 2dup set-new-gap-end gb-gap-end swap r> -rot copy ; - -: copy-before-gap ( array gb -- ) - #! copy everything before the gap in 'gb' into the start of 'array' - before-gap 0 rot copy ; ! gap start doesn't change - -: resize-buffer ( gb new-size -- ) - f <array> swap 2dup copy-before-gap 2dup copy-after-gap - >r <circular> r> set-gb-seq ; - -: decrease-buffer-size ( gb -- ) - #! the gap is too big, so resize to something sensible - dup length over required-space resize-buffer ; - -: increase-buffer-size ( n gb -- ) - #! increase the buffer to fit at least 'n' more elements - tuck length + over required-space resize-buffer ; - -: gb-too-big? ( gb -- ? ) - dup buffer-length over gb-min-size > [ - dup length over buffer-length rot gb-expand-factor sq / < - ] [ drop f ] if ; - -: ?decrease ( gb -- ) - dup gb-too-big? [ - decrease-buffer-size - ] [ drop ] if ; - -: ensure-room ( n gb -- ) - #! ensure that ther will be enough room for 'n' more elements - 2dup enough-room? [ 2drop ] [ - increase-buffer-size - ] if ; - -! ------- editing operations --------------- - -GENERIC# insert* 2 ( seq position gb -- ) - -: prepare-insert ( seq position gb -- seq gb ) - tuck move-gap over length over ensure-room ; - -: insert-elements ( seq gb -- ) - dup gb-gap-start swap gb-seq copy ; - -: increment-gap-start ( gb n -- ) - over gb-gap-start + swap set-gb-gap-start ; - -! generic dispatch identifies numbers as sequences before numbers... -! M: number insert* ( elem position gb -- ) >r >r 1array r> r> insert* ; -: number-insert ( num position gb -- ) >r >r 1array r> r> insert* ; - -M: sequence insert* ( seq position gb -- ) - pick number? [ - number-insert - ] [ - prepare-insert [ insert-elements ] 2keep swap length increment-gap-start - ] if ; - -: (delete*) ( gb -- ) - dup gb-gap-end 1+ over set-gb-gap-end ?decrease ; - -GENERIC: delete* ( pos gb -- ) - -M: gb delete* ( position gb -- ) - tuck move-gap (delete*) ; - -! -------- stack/queue operations ----------- - -: push-start ( obj gb -- ) 0 swap insert* ; - -: push-end ( obj gb -- ) [ length ] keep insert* ; - -: pop-elem ( position gb -- elem ) [ nth ] 2keep delete* ; - -: pop-start ( gb -- elem ) 0 swap pop-elem ; - -: pop-end ( gb -- elem ) [ length 1- ] keep pop-elem ; - -: rotate ( n gb -- ) - dup length 1 > [ - swap dup 0 > [ - [ dup [ pop-end ] keep push-start ] - ] [ - neg [ dup [ pop-start ] keep push-end ] - ] if times drop - ] [ 2drop ] if ; - diff --git a/unmaintained/gap-buffer/summary.txt b/unmaintained/gap-buffer/summary.txt deleted file mode 100644 index 0da4c0075d..0000000000 --- a/unmaintained/gap-buffer/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Gap buffer data structure diff --git a/unmaintained/gap-buffer/tags.txt b/unmaintained/gap-buffer/tags.txt deleted file mode 100644 index b5e4471134..0000000000 --- a/unmaintained/gap-buffer/tags.txt +++ /dev/null @@ -1,2 +0,0 @@ -collections -sequences diff --git a/unmaintained/geom/dim/authors.txt b/unmaintained/geom/dim/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/geom/dim/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/geom/dim/dim.factor b/unmaintained/geom/dim/dim.factor deleted file mode 100644 index 1cac5d765f..0000000000 --- a/unmaintained/geom/dim/dim.factor +++ /dev/null @@ -1,16 +0,0 @@ - -USING: sequences mortar slot-accessors ; - -IN: geom.dim - -SYMBOL: <dim> - -<dim> { "dim" } accessors define-independent-class - -<dim> { - -"width" !( dim -- width ) [ $dim first ] - -"height" !( dim -- second ) [ $dim second ] - -} add-methods \ No newline at end of file diff --git a/unmaintained/geom/pos/authors.txt b/unmaintained/geom/pos/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/geom/pos/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/geom/pos/pos.factor b/unmaintained/geom/pos/pos.factor deleted file mode 100644 index b626c40e37..0000000000 --- a/unmaintained/geom/pos/pos.factor +++ /dev/null @@ -1,28 +0,0 @@ - -USING: kernel arrays sequences math.vectors mortar slot-accessors ; - -IN: geom.pos - -SYMBOL: <pos> - -<pos> { "pos" } accessors define-independent-class - -<pos> { - -"x" !( pos -- x ) [ $pos first ] - -"y" !( pos -- y ) [ $pos second ] - -"set-x" !( pos x -- pos ) [ 0 pick $pos set-nth ] - -"set-y" !( pos y -- pos ) [ 1 pick $pos set-nth ] - -"distance" !( pos pos -- distance ) [ $pos swap $pos v- norm ] - -"move-by" !( pos offset -- pos ) [ over $pos v+ >>pos ] - -"move-by-x" !( pos x-offset -- pos ) [ 0 2array <-- move-by ] - -"move-by-y" !( pos y-offset -- pos ) [ 0 swap 2array <-- move-by ] - -} add-methods \ No newline at end of file diff --git a/unmaintained/geom/rect/authors.txt b/unmaintained/geom/rect/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/geom/rect/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/geom/rect/rect.factor b/unmaintained/geom/rect/rect.factor deleted file mode 100644 index 573b8e0e1d..0000000000 --- a/unmaintained/geom/rect/rect.factor +++ /dev/null @@ -1,41 +0,0 @@ - -USING: kernel namespaces arrays sequences math.vectors - mortar slot-accessors geom.pos geom.dim ; - -IN: geom.rect - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -USE: math - -: v+y ( pos y -- pos ) 0 swap 2array v+ ; - -: v-y ( pos y -- pos ) 0 swap 2array v- ; - -: v+x ( pos x -- pos ) 0 2array v+ ; - -: v-x ( pos x -- pos ) 0 2array v- ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYMBOL: <rect> - -<rect> - <pos> class-slots <dim> class-slots append - <pos> class-methods <dim> class-methods append { H{ } } append - { H{ } } -4array <rect> set-global - -! { 0 0 } { 0 0 } <rect> new - -<rect> { - -"top-left" !( rect -- point ) [ $pos ] - -"top-right" !( rect -- point ) [ dup $pos swap <- width 1- v+x ] - -"bottom-left" !( rect -- point ) [ dup $pos swap <- height 1- v+y ] - -"bottom-right" !( rect -- point ) [ dup $pos swap $dim { 1 1 } v- v+ ] - -} add-methods \ No newline at end of file diff --git a/extra/golden-section/authors.txt b/unmaintained/golden-section/authors.txt similarity index 100% rename from extra/golden-section/authors.txt rename to unmaintained/golden-section/authors.txt diff --git a/extra/golden-section/deploy.factor b/unmaintained/golden-section/deploy.factor similarity index 100% rename from extra/golden-section/deploy.factor rename to unmaintained/golden-section/deploy.factor diff --git a/extra/golden-section/golden-section.factor b/unmaintained/golden-section/golden-section.factor similarity index 100% rename from extra/golden-section/golden-section.factor rename to unmaintained/golden-section/golden-section.factor diff --git a/extra/golden-section/summary.txt b/unmaintained/golden-section/summary.txt similarity index 100% rename from extra/golden-section/summary.txt rename to unmaintained/golden-section/summary.txt diff --git a/extra/golden-section/tags.txt b/unmaintained/golden-section/tags.txt similarity index 100% rename from extra/golden-section/tags.txt rename to unmaintained/golden-section/tags.txt diff --git a/unmaintained/id3/authors.txt b/unmaintained/id3/authors.txt deleted file mode 100644 index bbc876e7b6..0000000000 --- a/unmaintained/id3/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Adam Wendt diff --git a/unmaintained/id3/id3-docs.factor b/unmaintained/id3/id3-docs.factor deleted file mode 100644 index 8083514c0d..0000000000 --- a/unmaintained/id3/id3-docs.factor +++ /dev/null @@ -1,29 +0,0 @@ -! Coyright (C) 2007 Adam Wendt -! See http://factorcode.org/license.txt for BSD license. -USING: help.syntax help.markup ; -IN: id3 - -ARTICLE: "id3-tags" "ID3 Tags" -"The " { $vocab-link "id3" } " vocabulary is used to read ID3 tags from MP3 audio streams." -{ $subsection id3v2 } -{ $subsection read-tag } -{ $subsection id3v2? } -{ $subsection read-id3v2 } ; - -ABOUT: "id3-tags" - -HELP: id3v2 -{ $values { "filename" "a pathname string" } { "tag/f" "a tag or f" } } -{ $description "Outputs a " { $link tag } " or " { $link f } " if file does not start with an ID3 tag." } ; - -HELP: read-tag -{ $values { "stream" "a stream" } { "tag/f" "a tag or f" } } -{ $description "Outputs a " { $link tag } " or " { $link f } " if stream does not start with an ID3 tag." } ; - -HELP: id3v2? -{ $values { "?" "a boolean" } } -{ $description "Tests if the current input stream begins with an ID3 tag." } ; - -HELP: read-id3v2 -{ $values { "tag/f" "a tag or f" } } -{ $description "Outputs a " { $link tag } " or " { $link f } " if the current input stream does not start with an ID3 tag." } ; diff --git a/unmaintained/id3/id3.factor b/unmaintained/id3/id3.factor deleted file mode 100755 index 7f39025c4c..0000000000 --- a/unmaintained/id3/id3.factor +++ /dev/null @@ -1,142 +0,0 @@ -! Copyright (C) 2007 Adam Wendt. -! See http://factorcode.org/license.txt for BSD license. - -USING: arrays combinators io io.binary io.files io.paths -io.encodings.utf16 kernel math math.parser namespaces sequences -splitting strings assocs unicode.categories io.encodings.binary ; - -IN: id3 - -TUPLE: tag header frames ; -C: <tag> tag - -TUPLE: header version revision flags size extended-header ; -C: <header> header - -TUPLE: frame id size flags data ; -C: <frame> frame - -TUPLE: extended-header size flags update crc restrictions ; -C: <extended-header> extended-header - -: debug-stream ( msg -- ) -! global [ . flush ] bind ; - drop ; - -: >hexstring ( str -- hex ) - >array [ >hex 2 CHAR: 0 pad-left ] map concat ; - -: good-frame-id? ( id -- ? ) - [ [ LETTER? ] keep digit? or ] all? ; - -! 4 byte syncsafe integer (28 effective bits) -: >syncsafe ( seq -- int ) - 0 [ >r 7 shift r> bitor ] reduce ; - -: read-size ( -- size ) - 4 read >syncsafe ; - -: read-frame-id ( -- id ) - 4 read ; - -: read-frame-flags ( -- flags ) - 2 read ; - -: read-frame-size ( -- size ) - 4 read be> ; - -: text-frame? ( id -- ? ) - "T" head? ; - -: read-text ( size -- text ) - read1 swap 1 - read swap 1 = [ decode-utf16 ] [ ] if - "\0" ?tail drop ; ! remove null terminator - -: read-popm ( size -- popm ) - read-text ; - -: read-frame-data ( id size -- data ) - swap - { - { [ dup text-frame? ] [ drop read-text ] } - { [ "POPM" = ] [ read-popm ] } - { [ t ] [ read ] } - } cond ; - -: (read-frame) ( id -- frame ) - read-frame-size read-frame-flags 2over read-frame-data <frame> ; - -: read-frame ( -- frame/f ) - read-frame-id dup good-frame-id? [ (read-frame) ] [ drop f ] if ; - -: (read-frames) ( vector -- frames ) - read-frame [ over push (read-frames) ] when* ; - -: read-frames ( -- frames ) - V{ } clone (read-frames) ; - -: read-eh-flags ( -- flags ) - read1 read le> ; - -: read-eh-data ( size -- data ) - 6 - read ; - -: read-crc ( flags -- crc ) - 5 bit? [ read1 read >syncsafe ] [ f ] if ; - -: tag-is-update? ( flags -- ? ) - 6 bit? dup [ read1 drop ] [ ] if ; - -: (read-tag-restrictions) ( -- restrictions ) - read1 dup read le> ; - -: read-tag-restrictions ( flags -- restrictions/f ) - 4 bit? [ (read-tag-restrictions) ] [ f ] if ; - -: (read-extended-header) ( -- extended-header ) - read-size read-eh-flags dup tag-is-update? over dup - read-crc swap read-tag-restrictions <extended-header> ; - -: read-extended-header ( flags -- extended-header/f ) - 6 bit? [ (read-extended-header) ] [ f ] if ; - -: read-header ( version -- header ) - read1 read1 read-size over read-extended-header <header> ; - -: (read-id3v2) ( version -- tag ) - read-header read-frames <tag> ; - -: supported-version? ( version -- ? ) - { 3 4 } member? ; - -: read-id3v2 ( -- tag/f ) - read1 dup supported-version? - [ (read-id3v2) ] [ drop f ] if ; - -: id3v2? ( -- ? ) - 3 read "ID3" sequence= ; - -: read-tag ( stream -- tag/f ) - id3v2? [ read-id3v2 ] [ f ] if ; - -: id3v2 ( filename -- tag/f ) - binary [ read-tag ] with-file-reader ; - -: file? ( path -- ? ) - stat 3drop not ; - -: files ( paths -- files ) - [ file? ] subset ; - -: mp3? ( path -- ? ) - ".mp3" tail? ; - -: mp3s ( paths -- mp3s ) - [ mp3? ] subset ; - -: id3? ( file -- ? ) - binary [ id3v2? ] with-file-reader ; - -: id3s ( files -- id3s ) - [ id3? ] subset ; - diff --git a/unmaintained/id3/summary.txt b/unmaintained/id3/summary.txt deleted file mode 100644 index 62016172bd..0000000000 --- a/unmaintained/id3/summary.txt +++ /dev/null @@ -1 +0,0 @@ -ID3 music file tag parser diff --git a/unmaintained/if/authors.txt b/unmaintained/if/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/if/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/if/if.factor b/unmaintained/if/if.factor deleted file mode 100644 index 0a908831ee..0000000000 --- a/unmaintained/if/if.factor +++ /dev/null @@ -1,98 +0,0 @@ - -USING: alien.syntax ; - -IN: unix.linux.if - -: IFNAMSIZ 16 ; -: IF_NAMESIZE 16 ; -: IFHWADDRLEN 6 ; - -! Standard interface flags (netdevice->flags) - -: IFF_UP HEX: 1 ; ! interface is up -: IFF_BROADCAST HEX: 2 ; ! broadcast address valid -: IFF_DEBUG HEX: 4 ; ! turn on debugging -: IFF_LOOPBACK HEX: 8 ; ! is a loopback net -: IFF_POINTOPOINT HEX: 10 ; ! interface is has p-p link -: IFF_NOTRAILERS HEX: 20 ; ! avoid use of trailers -: IFF_RUNNING HEX: 40 ; ! interface running and carrier ok -: IFF_NOARP HEX: 80 ; ! no ARP protocol -: IFF_PROMISC HEX: 100 ; ! receive all packets -: IFF_ALLMULTI HEX: 200 ; ! receive all multicast packets - -: IFF_MASTER HEX: 400 ; ! master of a load balancer -: IFF_SLAVE HEX: 800 ; ! slave of a load balancer - -: IFF_MULTICAST HEX: 1000 ; ! Supports multicast - -! #define IFF_VOLATILE -! (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_MASTER|IFF_SLAVE|IFF_RUNNING) - -: IFF_PORTSEL HEX: 2000 ; ! can set media type -: IFF_AUTOMEDIA HEX: 4000 ; ! auto media select active -: IFF_DYNAMIC HEX: 8000 ; ! dialup device with changing addresses - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -C-STRUCT: struct-ifmap - { "ulong" "mem-start" } - { "ulong" "mem-end" } - { "ushort" "base-addr" } - { "uchar" "irq" } - { "uchar" "dma" } - { "uchar" "port" } ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! Hmm... the generic sockaddr type isn't defined anywhere. -! Put it here for now. - -TYPEDEF: ushort sa_family_t - -C-STRUCT: struct-sockaddr - { "sa_family_t" "sa_family" } - { { "char" 14 } "sa_data" } ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! C-UNION: union-ifr-ifrn { "char" IFNAMSIZ } ; - -C-UNION: union-ifr-ifrn { "char" 16 } ; - -C-UNION: union-ifr-ifru - "struct-sockaddr" -! "sockaddr" - "short" - "int" - "struct-ifmap" -! { "char" IFNAMSIZ } - { "char" 16 } - "caddr_t" ; - -C-STRUCT: struct-ifreq - { "union-ifr-ifrn" "ifr-ifrn" } - { "union-ifr-ifru" "ifr-ifru" } ; - -: ifr-name ( struct-ifreq -- value ) struct-ifreq-ifr-ifrn ; - -: ifr-hwaddr ( struct-ifreq -- value ) struct-ifreq-ifr-ifru ; -: ifr-addr ( struct-ifreq -- value ) struct-ifreq-ifr-ifru ; -: ifr-dstaddr ( struct-ifreq -- value ) struct-ifreq-ifr-ifru ; -: ifr-broadaddr ( struct-ifreq -- value ) struct-ifreq-ifr-ifru ; -: ifr-netmask ( struct-ifreq -- value ) struct-ifreq-ifr-ifru ; -: ifr-flags ( struct-ifreq -- value ) struct-ifreq-ifr-ifru ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -C-UNION: union-ifc-ifcu "caddr_t" "struct-ifreq*" ; - -C-STRUCT: struct-ifconf - { "int" "ifc-len" } - { "union-ifc-ifcu" "ifc-ifcu" } ; - -: ifc-len ( struct-ifconf -- value ) struct-ifconf-ifc-len ; - -: ifc-buf ( struct-ifconf -- value ) struct-ifconf-ifc-ifcu ; -: ifc-req ( struct-ifconf -- value ) struct-ifconf-ifc-ifcu ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! \ No newline at end of file diff --git a/unmaintained/if/tags.txt b/unmaintained/if/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/unmaintained/if/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/unmaintained/ifreq/authors.txt b/unmaintained/ifreq/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/ifreq/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/ifreq/ifreq.factor b/unmaintained/ifreq/ifreq.factor deleted file mode 100644 index 5dc1c0fde2..0000000000 --- a/unmaintained/ifreq/ifreq.factor +++ /dev/null @@ -1,60 +0,0 @@ - -USING: kernel alien alien.c-types - io.sockets - unix - unix.linux.sockios - unix.linux.if ; - -IN: unix.linux.ifreq - -: set-if-addr ( name addr -- ) - "struct-ifreq" <c-object> - rot ascii string>alien over set-struct-ifreq-ifr-ifrn - swap 0 <inet4> make-sockaddr over set-struct-ifreq-ifr-ifru - - AF_INET SOCK_DGRAM 0 socket SIOCSIFADDR rot ioctl drop ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: set-if-flags ( name flags -- ) - "struct-ifreq" <c-object> - rot ascii string>alien over set-struct-ifreq-ifr-ifrn - swap <short> over set-struct-ifreq-ifr-ifru - - AF_INET SOCK_DGRAM 0 socket SIOCSIFFLAGS rot ioctl drop ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: set-if-dst-addr ( name addr -- ) - "struct-ifreq" <c-object> - rot ascii string>alien over set-struct-ifreq-ifr-ifrn - swap 0 <inet4> make-sockaddr over set-struct-ifreq-ifr-ifru - - AF_INET SOCK_DGRAM 0 socket SIOCSIFDSTADDR rot ioctl drop ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: set-if-brd-addr ( name addr -- ) - "struct-ifreq" <c-object> - rot ascii string>alien over set-struct-ifreq-ifr-ifrn - swap 0 <inet4> make-sockaddr over set-struct-ifreq-ifr-ifru - - AF_INET SOCK_DGRAM 0 socket SIOCSIFBRDADDR rot ioctl drop ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: set-if-netmask ( name addr -- ) - "struct-ifreq" <c-object> - rot ascii string>alien over set-struct-ifreq-ifr-ifrn - swap 0 <inet4> make-sockaddr over set-struct-ifreq-ifr-ifru - - AF_INET SOCK_DGRAM 0 socket SIOCSIFNETMASK rot ioctl drop ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: set-if-metric ( name metric -- ) - "struct-ifreq" <c-object> - rot ascii string>alien over set-struct-ifreq-ifr-ifrn - swap <int> over set-struct-ifreq-ifr-ifru - - AF_INET SOCK_DGRAM 0 socket SIOCSIFMETRIC rot ioctl drop ; \ No newline at end of file diff --git a/extra/irc/ui/authors.txt b/unmaintained/irc-ui/authors.txt similarity index 100% rename from extra/irc/ui/authors.txt rename to unmaintained/irc-ui/authors.txt diff --git a/extra/irc/ui/commandparser/commandparser.factor b/unmaintained/irc-ui/commandparser/commandparser.factor similarity index 100% rename from extra/irc/ui/commandparser/commandparser.factor rename to unmaintained/irc-ui/commandparser/commandparser.factor diff --git a/extra/irc/ui/commands/commands.factor b/unmaintained/irc-ui/commands/commands.factor similarity index 100% rename from extra/irc/ui/commands/commands.factor rename to unmaintained/irc-ui/commands/commands.factor diff --git a/extra/irc/ui/ircui-rc b/unmaintained/irc-ui/ircui-rc similarity index 100% rename from extra/irc/ui/ircui-rc rename to unmaintained/irc-ui/ircui-rc diff --git a/extra/irc/ui/load/load.factor b/unmaintained/irc-ui/load/load.factor similarity index 100% rename from extra/irc/ui/load/load.factor rename to unmaintained/irc-ui/load/load.factor diff --git a/extra/irc/ui/summary.txt b/unmaintained/irc-ui/summary.txt similarity index 100% rename from extra/irc/ui/summary.txt rename to unmaintained/irc-ui/summary.txt diff --git a/extra/irc/ui/ui.factor b/unmaintained/irc-ui/ui.factor similarity index 100% rename from extra/irc/ui/ui.factor rename to unmaintained/irc-ui/ui.factor diff --git a/unmaintained/jamshred/authors.txt b/unmaintained/jamshred/authors.txt deleted file mode 100644 index e9c193bac7..0000000000 --- a/unmaintained/jamshred/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Alex Chapman diff --git a/unmaintained/jamshred/deploy.factor b/unmaintained/jamshred/deploy.factor deleted file mode 100644 index 9a18cf1f9b..0000000000 --- a/unmaintained/jamshred/deploy.factor +++ /dev/null @@ -1,12 +0,0 @@ -USING: tools.deploy.config ; -V{ - { deploy-ui? t } - { deploy-io 1 } - { deploy-reflection 1 } - { deploy-compiler? t } - { deploy-math? t } - { deploy-word-props? f } - { deploy-c-types? f } - { "stop-after-last-window?" t } - { deploy-name "Jamshred" } -} diff --git a/unmaintained/jamshred/game/authors.txt b/unmaintained/jamshred/game/authors.txt deleted file mode 100755 index e9c193bac7..0000000000 --- a/unmaintained/jamshred/game/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Alex Chapman diff --git a/unmaintained/jamshred/game/game.factor b/unmaintained/jamshred/game/game.factor deleted file mode 100644 index 9cb5bc7c3a..0000000000 --- a/unmaintained/jamshred/game/game.factor +++ /dev/null @@ -1,40 +0,0 @@ -! Copyright (C) 2007, 2008 Alex Chapman -! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel opengl arrays sequences jamshred.log jamshred.player jamshred.sound jamshred.tunnel math math.constants math.vectors ; -IN: jamshred.game - -TUPLE: jamshred sounds tunnel players running quit ; - -: <jamshred> ( -- jamshred ) - <sounds> <random-tunnel> "Player 1" pick <player> - 2dup swap play-in-tunnel 1array f f jamshred boa ; - -: jamshred-player ( jamshred -- player ) - ! TODO: support more than one player - players>> first ; - -: jamshred-update ( jamshred -- ) - dup running>> [ - jamshred-player update-player - ] [ drop ] if ; - -: toggle-running ( jamshred -- ) - dup running>> [ - f >>running drop - ] [ - [ jamshred-player moved ] - [ t >>running drop ] bi - ] if ; - -: mouse-moved ( x-radians y-radians jamshred -- ) - jamshred-player -rot turn-player ; - -: units-per-full-roll ( -- n ) 50 ; - -: jamshred-roll ( jamshred n -- ) - [ jamshred-player ] dip 2 pi * * units-per-full-roll / roll-player ; - -: mouse-scroll-x ( jamshred x -- ) jamshred-roll ; - -: mouse-scroll-y ( jamshred y -- ) - neg swap jamshred-player change-player-speed ; diff --git a/unmaintained/jamshred/gl/authors.txt b/unmaintained/jamshred/gl/authors.txt deleted file mode 100755 index e9c193bac7..0000000000 --- a/unmaintained/jamshred/gl/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Alex Chapman diff --git a/unmaintained/jamshred/gl/gl.factor b/unmaintained/jamshred/gl/gl.factor deleted file mode 100644 index b78e7de88e..0000000000 --- a/unmaintained/jamshred/gl/gl.factor +++ /dev/null @@ -1,99 +0,0 @@ -! Copyright (C) 2007, 2008 Alex Chapman -! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types jamshred.game jamshred.oint -jamshred.player jamshred.tunnel kernel math math.constants -math.functions math.vectors opengl opengl.gl opengl.glu -opengl.demo-support sequences specialized-arrays.float ; -IN: jamshred.gl - -: min-vertices 6 ; inline -: max-vertices 32 ; inline - -: n-vertices ( -- n ) 32 ; inline - -! render enough of the tunnel that it looks continuous -: n-segments-ahead ( -- n ) 60 ; inline -: n-segments-behind ( -- n ) 40 ; inline - -: wall-drawing-offset ( -- n ) - #! so that we can't see through the wall, we draw it a bit further away - 0.15 ; - -: wall-drawing-radius ( segment -- r ) - radius>> wall-drawing-offset + ; - -: wall-up ( segment -- v ) - [ wall-drawing-radius ] [ up>> ] bi n*v ; - -: wall-left ( segment -- v ) - [ wall-drawing-radius ] [ left>> ] bi n*v ; - -: segment-vertex ( theta segment -- vertex ) - [ - [ wall-up swap sin v*n ] [ wall-left swap cos v*n ] 2bi v+ - ] [ - location>> v+ - ] bi ; - -: segment-vertex-normal ( vertex segment -- normal ) - location>> swap v- normalize ; - -: segment-vertex-and-normal ( segment theta -- vertex normal ) - swap [ segment-vertex ] keep dupd segment-vertex-normal ; - -: equally-spaced-radians ( n -- seq ) - #! return a sequence of n numbers between 0 and 2pi - dup [ / pi 2 * * ] curry map ; - -: draw-segment-vertex ( segment theta -- ) - over color>> gl-color segment-vertex-and-normal - gl-normal gl-vertex ; - -: draw-vertex-pair ( theta next-segment segment -- ) - rot tuck draw-segment-vertex draw-segment-vertex ; - -: draw-segment ( next-segment segment -- ) - GL_QUAD_STRIP [ - [ draw-vertex-pair ] 2curry - n-vertices equally-spaced-radians F{ 0.0 } append swap each - ] do-state ; - -: draw-segments ( segments -- ) - 1 over length pick subseq swap [ draw-segment ] 2each ; - -: segments-to-render ( player -- segments ) - dup nearest-segment>> number>> dup n-segments-behind - - swap n-segments-ahead + rot tunnel>> sub-tunnel ; - -: draw-tunnel ( player -- ) - segments-to-render draw-segments ; - -: init-graphics ( width height -- ) - GL_DEPTH_TEST glEnable - GL_SCISSOR_TEST glDisable - 1.0 glClearDepth - 0.0 0.0 0.0 0.0 glClearColor - GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear - GL_PROJECTION glMatrixMode glLoadIdentity - dup 0 = [ 2drop ] [ / >float 45.0 swap 0.1 100.0 gluPerspective ] if - GL_MODELVIEW glMatrixMode glLoadIdentity - GL_LEQUAL glDepthFunc - GL_LIGHTING glEnable - GL_LIGHT0 glEnable - GL_FOG glEnable - GL_FOG_DENSITY 0.09 glFogf - GL_FRONT GL_AMBIENT_AND_DIFFUSE glColorMaterial - GL_COLOR_MATERIAL glEnable - GL_LIGHT0 GL_POSITION float-array{ 0.0 0.0 0.0 1.0 } underlying>> glLightfv - GL_LIGHT0 GL_AMBIENT float-array{ 0.2 0.2 0.2 1.0 } underlying>> glLightfv - GL_LIGHT0 GL_DIFFUSE float-array{ 1.0 1.0 1.0 1.0 } underlying>> glLightfv - GL_LIGHT0 GL_SPECULAR float-array{ 1.0 1.0 1.0 1.0 } underlying>> glLightfv ; - -: player-view ( player -- ) - [ location>> ] - [ [ location>> ] [ forward>> ] bi v+ ] - [ up>> ] tri gl-look-at ; - -: draw-jamshred ( jamshred width height -- ) - init-graphics jamshred-player [ player-view ] [ draw-tunnel ] bi ; - diff --git a/unmaintained/jamshred/jamshred.factor b/unmaintained/jamshred/jamshred.factor deleted file mode 100755 index d0b74417d1..0000000000 --- a/unmaintained/jamshred/jamshred.factor +++ /dev/null @@ -1,94 +0,0 @@ -! Copyright (C) 2007, 2008 Alex Chapman -! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays calendar jamshred.game jamshred.gl jamshred.player jamshred.log kernel math math.constants math.geometry.rect math.vectors namespaces sequences threads ui ui.backend ui.gadgets ui.gadgets.worlds ui.gestures ui.render ; -IN: jamshred - -TUPLE: jamshred-gadget < gadget { jamshred jamshred } last-hand-loc ; - -: <jamshred-gadget> ( jamshred -- gadget ) - jamshred-gadget new-gadget swap >>jamshred ; - -: default-width ( -- x ) 800 ; -: default-height ( -- y ) 600 ; - -M: jamshred-gadget pref-dim* - drop default-width default-height 2array ; - -M: jamshred-gadget draw-gadget* ( gadget -- ) - [ jamshred>> ] [ rect-dim first2 draw-jamshred ] bi ; - -: jamshred-loop ( gadget -- ) - dup jamshred>> quit>> [ - drop - ] [ - [ jamshred>> jamshred-update ] - [ relayout-1 ] - [ 10 milliseconds sleep yield jamshred-loop ] tri - ] if ; - -: fullscreen ( gadget -- ) - find-world t swap set-fullscreen* ; - -: no-fullscreen ( gadget -- ) - find-world f swap set-fullscreen* ; - -: toggle-fullscreen ( world -- ) - [ fullscreen? not ] keep set-fullscreen* ; - -M: jamshred-gadget graft* ( gadget -- ) - [ jamshred-loop ] curry in-thread ; - -M: jamshred-gadget ungraft* ( gadget -- ) - jamshred>> t swap (>>quit) ; - -: jamshred-restart ( jamshred-gadget -- ) - <jamshred> >>jamshred drop ; - -: pix>radians ( n m -- theta ) - / pi 4 * * ; ! 2 / / pi 2 * * ; - -: x>radians ( x gadget -- theta ) - #! translate motion of x pixels to an angle - rect-dim first pix>radians neg ; - -: y>radians ( y gadget -- theta ) - #! translate motion of y pixels to an angle - rect-dim second pix>radians ; - -: (handle-mouse-motion) ( jamshred-gadget mouse-motion -- ) - over jamshred>> >r - [ first swap x>radians ] 2keep second swap y>radians - r> mouse-moved ; - -: handle-mouse-motion ( jamshred-gadget -- ) - hand-loc get [ - over last-hand-loc>> [ - v- (handle-mouse-motion) - ] [ 2drop ] if* - ] 2keep >>last-hand-loc drop ; - -: handle-mouse-scroll ( jamshred-gadget -- ) - jamshred>> scroll-direction get - [ first mouse-scroll-x ] - [ second mouse-scroll-y ] 2bi ; - -: quit ( gadget -- ) - [ no-fullscreen ] [ close-window ] bi ; - -jamshred-gadget H{ - { T{ key-down f f "r" } [ jamshred-restart ] } - { T{ key-down f f " " } [ jamshred>> toggle-running ] } - { T{ key-down f f "f" } [ find-world toggle-fullscreen ] } - { T{ key-down f f "UP" } [ jamshred>> jamshred-player 1 swap change-player-speed ] } - { T{ key-down f f "DOWN" } [ jamshred>> jamshred-player -1 swap change-player-speed ] } - { T{ key-down f f "LEFT" } [ jamshred>> 1 jamshred-roll ] } - { T{ key-down f f "RIGHT" } [ jamshred>> -1 jamshred-roll ] } - { T{ key-down f f "q" } [ quit ] } - { T{ motion } [ handle-mouse-motion ] } - { T{ mouse-scroll } [ handle-mouse-scroll ] } -} set-gestures - -: jamshred-window ( -- gadget ) - [ <jamshred> <jamshred-gadget> dup "Jamshred" open-window ] with-ui ; - -MAIN: jamshred-window diff --git a/unmaintained/jamshred/log/log.factor b/unmaintained/jamshred/log/log.factor deleted file mode 100644 index 33498d8a2e..0000000000 --- a/unmaintained/jamshred/log/log.factor +++ /dev/null @@ -1,10 +0,0 @@ -USING: kernel logging ; -IN: jamshred.log - -LOG: (jamshred-log) DEBUG - -: with-jamshred-log ( quot -- ) - "jamshred" swap with-logging ; - -: jamshred-log ( message -- ) - [ (jamshred-log) ] with-jamshred-log ; ! ugly... diff --git a/unmaintained/jamshred/oint/authors.txt b/unmaintained/jamshred/oint/authors.txt deleted file mode 100755 index e9c193bac7..0000000000 --- a/unmaintained/jamshred/oint/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Alex Chapman diff --git a/unmaintained/jamshred/oint/oint-tests.factor b/unmaintained/jamshred/oint/oint-tests.factor deleted file mode 100644 index 401935fd01..0000000000 --- a/unmaintained/jamshred/oint/oint-tests.factor +++ /dev/null @@ -1,8 +0,0 @@ -USING: jamshred.oint tools.test ; -IN: jamshred.oint-tests - -[ { 0 -1 -1 } ] [ { 0 1 -1 } { 0 -1 0 } reflect ] unit-test -[ { 0 1 0 } ] [ { 1 1 0 } { 1 0 0 } proj-perp ] unit-test -[ { 1 0 0 } ] [ { 1 1 0 } { 0 1 0 } proj-perp ] unit-test -[ { 1/2 -1/2 0 } ] [ { 1 0 0 } { 1 1 0 } proj-perp ] unit-test -[ { -1/2 1/2 0 } ] [ { 0 1 0 } { 1 1 0 } proj-perp ] unit-test diff --git a/unmaintained/jamshred/oint/oint.factor b/unmaintained/jamshred/oint/oint.factor deleted file mode 100644 index 808e92a1f9..0000000000 --- a/unmaintained/jamshred/oint/oint.factor +++ /dev/null @@ -1,73 +0,0 @@ -! Copyright (C) 2007, 2008 Alex Chapman -! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays float-arrays kernel locals math math.constants math.functions math.matrices math.vectors math.quaternions random sequences ; -IN: jamshred.oint - -! An oint is a point with three linearly independent unit vectors -! given relative to that point. In jamshred a player's location and -! direction are given by the player's oint. Similarly, a tunnel -! segment's location and orientation are given by an oint. - -TUPLE: oint location forward up left ; -C: <oint> oint - -: rotation-quaternion ( theta axis -- quaternion ) - swap 2 / dup cos swap sin rot n*v first3 rect> >r rect> r> 2array ; - -: rotate-vector ( q qrecip v -- v ) - v>q swap q* q* q>v ; - -: rotate-oint ( oint theta axis -- ) - rotation-quaternion dup qrecip pick - [ forward>> rotate-vector >>forward ] - [ up>> rotate-vector >>up ] - [ left>> rotate-vector >>left ] 3tri drop ; - -: left-pivot ( oint theta -- ) - over left>> rotate-oint ; - -: up-pivot ( oint theta -- ) - over up>> rotate-oint ; - -: forward-pivot ( oint theta -- ) - over forward>> rotate-oint ; - -: random-float+- ( n -- m ) - #! find a random float between -n/2 and n/2 - dup 10000 * >fixnum random 10000 / swap 2 / - ; - -: random-turn ( oint theta -- ) - 2 / 2dup random-float+- left-pivot random-float+- up-pivot ; - -: location+ ( v oint -- ) - [ location>> v+ ] [ (>>location) ] bi ; - -: go-forward ( distance oint -- ) - [ forward>> n*v ] [ location+ ] bi ; - -: distance-vector ( oint oint -- vector ) - [ location>> ] bi@ swap v- ; - -: distance ( oint oint -- distance ) - distance-vector norm ; - -: scalar-projection ( v1 v2 -- n ) - #! the scalar projection of v1 onto v2 - tuck v. swap norm / ; - -: proj-perp ( u v -- w ) - dupd proj v- ; - -: perpendicular-distance ( oint oint -- distance ) - tuck distance-vector swap 2dup left>> scalar-projection abs - -rot up>> scalar-projection abs + ; - -:: reflect ( v n -- v' ) - #! bounce v on a surface with normal n - v v n v. n n v. / 2 * n n*v v- ; - -: half-way ( p1 p2 -- p3 ) - over v- 2 v/n v+ ; - -: half-way-between-oints ( o1 o2 -- p ) - [ location>> ] bi@ half-way ; diff --git a/unmaintained/jamshred/player/authors.txt b/unmaintained/jamshred/player/authors.txt deleted file mode 100755 index e9c193bac7..0000000000 --- a/unmaintained/jamshred/player/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Alex Chapman diff --git a/unmaintained/jamshred/player/player.factor b/unmaintained/jamshred/player/player.factor deleted file mode 100644 index 72f26a2c79..0000000000 --- a/unmaintained/jamshred/player/player.factor +++ /dev/null @@ -1,137 +0,0 @@ -! Copyright (C) 2007, 2008 Alex Chapman -! See http://factorcode.org/license.txt for BSD license. -USING: accessors colors combinators float-arrays jamshred.log jamshred.oint jamshred.sound jamshred.tunnel kernel locals math math.constants math.order math.ranges math.vectors math.matrices sequences shuffle strings system ; -IN: jamshred.player - -TUPLE: player < oint - { name string } - { sounds sounds } - tunnel - nearest-segment - { last-move integer } - { speed float } ; - -! speeds are in GL units / second -: default-speed ( -- speed ) 1.0 ; -: max-speed ( -- speed ) 30.0 ; - -: <player> ( name sounds -- player ) - [ F{ 0 0 5 } F{ 0 0 -1 } F{ 0 1 0 } F{ -1 0 0 } ] 2dip - f f 0 default-speed player boa ; - -: turn-player ( player x-radians y-radians -- ) - >r over r> left-pivot up-pivot ; - -: roll-player ( player z-radians -- ) - forward-pivot ; - -: to-tunnel-start ( player -- ) - [ tunnel>> first dup location>> ] - [ tuck (>>location) (>>nearest-segment) ] bi ; - -: play-in-tunnel ( player segments -- ) - >>tunnel to-tunnel-start ; - -: update-nearest-segment ( player -- ) - [ tunnel>> ] [ dup nearest-segment>> nearest-segment ] - [ (>>nearest-segment) ] tri ; - -: update-time ( player -- seconds-passed ) - millis swap [ last-move>> - 1000 / ] [ (>>last-move) ] 2bi ; - -: moved ( player -- ) millis swap (>>last-move) ; - -: speed-range ( -- range ) - max-speed [0,b] ; - -: change-player-speed ( inc player -- ) - [ + speed-range clamp-to-range ] change-speed drop ; - -: multiply-player-speed ( n player -- ) - [ * speed-range clamp-to-range ] change-speed drop ; - -: distance-to-move ( seconds-passed player -- distance ) - speed>> * ; - -: bounce ( d-left player -- d-left' player ) - { - [ dup nearest-segment>> bounce-off-wall ] - [ sounds>> bang ] - [ 3/4 swap multiply-player-speed ] - [ ] - } cleave ; - -:: (distance) ( heading player -- current next location heading ) - player nearest-segment>> - player [ tunnel>> ] [ nearest-segment>> ] bi heading heading-segment - player location>> heading ; - -: distance-to-heading-segment ( heading player -- distance ) - (distance) distance-to-next-segment ; - -: distance-to-heading-segment-area ( heading player -- distance ) - (distance) distance-to-next-segment-area ; - -: distance-to-collision ( player -- distance ) - dup nearest-segment>> (distance-to-collision) ; - -: almost-to-collision ( player -- distance ) - distance-to-collision 0.1 - dup 0 < [ drop 0 ] when ; - -: from ( player -- radius distance-from-centre ) - [ nearest-segment>> dup radius>> swap ] [ location>> ] bi - distance-from-centre ; - -: distance-from-wall ( player -- distance ) from - ; -: fraction-from-centre ( player -- fraction ) from swap / ; -: fraction-from-wall ( player -- fraction ) - fraction-from-centre 1 swap - ; - -: update-nearest-segment2 ( heading player -- ) - 2dup distance-to-heading-segment-area 0 <= [ - [ tunnel>> ] [ nearest-segment>> rot heading-segment ] - [ (>>nearest-segment) ] tri - ] [ - 2drop - ] if ; - -:: move-player-on-heading ( d-left player distance heading -- d-left' player ) - [let* | d-to-move [ d-left distance min ] - move-v [ d-to-move heading n*v ] | - move-v player location+ - heading player update-nearest-segment2 - d-left d-to-move - player ] ; - -: distance-to-move-freely ( player -- distance ) - [ almost-to-collision ] - [ [ forward>> ] keep distance-to-heading-segment-area ] bi min ; - -: ?move-player-freely ( d-left player -- d-left' player ) - over 0 > [ - ! must make sure we are moving a significant distance, otherwise - ! we can recurse endlessly due to floating-point imprecision. - ! (at least I /think/ that's what causes it...) - dup distance-to-move-freely dup 0.1 > [ - over forward>> move-player-on-heading ?move-player-freely - ] [ drop ] if - ] when ; - -: drag-heading ( player -- heading ) - [ forward>> ] [ nearest-segment>> forward>> proj ] bi ; - -: drag-player ( d-left player -- d-left' player ) - dup [ [ drag-heading ] keep distance-to-heading-segment-area ] - [ drag-heading move-player-on-heading ] bi ; - -: (move-player) ( d-left player -- d-left' player ) - ?move-player-freely over 0 > [ - ! bounce - drag-player - (move-player) - ] when ; - -: move-player ( player -- ) - [ update-time ] [ distance-to-move ] [ (move-player) 2drop ] tri ; - -: update-player ( player -- ) - [ move-player ] [ nearest-segment>> white swap (>>color) ] bi ; diff --git a/unmaintained/jamshred/sound/bang.wav b/unmaintained/jamshred/sound/bang.wav deleted file mode 100644 index b15af141ec..0000000000 Binary files a/unmaintained/jamshred/sound/bang.wav and /dev/null differ diff --git a/unmaintained/jamshred/sound/sound.factor b/unmaintained/jamshred/sound/sound.factor deleted file mode 100644 index c19c67671f..0000000000 --- a/unmaintained/jamshred/sound/sound.factor +++ /dev/null @@ -1,15 +0,0 @@ -! Copyright (C) 2008 Alex Chapman -! See http://factorcode.org/license.txt for BSD license. -USING: accessors io.files kernel openal sequences ; -IN: jamshred.sound - -TUPLE: sounds bang ; - -: assign-sound ( source wav-path -- ) - resource-path create-buffer-from-wav AL_BUFFER swap set-source-param ; - -: <sounds> ( -- sounds ) - init-openal 1 gen-sources first sounds boa - dup bang>> "extra/jamshred/sound/bang.wav" assign-sound ; - -: bang ( sounds -- ) bang>> source-play check-error ; diff --git a/unmaintained/jamshred/summary.txt b/unmaintained/jamshred/summary.txt deleted file mode 100644 index e26fc1cf8b..0000000000 --- a/unmaintained/jamshred/summary.txt +++ /dev/null @@ -1 +0,0 @@ -A simple 3d tunnel racing game diff --git a/unmaintained/jamshred/tags.txt b/unmaintained/jamshred/tags.txt deleted file mode 100644 index 8ae5957a4b..0000000000 --- a/unmaintained/jamshred/tags.txt +++ /dev/null @@ -1,2 +0,0 @@ -applications -games diff --git a/unmaintained/jamshred/tunnel/authors.txt b/unmaintained/jamshred/tunnel/authors.txt deleted file mode 100755 index e9c193bac7..0000000000 --- a/unmaintained/jamshred/tunnel/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Alex Chapman diff --git a/unmaintained/jamshred/tunnel/tunnel-tests.factor b/unmaintained/jamshred/tunnel/tunnel-tests.factor deleted file mode 100644 index 9486713f55..0000000000 --- a/unmaintained/jamshred/tunnel/tunnel-tests.factor +++ /dev/null @@ -1,45 +0,0 @@ -! Copyright (C) 2007, 2008 Alex Chapman -! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays float-arrays jamshred.oint jamshred.tunnel kernel math.vectors sequences tools.test ; -IN: jamshred.tunnel.tests - -[ 0 ] [ T{ segment f { 0 0 0 } f f f 0 } - T{ segment f { 1 1 1 } f f f 1 } - T{ oint f { 0 0 0.25 } } - nearer-segment number>> ] unit-test - -[ 0 ] [ T{ oint f { 0 0 0 } } <straight-tunnel> find-nearest-segment number>> ] unit-test -[ 1 ] [ T{ oint f { 0 0 -1 } } <straight-tunnel> find-nearest-segment number>> ] unit-test -[ 2 ] [ T{ oint f { 0 0.1 -2.1 } } <straight-tunnel> find-nearest-segment number>> ] unit-test - -[ 3 ] [ <straight-tunnel> T{ oint f { 0 0 -3.25 } } 0 nearest-segment-forward number>> ] unit-test - -[ F{ 0 0 0 } ] [ <straight-tunnel> T{ oint f { 0 0 -0.25 } } over first nearest-segment location>> ] unit-test - -: test-segment-oint ( -- oint ) - { 0 0 0 } { 0 0 -1 } { 0 1 0 } { -1 0 0 } <oint> ; - -[ { -1 0 0 } ] [ test-segment-oint { 1 0 0 } vector-to-centre ] unit-test -[ { 1 0 0 } ] [ test-segment-oint { -1 0 0 } vector-to-centre ] unit-test -[ { 0 -1 0 } ] [ test-segment-oint { 0 1 0 } vector-to-centre ] unit-test -[ { 0 1 0 } ] [ test-segment-oint { 0 -1 0 } vector-to-centre ] unit-test -[ { -1 0 0 } ] [ test-segment-oint { 1 0 -1 } vector-to-centre ] unit-test -[ { 1 0 0 } ] [ test-segment-oint { -1 0 -1 } vector-to-centre ] unit-test -[ { 0 -1 0 } ] [ test-segment-oint { 0 1 -1 } vector-to-centre ] unit-test -[ { 0 1 0 } ] [ test-segment-oint { 0 -1 -1 } vector-to-centre ] unit-test - -: simplest-straight-ahead ( -- oint segment ) - { 0 0 0 } { 0 0 -1 } { 0 1 0 } { -1 0 0 } <oint> - initial-segment ; - -[ { 0.0 0.0 0.0 } ] [ simplest-straight-ahead sideways-heading ] unit-test -[ { 0.0 0.0 0.0 } ] [ simplest-straight-ahead sideways-relative-location ] unit-test - -: simple-collision-up ( -- oint segment ) - { 0 0 0 } { 0 1 0 } { 0 0 1 } { -1 0 0 } <oint> - initial-segment ; - -[ { 0.0 1.0 0.0 } ] [ simple-collision-up sideways-heading ] unit-test -[ { 0.0 0.0 0.0 } ] [ simple-collision-up sideways-relative-location ] unit-test -[ { 0.0 1.0 0.0 } ] -[ simple-collision-up collision-vector 0 0 0 3array v+ ] unit-test diff --git a/unmaintained/jamshred/tunnel/tunnel.factor b/unmaintained/jamshred/tunnel/tunnel.factor deleted file mode 100755 index 52f2d38dd1..0000000000 --- a/unmaintained/jamshred/tunnel/tunnel.factor +++ /dev/null @@ -1,167 +0,0 @@ -! Copyright (C) 2007, 2008 Alex Chapman -! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays colors combinators float-arrays kernel -locals math math.constants math.matrices math.order math.ranges -math.vectors math.quadratic random sequences vectors jamshred.oint ; -IN: jamshred.tunnel - -: n-segments ( -- n ) 5000 ; inline - -TUPLE: segment < oint number color radius ; -C: <segment> segment - -: segment-number++ ( segment -- ) - [ number>> 1+ ] keep (>>number) ; - -: random-color ( -- color ) - { 100 100 100 } [ random 100 / >float ] map first3 1.0 <rgba> ; - -: tunnel-segment-distance ( -- n ) 0.4 ; -: random-rotation-angle ( -- theta ) pi 20 / ; - -: random-segment ( previous-segment -- segment ) - clone dup random-rotation-angle random-turn - tunnel-segment-distance over go-forward - random-color >>color dup segment-number++ ; - -: (random-segments) ( segments n -- segments ) - dup 0 > [ - >r dup peek random-segment over push r> 1- (random-segments) - ] [ drop ] if ; - -: default-segment-radius ( -- r ) 1 ; - -: initial-segment ( -- segment ) - F{ 0 0 0 } F{ 0 0 -1 } F{ 0 1 0 } F{ -1 0 0 } - 0 random-color default-segment-radius <segment> ; - -: random-segments ( n -- segments ) - initial-segment 1vector swap (random-segments) ; - -: simple-segment ( n -- segment ) - [ F{ 0 0 -1 } n*v F{ 0 0 -1 } F{ 0 1 0 } F{ -1 0 0 } ] keep - random-color default-segment-radius <segment> ; - -: simple-segments ( n -- segments ) - [ simple-segment ] map ; - -: <random-tunnel> ( -- segments ) - n-segments random-segments ; - -: <straight-tunnel> ( -- segments ) - n-segments simple-segments ; - -: sub-tunnel ( from to segments -- segments ) - #! return segments between from and to, after clamping from and to to - #! valid values - [ sequence-index-range [ clamp-to-range ] curry bi@ ] keep <slice> ; - -: nearer-segment ( segment segment oint -- segment ) - #! return whichever of the two segments is nearer to the oint - >r 2dup r> tuck distance >r distance r> < -rot ? ; - -: (find-nearest-segment) ( nearest next oint -- nearest ? ) - #! find the nearest of 'next' and 'nearest' to 'oint', and return - #! t if the nearest hasn't changed - pick >r nearer-segment dup r> = ; - -: find-nearest-segment ( oint segments -- segment ) - dup first swap rest-slice rot [ (find-nearest-segment) ] curry - find 2drop ; - -: nearest-segment-forward ( segments oint start -- segment ) - rot dup length swap <slice> find-nearest-segment ; - -: nearest-segment-backward ( segments oint start -- segment ) - swapd 1+ 0 spin <slice> <reversed> find-nearest-segment ; - -: nearest-segment ( segments oint start-segment -- segment ) - #! find the segment nearest to 'oint', and return it. - #! start looking at segment 'start-segment' - number>> over >r - [ nearest-segment-forward ] 3keep - nearest-segment-backward r> nearer-segment ; - -: get-segment ( segments n -- segment ) - over sequence-index-range clamp-to-range swap nth ; - -: next-segment ( segments current-segment -- segment ) - number>> 1+ get-segment ; - -: previous-segment ( segments current-segment -- segment ) - number>> 1- get-segment ; - -: heading-segment ( segments current-segment heading -- segment ) - #! the next segment on the given heading - over forward>> v. 0 <=> { - { +gt+ [ next-segment ] } - { +lt+ [ previous-segment ] } - { +eq+ [ nip ] } ! current segment - } case ; - -:: distance-to-next-segment ( current next location heading -- distance ) - [let | cf [ current forward>> ] | - cf next location>> v. cf location v. - cf heading v. / ] ; - -:: distance-to-next-segment-area ( current next location heading -- distance ) - [let | cf [ current forward>> ] - h [ next current half-way-between-oints ] | - cf h v. cf location v. - cf heading v. / ] ; - -: vector-to-centre ( seg loc -- v ) - over location>> swap v- swap forward>> proj-perp ; - -: distance-from-centre ( seg loc -- distance ) - vector-to-centre norm ; - -: wall-normal ( seg oint -- n ) - location>> vector-to-centre normalize ; - -: distant ( -- n ) 1000 ; - -: max-real ( a b -- c ) - #! sometimes collision-coefficient yields complex roots, so we ignore these (hack) - dup real? [ - over real? [ max ] [ nip ] if - ] [ - drop dup real? [ drop distant ] unless - ] if ; - -:: collision-coefficient ( v w r -- c ) - v norm 0 = [ - distant - ] [ - [let* | a [ v dup v. ] - b [ v w v. 2 * ] - c [ w dup v. r sq - ] | - c b a quadratic max-real ] - ] if ; - -: sideways-heading ( oint segment -- v ) - [ forward>> ] bi@ proj-perp ; - -: sideways-relative-location ( oint segment -- loc ) - [ [ location>> ] bi@ v- ] keep forward>> proj-perp ; - -: (distance-to-collision) ( oint segment -- distance ) - [ sideways-heading ] [ sideways-relative-location ] - [ nip radius>> ] 2tri collision-coefficient ; - -: collision-vector ( oint segment -- v ) - dupd (distance-to-collision) swap forward>> n*v ; - -: bounce-forward ( segment oint -- ) - [ wall-normal ] [ forward>> swap reflect ] [ (>>forward) ] tri ; - -: bounce-left ( segment oint -- ) - #! must be done after forward - [ forward>> vneg ] dip [ left>> swap reflect ] - [ forward>> proj-perp normalize ] [ (>>left) ] tri ; - -: bounce-up ( segment oint -- ) - #! must be done after forward and left! - nip [ forward>> ] [ left>> cross ] [ (>>up) ] tri ; - -: bounce-off-wall ( oint segment -- ) - swap [ bounce-forward ] [ bounce-left ] [ bounce-up ] 2tri ; - diff --git a/unmaintained/lisp/authors.txt b/unmaintained/lisp/authors.txt deleted file mode 100644 index 4b7af4aac0..0000000000 --- a/unmaintained/lisp/authors.txt +++ /dev/null @@ -1 +0,0 @@ -James Cash diff --git a/unmaintained/lisp/lisp-docs.factor b/unmaintained/lisp/lisp-docs.factor deleted file mode 100644 index c970a1e0b7..0000000000 --- a/unmaintained/lisp/lisp-docs.factor +++ /dev/null @@ -1,22 +0,0 @@ -IN: lisp -USING: help.markup help.syntax ; -HELP: <LISP -{ $description "parsing word which converts the lisp code between <LISP and LISP> into factor quotations and calls it" } -{ $see-also lisp-string>factor } ; - -HELP: lisp-string>factor -{ $values { "str" "a string of lisp code" } { "quot" "the quotation the lisp compiles into" } } -{ $description "Turns a string of lisp into a factor quotation" } ; - -ARTICLE: "lisp" "Lisp in Factor" -"This is a simple implementation of a Lisp dialect, which somewhat resembles Scheme." $nl -"It works in two main stages: " -{ $list - { "Parse (via " { $vocab-link "lisp.parser" } " the Lisp code into a " - { $snippet "s-exp" } " tuple." } - { "Transform the " { $snippet "s-exp" } " into a Factor quotation, via " { $link convert-form } } -} - -{ $subsection "lisp.parser" } ; - -ABOUT: "lisp" \ No newline at end of file diff --git a/unmaintained/lisp/lisp-tests.factor b/unmaintained/lisp/lisp-tests.factor deleted file mode 100644 index 5f849c4416..0000000000 --- a/unmaintained/lisp/lisp-tests.factor +++ /dev/null @@ -1,94 +0,0 @@ -! Copyright (C) 2008 James Cash -! See http://factorcode.org/license.txt for BSD license. -USING: lisp lisp.parser tools.test sequences math kernel parser arrays lists -quotations ; - -IN: lisp.test - -[ - define-lisp-builtins - - { 5 } [ - "(+ 2 3)" lisp-eval - ] unit-test - - { 8.3 } [ - "(- 10.4 2.1)" lisp-eval - ] unit-test - - { 3 } [ - "((lambda (x y) (+ x y)) 1 2)" lisp-eval - ] unit-test - - { 42 } [ - "((lambda (x y z) (+ x (- y z))) 40 3 1)" lisp-eval - ] unit-test - - { "b" } [ - "(cond (#f \"a\") (#t \"b\"))" lisp-eval - ] unit-test - - { "b" } [ - "(cond ((< 1 2) \"b\") (#t \"a\"))" lisp-eval - ] unit-test - - { +nil+ } [ - "(list)" lisp-eval - ] unit-test - - { { 1 2 3 4 5 } } [ - "(list 1 2 3 4 5)" lisp-eval list>seq - ] unit-test - - { { 1 2 { 3 { 4 } 5 } } } [ - "(list 1 2 (list 3 (list 4) 5))" lisp-eval cons>seq - ] unit-test - - { 5 } [ - "(begin (+ 1 4))" lisp-eval - ] unit-test - - { 5 } [ - "(begin (+ 5 6) (+ 1 4))" lisp-eval - ] unit-test - - { t } [ - T{ lisp-symbol f "if" } lisp-macro? - ] unit-test - - { 1 } [ - "(if #t 1 2)" lisp-eval - ] unit-test - - { 3 } [ - "((lambda (x) (if x (+ 1 2) (- 3 5))) #t)" lisp-eval - ] unit-test - - { { 5 4 3 } } [ - "((lambda (x &rest xs) (cons x xs)) 5 4 3)" lisp-eval cons>seq - ] unit-test - - { { 5 } } [ - "((lambda (x &rest xs) (cons x xs)) 5)" lisp-eval cons>seq - ] unit-test - - { { 1 2 3 4 } } [ - "((lambda (&rest xs) xs) 1 2 3 4)" lisp-eval cons>seq - ] unit-test - - { 10 } [ - <LISP (begin (+ 1 2) (+ 9 1)) LISP> - ] unit-test - - { 4 } [ - <LISP ((lambda (x y) (if x (+ 1 y) (+ 2 y))) #t 3) LISP> - ] unit-test - - { { 3 3 4 } } [ - <LISP (defun foo (x y &rest z) - (cons (+ x y) z)) - (foo 1 2 3 4) - LISP> cons>seq - ] unit-test - -] with-interactive-vocabs diff --git a/unmaintained/lisp/lisp.factor b/unmaintained/lisp/lisp.factor deleted file mode 100644 index 4a933501e8..0000000000 --- a/unmaintained/lisp/lisp.factor +++ /dev/null @@ -1,178 +0,0 @@ -! Copyright (C) 2008 James Cash -! See http://factorcode.org/license.txt for BSD license. -USING: kernel peg sequences arrays strings -namespaces combinators math locals locals.private locals.backend accessors -vectors syntax lisp.parser assocs parser words -quotations fry lists summary combinators.short-circuit continuations multiline ; -IN: lisp - -DEFER: convert-form -DEFER: funcall -DEFER: lookup-var -DEFER: lookup-macro -DEFER: lisp-macro? -DEFER: lisp-var? -DEFER: define-lisp-macro - -! Functions to convert s-exps to quotations -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -: convert-body ( cons -- quot ) - [ ] [ convert-form compose ] foldl ; inline - -: convert-cond ( cons -- quot ) - cdr [ 2car [ convert-form ] bi@ 2array ] - { } lmap-as '[ _ cond ] ; - -: convert-general-form ( cons -- quot ) - uncons [ convert-body ] [ convert-form ] bi* '[ _ @ funcall ] ; - -! words for convert-lambda -<PRIVATE -: localize-body ( assoc body -- newbody ) - { - { [ dup list? ] [ [ lisp-symbol? ] rot '[ [ name>> _ at ] [ ] bi or ] traverse ] } - { [ dup lisp-symbol? ] [ name>> swap at ] } - [ nip ] - } cond ; - -: localize-lambda ( body vars -- newvars newbody ) - swap [ make-locals dup push-locals ] dip - dupd [ localize-body convert-form ] with lmap>array - >quotation swap pop-locals ; - -: split-lambda ( cons -- body-cons vars-seq ) - cdr uncons [ name>> ] lmap>array ; inline - -: rest-lambda ( body vars -- quot ) - "&rest" swap [ remove ] [ index ] 2bi - [ localize-lambda <lambda> lambda-rewrite call ] dip - swap '[ _ cut '[ @ _ seq>list ] call _ call call ] 1quotation ; - -: normal-lambda ( body vars -- quot ) - localize-lambda <lambda> lambda-rewrite '[ @ compose call call ] 1quotation ; -PRIVATE> - -: convert-lambda ( cons -- quot ) - split-lambda "&rest" over member? [ rest-lambda ] [ normal-lambda ] if ; - -: convert-quoted ( cons -- quot ) - cadr 1quotation ; - -: convert-defmacro ( cons -- quot ) - cdr [ convert-lambda ] [ car name>> ] bi define-lisp-macro [ ] ; - -: macro-expand ( cons -- quot ) - uncons [ list>seq >quotation ] [ lookup-macro ] bi* call call ; - -: expand-macros ( cons -- cons ) - dup list? [ [ expand-macros ] lmap dup car lisp-macro? [ macro-expand expand-macros ] when ] when ; - -: convert-begin ( cons -- quot ) - cdr [ convert-form ] [ ] lmap-as [ 1 tail* ] [ but-last ] bi - [ '[ { } _ with-datastack drop ] ] map prepend '[ _ [ call ] each ] ; - -: form-dispatch ( cons lisp-symbol -- quot ) - name>> - { { "lambda" [ convert-lambda ] } - { "defmacro" [ convert-defmacro ] } - { "quote" [ convert-quoted ] } - { "cond" [ convert-cond ] } - { "begin" [ convert-begin ] } - [ drop convert-general-form ] - } case ; - -: convert-list-form ( cons -- quot ) - dup car - { - { [ dup lisp-symbol? ] [ form-dispatch ] } - [ drop convert-general-form ] - } cond ; - -: convert-form ( lisp-form -- quot ) - { - { [ dup cons? ] [ convert-list-form ] } - { [ dup lisp-var? ] [ lookup-var 1quotation ] } - { [ dup lisp-symbol? ] [ '[ _ lookup-var ] ] } - [ 1quotation ] - } cond ; - -: lisp-string>factor ( str -- quot ) - lisp-expr expand-macros convert-form ; - -: lisp-eval ( str -- * ) - lisp-string>factor call ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYMBOL: lisp-env -SYMBOL: macro-env - -ERROR: no-such-var variable-name ; -M: no-such-var summary drop "No such variable" ; - -: init-env ( -- ) - H{ } clone lisp-env set - H{ } clone macro-env set ; - -: lisp-define ( quot name -- ) - lisp-env get set-at ; - -: define-lisp-var ( lisp-symbol body -- ) - swap name>> lisp-define ; - -: lisp-get ( name -- word ) - lisp-env get at ; - -: lookup-var ( lisp-symbol -- quot ) - [ name>> ] [ lisp-var? ] bi [ lisp-get ] [ no-such-var ] if ; - -: lisp-var? ( lisp-symbol -- ? ) - dup lisp-symbol? [ name>> lisp-env get key? ] [ drop f ] if ; - -: funcall ( quot sym -- * ) - [ 1array [ call ] with-datastack >quotation ] dip curry call ; inline - -: define-primitive ( name vocab word -- ) - swap lookup 1quotation '[ _ compose call ] swap lisp-define ; - -: lookup-macro ( lisp-symbol -- lambda ) - name>> macro-env get at ; - -: define-lisp-macro ( quot name -- ) - macro-env get set-at ; - -: lisp-macro? ( car -- ? ) - dup lisp-symbol? [ name>> macro-env get key? ] [ drop f ] if ; - -: define-lisp-builtins ( -- ) - init-env - - f "#f" lisp-define - t "#t" lisp-define - - "+" "math" "+" define-primitive - "-" "math" "-" define-primitive - "<" "math" "<" define-primitive - ">" "math" ">" define-primitive - - "cons" "lists" "cons" define-primitive - "car" "lists" "car" define-primitive - "cdr" "lists" "cdr" define-primitive - "append" "lists" "lappend" define-primitive - "nil" "lists" "nil" define-primitive - "nil?" "lists" "nil?" define-primitive - - "set" "lisp" "define-lisp-var" define-primitive - - "(set 'list (lambda (&rest xs) xs))" lisp-eval - "(defmacro setq (var val) (list 'set (list 'quote var) val))" lisp-eval - - <" (defmacro defun (name vars &rest body) - (list 'setq name (cons 'lambda (cons vars body)))) "> lisp-eval - - "(defmacro if (pred tr fl) (list 'cond (list pred tr) (list (quote #t) fl)))" lisp-eval - ; - -: <LISP - "LISP>" parse-multiline-string "(begin " prepend ")" append define-lisp-builtins - lisp-string>factor parsed \ call parsed ; parsing \ No newline at end of file diff --git a/unmaintained/lisp/parser/authors.txt b/unmaintained/lisp/parser/authors.txt deleted file mode 100644 index 4b7af4aac0..0000000000 --- a/unmaintained/lisp/parser/authors.txt +++ /dev/null @@ -1 +0,0 @@ -James Cash diff --git a/unmaintained/lisp/parser/parser-docs.factor b/unmaintained/lisp/parser/parser-docs.factor deleted file mode 100644 index fc16a0a310..0000000000 --- a/unmaintained/lisp/parser/parser-docs.factor +++ /dev/null @@ -1,6 +0,0 @@ -IN: lisp.parser -USING: help.markup help.syntax ; - -ARTICLE: "lisp.parser" "Parsing strings of Lisp" -"This vocab uses " { $vocab-link "peg.ebnf" } " to turn strings of Lisp into " { $snippet "s-exp" } "s, which are then used by" -{ $vocab-link "lisp" } " to produce Factor quotations." ; \ No newline at end of file diff --git a/unmaintained/lisp/parser/parser-tests.factor b/unmaintained/lisp/parser/parser-tests.factor deleted file mode 100644 index 911a8d3440..0000000000 --- a/unmaintained/lisp/parser/parser-tests.factor +++ /dev/null @@ -1,80 +0,0 @@ -! Copyright (C) 2008 James Cash -! See http://factorcode.org/license.txt for BSD license. -USING: lisp.parser tools.test peg peg.ebnf lists ; - -IN: lisp.parser.tests - -{ 1234 } [ - "1234" "atom" \ lisp-expr rule parse -] unit-test - -{ -42 } [ - "-42" "atom" \ lisp-expr rule parse -] unit-test - -{ 37/52 } [ - "37/52" "atom" \ lisp-expr rule parse -] unit-test - -{ 123.98 } [ - "123.98" "atom" \ lisp-expr rule parse -] unit-test - -{ "" } [ - "\"\"" "atom" \ lisp-expr rule parse -] unit-test - -{ "aoeu" } [ - "\"aoeu\"" "atom" \ lisp-expr rule parse -] unit-test - -{ "aoeu\"de" } [ - "\"aoeu\\\"de\"" "atom" \ lisp-expr rule parse -] unit-test - -{ T{ lisp-symbol f "foobar" } } [ - "foobar" "atom" \ lisp-expr rule parse -] unit-test - -{ T{ lisp-symbol f "+" } } [ - "+" "atom" \ lisp-expr rule parse -] unit-test - -{ +nil+ } [ - "()" lisp-expr -] unit-test - -{ T{ - cons - f - T{ lisp-symbol f "foo" } - T{ - cons - f - 1 - T{ cons f 2 T{ cons f "aoeu" +nil+ } } - } } } [ - "(foo 1 2 \"aoeu\")" lisp-expr -] unit-test - -{ T{ cons f - 1 - T{ cons f - T{ cons f 3 T{ cons f 4 +nil+ } } - T{ cons f 2 +nil+ } } - } -} [ - "(1 (3 4) 2)" lisp-expr -] unit-test - -{ { T{ lisp-symbol { name "quote" } } { 1 2 3 } } } [ - "'(1 2 3)" lisp-expr cons>seq -] unit-test - -{ { T{ lisp-symbol f "quote" } T{ lisp-symbol f "foo" } } } [ - "'foo" lisp-expr cons>seq -] unit-test - -{ { 1 2 { T{ lisp-symbol { name "quote" } } { 3 4 } } 5 } } [ - "(1 2 '(3 4) 5)" lisp-expr cons>seq -] unit-test \ No newline at end of file diff --git a/unmaintained/lisp/parser/parser.factor b/unmaintained/lisp/parser/parser.factor deleted file mode 100644 index 50f58692d5..0000000000 --- a/unmaintained/lisp/parser/parser.factor +++ /dev/null @@ -1,41 +0,0 @@ -! Copyright (C) 2008 James Cash -! See http://factorcode.org/license.txt for BSD license. -USING: kernel peg peg.ebnf math.parser sequences arrays strings -math fry accessors lists combinators.short-circuit ; - -IN: lisp.parser - -TUPLE: lisp-symbol name ; -C: <lisp-symbol> lisp-symbol - -EBNF: lisp-expr -_ = (" " | "\t" | "\n")* -LPAREN = "(" -RPAREN = ")" -dquote = '"' -squote = "'" -digit = [0-9] -integer = ("-")? (digit)+ => [[ first2 append string>number ]] -float = integer "." (digit)* => [[ first3 >string [ number>string ] 2dip 3append string>number ]] -rational = integer "/" (digit)+ => [[ first3 nip string>number / ]] -number = float - | rational - | integer -id-specials = "!" | "$" | "%" | "&" | "*" | "/" | ":" - | "<" | "#" | " =" | ">" | "?" | "^" | "_" - | "~" | "+" | "-" | "." | "@" -letters = [a-zA-Z] => [[ 1array >string ]] -initials = letters | id-specials -numbers = [0-9] => [[ 1array >string ]] -subsequents = initials | numbers -identifier = initials (subsequents)* => [[ first2 concat append <lisp-symbol> ]] -escaped = "\" . => [[ second ]] -string = dquote ( escaped | !(dquote) . )* dquote => [[ second >string ]] -atom = number - | identifier - | string -s-expression = LPAREN (list-item)* RPAREN => [[ second seq>cons ]] -list-item = _ ( atom | s-expression | quoted ) _ => [[ second ]] -quoted = squote list-item => [[ second nil cons "quote" <lisp-symbol> swap cons ]] -expr = list-item -;EBNF \ No newline at end of file diff --git a/unmaintained/lisp/parser/summary.txt b/unmaintained/lisp/parser/summary.txt deleted file mode 100644 index aa407b3dfb..0000000000 --- a/unmaintained/lisp/parser/summary.txt +++ /dev/null @@ -1 +0,0 @@ -EBNF grammar for parsing Lisp diff --git a/unmaintained/lisp/summary.txt b/unmaintained/lisp/summary.txt deleted file mode 100644 index 7277c2a5b5..0000000000 --- a/unmaintained/lisp/summary.txt +++ /dev/null @@ -1 +0,0 @@ -A Lisp interpreter/compiler in Factor diff --git a/unmaintained/lisp/tags.txt b/unmaintained/lisp/tags.txt deleted file mode 100644 index c369ccae57..0000000000 --- a/unmaintained/lisp/tags.txt +++ /dev/null @@ -1,2 +0,0 @@ -lisp -languages diff --git a/unmaintained/mad/api/api.factor b/unmaintained/mad/api/api.factor deleted file mode 100644 index fdc2903d46..0000000000 --- a/unmaintained/mad/api/api.factor +++ /dev/null @@ -1,95 +0,0 @@ -! Copyright (C) 2007 Adam Wendt. -! See http://factorcode.org/license.txt for BSD license. -USING: alien alien.c-types byte-arrays io io.binary io.files kernel mad - namespaces prettyprint sbufs sequences tools.interpreter vars - io.encodings.binary ; -IN: mad.api - -VARS: buffer-start buffer-length output-callback-var ; - -: create-mad-callback-generic ( sequence parameters -- alien ) - swap >r >r "mad_flow" r> "cdecl" r> alien-callback ; inline - -: create-input-callback ( sequence -- alien ) - { "void*" "mad_stream*" } create-mad-callback-generic ; inline - -: create-header-callback ( sequence -- alien ) - { "void*" "mad_header*" } create-mad-callback-generic ; inline - -: create-filter-callback ( sequence -- alien ) - { "void*" "mad_stream*" "mad_frame*" } create-mad-callback-generic ; inline - -: create-output-callback ( sequence -- alien ) - { "void*" "mad_header*" "mad_pcm*" } create-mad-callback-generic ; inline - -: create-error-callback ( sequence -- alien ) - { "void*" "mad_stream*" "mad_frame*" } create-mad-callback-generic ; inline - -: create-message-callback ( sequence -- alien ) - { "void*" "void*" "uint*" } create-mad-callback-generic ; inline - -: input ( buffer mad_stream -- mad_flow ) - "input" print flush - nip ! mad_stream - buffer-start get ! mad_stream start - buffer-length get ! mad_stream start length - dup 0 = ! mad-stream start length bool - [ 3drop MAD_FLOW_STOP ] ! mad_flow - [ mad_stream_buffer ! - 0 buffer-length set ! - MAD_FLOW_CONTINUE ] if ; ! mad_flow - -: input-callback ( -- callback ) - [ input ] create-input-callback ; - -: header-callback ( -- callback ) - [ "header" print flush drop drop MAD_FLOW_CONTINUE ] create-header-callback ; - -: filter-callback ( -- callback ) - [ "filter" print flush 3drop MAD_FLOW_CONTINUE ] create-filter-callback ; - -: write-sample ( sample -- ) - 4 >le write ; - -: output ( data header pcm -- mad_flow ) - "output" . flush - -rot 2drop output-callback-var> call - [ MAD_FLOW_CONTINUE ] [ MAD_FLOW_STOP ] if ; - -: output-stdout ( pcm -- ? ) - [ mad_pcm-channels ] keep - [ mad_pcm-length ] keep swap - [ - [ mad_pcm-sample-right ] 2keep - [ mad_pcm-sample-left ] 2keep - drop -rot write-sample pick - 2 = [ write-sample ] [ drop ] if - ] each drop t ; - -: output-callback ( -- callback ) - [ output ] create-output-callback ; - -: error-callback ( -- callback ) - [ "error" print flush drop drop drop MAD_FLOW_CONTINUE ] create-error-callback ; - -: message-callback ( -- callback ) - [ "message" print flush drop drop drop MAD_FLOW_CONTINUE ] create-message-callback ; - -: mad-init ( decoder -- ) - 0 <alien> input-callback 0 <alien> 0 <alien> output-callback error-callback message-callback mad_decoder_init ; - -: make-decoder ( -- decoder ) - "mad_decoder" malloc-object ; - -: mad-run ( -- int ) - make-decoder [ mad-init ] keep MAD_DECODER_MODE_SYNC mad_decoder_run ; - -: init-vars ( alien length -- ) - buffer-length set buffer-start set ; - -: decode-mp3 ( filename -- results ) - [ malloc-file-contents ] keep file-length init-vars mad-run ; - -: mad-test ( -- results ) - [ output-stdout ] >output-callback-var - "/home/adam/download/mp3/Misc/wutbf.mp3" decode-mp3 ; diff --git a/unmaintained/mad/api/authors.txt b/unmaintained/mad/api/authors.txt deleted file mode 100755 index bbc876e7b6..0000000000 --- a/unmaintained/mad/api/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Adam Wendt diff --git a/unmaintained/mad/authors.txt b/unmaintained/mad/authors.txt deleted file mode 100644 index bbc876e7b6..0000000000 --- a/unmaintained/mad/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Adam Wendt diff --git a/unmaintained/mad/mad-tests.factor b/unmaintained/mad/mad-tests.factor deleted file mode 100644 index c53b14f6bf..0000000000 --- a/unmaintained/mad/mad-tests.factor +++ /dev/null @@ -1,12 +0,0 @@ -! Copyright (C) 2007 Adam Wendt. -! See http://factorcode.org/license.txt for BSD license. -! -IN: temporary - -USING: kernel mad mad.api alien alien.c-types tools.test -namespaces ; - -: setup-buffer ( -- ) - 0 <alien> buffer-start set 0 buffer-length set ; - -[ t ] [ 0 "mad_stream" malloc-object setup-buffer input MAD_FLOW_STOP = ] unit-test diff --git a/unmaintained/mad/mad.factor b/unmaintained/mad/mad.factor deleted file mode 100644 index ce65c066b4..0000000000 --- a/unmaintained/mad/mad.factor +++ /dev/null @@ -1,156 +0,0 @@ -! Copyright (C) 2007 Adam Wendt. -! See http://factorcode.org/license.txt for BSD license. -! -USING: alien alien.c-types alien.syntax combinators kernel math system ; -IN: mad - -<< "mad" { - { [ macosx? ] [ "libmad.0.dylib" ] } - { [ unix? ] [ "libmad.so" ] } - { [ windows? ] [ "mad.dll" ] } - } cond "cdecl" add-library >> - -LIBRARY: mad - -TYPEDEF: int mad_fixed_t -TYPEDEF: int mad_fixed64hi_t -TYPEDEF: uint mad_fixed64lo_t - -TYPEDEF: int mad_flow -TYPEDEF: int mad_decoder_mode -TYPEDEF: int mad_error -TYPEDEF: int mad_layer -TYPEDEF: int mad_mode -TYPEDEF: int mad_emphasis - -C-STRUCT: mad_timer_t - { "long" "seconds" } - { "ulong" "fraction" } -; - -C-STRUCT: mad_bitptr - { "uchar*" "byte" } - { "short" "cache" } - { "short" "left" } -; - -C-STRUCT: mad_stream - { "uchar*" "buffer" } - { "uchar*" "buffend" } - { "long" "skiplen" } - { "int" "sync" } - { "ulong" "freerate" } - { "uchar*" "this_frame" } - { "uchar*" "next_frame" } - { "mad_bitptr" "ptr" } - { "mad_bitptr" "anc_ptr" } - { "uchar*" "main_data" } - { "int" "md_len" } - { "int" "options" } - { "mad_error" "error" } -; - -C-STRUCT: struct_async - { "long" "pid" } - { "int" "in" } - { "int" "out" } -; - -C-STRUCT: mad_header - { "mad_layer" "layer" } - { "mad_mode" "mode" } - { "int" "mode_extension" } - { "mad_emphasis" "emphasis" } - { "ulong" "bitrate" } - { "uint" "samplerate" } - { "ushort" "crc_check" } - { "ushort" "crc_target" } - { "int" "flags" } - { "int" "private_bits" } - { "mad_timer_t" "duration" } -; - -C-STRUCT: mad_frame - { "mad_header" "header" } - { "int" "options" } - { { "mad_fixed_t" 2304 } "sbsample" } - { "mad_fixed_t*" "overlap" } -; - -C-STRUCT: mad_pcm - { "uint" "samplerate" } - { "ushort" "channels" } - { "ushort" "length" } - { { "mad_fixed_t" 2304 } "samples" } -; - -: mad_pcm-sample-left ( pcm int -- sample ) - swap mad_pcm-samples int-nth ; -: mad_pcm-sample-right ( pcm int -- sample ) - 1152 + swap mad_pcm-samples int-nth ; - -C-STRUCT: mad_synth - { { "mad_fixed_t" 1024 } "filter" } - { "uint" "phase" } - { "mad_pcm" "pcm" } -; - -C-STRUCT: struct_sync - { "mad_stream" "stream" } - { "mad_frame" "frame" } - { "mad_synth" "synth" } -; - -C-STRUCT: mad_decoder - { "mad_decoder_mode" "mode" } - { "int" "options" } - { "struct_async" "async" } - { "struct_sync*" "sync" } - { "void*" "cb_data" } - { "void*" "input_func" } - { "void*" "header_func" } - { "void*" "filter_func" } - { "void*" "output_func" } - { "void*" "error_func" } - { "void*" "message_func" } -; - -: MAD_F_FRACBITS ( -- number ) 28 ; inline -: MAD_F_ONE HEX: 10000000 ; - -: MAD_DECODER_MODE_SYNC ( -- number ) HEX: 0 ; inline -: MAD_DECODER_MODE_ASYNC ( -- number ) HEX: 1 ; inline - -: MAD_FLOW_CONTINUE ( -- number ) HEX: 0 ; inline -: MAD_FLOW_STOP ( -- number ) HEX: 10 ; inline -: MAD_FLOW_BREAK ( -- number ) HEX: 11 ; inline -: MAD_FLOW_IGNORE ( -- number ) HEX: 20 ; inline - -: MAD_ERROR_NONE ( -- number ) HEX: 0 ; inline -: MAD_ERROR_BUFLEN ( -- number ) HEX: 1 ; inline -: MAD_ERROR_BUFPTR ( -- number ) HEX: 2 ; inline -: MAD_ERROR_NOMEM ( -- number ) HEX: 31 ; inline -: MAD_ERROR_LOSTSYNC ( -- number ) HEX: 101 ; inline -: MAD_ERROR_BADLAYER ( -- number ) HEX: 102 ; inline -: MAD_ERROR_BADBITRATE ( -- number ) HEX: 103 ; inline -: MAD_ERROR_BADSAMPLERATE ( -- number ) HEX: 104 ; inline -: MAD_ERROR_BADEMPHASIS ( -- number ) HEX: 105 ; inline -: MAD_ERROR_BADCRC ( -- number ) HEX: 201 ; inline -: MAD_ERROR_BADBITALLOC ( -- number ) HEX: 211 ; inline -: MAD_ERROR_BADSCALEFACTOR ( -- number ) HEX: 221 ; inline -: MAD_ERROR_BADMODE ( -- number ) HEX: 222 ; inline -: MAD_ERROR_BADFRAMELEN ( -- number ) HEX: 231 ; inline -: MAD_ERROR_BADBIGVALUES ( -- number ) HEX: 232 ; inline -: MAD_ERROR_BADBLOCKTYPE ( -- number ) HEX: 233 ; inline -: MAD_ERROR_BADSCFSI ( -- number ) HEX: 234 ; inline -: MAD_ERROR_BADDATAPTR ( -- number ) HEX: 235 ; inline -: MAD_ERROR_BADPART3LEN ( -- number ) HEX: 236 ; inline -: MAD_ERROR_BADHUFFTABLE ( -- number ) HEX: 237 ; inline -: MAD_ERROR_BADHUFFDATA ( -- number ) HEX: 238 ; inline -: MAD_ERROR_BADSTEREO ( -- number ) HEX: 239 ; inline - - -FUNCTION: void mad_decoder_init ( mad_decoder* decoder, void* data, void* input_func, void* header_func, void* filter_func, void* output_func, void* error_func, void* message_func ) ; -FUNCTION: int mad_decoder_run ( mad_decoder* decoder, mad_decoder_mode mode ) ; -FUNCTION: void mad_stream_buffer ( mad_stream* stream, uchar* start, ulong length ) ; - diff --git a/unmaintained/mad/player/authors.txt b/unmaintained/mad/player/authors.txt deleted file mode 100755 index bbc876e7b6..0000000000 --- a/unmaintained/mad/player/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Adam Wendt diff --git a/unmaintained/mad/player/player.factor b/unmaintained/mad/player/player.factor deleted file mode 100644 index 3d0b1c16c2..0000000000 --- a/unmaintained/mad/player/player.factor +++ /dev/null @@ -1,58 +0,0 @@ -! Copyright (C) 2007 Adam Wendt. -! See http://factorcode.org/license.txt for BSD license. -! -USING: alien.c-types io kernel libc mad mad.api math namespaces openal prettyprint sequences tools.interpreter vars ; -IN: mad.player - -VARS: openal-buffer ; - -: get-format ( pcm -- format ) - mad_pcm-channels 2 = - [ AL_FORMAT_STEREO16 ] [ AL_FORMAT_MONO16 ] if ; - -: no-error? ( -- ? ) - alGetError dup . flush AL_NO_ERROR = ; - -: round ( sample -- rounded ) - 1 MAD_F_FRACBITS 16 - shift + ; - -: clip ( sample -- clipped ) MAD_F_ONE 1- min MAD_F_ONE neg max ; - -: quantize ( sample -- quantized ) - MAD_F_FRACBITS 1+ 16 - neg shift ; - -: scale-sample ( sample -- scaled ) - round clip quantize ; - -: get-needed-size ( pcm -- size ) - [ mad_pcm-channels ] keep mad_pcm-length 2 * * ; - -: make-data ( pcm -- ) - [ mad_pcm-channels ] keep ! channels pcm - [ mad_pcm-length ] keep swap ! channels pcm length - [ ! channels pcm counter - [ mad_pcm-sample-right ] 2keep ! channels right pcm counter - [ mad_pcm-sample-left ] 2keep ! channels right left pcm counter - drop -rot scale-sample , pick ! channels pcm right channels - 2 = [ scale-sample , ] [ drop ] if ! channels pcm right - ] each 2drop ; - -: array>alien ( alien array -- ) dup length [ pick set-int-nth ] 2each drop ; - -: fill-data ( pcm alien -- ) - swap [ make-data ] { } make array>alien ; - -: get-data ( pcm -- size alien ) - [ get-needed-size ] keep over - malloc [ fill-data ] keep ; - -: output-openal ( pcm -- ? ) - openal-buffer> swap ! buffer pcm - [ get-format ] keep ! buffer format pcm - [ get-data ] keep ! buffer format size alien pcm - mad_pcm-samplerate ! buffer format size alien samplerate - swapd alBufferData no-error? - ; - -: play-mp3 ( filename -- ) - gen-buffer >openal-buffer [ output-openal ] >output-callback-var decode-mp3 ; diff --git a/unmaintained/mad/summary.txt b/unmaintained/mad/summary.txt deleted file mode 100644 index a9a902032d..0000000000 --- a/unmaintained/mad/summary.txt +++ /dev/null @@ -1 +0,0 @@ -libmad MP3 library binding diff --git a/unmaintained/mortar/authors.txt b/unmaintained/mortar/authors.txt deleted file mode 100644 index 6cfd5da273..0000000000 --- a/unmaintained/mortar/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/mortar/mortar.factor b/unmaintained/mortar/mortar.factor deleted file mode 100755 index 1842b9a1e2..0000000000 --- a/unmaintained/mortar/mortar.factor +++ /dev/null @@ -1,182 +0,0 @@ - -USING: kernel io parser lexer words namespaces quotations arrays assocs sequences - splitting grouping math generalizations ; - -IN: mortar - -! class { name slots methods class-methods } - -: class-name ( class -- name ) dup symbol? [ get ] when first ; - -: class-slots ( class -- slots ) dup symbol? [ get ] when second ; - -: class-methods ( class -- methods ) dup symbol? [ get ] when third ; - -: class-class-methods ( class -- methods ) dup symbol? [ get ] when fourth ; - -: class? ( thing -- ? ) -dup array? -[ dup length 4 = [ first symbol? ] [ drop f ] if ] -[ drop f ] -if ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: add-method ( class name quot -- ) -rot get class-methods peek swapd set-at ; - -: add-class-method ( class name quot -- ) -rot get class-class-methods peek swapd set-at ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! object { class values } - -: object-class ( object -- class ) first ; - -: object-values ( object -- values ) second ; - -: object? ( thing -- ? ) -dup array? -[ dup length 2 = [ first class? ] [ drop f ] if ] -[ drop f ] -if ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: is? ( object class -- ? ) swap object-class class-name = ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: new ( class -- object ) -get dup >r class-slots length narray r> swap 2array ; - -: new-empty ( class -- object ) -get dup >r class-slots length f <array> r> swap 2array ; - -! : new* ( class -- object ) new-empty <- init ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: slot-value ( object slot -- value ) -over object-class class-slots index swap object-values nth ; - -: set-slot-value ( object slot value -- object ) -swap pick object-class class-slots index pick object-values set-nth ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! : send-message ( object message -- ) -! over object-class class-methods assoc-stack call ; - -: send-message ( object message -- ) -2dup swap object-class class-methods assoc-stack dup -[ nip call ] -! [ drop nip "message not understood: " write print flush ] -[ drop "message not understood: " write print drop ] -if ; - -: <- scan parsed \ send-message parsed ; parsing - -! : send-message* ( message n -- ) -! 1+ npick object-class class-methods assoc-stack call ; - -: send-message* ( message n -- ) -1+ npick dupd object-class class-methods assoc-stack dup -[ nip call ] -[ drop "message not understood: " write print flush ] -if ; - -: <-- scan parsed 2 parsed \ send-message* parsed ; parsing - -: <--- scan parsed 3 parsed \ send-message* parsed ; parsing - -: <---- scan parsed 4 parsed \ send-message* parsed ; parsing - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: send-message-to-class ( class message -- ) -over class-class-methods assoc-stack call ; - -: <<- scan parsed \ send-message-to-class parsed ; parsing - -: send-message-to-class* ( message n -- ) -1+ npick class-class-methods assoc-stack call ; - -: <<-- scan parsed 2 parsed \ send-message-to-class* parsed ; parsing - -: <<--- scan parsed 3 parsed \ send-message-to-class* parsed ; parsing - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: send-message-next ( object message -- ) -over object-class class-methods but-last assoc-stack call ; - -: <-~ scan parsed \ send-message-next parsed ; parsing - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! : new* ( class -- object ) <<- create ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -IN: slot-accessors - -IN: mortar - -! : generate-slot-getter ( name -- ) -! "$" over append "slot-accessors" create swap [ slot-value ] curry -! define-compound ; - -: generate-slot-getter ( name -- ) -"$" over append "slot-accessors" create swap [ slot-value ] curry define ; - -! : generate-slot-setter ( name -- ) -! ">>" over append "slot-accessors" create swap [ swap set-slot-value ] curry -! define-compound ; - -: generate-slot-setter ( name -- ) -">>" over append "slot-accessors" create swap [ swap set-slot-value ] curry -define ; - -: generate-slot-accessors ( name -- ) -dup -generate-slot-getter -generate-slot-setter ; - -: accessors ( seq -- seq ) dup peek [ generate-slot-accessors ] each ; parsing - -! : slots: -! ";" parse-tokens dup [ generate-slot-accessors ] each parsed ; parsing - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! : <symbol> ( string -- symbol ) in get create dup define-symbol ; - -: empty-method-table ( -- array ) H{ } clone 1array ; - -! : define-simple-class ( name parent slots -- ) -! >r >r <symbol> -! r> dup class-slots r> append -! swap dup class-methods empty-method-table append -! swap class-class-methods empty-method-table append -! 4array dup first set-global ; - -: define-simple-class ( name parent slots -- ) ->r dup class-slots r> append -swap dup class-methods empty-method-table append -swap class-class-methods empty-method-table append -4array dup first set-global ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: define-independent-class ( name slots -- ) -empty-method-table empty-method-table 4array dup first set-global ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: add-methods ( class seq -- ) 2 group [ first2 add-method ] with each ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: !( ")" parse-tokens drop ; parsing \ No newline at end of file diff --git a/unmaintained/mortar/sugar/sugar.factor b/unmaintained/mortar/sugar/sugar.factor deleted file mode 100644 index 04d2f6f651..0000000000 --- a/unmaintained/mortar/sugar/sugar.factor +++ /dev/null @@ -1,6 +0,0 @@ - -USING: mortar ; - -IN: mortar.sugar - -: new* ( class -- object ) <<- create ; \ No newline at end of file diff --git a/unmaintained/mortar/tags.txt b/unmaintained/mortar/tags.txt deleted file mode 100644 index f4274299b1..0000000000 --- a/unmaintained/mortar/tags.txt +++ /dev/null @@ -1 +0,0 @@ -extensions diff --git a/extra/multi-method-syntax/multi-method-syntax.factor b/unmaintained/multi-method-syntax/multi-method-syntax.factor similarity index 100% rename from extra/multi-method-syntax/multi-method-syntax.factor rename to unmaintained/multi-method-syntax/multi-method-syntax.factor diff --git a/unmaintained/namespaces-lib/authors.txt b/unmaintained/namespaces-lib/authors.txt deleted file mode 100644 index 6cfd5da273..0000000000 --- a/unmaintained/namespaces-lib/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/namespaces-lib/lib-tests.factor b/unmaintained/namespaces-lib/lib-tests.factor deleted file mode 100755 index d3f5a12faa..0000000000 --- a/unmaintained/namespaces-lib/lib-tests.factor +++ /dev/null @@ -1 +0,0 @@ - diff --git a/unmaintained/namespaces-lib/lib.factor b/unmaintained/namespaces-lib/lib.factor deleted file mode 100755 index dfa4df245c..0000000000 --- a/unmaintained/namespaces-lib/lib.factor +++ /dev/null @@ -1,23 +0,0 @@ -USING: kernel namespaces namespaces.private quotations sequences - assocs.lib math.parser math generalizations locals mirrors - macros ; - -IN: namespaces.lib - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: save-namestack ( quot -- ) namestack slip set-namestack ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: make* ( seq -- seq ) [ dup quotation? [ call ] [ ] if ] map ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: set* ( val var -- ) namestack* set-assoc-stack ; - -: make-object ( quot class -- object ) - new [ <mirror> swap bind ] keep ; inline - -: with-object ( object quot -- ) - [ <mirror> ] dip bind ; inline diff --git a/unmaintained/namespaces-lib/summary.txt b/unmaintained/namespaces-lib/summary.txt deleted file mode 100644 index ec8129b6a7..0000000000 --- a/unmaintained/namespaces-lib/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Non-core namespace words diff --git a/unmaintained/namespaces-lib/tags.txt b/unmaintained/namespaces-lib/tags.txt deleted file mode 100644 index 42d711b32b..0000000000 --- a/unmaintained/namespaces-lib/tags.txt +++ /dev/null @@ -1 +0,0 @@ -collections diff --git a/unmaintained/obj/alist/alist.factor b/unmaintained/obj/alist/alist.factor deleted file mode 100644 index a4e8ebb7c8..0000000000 --- a/unmaintained/obj/alist/alist.factor +++ /dev/null @@ -1,11 +0,0 @@ - -USING: arrays sequences ; - -IN: obj.alist - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -PREDICATE: alist < sequence [ pair? ] all? ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - diff --git a/unmaintained/obj/examples/todo/todo.factor b/unmaintained/obj/examples/todo/todo.factor deleted file mode 100644 index 3d545479e9..0000000000 --- a/unmaintained/obj/examples/todo/todo.factor +++ /dev/null @@ -1,83 +0,0 @@ - -USING: kernel sequences sets combinators.cleave - obj obj.view obj.util obj.print ; - -IN: obj.examples.todo - -SYM: person types adjoin -SYM: todo types adjoin - -SYM: owners properties adjoin -SYM: eta properties adjoin -SYM: notes properties adjoin - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYM: slava { type person } define-object -SYM: doug { type person } define-object -SYM: ed { type person } define-object - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYM: compiler-bugs - { - type todo - owners { slava } - notes { - "Investitage FEP on Terrorist" - "Problem with cutler in VirtualBox?" - } - } -define-object - -SYM: remove-old-accessors-from-core - { - type todo - owners { slava } - } -define-object - -SYM: move-db-and-web-framework-to-basis - { - type todo - owners { slava } - } -define-object - -SYM: remove-old-accessors-from-basis - { - type todo - owners { doug ed } - } -define-object - -SYM: blas-on-bsd - { - type todo - owners { slava doug } - } -define-object - -SYM: multi-methods-backend - { - type todo - owners { slava } - } -define-object - -SYM: update-core-for-multi-methods { type todo owners { slava } } define-object -SYM: update-basis-for-multi-methods { type todo } define-object -SYM: update-extra-for-multi-methods { type todo } define-object - - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: todo-list ( -- ) - objects [ type -> todo = ] filter - [ { [ self -> ] [ owners -> ] [ eta -> ] } 1arr ] - map - { "ITEM" "OWNERS" "ETA" } prefix - print-table ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - diff --git a/unmaintained/obj/misc/misc.factor b/unmaintained/obj/misc/misc.factor deleted file mode 100644 index 06b3056ea0..0000000000 --- a/unmaintained/obj/misc/misc.factor +++ /dev/null @@ -1,8 +0,0 @@ - -USING: kernel namespaces sequences assocs sequences.deep obj ; - -IN: obj.misc - -: related ( obj -- seq ) - objects dupd remove [ get values flatten member? ] with filter ; - diff --git a/unmaintained/obj/obj.factor b/unmaintained/obj/obj.factor deleted file mode 100644 index a4af627926..0000000000 --- a/unmaintained/obj/obj.factor +++ /dev/null @@ -1,45 +0,0 @@ - -USING: kernel words namespaces arrays vectors hashtables - sequences assocs sets grouping - combinators.conditional - combinators.short-circuit - obj.util obj.alist ; - -IN: obj - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: properties ( -- properties ) V{ } ; - -SYM: self properties adjoin -SYM: type properties adjoin -SYM: title properties adjoin - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: types ( -- types ) V{ } ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: >obj ( val -- obj ) [ symbol? ] [ get ] [ ] 1if ; - -: -> ( obj pro -- val ) swap >obj at ; - -PREDICATE: obj < alist { [ self -> ] [ type -> ] } 1&& ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: objects ( -- objects ) V{ } ; - -: define-object ( symbol table -- ) - 2 group >vector - self rot 2array prefix - dup dup self -> set-global - self -> objects adjoin ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -PREDICATE: ptr < symbol get obj? ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - diff --git a/unmaintained/obj/papers/papers.factor b/unmaintained/obj/papers/papers.factor deleted file mode 100644 index 46683ad997..0000000000 --- a/unmaintained/obj/papers/papers.factor +++ /dev/null @@ -1,178 +0,0 @@ - -USING: sets obj obj.util obj.view ; - -IN: obj.papers - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYM: title properties adjoin -SYM: abstract properties adjoin -SYM: authors properties adjoin -SYM: file properties adjoin -SYM: date properties adjoin -SYM: participants properties adjoin -SYM: description properties adjoin - -SYM: chapter properties adjoin -SYM: section properties adjoin -SYM: paragraph properties adjoin -SYM: content properties adjoin - -SYM: subjects properties adjoin -SYM: source properties adjoin - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYM: paper types adjoin -SYM: person types adjoin -SYM: event types adjoin - -SYM: excerpt types adjoin - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYM: bay-wei-chang { type person } define-object -SYM: chuck-moore { type person } define-object -SYM: craig-chambers { type person } define-object -SYM: david-ungar { type person } define-object -SYM: frank-g-halasz { type person } define-object -SYM: gerald-jay-sussman { type person } define-object -SYM: guy-lewis-steele-jr { type person } define-object -SYM: randall-b-smith { type person } define-object -SYM: randall-h-trigg { type person } define-object -SYM: robert-adams { type person } define-object -SYM: russell-noftsker { type person } define-object -SYM: thomas-p-moran { type person } define-object -SYM: urs-holzle { type person } define-object - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYM: programming-as-an-experience - { - type paper - title "Programming as an Experience: The Inspiration for Self" - abstract "The Self system attempts to integrate intellectual and non-intellectual aspects of programming to create an overall experience. The language semantics, user interface, and implementation each help create this integrated experience. The language semantics embed the programmer in a uniform world of simple ob jects that can be modified without appealing to definitions of abstractions. In a similar way, the graphical interface puts the user into a uniform world of tangible objects that can be directly manipulated and changed without switching modes. The implementation strives to support the world-of-objects illusion by minimiz ing perceptible pauses and by providing true source-level semantics without sac rificing performance. As a side benefit, it encourages factoring. Although we see areas that fall short of the vision, on the whole, the language, interface, and im plementation conspire so that the Self programmer lives and acts in a consistent and malleable world of objects." - authors { randall-b-smith david-ungar } - date 1995 - } -define-object - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYM: self-the-power-of-simplicity - { - type paper - title "Self: The Power of Simplicity" - abstract "Self is an object-oriented language for exploratory programming based on a small number of simple and concrete ideas: prototypes, slots, and behavior. Prototypes combine inheritance and instantiation to provide a framework that is simpler and more flexible than most object-oriented languages. Slots unite variables and procedures into a single construct. This permits the inheritance hierarchy to take over the function of lexical scoping in conventional languages. Finally, because Self does not distinguish state from behavior, it narrows the gaps between ordinary objects, procedures, and closures. Self's simplicity and expressiveness offer new insights into object-oriented computation." - authors { randall-b-smith david-ungar } - date 1987 - } -define-object - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYM: parents-are-shared-parts - { - type paper - title "Parents are Shared Parts: Inheritance and Encapsulation in Self" - abstract "The design of inheritance and encapsulation in Self, an object-oriented language based on prototypes, results from understanding that inheritance allows parents to be shared parts of their children. The programmer resolves ambiguities arising from multiple inheritance by prioritizing an object's parents. Unifying unordered and ordered multiple inheritance supports differential programming of abstractions and methods, combination of unrelated abstractions, unequal combination of abstractions, and mixins. In Self, a private slot may be accessed if the sending method is a shared part of the receiver, allowing privileged communication between related objects. Thus, classless Self enjoys the benefits of class-based encapsulation." - authors { craig-chambers david-ungar bay-wei-chang urs-holzle } - date 1991 - } -define-object - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYM: organizing-programs-without-classes - { - type paper - title "Organizing Programs Without Classes" - abstract "All organizational functions carried out by classes can be accomplished in a simple and natural way by object inheritance in classless languages, with no need for special mechanisms. A single model--dividing types into prototypes and traits--supports sharing of behavior and extending or replacing representations. A natural extension, dynamic object inheritance, can model behavioral modes. Object inheritance can also be used to provide structured name spaces for well-known objects. Classless languages can even express 'class-based' encapsulation. These stylized uses of object inheritance become instantly recognizable idioms, and extend the repertory of organizing principles to cover a wider range of programs." - authors { david-ungar craig-chambers bay-wei-chang urs-holzle } - date 1991 - } -define-object - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYM: scheme-an-interpreter-for-extended-lambda-calculus - { - type paper - title "Scheme: An Interpreter for Extended Lambda Calculus" - abstract "Inspired by ACTORS [Greif and Hewitt] [Smith and Hewitt], we have implemented an interpreter for a LISP-like language, SCHEME, based on the lambda calculus [Church], but extended for side effects, multiprocessing, and process synchronization. The purpose of this implementation is tutorial. We wish to: (1) alleviate the confusion caused by Micro-PLANNER, CONNIVER, etc. by clarifying the embedding of non-recursive control structures in a recursive host language like LISP. (2) explain how to use these control structures, independent of such issues as pattern matching and data base manipulation. (3) have a simple concrete experimental domain for certain issues of programming semantics and style." - authors { gerald-jay-sussman guy-lewis-steele-jr } - date 1975 - } -define-object - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYM: symbolics-is-founded - { - type event - participants { russell-noftsker robert-adams } - date 1980 - } -define-object - -SYM: symbolics-funding-from-gi - { - type event - description "Symbolics receives $500,000 from General Instruments" - date 1982 - } -define-object - -SYM: symbolics-files-for-bankruptcy - { - type event - date "1993-01-28" - } -define-object - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYM: the-evolution-of-forth - { - type paper - title "The Evolution of Forth" - authors { chuck-moore "elizabeth-d-rather" "donald-r-colburn" } - abstract - "Forth is unique among programming languages in that its development and proliferation has been a grass-roots effort unsupported by any major corporate or academic sponsors. Originally conceived and developed by a single individual, its later development has progressed under two significant influences: professional programmers who developed tools to solve application problems and then commercialized them, and the interests of hobbyists concerned with free distribution of Forth. These influences have produced a language markedly different from traditional programming languages." - date 1993 - } -define-object - -SYM: first-complete-stand-alone-forth - { - type event - participants { chuck-moore } - date 1971 - } -define-object - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYM: notecards-in-a-nutshell - { - type paper - authors { frank-g-halasz thomas-p-moran randall-h-trigg } - date 1987 - } -define-object - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYM: the-evolution-of-forth-excerpt-2-1-1 - { - type excerpt - source the-evolution-of-forth - chapter 2 - section 1 - paragraph 1 - content - "Moore developed the first complete, stand-alone implementation of Forth in 1971 for the 11-meter radio telescope operated by the National Radio Astronomy Observatory (NRAO) at Kitt Peak, Arizona. This system ran on two early minicomputers (a 16 KB DDP-116 and a 32 KB H316) joined by a serial link. Both a multiprogrammed system and a multiprocessor system (in that both computers shared responsibility for controlling the telescope and its scientific instruments), it was responsible for pointing and tracking the telescope, collecting data and recording it on magnetic tape, and supporting an interactive graphics terminal on which an astronomer could analyze previously recorded data. The multiprogrammed nature of the system allowed all these functions to be performed concurrently, without timing conflicts or other interference." - subjects { chuck-moore first-complete-stand-alone-forth } - } -define-object - diff --git a/unmaintained/obj/print/print.factor b/unmaintained/obj/print/print.factor deleted file mode 100644 index 000e161387..0000000000 --- a/unmaintained/obj/print/print.factor +++ /dev/null @@ -1,37 +0,0 @@ - -USING: kernel arrays strings sequences assocs io io.styles prettyprint colors - combinators.conditional ; - -IN: obj.print - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: write-wrapped ( string -- ) H{ { wrap-margin 500 } } [ write ] with-nesting ; - -! : print-elt ( val -- ) -! { -! { [ string? ] [ write-wrapped ] } -! { [ array? ] [ [ . ] each ] } -! { [ drop t ] [ . ] } -! } -! 1cond ; - -USING: accessors vocabs help.markup ; - -: print-elt ( val -- ) - { - { [ vocab? ] [ [ name>> ] [ ] bi write-object ] } - { [ string? ] [ write-wrapped ] } - { [ array? ] [ [ . ] each ] } - { [ drop t ] [ . ] } - } - 1cond ; - -: print-grid ( grid -- ) - H{ { table-gap { 10 10 } } { table-border T{ rgba f 0 0 0 1 } } } - [ [ [ [ [ print-elt ] with-cell ] each ] with-row ] each ] tabular-output ; - -: print-table ( assoc -- ) >alist print-grid ; - -: print-seq ( seq -- ) [ 1array ] map print-grid ; - diff --git a/unmaintained/obj/util/util.factor b/unmaintained/obj/util/util.factor deleted file mode 100644 index 086fcd1835..0000000000 --- a/unmaintained/obj/util/util.factor +++ /dev/null @@ -1,8 +0,0 @@ - -USING: kernel parser words ; - -IN: obj.util - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: SYM: CREATE-WORD dup define-symbol parsed ; parsing \ No newline at end of file diff --git a/unmaintained/obj/view/view.factor b/unmaintained/obj/view/view.factor deleted file mode 100644 index cf5ca33745..0000000000 --- a/unmaintained/obj/view/view.factor +++ /dev/null @@ -1,52 +0,0 @@ - -USING: kernel words namespaces arrays sequences prettyprint - help.topics help.markup bake combinators.cleave - obj obj.misc obj.print ; - -IN: obj.view - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: $tab ( seq -- ) first print-table ; -: $obj ( seq -- ) first print-table ; -: $seq ( seq -- ) first print-seq ; -: $ptr ( seq -- ) first get print-table ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -PREDICATE: obj-type < symbol types member? ; - -M: obj-type article-title ( type -- title ) unparse ; - -M: obj-type article-content ( type -- content ) - objects [ type -> = ] with filter - { $seq , } bake ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -M: ptr article-title ( ptr -- title ) [ title -> ] [ unparse ] bi or ; - -M: ptr article-content ( ptr -- content ) - { - [ get { $obj , } bake ] - [ drop { $heading "Related\n" } ] - [ related { $seq , } bake ] - } - 1arr ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -PREDICATE: obj-list < word \ objects = ; - -M: obj-list article-title ( objects -- title ) drop "Objects" ; - -! M: obj-list article-content ( objects -- title ) -! execute -! [ [ type -> ] [ ] bi 2array ] map -! { $tab , } bake ; - -M: obj-list article-content ( objects -- title ) - drop - objects - [ [ type -> ] [ ] bi 2array ] map - { $tab , } bake ; \ No newline at end of file diff --git a/extra/opengl/gadgets/gadgets-tests.factor b/unmaintained/opengl-gadgets/gadgets-tests.factor similarity index 100% rename from extra/opengl/gadgets/gadgets-tests.factor rename to unmaintained/opengl-gadgets/gadgets-tests.factor diff --git a/extra/opengl/gadgets/gadgets.factor b/unmaintained/opengl-gadgets/gadgets.factor similarity index 100% rename from extra/opengl/gadgets/gadgets.factor rename to unmaintained/opengl-gadgets/gadgets.factor diff --git a/extra/ori/authors.txt b/unmaintained/ori/authors.txt similarity index 100% rename from extra/ori/authors.txt rename to unmaintained/ori/authors.txt diff --git a/extra/ori/ori-tests.factor b/unmaintained/ori/ori-tests.factor similarity index 100% rename from extra/ori/ori-tests.factor rename to unmaintained/ori/ori-tests.factor diff --git a/extra/ori/ori.factor b/unmaintained/ori/ori.factor similarity index 100% rename from extra/ori/ori.factor rename to unmaintained/ori/ori.factor diff --git a/extra/math/physics/pos/pos.factor b/unmaintained/physics/pos/pos.factor similarity index 100% rename from extra/math/physics/pos/pos.factor rename to unmaintained/physics/pos/pos.factor diff --git a/extra/math/physics/vel/vel.factor b/unmaintained/physics/vel/vel.factor similarity index 100% rename from extra/math/physics/vel/vel.factor rename to unmaintained/physics/vel/vel.factor diff --git a/extra/pong/pong.factor b/unmaintained/pong/pong.factor similarity index 100% rename from extra/pong/pong.factor rename to unmaintained/pong/pong.factor diff --git a/extra/pos/authors.txt b/unmaintained/pos/authors.txt similarity index 100% rename from extra/pos/authors.txt rename to unmaintained/pos/authors.txt diff --git a/extra/pos/pos.factor b/unmaintained/pos/pos.factor similarity index 100% rename from extra/pos/pos.factor rename to unmaintained/pos/pos.factor diff --git a/extra/processing/shapes/shapes.factor b/unmaintained/processing/shapes/shapes.factor similarity index 100% rename from extra/processing/shapes/shapes.factor rename to unmaintained/processing/shapes/shapes.factor diff --git a/unmaintained/prolog/authors.txt b/unmaintained/prolog/authors.txt deleted file mode 100644 index 194cb22416..0000000000 --- a/unmaintained/prolog/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Gavin Harrison diff --git a/unmaintained/prolog/prolog.factor b/unmaintained/prolog/prolog.factor deleted file mode 100755 index ea55ac5bf5..0000000000 --- a/unmaintained/prolog/prolog.factor +++ /dev/null @@ -1,84 +0,0 @@ -! Copyright (C) 2007 Gavin Harrison -! See http://factorcode.org/license.txt for BSD license. - -USING: kernel sequences arrays vectors namespaces math strings - combinators continuations quotations io assocs ascii ; - -IN: prolog - -SYMBOL: pldb -SYMBOL: plchoice - -: init-pl ( -- ) V{ } clone pldb set V{ } clone plchoice set ; - -: reset-choice ( -- ) V{ } clone plchoice set ; -: remove-choice ( -- ) plchoice get pop drop ; -: add-choice ( continuation -- ) - dup continuation? [ plchoice get push ] [ drop ] if ; -: last-choice ( -- ) plchoice get pop continue ; - -: rules ( -- vector ) pldb get ; -: rule ( n -- rule ) dup rules length >= [ drop "No." ] [ rules nth ] if ; - -: var? ( pl-obj -- ? ) - dup string? [ 0 swap nth LETTER? ] [ drop f ] if ; -: const? ( pl-obj -- ? ) var? not ; - -: check-arity ( pat fact -- pattern fact ? ) 2dup [ length ] 2apply = ; -: check-elements ( pat fact -- ? ) [ over var? [ 2drop t ] [ = ] if ] 2all? ; -: (double-bound) ( key value assoc -- ? ) - pick over at* [ pick = >r 3drop r> ] [ drop swapd set-at t ] if ; -: single-bound? ( pat-d pat-f -- ? ) - H{ } clone [ (double-bound) ] curry 2all? ; -: match-pattern ( pat fact -- ? ) - check-arity [ 2dup check-elements -rot single-bound? and ] [ 2drop f ] if ; -: good-result? ( pat fact -- pat fact ? ) - 2dup dup "No." = [ 2drop t ] [ match-pattern ] if ; - -: add-rule ( name pat body -- ) 3array rules dup length swap set-nth ; - -: (lookup-rule) ( name num -- pat-f rules ) - dup rule dup "No." = >r 0 swap nth swapd dupd = swapd r> or - [ dup rule [ ] callcc0 add-choice ] when - dup number? [ 1+ (lookup-rule) ] [ 2nip ] if ; - -: add-bindings ( pat-d pat-f binds -- binds ) - clone - [ over var? over const? or - [ 2drop ] [ rot dup >r set-at r> ] if - ] 2reduce ; -: init-binds ( pat-d pat-f -- binds ) V{ } clone add-bindings >alist ; - -: replace-if-bound ( binds elt -- binds elt' ) - over 2dup key? [ at ] [ drop ] if ; -: deep-replace ( binds seq -- binds seq' ) - [ dup var? [ replace-if-bound ] - [ dup array? [ dupd deep-replace nip ] when ] if - ] map ; - -: backtrace? ( result -- ) - dup "No." = [ remove-choice last-choice ] - [ [ last-choice ] unless ] if ; - -: resolve-rule ( pat-d pat-f rule-body -- binds ) - >r 2dup init-binds r> [ deep-replace >quotation call dup backtrace? - dup t = [ drop ] when ] each ; - -: rule>pattern ( rule -- pattern ) 1 swap nth ; -: rule>body ( rule -- body ) 2 swap nth ; - -: binds>fact ( pat-d pat-f binds -- fact ) - [ 2dup key? [ at ] [ drop ] if ] curry map good-result? - [ nip ] [ last-choice ] if ; - -: lookup-rule ( name pat -- fact ) - swap 0 (lookup-rule) dup "No." = - [ nip ] - [ dup rule>pattern swapd check-arity - [ rot rule>body resolve-rule dup -roll binds>fact nip ] [ last-choice ] if - ] if ; - -: binding-resolve ( binds name pat -- binds ) - tuck lookup-rule dup backtrace? spin add-bindings ; - -: is ( binds val var -- binds ) rot [ set-at ] keep ; diff --git a/unmaintained/prolog/summary.txt b/unmaintained/prolog/summary.txt deleted file mode 100644 index 48ad1f312e..0000000000 --- a/unmaintained/prolog/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Implementation of an embedded prolog for factor diff --git a/unmaintained/prolog/tags.txt b/unmaintained/prolog/tags.txt deleted file mode 100644 index eab42feac7..0000000000 --- a/unmaintained/prolog/tags.txt +++ /dev/null @@ -1 +0,0 @@ -languages diff --git a/unmaintained/random-tester/authors.txt b/unmaintained/random-tester/authors.txt deleted file mode 100755 index 7c1b2f2279..0000000000 --- a/unmaintained/random-tester/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Doug Coleman diff --git a/unmaintained/random-tester/databank/authors.txt b/unmaintained/random-tester/databank/authors.txt deleted file mode 100755 index 7c1b2f2279..0000000000 --- a/unmaintained/random-tester/databank/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Doug Coleman diff --git a/unmaintained/random-tester/databank/databank.factor b/unmaintained/random-tester/databank/databank.factor deleted file mode 100644 index 45ee779372..0000000000 --- a/unmaintained/random-tester/databank/databank.factor +++ /dev/null @@ -1,11 +0,0 @@ -USING: kernel math.constants ; -IN: random-tester.databank - -: databank ( -- array ) - { - ! V{ } H{ } V{ 3 } { 3 } { } "" "asdf" - pi 1/0. -1/0. 0/0. [ ] - f t "" 0 0.0 3.14 2 -3 -7 20 3/4 -3/4 1.2/3 3.5 - C{ 2 2 } C{ 1/0. 1/0. } - } ; - diff --git a/unmaintained/random-tester/random-tester.factor b/unmaintained/random-tester/random-tester.factor deleted file mode 100755 index cbf9f52fa6..0000000000 --- a/unmaintained/random-tester/random-tester.factor +++ /dev/null @@ -1,49 +0,0 @@ -USING: compiler continuations io kernel math namespaces -prettyprint quotations random sequences vectors -compiler.units ; -USING: random-tester.databank random-tester.safe-words -random-tester.random ; -IN: random-tester - -SYMBOL: errored -SYMBOL: before -SYMBOL: after -SYMBOL: quot -ERROR: random-tester-error ; - -: setup-test ( #data #code -- data... quot ) - #! Variable stack effect - >r [ databank random ] times r> - ! 200 300 random-cond ; - ! random-if ; - [ drop \ safe-words get random ] map >quotation ; - -: test-compiler ! ( data... quot -- ... ) - errored off - dup quot set - datastack 1 head* before set - [ call ] [ drop ] recover - datastack after set - clear - before get [ ] each - quot get [ compile-call ] [ errored on ] recover ; - -: do-test ! ( data... quot -- ) - .s flush test-compiler - errored get [ - datastack after get 2dup = [ - 2drop - ] [ - [ . ] each - "--" print - [ . ] each - quot get . - random-tester-error - ] if - ] unless clear ; - -: random-test1 ( #data #code -- ) - setup-test do-test ; - -: random-test2 ( -- ) - 3 2 setup-test do-test ; diff --git a/unmaintained/random-tester/random/authors.txt b/unmaintained/random-tester/random/authors.txt deleted file mode 100755 index 7c1b2f2279..0000000000 --- a/unmaintained/random-tester/random/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Doug Coleman diff --git a/unmaintained/random-tester/random/random.factor b/unmaintained/random-tester/random/random.factor deleted file mode 100755 index 7bedcb8cec..0000000000 --- a/unmaintained/random-tester/random/random.factor +++ /dev/null @@ -1,86 +0,0 @@ -USING: kernel math sequences namespaces hashtables words -arrays parser compiler syntax io prettyprint random -math.constants math.functions layouts random-tester.utils -random-tester.safe-words quotations fry combinators ; -IN: random-tester - -! Tweak me -: max-length 15 ; inline -: max-value 1000000000 ; inline - -! varying bit-length random number -: random-bits ( n -- int ) - random 2 swap ^ random ; - -: random-seq ( -- seq ) - { [ ] { } V{ } "" } random - [ max-length random [ max-value random , ] times ] swap make ; - -: random-string - [ max-length random [ max-value random , ] times ] "" make ; - -: special-integers ( -- seq ) \ special-integers get ; -[ { -1 0 1 } % most-negative-fixnum , most-positive-fixnum , first-bignum , ] -{ } make \ special-integers set-global -: special-floats ( -- seq ) \ special-floats get ; -[ { 0.0 -0.0 } % e , pi , 1./0. , -1./0. , 0./0. , epsilon , epsilon neg , ] -{ } make \ special-floats set-global -: special-complexes ( -- seq ) \ special-complexes get ; -[ - { -1 0 1 C{ 0 1 } C{ 0 -1 } } % - e , e neg , pi , pi neg , - 0 pi rect> , 0 pi neg rect> , pi neg 0 rect> , pi pi rect> , - pi pi neg rect> , pi neg pi rect> , pi neg pi neg rect> , - e neg e neg rect> , e e rect> , -] { } make \ special-complexes set-global - -: random-fixnum ( -- fixnum ) - most-positive-fixnum random 1+ 50% [ neg 1- ] when >fixnum ; - -: random-bignum ( -- bignum ) - 400 random-bits first-bignum + 50% [ neg ] when ; - -: random-integer ( -- n ) - 50% [ - random-fixnum - ] [ - 50% [ random-bignum ] [ special-integers get random ] if - ] if ; - -: random-positive-integer ( -- int ) - random-integer dup 0 < [ - neg - ] [ - dup 0 = [ 1 + ] when - ] if ; - -: random-ratio ( -- ratio ) - 1000000000 dup [ random ] bi@ 1+ / 50% [ neg ] when dup [ drop random-ratio ] unless 10% [ drop 0 ] when ; - -: random-float ( -- float ) - 50% [ random-ratio ] [ special-floats get random ] if - 50% - [ .0000000000000000001 /f ] [ 50% [ .00000000000000001 * ] when ] if - >float ; - -: random-number ( -- number ) - { - [ random-integer ] - [ random-ratio ] - [ random-float ] - } do-one ; - -: random-complex ( -- C ) - random-number random-number rect> ; - -: random-quot ( n -- quot ) - [ \ safe-words get random ] replicate >quotation ; - -: random-if ( n -- quot ) - [ random-quot ] [ random-quot ] bi - '[ , , if ] ; - -: random-cond ( m n -- quot ) - [ '[ , [ random-quot ] [ random-quot ] bi 2array ] replicate ] - [ random-quot ] bi suffix - '[ , cond ] ; diff --git a/unmaintained/random-tester/safe-words/authors.txt b/unmaintained/random-tester/safe-words/authors.txt deleted file mode 100755 index 7c1b2f2279..0000000000 --- a/unmaintained/random-tester/safe-words/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Doug Coleman diff --git a/unmaintained/random-tester/safe-words/safe-words.factor b/unmaintained/random-tester/safe-words/safe-words.factor deleted file mode 100755 index 77e5562f4d..0000000000 --- a/unmaintained/random-tester/safe-words/safe-words.factor +++ /dev/null @@ -1,120 +0,0 @@ -USING: kernel namespaces sequences sets sorting vocabs ; -USING: arrays assocs generic hashtables -math math.intervals math.parser math.order math.functions -refs shuffle vectors words ; -IN: random-tester.safe-words - -: ?-words - { - /f - - bits>float bits>double - float>bits double>bits - - >bignum >boolean >fixnum >float - - array? integer? complex? value-ref? ref? key-ref? - interval? number? - wrapper? tuple? - [-1,1]? between? bignum? both? either? eq? equal? even? fixnum? - float? fp-nan? hashtable? interval-contains? interval-subset? - interval? key-ref? key? number? odd? pair? power-of-2? - ratio? rational? real? zero? assoc? curry? vector? callstack? - - 2^ not - ! arrays - resize-array <array> - ! assocs - (assoc-stack) - new-assoc - assoc-like - <hashtable> - all-integers? (all-integers?) ! hangs? - assoc-push-if - - (clone) assoc-clone-like ! SYMBOL: foo foo dup (clone) = - } ; - -: bignum-words - { - next-power-of-2 (next-power-of-2) - times - hashcode hashcode* - } ; - -: initialization-words - { - init-namespaces - } ; - -: stack-words - { - dup - drop 2drop 3drop - roll -roll 2swap - - >r r> - } ; - -: stateful-words - { - counter - gensym - } ; - -: foo-words - { - set-retainstack - retainstack callstack - datastack - callstack>array - - curry 2curry 3curry compose 3compose - (assoc-each) - } ; - -: exit-words - { - call-clear die - } ; - -: bad-words ( -- array ) - [ - ?-words % - bignum-words % - initialization-words % - stack-words % - stateful-words % - exit-words % - foo-words % - ] { } make ; - -: safe-words ( -- array ) - { - ! "accessors" - "alists" "arrays" "assocs" "bit-arrays" "byte-arrays" - ! "classes" "combinators" "compiler" "continuations" - ! "core-foundation" "definitions" "documents" - ! "float-arrays" "generic" "graphs" "growable" - "hashtables" ! io.* - "kernel" "math" - "math.bitfields" "math.complex" "math.constants" "math.floats" - "math.functions" "math.integers" "math.intervals" "math.libm" - "math.parser" "math.order" "math.ratios" "math.vectors" - ! "namespaces" - "quotations" "sbufs" - ! "queues" "strings" "sequences" - "sets" - "vectors" - ! "words" - } [ words ] map concat bad-words diff natural-sort ; - -safe-words \ safe-words set-global - -! foo dup (clone) = . -! foo dup clone = . -! f [ byte-array>bignum assoc-clone-like ] compile-1 -! 2 3.14 [ number= ] compile-1 -! 3.14 [ <vector> assoc? ] compile-1 -! -3 [ ] 2 [ byte-array>bignum denominator ] compile-1 -! : foo ( x -- y ) euler bitand ; { foo } compile 20 foo diff --git a/unmaintained/random-tester/utils/authors.txt b/unmaintained/random-tester/utils/authors.txt deleted file mode 100755 index 7c1b2f2279..0000000000 --- a/unmaintained/random-tester/utils/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Doug Coleman diff --git a/unmaintained/random-tester/utils/utils.factor b/unmaintained/random-tester/utils/utils.factor deleted file mode 100644 index a025bbf45f..0000000000 --- a/unmaintained/random-tester/utils/utils.factor +++ /dev/null @@ -1,34 +0,0 @@ -USING: arrays assocs combinators.lib continuations kernel -math math.functions memoize namespaces quotations random sequences -sequences.private shuffle ; -IN: random-tester.utils - -: %chance ( n -- ? ) - 100 random > ; - -: 10% ( -- ? ) 10 %chance ; -: 20% ( -- ? ) 20 %chance ; -: 30% ( -- ? ) 30 %chance ; -: 40% ( -- ? ) 40 %chance ; -: 50% ( -- ? ) 50 %chance ; -: 60% ( -- ? ) 60 %chance ; -: 70% ( -- ? ) 70 %chance ; -: 80% ( -- ? ) 80 %chance ; -: 90% ( -- ? ) 90 %chance ; - -: call-if ( quot ? -- ) swap when ; inline - -: with-10% ( quot -- ) 10% call-if ; inline -: with-20% ( quot -- ) 20% call-if ; inline -: with-30% ( quot -- ) 30% call-if ; inline -: with-40% ( quot -- ) 40% call-if ; inline -: with-50% ( quot -- ) 50% call-if ; inline -: with-60% ( quot -- ) 60% call-if ; inline -: with-70% ( quot -- ) 70% call-if ; inline -: with-80% ( quot -- ) 80% call-if ; inline -: with-90% ( quot -- ) 90% call-if ; inline - -: random-key keys random ; -: random-value [ random-key ] keep at ; - -: do-one ( seq -- ) random call ; inline diff --git a/extra/random-weighted/authors.txt b/unmaintained/random-weighted/authors.txt similarity index 100% rename from extra/random-weighted/authors.txt rename to unmaintained/random-weighted/authors.txt diff --git a/extra/random-weighted/random-weighted.factor b/unmaintained/random-weighted/random-weighted.factor similarity index 100% rename from extra/random-weighted/random-weighted.factor rename to unmaintained/random-weighted/random-weighted.factor diff --git a/unmaintained/raptor/authors.txt b/unmaintained/raptor/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/raptor/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/raptor/config.factor b/unmaintained/raptor/config.factor deleted file mode 100644 index 29e26d4381..0000000000 --- a/unmaintained/raptor/config.factor +++ /dev/null @@ -1,165 +0,0 @@ - -USING: namespaces threads - unix.process unix.linux.if unix.linux.ifreq unix.linux.route - raptor.cron ; - -IN: raptor - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! Networking -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: configure-lo ( -- ) - "lo" "127.0.0.1" set-if-addr - "lo" { IFF_UP } flags set-if-flags ; - -: configure-eth1 ( -- ) - "eth1" "192.168.1.10" set-if-addr - "eth1" { IFF_UP IFF_MULTICAST } flags set-if-flags ; - -: configure-route ( -- ) - "0.0.0.0" "192.168.1.1" "0.0.0.0" { RTF_UP RTF_GATEWAY } flags route ; - -[ - configure-lo - configure-eth1 - configure-route -] networking-hook set-global - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! Filesystems -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -"/dev/hda1" root-device set-global - -{ "/dev/hda5" } swap-devices set-global - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! boot-hook -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -[ - start-wait-loop - - ! rcS.d - - "mountvirtfs" start-service - - ! "hostname.sh" start-service - "narodnik" set-hostname - - "keymap.sh" start-service - "linux-restricted-modules-common" start-service - "udev" start-service - "mountdevsubfs" start-service - "module-init-tools" start-service - "procps.sh" start-service - - ! "checkroot.sh" start-service - - activate-swap - mount-root - - "mtab" start-service - "checkfs.sh" start-service - "mountall.sh" start-service - - start-networking -! "loopback" start-service -! "networking" start-service - - "hwclock.sh" start-service - "displayconfig-hwprobe.py" start-service - "screen" start-service - "x11-common" start-service - "bootmisc.sh" start-service - "urandom" start-service - - ! rc2.d - - "vbesave" start-service - "acpid" start-service - "powernowd.early" start-service - "sysklogd" start-service - "klogd" start-service - "dbus" start-service - "apmd" start-service - "hotkey-setup" start-service - "laptop-mode" start-service - "makedev" start-service - "nvidia-kernel" start-service - "postfix" start-service - "powernowd" start-service - "ntp-server" start-service - "binfmt-support" start-service - "acpi-support" start-service - "rc.local" start-service - "rmnologin" start-service - - schedule-cron-jobs - - [ [ "/dev/tty2" tty-listener ] forever ] in-thread - [ [ "/dev/tty3" tty-listener ] forever ] in-thread - [ [ "/dev/tty4" tty-listener ] forever ] in-thread - [ [ "/dev/tty5" getty ] forever ] in-thread - [ [ "/dev/tty6" getty ] forever ] in-thread - -] boot-hook set-global - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! reboot-hook -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -[ - "acpi-support" stop-service - "apmd" stop-service - "dbus" stop-service - "hotkey-setup" stop-service - "laptop-mode" stop-service - "makedev" stop-service - "nvidia-kernel" stop-service - "powernowd" stop-service - "acpid" stop-service - "hwclock.sh" stop-service - "alsa-utils" stop-service - "klogd" stop-service - "binfmt-support" stop-service - "sysklogd" stop-service - "linux-restricted-modules-common" stop-service - "sendsigs" stop-service - "urandom" stop-service - "umountnfs.sh" stop-service - "networking" stop-service - "umountfs" stop-service - "umountroot" stop-service - "reboot" stop-service -] reboot-hook set-global - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! shutdown-hook -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -[ - "acpi-support" stop-service - "apmd" stop-service - "dbus" stop-service - "hotkey-setup" stop-service - "laptop-mode" stop-service - "makedev" stop-service - "nvidia-kernel" stop-service - "postfix" stop-service - "powernowd" stop-service - "acpid" stop-service - "hwclock.sh" stop-service - "alsa-utils" stop-service - "klogd" stop-service - "binfmt-support" stop-service - "sysklogd" stop-service - "linux-restricted-modules-common" stop-service - "sendsigs" stop-service - "urandom" stop-service - "umountnfs.sh" stop-service - "umountfs" stop-service - "umountroot" stop-service - "halt" stop-service -] shutdown-hook set-global \ No newline at end of file diff --git a/unmaintained/raptor/cron/authors.txt b/unmaintained/raptor/cron/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/raptor/cron/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/raptor/cron/cron.factor b/unmaintained/raptor/cron/cron.factor deleted file mode 100755 index d818fb487d..0000000000 --- a/unmaintained/raptor/cron/cron.factor +++ /dev/null @@ -1,62 +0,0 @@ - -USING: kernel namespaces threads sequences calendar - combinators.lib debugger ; - -IN: raptor.cron - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -TUPLE: when minute hour day-of-month month day-of-week ; - -C: <when> when - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: slot-match? ( now-slot when-slot -- ? ) dup f = [ 2drop t ] [ member? ] if ; - -: minute-match? ( now when -- ? ) - [ timestamp-minute ] [ when-minute ] bi* slot-match? ; - -: hour-match? ( now when -- ? ) - [ timestamp-hour ] [ when-hour ] bi* slot-match? ; - -: day-of-month-match? ( now when -- ? ) - [ timestamp-day ] [ when-day-of-month ] bi* slot-match? ; - -: month-match? ( now when -- ? ) - [ timestamp-month ] [ when-month ] bi* slot-match? ; - -: day-of-week-match? ( now when -- ? ) - [ day-of-week ] [ when-day-of-week ] bi* slot-match? ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: when=now? ( when -- ? ) - now swap - { [ minute-match? ] - [ hour-match? ] - [ day-of-month-match? ] - [ month-match? ] - [ day-of-week-match? ] } - <--&& ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: recurring-job ( when quot -- ) - [ swap when=now? [ try ] [ drop ] if 60000 sleep ] [ recurring-job ] 2bi ; - -: schedule ( when quot -- ) [ recurring-job ] 2curry in-thread ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYMBOL: cron-jobs-hourly -SYMBOL: cron-jobs-daily -SYMBOL: cron-jobs-weekly -SYMBOL: cron-jobs-monthly - -: schedule-cron-jobs ( -- ) - { 17 } f f f f <when> [ cron-jobs-hourly get call ] schedule - { 25 } { 6 } f f f <when> [ cron-jobs-daily get call ] schedule - { 47 } { 6 } f f { 7 } <when> [ cron-jobs-weekly get call ] schedule - { 52 } { 6 } { 1 } f f <when> [ cron-jobs-monthly get call ] schedule ; - diff --git a/unmaintained/raptor/cronjobs.factor b/unmaintained/raptor/cronjobs.factor deleted file mode 100644 index 436fb8580f..0000000000 --- a/unmaintained/raptor/cronjobs.factor +++ /dev/null @@ -1,34 +0,0 @@ - -USING: kernel namespaces threads arrays sequences - raptor raptor.cron ; - -IN: raptor - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -[ - "/etc/cron.daily/apt" fork-exec-arg - "/etc/cron.daily/aptitude" fork-exec-arg - "/etc/cron.daily/bsdmainutils" fork-exec-arg - "/etc/cron.daily/find.notslocate" fork-exec-arg - "/etc/cron.daily/logrotate" fork-exec-arg - "/etc/cron.daily/man-db" fork-exec-arg - "/etc/cron.daily/ntp-server" fork-exec-arg - "/etc/cron.daily/slocate" fork-exec-arg - "/etc/cron.daily/standard" fork-exec-arg - "/etc/cron.daily/sysklogd" fork-exec-arg - "/etc/cron.daily/tetex-bin" fork-exec-arg -] cron-jobs-daily set-global - -[ - "/etc/cron.weekly/cvs" fork-exec-arg - "/etc/cron.weekly/man-db" fork-exec-arg - "/etc/cron.weekly/ntp-server" fork-exec-arg - "/etc/cron.weekly/popularity-contest" fork-exec-arg - "/etc/cron.weekly/sysklogd" fork-exec-arg -] cron-jobs-weekly set-global - -[ - "/etc/cron.monthly/scrollkeeper" fork-exec-arg - "/etc/cron.monthly/standard" fork-exec-arg -] cron-jobs-monthly set-global \ No newline at end of file diff --git a/unmaintained/raptor/raptor.factor b/unmaintained/raptor/raptor.factor deleted file mode 100755 index c0605fe837..0000000000 --- a/unmaintained/raptor/raptor.factor +++ /dev/null @@ -1,80 +0,0 @@ - -USING: kernel parser namespaces threads arrays sequences unix unix.process - bake ; - -IN: raptor - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYMBOL: boot-hook -SYMBOL: reboot-hook -SYMBOL: shutdown-hook -SYMBOL: networking-hook - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: reload-raptor-config ( -- ) - "/etc/raptor/config.factor" run-file - "/etc/raptor/cronjobs.factor" run-file ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: fork-exec-wait ( pathname args -- ) - fork dup 0 = [ drop exec drop ] [ 2nip wait-for-pid drop ] if ; - -: fork-exec-args-wait ( args -- ) [ first ] [ ] bi fork-exec-wait ; - -: fork-exec-arg ( arg -- ) 1array [ fork-exec-args-wait ] curry in-thread ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: forever ( quot -- ) [ call ] [ forever ] bi ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: start-service ( name -- ) "/etc/init.d/" " start" surround system drop ; -: stop-service ( name -- ) "/etc/init.d/" " stop" surround system drop ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: getty ( tty -- ) `{ "/sbin/getty" "38400" , } fork-exec-args-wait ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -USING: io io.files io.streams.lines io.streams.plain io.streams.duplex - listener io.encodings.utf8 ; - -: tty-listener ( tty -- ) - dup utf8 <file-reader> [ - swap utf8 <file-writer> [ - <duplex-stream> [ - listener - ] with-stream - ] with-disposal - ] with-disposal ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -USING: unix.linux.swap unix.linux.fs ; - -SYMBOL: root-device -SYMBOL: swap-devices - -: activate-swap ( -- ) swap-devices get [ 0 swapon drop ] each ; - -: mount-root ( -- ) root-device get "/" "ext3" MS_REMOUNT f mount drop ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: start-networking ( -- ) networking-hook get call ; - -: set-hostname ( name -- ) `{ "/bin/hostname" , } fork-exec-args-wait ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: boot ( -- ) boot-hook get call ; -: reboot ( -- ) reboot-hook get call ; -: shutdown ( -- ) shutdown-hook get call ; - -MAIN: boot - diff --git a/unmaintained/raptor/readme b/unmaintained/raptor/readme deleted file mode 100644 index dfb6890cda..0000000000 --- a/unmaintained/raptor/readme +++ /dev/null @@ -1,134 +0,0 @@ - -Raptor Linux - -*** Introduction *** - -Raptor Linux is a mod of Ubuntu 6.06 (Dapper Drake) - -This is unlikely to work on another version of Ubuntu, much less -another Linux distribution. - -*** Features *** - - * /sbin/init is replaced with Factor - * Virtual terminals managed by Factor - * Listeners run on virtual terminals - * Native support for static ip networking - * Crontab replacement - -*** Install *** - - # mkdir -v /etc/raptor - - # cp -v /scratch/factor/extra/raptor/{config,cronjobs}.factor /etc/raptor - - ( scratchpad ) USE: raptor - ( scratchpad ) reload-raptor-config - ( scratchpad ) save - - # mv -v /sbin/{init,init.orig} - - # cp -v /scratch/factor/factor /sbin/init - - # cp -v /scratch/factor/factor.image /sbin/init.image - -*** Filesystems *** - - # emacs /etc/raptor/config.factor - -Edit the root-device and swap-devices variables. - -*** Static IP networking *** - -If you use a static IP in your network then Factor can take care of -networking. - - # emacs /etc/raptor/config.factor - - (change the settings accordingly) - -The udev system has a hook to bring up ethernet interfaces when they -are detected. Let's remove this hook since we'll be bringing up the -interface. Actually, we'll move it, not delete it. - - # mv -v /etc/udev/rules.d/85-ifupdown.rules /root - -*** DHCP networking *** - -If you're using dhcp then we'll fall back on what Ubuntu offers. In -your config.factor change the line : - - start-networking - -to - - "loopback" start-service - "networking" start-service - -Add these to your reboot-hook and shutdown-hook : - - "loopback" stop-service - "networking" stop-service - -*** Editing the hooks *** - -The items in boot-hook correspond to the things in '/etc/rcS.d' and -'/etc/rc2.d'. Feel free to add and remove items from that hook. For -example, I removed the printer services. I also removed other things -that I didn't feel were necessary on my system. - -Look for the line with the call to 'set-hostname' and edit it appropriately. - -*** Grub *** - -Edit your '/boot/grub/menu.lst'. Basically, copy and paste your -current good entry. My default entry is this: - -title Ubuntu, kernel 2.6.15-28-686 -root (hd0,0) -kernel /boot/vmlinuz-2.6.15-28-686 root=/dev/hda1 ro quiet splash -initrd /boot/initrd.img-2.6.15-28-686 -savedefault -boot - -I pasted a copy above it and edited it to look like this: - -title Raptor, kernel 2.6.15-28-686 -root (hd0,0) -kernel /boot/vmlinuz-2.6.15-28-686 root=/dev/hda1 ro quiet -run=ubuntu.dapper.boot -initrd /boot/initrd.img-2.6.15-28-686 -savedefault -boot - -* Note that I removed the 'splash' kernel option - -* Note the '-run=ubuntu.dapper.boot' option. Unfortunately, this isn't - working yet... - -*** Boot *** - -Reboot or turn on your computer. Eventually, hopefully, you'll be at a -Factor prompt. Boot your system: - - ( scratchpad ) boot - -You'll probably be prompted to select a vocab. Select 'raptor'. - -*** Now what *** - -The virtual consoles are allocated like so: - - 1 - Main listener console - 2 - listener - 3 - listener - 4 - listener - 5 - getty - 6 - getty - -So you're next step might be to alt-f5, login, and run startx. - -*** Join the fun *** - -Take a loot at what happens during run levels S and 2. Implement a -Factor version of something. Let me know about it. - diff --git a/unmaintained/raptor/tags.txt b/unmaintained/raptor/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/unmaintained/raptor/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/unmaintained/route/authors.txt b/unmaintained/route/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/route/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/route/route.factor b/unmaintained/route/route.factor deleted file mode 100644 index 4d9bbfae99..0000000000 --- a/unmaintained/route/route.factor +++ /dev/null @@ -1,55 +0,0 @@ - -USING: alien.syntax ; - -IN: unix.linux.route - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -C-STRUCT: struct-rtentry - { "ulong" "rt_pad1" } - { "struct-sockaddr" "rt_dst" } - { "struct-sockaddr" "rt_gateway" } - { "struct-sockaddr" "rt_genmask" } - { "ushort" "rt_flags" } - { "short" "rt_pad2" } - { "ulong" "rt_pad3" } - { "uchar" "rt_tos" } - { "uchar" "rt_class" } - { "short" "rt_pad4" } - { "short" "rt_metric" } - { "char*" "rt_dev" } - { "ulong" "rt_mtu" } - { "ulong" "rt_window" } - { "ushort" "rt_irtt" } ; - -: RTF_UP HEX: 0001 ; ! Route usable. -: RTF_GATEWAY HEX: 0002 ; ! Destination is a gateway. - -: RTF_HOST HEX: 0004 ; ! Host entry (net otherwise). -: RTF_REINSTATE HEX: 0008 ; ! Reinstate route after timeout. -: RTF_DYNAMIC HEX: 0010 ; ! Created dyn. (by redirect). -: RTF_MODIFIED HEX: 0020 ; ! Modified dyn. (by redirect). -: RTF_MTU HEX: 0040 ; ! Specific MTU for this route. -: RTF_MSS RTF_MTU ; ! Compatibility. -: RTF_WINDOW HEX: 0080 ; ! Per route window clamping. -: RTF_IRTT HEX: 0100 ; ! Initial round trip time. -: RTF_REJECT HEX: 0200 ; ! Reject route. -: RTF_STATIC HEX: 0400 ; ! Manually injected route. -: RTF_XRESOLVE HEX: 0800 ; ! External resolver. -: RTF_NOFORWARD HEX: 1000 ; ! Forwarding inhibited. -: RTF_THROW HEX: 2000 ; ! Go to next class. -: RTF_NOPMTUDISC HEX: 4000 ; ! Do not send packets with DF. - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -USING: kernel alien.c-types io.sockets - unix unix.linux.sockios ; - -: route ( dst gateway genmask flags -- ) - >r >r >r >r - "struct-rtentry" <c-object> - r> 0 <inet4> make-sockaddr over set-struct-rtentry-rt_dst - r> 0 <inet4> make-sockaddr over set-struct-rtentry-rt_gateway - r> 0 <inet4> make-sockaddr over set-struct-rtentry-rt_genmask - r> over set-struct-rtentry-rt_flags - AF_INET SOCK_DGRAM 0 socket SIOCADDRT rot ioctl drop ; diff --git a/unmaintained/route/tags.txt b/unmaintained/route/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/unmaintained/route/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/unmaintained/sequences-lib/authors.txt b/unmaintained/sequences-lib/authors.txt deleted file mode 100644 index 07c1c4a765..0000000000 --- a/unmaintained/sequences-lib/authors.txt +++ /dev/null @@ -1,2 +0,0 @@ -Eduardo Cavazos -Doug Coleman diff --git a/unmaintained/sequences-lib/lib-docs.factor b/unmaintained/sequences-lib/lib-docs.factor deleted file mode 100755 index e279230b1b..0000000000 --- a/unmaintained/sequences-lib/lib-docs.factor +++ /dev/null @@ -1,29 +0,0 @@ -USING: help.syntax help.markup kernel prettyprint sequences -quotations math ; -IN: sequences.lib - -HELP: map-withn -{ $values { "seq" sequence } { "quot" quotation } { "n" number } { "newseq" sequence } } -{ $description "A generalisation of " { $link map } ". The first " { $snippet "n" } " items after the quotation will be " -"passed to the quotation given to map-withn for each element in the sequence." -} -{ $examples - { $example "USING: math sequences.lib prettyprint ;" "1 2 3 4 { 6 7 8 9 10 } [ + + + + ] 4 map-withn .s" "{ 16 17 18 19 20 }" } -} -{ $see-also each-withn } ; - -HELP: each-withn -{ $values { "seq" sequence } { "quot" quotation } { "n" number } } -{ $description "A generalisation of " { $link each } ". The first " { $snippet "n" } " items after the quotation will be " -"passed to the quotation given to each-withn for each element in the sequence." -} -{ $see-also map-withn } ; - -HELP: randomize -{ $values { "seq" sequence } { "seq'" sequence } } -{ $description "Shuffle the elements in the sequence randomly, returning the new sequence." } ; - -HELP: enumerate -{ $values { "seq" sequence } { "seq'" sequence } } -{ $description "Returns a new sequence where each element is an array of { index, value }" } ; - diff --git a/unmaintained/sequences-lib/lib-tests.factor b/unmaintained/sequences-lib/lib-tests.factor deleted file mode 100755 index 509d9b1432..0000000000 --- a/unmaintained/sequences-lib/lib-tests.factor +++ /dev/null @@ -1,58 +0,0 @@ -USING: arrays kernel sequences sequences.lib math math.functions math.ranges - tools.test strings ; -IN: sequences.lib.tests - -[ 1 2 { 3 4 } [ + + drop ] 2 each-withn ] must-infer -{ 13 } [ 1 2 { 3 4 } [ + + ] 2 each-withn + ] unit-test - -[ 1 2 { 3 4 } [ + + ] 2 map-withn ] must-infer -{ { 6 7 } } [ 1 2 { 3 4 } [ + + ] 2 map-withn ] unit-test -{ { 16 17 18 19 20 } } [ 1 2 3 4 { 6 7 8 9 10 } [ + + + + ] 4 map-withn ] unit-test -[ { 910 911 912 } ] [ 10 900 3 [ + + ] map-with2 ] unit-test - -[ 10 ] [ { 1 2 3 4 } [ + ] reduce* ] unit-test -[ 24 ] [ { 1 2 3 4 } [ * ] reduce* ] unit-test - -[ -4 ] [ 1 -4 [ abs ] higher ] unit-test -[ 1 ] [ 1 -4 [ abs ] lower ] unit-test - -[ { 1 2 3 4 } ] [ { { 1 2 3 4 } { 1 2 3 } } longest ] unit-test -[ { 1 2 3 4 } ] [ { { 1 2 3 } { 1 2 3 4 } } longest ] unit-test - -[ { 1 2 3 } ] [ { { 1 2 3 4 } { 1 2 3 } } shortest ] unit-test -[ { 1 2 3 } ] [ { { 1 2 3 } { 1 2 3 4 } } shortest ] unit-test - -[ 3 ] [ 1 3 bigger ] unit-test -[ 1 ] [ 1 3 smaller ] unit-test - -[ "abd" ] [ "abc" "abd" bigger ] unit-test -[ "abc" ] [ "abc" "abd" smaller ] unit-test - -[ "abe" ] [ { "abc" "abd" "abe" } biggest ] unit-test -[ "abc" ] [ { "abc" "abd" "abe" } smallest ] unit-test - -[ 1 3 ] [ { 1 2 3 } minmax ] unit-test -[ -11 -9 ] [ { -11 -10 -9 } minmax ] unit-test -[ -1/0. 1/0. ] [ { -1/0. 1/0. -11 -10 -9 } minmax ] unit-test - -[ { { 1 } { -1 5 } { 2 4 } } ] -[ { 1 -1 5 2 4 } [ < ] monotonic-split [ >array ] map ] unit-test -[ { { 1 1 1 1 } { 2 2 } { 3 } { 4 } { 5 } { 6 6 6 } } ] -[ { 1 1 1 1 2 2 3 4 5 6 6 6 } [ = ] monotonic-split [ >array ] map ] unit-test - -[ { 1 9 25 } ] [ { 1 3 5 6 } [ sq ] [ even? ] map-until ] unit-test -[ { 2 4 } ] [ { 2 4 1 3 } [ even? ] take-while ] unit-test - -[ { { 0 0 } { 1 0 } { 0 1 } { 1 1 } } ] [ 2 2 exact-strings ] unit-test -[ t ] [ "ab" 4 strings [ >string ] map "abab" swap member? ] unit-test -[ { { } { 1 } { 2 } { 1 2 } } ] [ { 1 2 } power-set ] unit-test - -[ 1 2 { 3 4 } [ + + ] 2 map-withn ] must-infer -{ { 6 7 } } [ 1 2 { 3 4 } [ + + ] 2 map-withn ] unit-test -{ { 16 17 18 19 20 } } [ 1 2 3 4 { 6 7 8 9 10 } [ + + + + ] 4 map-withn ] unit-test -[ 1 2 { 3 4 } [ + + drop ] 2 each-withn ] must-infer -{ 13 } [ 1 2 { 3 4 } [ + + ] 2 each-withn + ] unit-test -[ { 910 911 912 } ] [ 10 900 3 [ + + ] map-with2 ] unit-test - -[ { { 0 1 } { 1 2 } { 2 3 } } ] [ { 1 2 3 } enumerate ] unit-test - diff --git a/unmaintained/sequences-lib/lib.factor b/unmaintained/sequences-lib/lib.factor deleted file mode 100755 index 72944c09b4..0000000000 --- a/unmaintained/sequences-lib/lib.factor +++ /dev/null @@ -1,149 +0,0 @@ -! Copyright (C) 2007 Slava Pestov, Chris Double, Doug Coleman, -! Eduardo Cavazos, Daniel Ehrenberg. -! See http://factorcode.org/license.txt for BSD license. -USING: combinators.lib kernel sequences math namespaces make -assocs random sequences.private shuffle math.functions arrays -math.parser math.private sorting strings ascii macros assocs.lib -quotations hashtables math.order locals generalizations -math.ranges random fry ; -IN: sequences.lib - -: each-withn ( seq quot n -- ) nwith each ; inline - -: each-with ( seq quot -- ) with each ; inline - -: each-with2 ( obj obj list quot -- ) 2 each-withn ; inline - -: map-withn ( seq quot n -- newseq ) nwith map ; inline - -: map-with ( seq quot -- ) with map ; inline - -: map-with2 ( obj obj list quot -- newseq ) 2 map-withn ; inline - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: each-percent ( seq quot -- ) - [ - dup length - dup [ / ] curry - [ 1+ ] prepose - ] dip compose - 2each ; inline - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: reduce* ( seq quot -- result ) [ ] swap map-reduce ; inline - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: higher ( a b quot -- c ) [ compare +gt+ eq? ] curry most ; inline - -: lower ( a b quot -- c ) [ compare +lt+ eq? ] curry most ; inline - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: longer ( a b -- c ) [ length ] higher ; - -: shorter ( a b -- c ) [ length ] lower ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: longest ( seq -- item ) [ longer ] reduce* ; - -: shortest ( seq -- item ) [ shorter ] reduce* ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: bigger ( a b -- c ) [ ] higher ; - -: smaller ( a b -- c ) [ ] lower ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: biggest ( seq -- item ) [ bigger ] reduce* ; - -: smallest ( seq -- item ) [ smaller ] reduce* ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: minmax ( seq -- min max ) - #! find the min and max of a seq in one pass - 1/0. -1/0. rot [ tuck max [ min ] dip ] each ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: ,, ( obj -- ) building get peek push ; -: v, ( -- ) V{ } clone , ; -: ,v ( -- ) building get dup peek empty? [ dup pop* ] when drop ; - -: (monotonic-split) ( seq quot -- newseq ) - [ - [ dup unclip suffix ] dip - v, [ pick ,, call [ v, ] unless ] curry 2each ,v - ] { } make ; - -: monotonic-split ( seq quot -- newseq ) - over empty? [ 2drop { } ] [ (monotonic-split) ] if ; - -ERROR: element-not-found ; -: split-around ( seq quot -- before elem after ) - dupd find over [ element-not-found ] unless - [ cut rest ] dip swap ; inline - -: map-until ( seq quot pred -- newseq ) - '[ [ @ dup @ [ drop t ] [ , f ] if ] find 2drop ] { } make ; - -: take-while ( seq quot -- newseq ) - [ not ] compose - [ find drop [ head-slice ] when* ] curry - [ dup ] prepose keep like ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -<PRIVATE -: translate-string ( n alphabet out-len -- seq ) - [ drop /mod ] with map nip ; - -: map-alphabet ( alphabet seq[seq] -- seq[seq] ) - [ [ swap nth ] with map ] with map ; - -: exact-number-strings ( n out-len -- seqs ) - [ ^ ] 2keep [ translate-string ] 2curry map ; - -: number-strings ( n max-length -- seqs ) - 1+ [ exact-number-strings ] with map concat ; -PRIVATE> - -: exact-strings ( alphabet length -- seqs ) - [ dup length ] dip exact-number-strings map-alphabet ; - -: strings ( alphabet length -- seqs ) - [ dup length ] dip number-strings map-alphabet ; - -: switches ( seq1 seq -- subseq ) - ! seq1 is a sequence of ones and zeroes - [ [ length ] keep [ nth 1 = ] curry filter ] dip - [ nth ] curry { } map-as ; - -: power-set ( seq -- subsets ) - 2 over length exact-number-strings swap [ switches ] curry map ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -<PRIVATE -: (attempt-each-integer) ( i n quot -- result ) - [ - iterate-step roll - [ 3nip ] [ iterate-next (attempt-each-integer) ] if* - ] [ 3drop f ] if-iterate? ; inline recursive -PRIVATE> - -: attempt-each ( seq quot -- result ) - (each) iterate-prep (attempt-each-integer) ; inline - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: randomize ( seq -- seq' ) - dup length 1 (a,b] [ dup random pick exchange ] each ; - -: enumerate ( seq -- seq' ) <enum> >alist ; diff --git a/unmaintained/sequences-lib/summary.txt b/unmaintained/sequences-lib/summary.txt deleted file mode 100644 index e389b415ca..0000000000 --- a/unmaintained/sequences-lib/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Non-core sequence words diff --git a/unmaintained/sequences-lib/tags.txt b/unmaintained/sequences-lib/tags.txt deleted file mode 100644 index 42d711b32b..0000000000 --- a/unmaintained/sequences-lib/tags.txt +++ /dev/null @@ -1 +0,0 @@ -collections diff --git a/unmaintained/sockios/authors.txt b/unmaintained/sockios/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/sockios/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/sockios/sockios.factor b/unmaintained/sockios/sockios.factor deleted file mode 100644 index fd1bb10e2e..0000000000 --- a/unmaintained/sockios/sockios.factor +++ /dev/null @@ -1,64 +0,0 @@ - -IN: unix.linux.sockios - -! Imported from linux-headers-2.6.15-28-686 on Ubuntu 6.06 - -! Routing table calls -: SIOCADDRT HEX: 890B ; ! add routing table entry -: SIOCDELRT HEX: 890C ; ! delete routing table entry -: SIOCRTMSG HEX: 890D ; ! call to routing system - -! Socket configuration controls - -: SIOCGIFNAME HEX: 8910 ; ! get iface name -: SIOCSIFLINK HEX: 8911 ; ! set iface channel -: SIOCGIFCONF HEX: 8912 ; ! get iface list -: SIOCGIFFLAGS HEX: 8913 ; ! get flags -: SIOCSIFFLAGS HEX: 8914 ; ! set flags -: SIOCGIFADDR HEX: 8915 ; ! get PA address -: SIOCSIFADDR HEX: 8916 ; ! set PA address -: SIOCGIFDSTADDR HEX: 8917 ; ! get remote PA address -: SIOCSIFDSTADDR HEX: 8918 ; ! set remote PA address -: SIOCGIFBRDADDR HEX: 8919 ; ! get broadcast PA address -: SIOCSIFBRDADDR HEX: 891a ; ! set broadcast PA address -: SIOCGIFNETMASK HEX: 891b ; ! get network PA mask -: SIOCSIFNETMASK HEX: 891c ; ! set network PA mask -: SIOCGIFMETRIC HEX: 891d ; ! get metric -: SIOCSIFMETRIC HEX: 891e ; ! set metric -: SIOCGIFMEM HEX: 891f ; ! get memory address (BSD) -: SIOCSIFMEM HEX: 8920 ; ! set memory address (BSD) -: SIOCGIFMTU HEX: 8921 ; ! get MTU size -: SIOCSIFMTU HEX: 8922 ; ! set MTU size -: SIOCSIFNAME HEX: 8923 ; ! set interface name -: SIOCSIFHWADDR HEX: 8924 ; ! set hardware address -: SIOCGIFENCAP HEX: 8925 ; ! get/set encapsulations -: SIOCSIFENCAP HEX: 8926 ; -: SIOCGIFHWADDR HEX: 8927 ; ! Get hardware address -: SIOCGIFSLAVE HEX: 8929 ; ! Driver slaving support -: SIOCSIFSLAVE HEX: 8930 ; -: SIOCADDMULTI HEX: 8931 ; ! Multicast address lists -: SIOCDELMULTI HEX: 8932 ; -: SIOCGIFINDEX HEX: 8933 ; ! name -> if_index mapping -: SIOGIFINDEX SIOCGIFINDEX ; ! misprint compatibility :-) -: SIOCSIFPFLAGS HEX: 8934 ; ! set/get extended flags set -: SIOCGIFPFLAGS HEX: 8935 ; -: SIOCDIFADDR HEX: 8936 ; ! delete PA address -: SIOCSIFHWBROADCAST HEX: 8937 ; ! set hardware broadcast addr -: SIOCGIFCOUNT HEX: 8938 ; ! get number of devices - -: SIOCGIFBR HEX: 8940 ; ! Bridging support -: SIOCSIFBR HEX: 8941 ; ! Set bridging options - -: SIOCGIFTXQLEN HEX: 8942 ; ! Get the tx queue length -: SIOCSIFTXQLEN HEX: 8943 ; ! Set the tx queue length - -: SIOCGIFDIVERT HEX: 8944 ; ! Frame diversion support -: SIOCSIFDIVERT HEX: 8945 ; ! Set frame diversion options - -: SIOCETHTOOL HEX: 8946 ; ! Ethtool interface - -: SIOCGMIIPHY HEX: 8947 ; ! Get address of MII PHY in use -: SIOCGMIIREG HEX: 8948 ; ! Read MII PHY register. -: SIOCSMIIREG HEX: 8949 ; ! Write MII PHY register. - -: SIOCWANDEV HEX: 894A ; ! get/set netdev parameters diff --git a/unmaintained/sockios/tags.txt b/unmaintained/sockios/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/unmaintained/sockios/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/extra/rewrite-closures/authors.txt b/unmaintained/springies/authors.txt similarity index 100% rename from extra/rewrite-closures/authors.txt rename to unmaintained/springies/authors.txt diff --git a/extra/springies/models/2snake/2snake.factor b/unmaintained/springies/models/2snake/2snake.factor similarity index 100% rename from extra/springies/models/2snake/2snake.factor rename to unmaintained/springies/models/2snake/2snake.factor diff --git a/extra/self/authors.txt b/unmaintained/springies/models/2snake/authors.txt old mode 100644 new mode 100755 similarity index 100% rename from extra/self/authors.txt rename to unmaintained/springies/models/2snake/authors.txt diff --git a/extra/springies/models/2snake/tags.txt b/unmaintained/springies/models/2snake/tags.txt similarity index 100% rename from extra/springies/models/2snake/tags.txt rename to unmaintained/springies/models/2snake/tags.txt diff --git a/extra/springies/models/2x2snake/2x2snake.factor b/unmaintained/springies/models/2x2snake/2x2snake.factor similarity index 100% rename from extra/springies/models/2x2snake/2x2snake.factor rename to unmaintained/springies/models/2x2snake/2x2snake.factor diff --git a/extra/springies/authors.txt b/unmaintained/springies/models/2x2snake/authors.txt old mode 100644 new mode 100755 similarity index 100% rename from extra/springies/authors.txt rename to unmaintained/springies/models/2x2snake/authors.txt diff --git a/extra/springies/models/2x2snake/deploy.factor b/unmaintained/springies/models/2x2snake/deploy.factor similarity index 100% rename from extra/springies/models/2x2snake/deploy.factor rename to unmaintained/springies/models/2x2snake/deploy.factor diff --git a/extra/springies/models/2x2snake/tags.txt b/unmaintained/springies/models/2x2snake/tags.txt similarity index 100% rename from extra/springies/models/2x2snake/tags.txt rename to unmaintained/springies/models/2x2snake/tags.txt diff --git a/extra/springies/models/3snake/3snake.factor b/unmaintained/springies/models/3snake/3snake.factor similarity index 100% rename from extra/springies/models/3snake/3snake.factor rename to unmaintained/springies/models/3snake/3snake.factor diff --git a/extra/springies/models/2snake/authors.txt b/unmaintained/springies/models/3snake/authors.txt similarity index 100% rename from extra/springies/models/2snake/authors.txt rename to unmaintained/springies/models/3snake/authors.txt diff --git a/extra/springies/models/3snake/tags.txt b/unmaintained/springies/models/3snake/tags.txt similarity index 100% rename from extra/springies/models/3snake/tags.txt rename to unmaintained/springies/models/3snake/tags.txt diff --git a/extra/springies/models/2x2snake/authors.txt b/unmaintained/springies/models/ball/authors.txt similarity index 100% rename from extra/springies/models/2x2snake/authors.txt rename to unmaintained/springies/models/ball/authors.txt diff --git a/extra/springies/models/ball/ball.factor b/unmaintained/springies/models/ball/ball.factor similarity index 100% rename from extra/springies/models/ball/ball.factor rename to unmaintained/springies/models/ball/ball.factor diff --git a/extra/springies/models/ball/tags.txt b/unmaintained/springies/models/ball/tags.txt similarity index 100% rename from extra/springies/models/ball/tags.txt rename to unmaintained/springies/models/ball/tags.txt diff --git a/extra/springies/models/3snake/authors.txt b/unmaintained/springies/models/belt-tire/authors.txt similarity index 100% rename from extra/springies/models/3snake/authors.txt rename to unmaintained/springies/models/belt-tire/authors.txt diff --git a/extra/springies/models/belt-tire/belt-tire.factor b/unmaintained/springies/models/belt-tire/belt-tire.factor similarity index 100% rename from extra/springies/models/belt-tire/belt-tire.factor rename to unmaintained/springies/models/belt-tire/belt-tire.factor diff --git a/extra/springies/models/belt-tire/deploy.factor b/unmaintained/springies/models/belt-tire/deploy.factor similarity index 100% rename from extra/springies/models/belt-tire/deploy.factor rename to unmaintained/springies/models/belt-tire/deploy.factor diff --git a/extra/springies/models/belt-tire/tags.txt b/unmaintained/springies/models/belt-tire/tags.txt similarity index 100% rename from extra/springies/models/belt-tire/tags.txt rename to unmaintained/springies/models/belt-tire/tags.txt diff --git a/extra/springies/models/ball/authors.txt b/unmaintained/springies/models/nifty/authors.txt similarity index 100% rename from extra/springies/models/ball/authors.txt rename to unmaintained/springies/models/nifty/authors.txt diff --git a/extra/springies/models/nifty/nifty.factor b/unmaintained/springies/models/nifty/nifty.factor similarity index 100% rename from extra/springies/models/nifty/nifty.factor rename to unmaintained/springies/models/nifty/nifty.factor diff --git a/extra/springies/models/nifty/tags.txt b/unmaintained/springies/models/nifty/tags.txt similarity index 100% rename from extra/springies/models/nifty/tags.txt rename to unmaintained/springies/models/nifty/tags.txt diff --git a/extra/springies/models/belt-tire/authors.txt b/unmaintained/springies/models/urchin/authors.txt similarity index 100% rename from extra/springies/models/belt-tire/authors.txt rename to unmaintained/springies/models/urchin/authors.txt diff --git a/extra/springies/models/urchin/tags.txt b/unmaintained/springies/models/urchin/tags.txt similarity index 100% rename from extra/springies/models/urchin/tags.txt rename to unmaintained/springies/models/urchin/tags.txt diff --git a/extra/springies/models/urchin/urchin.factor b/unmaintained/springies/models/urchin/urchin.factor similarity index 100% rename from extra/springies/models/urchin/urchin.factor rename to unmaintained/springies/models/urchin/urchin.factor diff --git a/extra/springies/springies.factor b/unmaintained/springies/springies.factor similarity index 100% rename from extra/springies/springies.factor rename to unmaintained/springies/springies.factor diff --git a/extra/springies/summary.txt b/unmaintained/springies/summary.txt similarity index 100% rename from extra/springies/summary.txt rename to unmaintained/springies/summary.txt diff --git a/extra/springies/tags.factor b/unmaintained/springies/tags.factor similarity index 100% rename from extra/springies/tags.factor rename to unmaintained/springies/tags.factor diff --git a/extra/springies/models/nifty/authors.txt b/unmaintained/springies/ui/authors.txt similarity index 100% rename from extra/springies/models/nifty/authors.txt rename to unmaintained/springies/ui/authors.txt diff --git a/extra/springies/ui/ui.factor b/unmaintained/springies/ui/ui.factor similarity index 100% rename from extra/springies/ui/ui.factor rename to unmaintained/springies/ui/ui.factor diff --git a/extra/sto/sto.factor b/unmaintained/sto/sto.factor similarity index 100% rename from extra/sto/sto.factor rename to unmaintained/sto/sto.factor diff --git a/unmaintained/strings-lib/lib-tests.factor b/unmaintained/strings-lib/lib-tests.factor deleted file mode 100644 index 6e0ce05eaa..0000000000 --- a/unmaintained/strings-lib/lib-tests.factor +++ /dev/null @@ -1,8 +0,0 @@ -USING: kernel sequences strings.lib tools.test ; -IN: temporary - -[ "abcdefghijklmnopqrstuvwxyz" ] [ lower-alpha-chars "" like ] unit-test -[ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ] [ upper-alpha-chars "" like ] unit-test -[ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ] [ alpha-chars "" like ] unit-test -[ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ] [ alphanumeric-chars "" like ] unit-test -[ t ] [ 100 [ random-alphanumeric-char ] replicate alphanumeric-chars [ member? ] curry all? ] unit-test diff --git a/unmaintained/strings-lib/lib.factor b/unmaintained/strings-lib/lib.factor deleted file mode 100644 index 6ecca05ec8..0000000000 --- a/unmaintained/strings-lib/lib.factor +++ /dev/null @@ -1,33 +0,0 @@ -USING: math math.ranges arrays sequences kernel random splitting -strings unicode.case ; -IN: strings.lib - -: >Upper ( str -- str ) - dup empty? [ unclip ch>upper prefix ] unless ; - -: >Upper-dashes ( str -- str ) - "-" split [ >Upper ] map "-" join ; - -: lower-alpha-chars ( -- seq ) - CHAR: a CHAR: z [a,b] ; - -: upper-alpha-chars ( -- seq ) - CHAR: A CHAR: Z [a,b] ; - -: numeric-chars ( -- seq ) - CHAR: 0 CHAR: 9 [a,b] ; - -: alpha-chars ( -- seq ) - lower-alpha-chars upper-alpha-chars append ; - -: alphanumeric-chars ( -- seq ) - alpha-chars numeric-chars append ; - -: random-alpha-char ( -- ch ) - alpha-chars random ; - -: random-alphanumeric-char ( -- ch ) - alphanumeric-chars random ; - -: random-alphanumeric-string ( length -- str ) - [ random-alphanumeric-char ] "" replicate-as ; diff --git a/unmaintained/swap/authors.txt b/unmaintained/swap/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/swap/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/swap/swap.factor b/unmaintained/swap/swap.factor deleted file mode 100644 index b4edaaa8e3..0000000000 --- a/unmaintained/swap/swap.factor +++ /dev/null @@ -1,12 +0,0 @@ - -USING: alien.syntax ; - -IN: unix.linux.swap - -: SWAP_FLAG_PREFER HEX: 8000 ; ! Set if swap priority is specified. -: SWAP_FLAG_PRIO_MASK HEX: 7fff ; -: SWAP_FLAG_PRIO_SHIFT 0 ; - -FUNCTION: int swapon ( char* path, int flags ) ; - -FUNCTION: int swapoff ( char* path ) ; \ No newline at end of file diff --git a/unmaintained/swap/tags.txt b/unmaintained/swap/tags.txt deleted file mode 100644 index 6bf68304bb..0000000000 --- a/unmaintained/swap/tags.txt +++ /dev/null @@ -1 +0,0 @@ -unportable diff --git a/extra/ui/gadgets/tabs/authors.txt b/unmaintained/tabs/authors.txt similarity index 100% rename from extra/ui/gadgets/tabs/authors.txt rename to unmaintained/tabs/authors.txt diff --git a/extra/ui/gadgets/tabs/summary.txt b/unmaintained/tabs/summary.txt similarity index 100% rename from extra/ui/gadgets/tabs/summary.txt rename to unmaintained/tabs/summary.txt diff --git a/extra/ui/gadgets/tabs/tabs.factor b/unmaintained/tabs/tabs.factor similarity index 100% rename from extra/ui/gadgets/tabs/tabs.factor rename to unmaintained/tabs/tabs.factor diff --git a/extra/trails/trails.factor b/unmaintained/trails/trails.factor similarity index 100% rename from extra/trails/trails.factor rename to unmaintained/trails/trails.factor diff --git a/unmaintained/x/authors.txt b/unmaintained/x/authors.txt deleted file mode 100644 index 6cfd5da273..0000000000 --- a/unmaintained/x/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/font/authors.txt b/unmaintained/x/font/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/font/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/font/font.factor b/unmaintained/x/font/font.factor deleted file mode 100644 index 77743fa75d..0000000000 --- a/unmaintained/x/font/font.factor +++ /dev/null @@ -1,27 +0,0 @@ - -USING: kernel namespaces arrays sequences math x11.xlib - mortar slot-accessors x ; - -IN: x.font - -SYMBOL: <font> - -<font> { "dpy" "name" "id" "struct" } accessors define-independent-class - -<font> "create" !( name <font> -- font ) [ -new-empty swap >>name dpy get >>dpy -dpy get $ptr over $name XLoadQueryFont >>struct -dup $struct XFontStruct-fid >>id -] add-class-method - -<font> { - -"ascent" !( font -- ascent ) [ $struct XFontStruct-ascent ] - -"descent" !( font -- ascent ) [ $struct XFontStruct-descent ] - -"height" !( font -- ascent ) [ dup <- ascent swap <- descent + ] - -"text-width" !( font string -- width ) [ >r $struct r> dup length XTextWidth ] - -} add-methods \ No newline at end of file diff --git a/unmaintained/x/gc/authors.txt b/unmaintained/x/gc/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/gc/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/gc/gc.factor b/unmaintained/x/gc/gc.factor deleted file mode 100644 index 8db610a1ac..0000000000 --- a/unmaintained/x/gc/gc.factor +++ /dev/null @@ -1,28 +0,0 @@ - -USING: kernel namespaces arrays x11.xlib mortar mortar.sugar - slot-accessors x x.font ; - -IN: x.gc - -SYMBOL: <gc> - -<gc> { "dpy" "ptr" "font" } accessors define-independent-class - -<gc> "create" !( <gc> -- gc ) [ -new-empty dpy get >>dpy -dpy get $ptr dpy get $default-root $id 0 f XCreateGC >>ptr -"6x13" <font> new* >>font -] add-class-method - -<gc> { - -"set-subwindow-mode" !( gc mode -- gc ) - [ >r dup $dpy $ptr over $ptr r> XSetSubwindowMode drop ] - -"set-function" !( gc function -- gc ) - [ >r dup $dpy $ptr over $ptr r> XSetFunction drop ] - -"set-foreground" !( gc foreground -- gc ) - [ >r dup $dpy $ptr over $ptr r> lookup-color XSetForeground drop ] - -} add-methods \ No newline at end of file diff --git a/unmaintained/x/keysym-table/authors.txt b/unmaintained/x/keysym-table/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/keysym-table/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/keysym-table/keysym-table.factor b/unmaintained/x/keysym-table/keysym-table.factor deleted file mode 100644 index 55d2ab43cd..0000000000 --- a/unmaintained/x/keysym-table/keysym-table.factor +++ /dev/null @@ -1,45 +0,0 @@ -USING: kernel strings assocs sequences math ; - -IN: x.keysym-table - -: keysym-table ( -- table ) -H{ { HEX: FF08 "BACKSPACE" } - { HEX: FF09 "TAB" } - { HEX: FF0D "RETURN" } - { HEX: FF8D "ENTER" } - { HEX: FF1B "ESCAPE" } - { HEX: FFFF "DELETE" } - { HEX: FF50 "HOME" } - { HEX: FF51 "LEFT" } - { HEX: FF52 "UP" } - { HEX: FF53 "RIGHT" } - { HEX: FF54 "DOWN" } - { HEX: FF55 "PAGE-UP" } - { HEX: FF56 "PAGE-DOWN" } - { HEX: FF57 "END" } - { HEX: FF58 "BEGIN" } - { HEX: FFBE "F1" } - { HEX: FFBF "F2" } - { HEX: FFC0 "F3" } - { HEX: FFC1 "F4" } - { HEX: FFC2 "F5" } - { HEX: FFC3 "F6" } - { HEX: FFC4 "F7" } - { HEX: FFC5 "F8" } - { HEX: FFC6 "F9" } - { HEX: FFC7 "F10" } - { HEX: FFC8 "F11" } - { HEX: FFC9 "F12" } - { HEX: FFE1 "LEFT-SHIFT" } - { HEX: FFE2 "RIGHT-SHIFT" } - { HEX: FFE3 "LEFT-CONTROL" } - { HEX: FFE4 "RIGHT-CONTROL" } - { HEX: FFE5 "CAPSLOCK" } - { HEX: FFE9 "LEFT-ALT" } - { HEX: FFEA "RIGHT-ALT" } -} ; - -: keysym>name ( keysym -- name ) -dup keysym-table at dup [ nip ] [ drop 1string ] if ; - -: name>keysym ( name -- keysym ) keysym-table value-at ; diff --git a/unmaintained/x/pen/authors.txt b/unmaintained/x/pen/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/pen/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/pen/pen.factor b/unmaintained/x/pen/pen.factor deleted file mode 100644 index 59b8aeea44..0000000000 --- a/unmaintained/x/pen/pen.factor +++ /dev/null @@ -1,26 +0,0 @@ - -USING: kernel arrays math.vectors mortar mortar.sugar x.gc slot-accessors geom.pos ; - -IN: x.pen - -SYMBOL: <pen> - -<pen> <pos> { "window" "gc" } accessors define-simple-class - -<pen> "create" !( window <pen> -- pen ) -[ new-empty swap >>window <gc> new* >>gc 0 0 2array >>pos ] -add-class-method - -<pen> { - -"line-to" ! ( pen point -- pen ) - [ 2dup >r dup $window swap dup $gc swap $pos r> <---- draw-line >>pos ] - -"line-by" ! ( pen offset -- pen ) - [ 2dup >r dup $window swap dup $gc swap $pos dup r> v+ <---- draw-line - <-- move-by ] - -"draw-string" ! ( pen string -- pen ) - [ >r dup dup $window swap dup $gc swap $pos r> <---- draw-string ] - -} add-methods \ No newline at end of file diff --git a/unmaintained/x/widgets/authors.txt b/unmaintained/x/widgets/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/widgets/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/widgets/button/authors.txt b/unmaintained/x/widgets/button/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/widgets/button/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/widgets/button/button.factor b/unmaintained/x/widgets/button/button.factor deleted file mode 100644 index ea46b62a69..0000000000 --- a/unmaintained/x/widgets/button/button.factor +++ /dev/null @@ -1,24 +0,0 @@ - -USING: kernel combinators math x11.xlib - mortar mortar.sugar slot-accessors x.gc x.widgets.label ; - -IN: x.widgets.button - -SYMBOL: <button> - -<button> - <label> - { "action-1" "action-2" "action-3" } accessors -define-simple-class - -<button> "create" !( <button> -- button ) [ -new-empty -<gc> new* >>gc ExposureMask ButtonPressMask bitor >>mask <- init-widget -] add-class-method - -<button> "handle-button-press" !( event button -- ) [ -{ { [ over XButtonEvent-button Button1 = ] [ nip $action-1 call ] } - { [ over XButtonEvent-button Button2 = ] [ nip $action-2 call ] } - { [ over XButtonEvent-button Button3 = ] [ nip $action-3 call ] } } -cond -] add-method \ No newline at end of file diff --git a/unmaintained/x/widgets/keymenu/authors.txt b/unmaintained/x/widgets/keymenu/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/widgets/keymenu/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/widgets/keymenu/keymenu.factor b/unmaintained/x/widgets/keymenu/keymenu.factor deleted file mode 100644 index b10f8f5593..0000000000 --- a/unmaintained/x/widgets/keymenu/keymenu.factor +++ /dev/null @@ -1,65 +0,0 @@ - -USING: kernel strings arrays sequences sequences.lib math x11.xlib - mortar mortar.sugar slot-accessors x x.pen x.widgets ; - -IN: x.widgets.keymenu - -SYMBOL: <keymenu> - -<keymenu> <widget> { "items" "pen" } accessors define-simple-class - -<keymenu> "create" !( <keymenu> -- keymenu ) - [ new-empty <- keymenu-init ] -add-class-method - -: numbers-and-letters ( -- seq ) -"1234567890abcdefghijklmnopqrstuvwxyz" [ 1string ] { } map-as ; - -<keymenu> { - -"keymenu-init" !( keymenu -- keymenu ) [ - dup <pen> new* >>pen - ExposureMask KeyPressMask bitor >>mask - <- init-widget -] - -"item-labels" !( keymenu -- labels ) [ $items [ first ] map ] - -"item-actions" !( keymenu -- actions ) [ $items [ second ] map ] - -"keymenu-labels" !( keymenu -- seq ) -[ numbers-and-letters swap <- item-labels [ " - " swap 3append ] 2map ] - -"reset-pen" !( keymenu -- keymenu ) [ - dup $pen - 1 <-- set-x - dup $gc $font <- ascent 1+ <-- set-y - drop ] - -"handle-expose" !( event keymenu -- ) [ - nip - <- reset-pen - dup $pen swap <- keymenu-labels - [ <-- draw-string dup $gc $font <- height <-- move-by-y ] each drop ] - -"keymenu-handle-key-press" !( event keymenu -- ) [ - swap 0 key-event-to-string numbers-and-letters index - [ swap <- item-actions ?nth [ call ] when* ] - [ drop ] - if* ] - -"handle-key-press" !( event keymenu -- ) [ <- keymenu-handle-key-press ] - -"calc-height" !( keymenu -- height ) - [ dup $items length swap $pen $gc $font <- height * ] - -"calc-width" !( keymenu -- width ) - [ dup $pen $gc $font - swap $items [ first " " append ] map - dup empty? [ drop "" ] [ longest ] if - <-- text-width ] - -"calc-size" !( keymenu -- size ) - [ dup <- calc-width swap <- calc-height 2array ] - -} add-methods \ No newline at end of file diff --git a/unmaintained/x/widgets/label/authors.txt b/unmaintained/x/widgets/label/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/widgets/label/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/widgets/label/label.factor b/unmaintained/x/widgets/label/label.factor deleted file mode 100644 index 39eff20221..0000000000 --- a/unmaintained/x/widgets/label/label.factor +++ /dev/null @@ -1,16 +0,0 @@ - -USING: kernel x11.xlib mortar mortar.sugar slot-accessors x.gc x.widgets ; - -IN: x.widgets.label - -SYMBOL: <label> - -<label> <widget> { "gc" "text" } accessors define-simple-class - -<label> "create" !( text <label> -- label ) [ -new-empty swap >>text <gc> new* >>gc ExposureMask >>mask <- init-widget -] add-class-method - -<label> "handle-expose" !( event label -- ) [ - nip <- clear dup $gc { 20 20 } pick $text <---- draw-string -] add-method diff --git a/unmaintained/x/widgets/widgets.factor b/unmaintained/x/widgets/widgets.factor deleted file mode 100644 index d8c28f5d64..0000000000 --- a/unmaintained/x/widgets/widgets.factor +++ /dev/null @@ -1,38 +0,0 @@ - -USING: kernel io namespaces arrays sequences combinators math x11.xlib - mortar slot-accessors x ; - -IN: x.widgets - -SYMBOL: <widget> - -<widget> <window> { "mask" } accessors define-simple-class - -<widget> { - -"init-widget" !( widget -- widget ) - [ <- init-window <- add-to-window-table dup $mask <-- select-input ] - -"add-to-window-table" !( window -- window ) - [ dup $dpy over <-- add-to-window-table ] - -"remove-from-window-table" !( window -- window ) - [ dup $dpy over <-- remove-from-window-table ] - -"handle-event" !( event widget -- ) [ - over XAnyEvent-type - { { [ dup Expose = ] [ drop <- handle-expose ] } - { [ dup KeyPress = ] [ drop <- handle-key-press ] } - { [ dup ButtonPress = ] [ drop <- handle-button-press ] } - { [ dup EnterNotify = ] [ drop <- handle-enter-window ] } - { [ dup DestroyNotify = ] [ drop <- handle-destroy-window ] } - { [ dup MapRequest = ] [ drop <- handle-map-request ] } - { [ dup MapNotify = ] [ drop <- handle-map ] } - { [ dup ConfigureRequest = ] [ drop <- handle-configure-request ] } - { [ dup UnmapNotify = ] [ drop <- handle-unmap ] } - { [ dup PropertyNotify = ] [ drop <- handle-property ] } - { [ t ] [ "handle-event :: ignoring event" - print flush 3drop ] } - } cond ] - -} add-methods \ No newline at end of file diff --git a/unmaintained/x/widgets/wm/child/authors.txt b/unmaintained/x/widgets/wm/child/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/widgets/wm/child/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/widgets/wm/child/child.factor b/unmaintained/x/widgets/wm/child/child.factor deleted file mode 100644 index c0c6f9da57..0000000000 --- a/unmaintained/x/widgets/wm/child/child.factor +++ /dev/null @@ -1,23 +0,0 @@ - -USING: kernel io namespaces arrays sequences - x11.xlib mortar slot-accessors x x.widgets ; - -IN: x.widgets.wm.child - -SYMBOL: <wm-child> - -<wm-child> <widget> { } define-simple-class - -<wm-child> "create" !( id <wm-child> -- wm-child ) [ - new-empty swap >>id dpy get >>dpy PropertyChangeMask >>mask - <- add-to-save-set - 0 <-- set-border-width - <- add-to-window-table - dup $mask <-- select-input -] add-class-method - -<wm-child> "handle-property" !( event wm-child -- ) [ - drop - "child handle-property :: atom name = " write - XPropertyEvent-atom get-atom-name print flush -] add-method \ No newline at end of file diff --git a/unmaintained/x/widgets/wm/frame/authors.txt b/unmaintained/x/widgets/wm/frame/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/widgets/wm/frame/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/widgets/wm/frame/drag/authors.txt b/unmaintained/x/widgets/wm/frame/drag/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/widgets/wm/frame/drag/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/widgets/wm/frame/drag/drag.factor b/unmaintained/x/widgets/wm/frame/drag/drag.factor deleted file mode 100644 index 0c6cabf2b1..0000000000 --- a/unmaintained/x/widgets/wm/frame/drag/drag.factor +++ /dev/null @@ -1,24 +0,0 @@ - -USING: kernel namespaces arrays sequences combinators math.vectors - x11.xlib x11.constants - mortar slot-accessors x x.gc geom.rect ; - -IN: x.widgets.wm.frame.drag - -SYMBOL: <wm-frame-drag> - -<wm-frame-drag> - { "dpy" "gc" "frame" "event" "push" "posn" } accessors -define-independent-class - -<wm-frame-drag> { - -"next-event" !( wfdm -- wfdm ) [ dup $dpy over $event <-- next-event 2drop ] - -"event-type" !( wfdm -- wfdm event-type ) [ dup $event XAnyEvent-type ] - -"drag-offset" !( wfdm -- offset ) [ dup $posn swap $push v- ] - -"update-posn" !( wfd -- wfd ) [ dup $event XMotionEvent-root-position >>posn ] - -} add-methods diff --git a/unmaintained/x/widgets/wm/frame/drag/move/authors.txt b/unmaintained/x/widgets/wm/frame/drag/move/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/widgets/wm/frame/drag/move/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/widgets/wm/frame/drag/move/move.factor b/unmaintained/x/widgets/wm/frame/drag/move/move.factor deleted file mode 100644 index f29993e1d7..0000000000 --- a/unmaintained/x/widgets/wm/frame/drag/move/move.factor +++ /dev/null @@ -1,46 +0,0 @@ - -USING: kernel combinators namespaces math.vectors x11.xlib x11.constants - mortar mortar.sugar slot-accessors x x.gc x.widgets.wm.frame.drag ; - -IN: x.widgets.wm.frame.drag.move - -SYMBOL: <wm-frame-drag-move> - -<wm-frame-drag-move> <wm-frame-drag> { } define-simple-class - -<wm-frame-drag-move> "create" !( event frame <wm-frame-drag-move> -- ) [ - new-empty swap >>frame swap >>event dup $frame $dpy >>dpy - - <gc> new* - IncludeInferiors <-- set-subwindow-mode - GXxor <-- set-function - "white" <-- set-foreground - >>gc - - dup $event XButtonEvent-root-position >>push - dup $event XButtonEvent-root-position >>posn - <- draw-move-outline - <- loop -] add-class-method - -<wm-frame-drag-move> { - -"move-outline" !( wfdm -- rect ) - [ dup $frame <- as-rect swap <- drag-offset <-- move-by ] - -"draw-move-outline" !( wfdm -- wfdm ) - [ dpy get $default-root over $gc pick <- move-outline <--- draw-rect ] - -"loop" !( wfdm -- wfdm ) [ - <- next-event - { { [ <- event-type MotionNotify = ] - [ <- draw-move-outline <- update-posn <- draw-move-outline <- loop ] } - { [ <- event-type ButtonRelease = ] - [ <- draw-move-outline - dup $frame <- position over <- drag-offset v+ >r - dup $frame r> <-- move drop - dup $frame <- raise drop drop ] } - { [ t ] [ <- loop ] } } - cond ] - -} add-methods diff --git a/unmaintained/x/widgets/wm/frame/drag/size/authors.txt b/unmaintained/x/widgets/wm/frame/drag/size/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/widgets/wm/frame/drag/size/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/widgets/wm/frame/drag/size/size.factor b/unmaintained/x/widgets/wm/frame/drag/size/size.factor deleted file mode 100644 index 8dba541768..0000000000 --- a/unmaintained/x/widgets/wm/frame/drag/size/size.factor +++ /dev/null @@ -1,45 +0,0 @@ - -USING: kernel combinators namespaces math.vectors x11.xlib x11.constants - mortar mortar.sugar slot-accessors geom.rect x x.gc x.widgets.wm.frame.drag ; - -IN: x.widgets.wm.frame.drag.size - -SYMBOL: <wm-frame-drag-size> - -<wm-frame-drag-size> <wm-frame-drag> { } define-simple-class - -<wm-frame-drag-size> "create" !( event frame <wfds> -- ) [ - new-empty swap >>frame swap >>event - dup $frame $dpy >>dpy - - <gc> new* - IncludeInferiors <-- set-subwindow-mode - GXxor <-- set-function - "white" <-- set-foreground - >>gc - - dup $event XButtonEvent-root-position >>push - dup $event XButtonEvent-root-position >>posn - <- draw-size-outline <- loop -] add-class-method - -<wm-frame-drag-size> { - -"size-outline" !( wfds -- rect ) - [ dup $frame <- position swap $posn over v- <rect> new ] - -"draw-size-outline" !( wfdm -- wfdm ) - [ dup $dpy $default-root over $gc pick <- size-outline <--- draw-rect ] - -"loop" !( wfdm -- ) [ - <- next-event - { { [ <- event-type MotionNotify = ] - [ <- draw-size-outline <- update-posn <- draw-size-outline <- loop ] } - { [ <- event-type ButtonRelease = ] - [ <- draw-size-outline - dup $frame over $posn pick $frame <- position v- <-- resize - <- adjust-child drop ] } - { [ t ] [ <- loop ] } } - cond ] - -} add-methods \ No newline at end of file diff --git a/unmaintained/x/widgets/wm/frame/frame.factor b/unmaintained/x/widgets/wm/frame/frame.factor deleted file mode 100755 index d20c5bf672..0000000000 --- a/unmaintained/x/widgets/wm/frame/frame.factor +++ /dev/null @@ -1,179 +0,0 @@ - -USING: kernel io combinators namespaces quotations arrays sequences - math math.vectors - x11.xlib x11.constants - mortar mortar.sugar slot-accessors - geom.rect - math.bitwise - x x.gc x.widgets - x.widgets.button - x.widgets.wm.child - x.widgets.wm.frame.drag.move - x.widgets.wm.frame.drag.size ; - -IN: x.widgets.wm.frame - -SYMBOL: <wm-frame> - -<wm-frame> <widget> { "child" "gc" "last-state" } accessors define-simple-class - -<wm-frame> "create" !( id <wm-frame> -- wm-frame ) [ - new-empty - swap <wm-child> new* >>child - <gc> new* "white" <-- set-foreground >>gc - - { - SubstructureRedirectMask - ExposureMask - ButtonPressMask - ButtonReleaseMask - ButtonMotionMask - EnterWindowMask - ! experimental masks - SubstructureNotifyMask - } flags - >>mask - - <- init-widget - "cornflowerblue" <-- set-background - dup $child <- position <-- move - dup $child over <-- reparent drop - <- position-child - <- fit-to-child - <- make-frame-button - - <- map-subwindows - <- map -] add-class-method - -SYMBOL: WM_PROTOCOLS -SYMBOL: WM_DELETE_WINDOW - -: init-atoms ( -- ) -"WM_PROTOCOLS" 0 intern-atom WM_PROTOCOLS set -"WM_DELETE_WINDOW" 0 intern-atom WM_DELETE_WINDOW set ; - -<wm-frame> { - -"fit-to-child" !( wm-frame -- wm-frame ) - [ dup $child <- size { 10 20 } v+ <-- resize ] - -"position-child" !( wm-frame -- wm-frame ) - [ dup $child { 5 15 } <-- move drop ] - -"set-child-size" !( wm-frame size -- frame ) - [ >r dup $child r> <-- resize drop <- fit-to-child ] - -"set-child-width" !( wm-frame width -- frame ) - [ >r dup $child r> <- set-width drop <- fit-to-child ] - -"set-child-height" !( wm-frame height -- frame ) - [ >r dup $child r> <- set-height drop <- fit-to-child ] - -"adjust-child" !( wm-frame -- wm-frame ) - [ dup $child over <- size { 10 20 } v- <-- resize drop ] - -"update-title" !( wm-frame -- wm-frame ) - [ <- clear - dup >r - ! dup $gc { 5 1 } pick $child <- fetch-name <--- draw-string/top-left - dup $gc { 5 11 } pick $child <- fetch-name <---- draw-string - r> ] - -"delete-child" !( wm-frame -- wm-frame ) [ - dup $child WM_PROTOCOLS get WM_DELETE_WINDOW get <--- send-client-message - drop ] - -"drag-move" !( event wm-frame -- ) [ <wm-frame-drag-move> new* ] - -"drag-size" !( event wm-frame -- ) [ <wm-frame-drag-size> new* ] - -"make-frame-button" !( frame -- frame ) [ -<button> new* - over <-- reparent - "" >>text - over [ <- unmap drop ] curry >>action-1 - over [ <- delete-child drop ] curry >>action-3 - { 9 9 } <-- resize - NorthEastGravity <-- set-gravity - "white" <-- set-background - over <- width 9 - 5 - 3 2array <-- move - drop ] - -! !!!!!!!!!! Event handlers !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -"handle-enter-window" !( event wm-frame -- ) - [ nip $child RevertToPointerRoot CurrentTime <--- set-input-focus drop ] - -"handle-expose" !( event wm-frame -- ) [ nip <- clear <- update-title drop ] - -"handle-button-press" !( event wm-frame -- ) [ - over XButtonEvent-button - { { [ dup Button1 = ] [ drop <- drag-move ] } - { [ dup Button2 = ] [ drop <- drag-size ] } - { [ t ] [ 3drop ] } } - cond ] - -"handle-map" !( event wm-frame -- ) - [ "<wm-frame> handle-map :: ignoring values" print flush 2drop ] - -"handle-unmap" !( event wm-frame -- ) [ nip <- unmap drop ] - -"handle-destroy-window" !( event wm-frame -- ) [ - nip dup $child <- remove-from-window-table drop - <- remove-from-window-table <- destroy ] - -"handle-configure-request" !( event frame -- ) [ - { { [ over dup CWX? swap CWY? and ] - [ over XConfigureRequestEvent-position <-- move ] } - { [ over CWX? ] [ over XConfigureRequestEvent-x <-- set-x ] } - { [ over CWY? ] [ over XConfigureRequestEvent-y <-- set-y ] } - { [ t ] [ "<wm-frame> handle-configure-request :: move not requested" - print flush ] } } - cond - - { { [ over dup CWWidth? swap CWHeight? and ] - [ over XConfigureRequestEvent-size <-- set-child-size ] } - { [ over CWWidth? ] - [ over XConfigureRequestEvent-width <-- set-child-width ] } - { [ over CWHeight? ] - [ over XConfigureRequestEvent-height <-- set-child-height ] } - { [ t ] - [ "<wm-frame> handle-configure-request :: resize not requested" - print flush ] } } - cond - 2drop ] - -} add-methods - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: wm-frame-maximize ( wm-frame -- wm-frame ) -<- save-state -{ 0 0 } <-- move -dup $dpy $default-root <- size - <-- resize -<- adjust-child -<- raise ; - -: wm-frame-maximize-vertical ( wm-frame -- wm-frame ) -0 <-- set-y -dup $dpy $default-root <- height - <-- set-height -<- adjust-child ; - -<wm-frame> "save-state" !( wm-frame -- wm-frame ) [ - dup <- position - over <- size - <rect> new - >>last-state -] add-method - -<wm-frame> "restore-state" !( wm-frame -- wm-frame ) [ - dup $last-state $pos <-- move - dup $last-state $dim <-- resize - <- adjust-child -] add-method - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - diff --git a/unmaintained/x/widgets/wm/menu/authors.txt b/unmaintained/x/widgets/wm/menu/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/widgets/wm/menu/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/widgets/wm/menu/menu.factor b/unmaintained/x/widgets/wm/menu/menu.factor deleted file mode 100644 index ca79b35136..0000000000 --- a/unmaintained/x/widgets/wm/menu/menu.factor +++ /dev/null @@ -1,26 +0,0 @@ - -USING: kernel x11.constants mortar mortar.sugar slot-accessors x.widgets.keymenu ; - -IN: x.widgets.wm.menu - -SYMBOL: <wm-menu> - -<wm-menu> <keymenu> { } define-simple-class - -<wm-menu> "create" !( <wm-menu> -- wm-menu ) - [ new-empty <- keymenu-init ] -add-class-method - -<wm-menu> { - -"wm-menu-handle-key-press" !( event wm-menu -- ) - [ <- unmap <- keymenu-handle-key-press ] - -"handle-key-press" !( event wm-menu -- ) [ <- wm-menu-handle-key-press ] - -"wm-menu-popup" !( wm-menu -- wm-menu ) - [ <- map <- raise RevertToPointerRoot CurrentTime <--- set-input-focus ] - -"popup" !( wm-menu -- wm-menu ) [ <- wm-menu-popup ] - -} add-methods \ No newline at end of file diff --git a/unmaintained/x/widgets/wm/root/authors.txt b/unmaintained/x/widgets/wm/root/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/widgets/wm/root/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/widgets/wm/root/root.factor b/unmaintained/x/widgets/wm/root/root.factor deleted file mode 100755 index ff18862d05..0000000000 --- a/unmaintained/x/widgets/wm/root/root.factor +++ /dev/null @@ -1,103 +0,0 @@ - -USING: kernel io combinators namespaces arrays assocs sequences math - x11.xlib - x11.constants - vars mortar slot-accessors - x x.keysym-table x.widgets x.widgets.wm.child x.widgets.wm.frame ; - -IN: x.widgets.wm.root - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYMBOL: <wm-root> - -<wm-root> - <widget> - { "keymap" } accessors -define-simple-class - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -VAR: wm-root - -: create-wm-root ( -- ) - <wm-root> new-empty - dpy> >>dpy - dpy> $default-root $id >>id - SubstructureRedirectMask >>mask - <- add-to-window-table - SubstructureRedirectMask <-- select-input - H{ } clone >>keymap - >wm-root ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: find-in-table ( window -- object ) -dup >r $id dpy get $window-table at r> or ; - -: circulate-focus ( -- ) -dpy get $default-root <- children -[ find-in-table ] map [ <- mapped? ] filter dup length 1 > -[ reverse dup first <- lower drop - second <- raise - dup <wm-frame> is? [ $child ] [ ] if - RevertToPointerRoot CurrentTime <--- set-input-focus drop ] -[ drop ] -if ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: managed? ( id -- ? ) -dpy get $window-table values [ <wm-child> is? ] filter [ $id ] map member? ; - -: event>keyname ( event -- keyname ) lookup-keysym keysym>name ; - -: event>state-and-name ( event -- array ) -dup XKeyEvent-state swap event>keyname 2array ; - -: resolve-key-event ( keymap event -- item ) event>state-and-name swap at ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -<wm-root> { - -"handle-map-request" !( event wm-root -- ) [ - { { [ over XMapRequestEvent-window managed? ] - [ "<wm-root> handle-map-request :: window already managed" print flush - 2drop ] } - { [ t ] [ drop XMapRequestEvent-window <wm-frame> <<- create drop ] } } - cond ] - -"handle-unmap" !( event wm-root -- ) [ 2drop ] - -"handle-key-press" !( event wm-root -- ) - [ $keymap swap resolve-key-event call ] - -"grab-key" !( wm-root modifiers keyname -- wm-root modifiers keyname ) [ - 3dup name>keysym keysym-to-keycode spin - False GrabModeAsync GrabModeAsync grab-key ] - -"set-key-action" !( wm-root modifiers keyname action -- wm-root ) [ - >r <--- grab-key r> - -rot 2array pick $keymap set-at ] - -"handle-configure-request" !( event wm-root -- ) [ - $dpy over XConfigureRequestEvent-window <window> new ! event window - { { [ over dup CWX? swap CWY? and ] - [ over XConfigureRequestEvent-position <-- move ] } - { [ over CWX? ] [ over XConfigureRequestEvent-x <-- set-x ] } - { [ over CWY? ] [ over XConfigureRequestEvent-y <-- set-y ] } - { [ t ] [ "<wm-root> handle-configure-request :: move not requested" - print flush ] } } - cond - - { { [ over dup CWWidth? swap CWHeight? and ] - [ over XConfigureRequestEvent-size <-- resize ] } - { [ over CWWidth? ] [ over XConfigureRequestEvent-width <-- set-width ] } - { [ over CWHeight? ] [ over XConfigureRequestEvent-height <-- set-height ] } - { [ t ] [ "<wm-root> handle-configure-request :: resize not requested" - print flush ] } } - cond - 2drop ] - -} add-methods \ No newline at end of file diff --git a/unmaintained/x/widgets/wm/unmapped-frames-menu/authors.txt b/unmaintained/x/widgets/wm/unmapped-frames-menu/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/widgets/wm/unmapped-frames-menu/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/widgets/wm/unmapped-frames-menu/unmapped-frames-menu.factor b/unmaintained/x/widgets/wm/unmapped-frames-menu/unmapped-frames-menu.factor deleted file mode 100644 index 214d45da6c..0000000000 --- a/unmaintained/x/widgets/wm/unmapped-frames-menu/unmapped-frames-menu.factor +++ /dev/null @@ -1,41 +0,0 @@ - -USING: kernel namespaces quotations arrays assocs sequences - mortar slot-accessors x x.widgets.wm.menu x.widgets.wm.frame - vars ; - -IN: x.widgets.wm.unmapped-frames-menu - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYMBOL: <unmapped-frames-menu> - -<unmapped-frames-menu> <wm-menu> { } define-simple-class - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -VAR: unmapped-frames-menu - -: create-unmapped-frames-menu ( -- ) -<unmapped-frames-menu> - new-empty - <- keymenu-init - 1 <-- set-border-width ->unmapped-frames-menu ; - -: unmapped-frames ( -- seq ) -dpy get $window-table values -[ <wm-frame> is? ] filter [ <- mapped? not ] filter ; - -<unmapped-frames-menu> { - -"refresh" !( menu -- menu ) [ - unmapped-frames dup - [ $child <- fetch-name ] map swap - [ [ <- map ] curry ] map - [ 2array ] 2map - >>items - dup <- calc-size <-- resize ] - -"popup" !( menu -- menu ) [ <- refresh <- wm-menu-popup ] - -} add-methods \ No newline at end of file diff --git a/unmaintained/x/widgets/wm/workspace/authors.txt b/unmaintained/x/widgets/wm/workspace/authors.txt deleted file mode 100755 index 6cfd5da273..0000000000 --- a/unmaintained/x/widgets/wm/workspace/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Eduardo Cavazos diff --git a/unmaintained/x/widgets/wm/workspace/workspace.factor b/unmaintained/x/widgets/wm/workspace/workspace.factor deleted file mode 100644 index c11ad7e04d..0000000000 --- a/unmaintained/x/widgets/wm/workspace/workspace.factor +++ /dev/null @@ -1,48 +0,0 @@ - -USING: kernel namespaces namespaces.lib math sequences vars mortar -accessors slot-accessors x ; - -IN: x.widgets.wm.workspace - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -TUPLE: workspace windows ; - -C: <workspace> workspace - -VAR: workspaces - -VAR: current-workspace - -: init-workspaces ( -- ) V{ } clone >workspaces ; - -: add-workspace ( -- ) { } clone <workspace> workspaces> push ; - -: mapped-windows ( -- seq ) -dpy get $default-root <- children [ <- mapped? ] filter ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: switch-to-workspace ( n -- ) -mapped-windows current-workspace> workspaces> nth (>>windows) -mapped-windows [ <- unmap drop ] each -dup workspaces> nth windows>> [ <- map drop ] each -current-workspace set* ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: next-workspace ( -- ) -current-workspace> 1+ dup workspaces> length < -[ switch-to-workspace ] [ drop ] if ; - -: prev-workspace ( -- ) -current-workspace> 1- dup 0 >= -[ switch-to-workspace ] [ drop ] if ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: setup-workspaces ( n -- ) -workspaces> - [ drop ] - [ init-workspaces [ add-workspace ] times 0 >current-workspace ] -if ; \ No newline at end of file diff --git a/unmaintained/x/x.factor b/unmaintained/x/x.factor deleted file mode 100644 index aeb6af3ee6..0000000000 --- a/unmaintained/x/x.factor +++ /dev/null @@ -1,505 +0,0 @@ - -USING: kernel io alien alien.c-types alien.strings namespaces threads - arrays sequences assocs math vars combinators.lib - x11.constants x11.events x11.xlib mortar slot-accessors geom.rect - io.encodings.ascii ; - -IN: x - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYMBOL: <display> - -SYMBOL: <window> - -! SYMBOL: dpy - -VAR: dpy - -<display> - { "ptr" - "name" - "default-screen" - "default-root" - "default-gc" - "black-pixel" - "white-pixel" - "colormap" - "window-table" } accessors -define-independent-class - -<display> "create" !( name <display> -- display ) [ - new-empty swap >>name - dup $name dup [ ascii string>alien ] [ ] if XOpenDisplay - dup [ >>ptr ] [ "XOpenDisplay error" throw ] if - dup $ptr XDefaultScreen >>default-screen - dup $ptr XDefaultRootWindow dupd <window> new >>default-root - dup $ptr over $default-screen XDefaultGC >>default-gc - dup $ptr over $default-screen XBlackPixel >>black-pixel - dup $ptr over $default-screen XWhitePixel >>white-pixel - dup $ptr over $default-screen XDefaultColormap >>colormap - H{ } clone >>window-table - [ <- start-event-loop ] in-thread -] add-class-method - -{ "id" } accessors drop - -DEFER: check-window-table - -<display> { - -"add-to-window-table" !( display window -- ) - [ dup $id rot $window-table set-at ] - -"remove-from-window-table" !( display window -- ) - [ $id swap $window-table delete-at ] - -"next-event" !( display event -- display event ) - [ over $ptr over XNextEvent drop ] - -"events-queued" !( display mode -- n ) [ >r $ptr r> XEventsQueued ] - -"concurrent-next-event" !( display event -- display event ) - [ over QueuedAfterFlush <-- events-queued 0 > - [ <-- next-event ] [ 100 sleep <-- concurrent-next-event ] if ] - -"event-loop" !( display event -- ) -[ <-- concurrent-next-event - 2dup >r >r - dup XAnyEvent-window rot $window-table at dup - [ <- handle-event ] [ 2drop ] if - r> r> - <-- event-loop ] - -"start-event-loop" !( display -- ) [ "XEvent" <c-object> <-- event-loop ] - -"flush" !( display -- display ) [ dup $ptr XFlush drop ] - -"pointer-window" !( display -- window ) [ - dup $ptr - over $default-root $id - 0 <Window> - 0 <Window> dup >r - 0 <int> - 0 <int> - 0 <int> - 0 <int> - 0 <uint> - XQueryPointer drop - r> *Window <window> new - check-window-table ] - -} add-methods - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -<window> { "dpy" "id" } accessors define-independent-class - -: create-window ( -- window ) <window> new-empty <- init-window ; - -: create-window-from-id ( dpy id -- window ) <window> new ; - -: check-window-table ( window -- window ) - dup $id - over $dpy $window-table - at - swap or ; - -<window> "init-window" - !( window -- window ) - [ dpy get - >>dpy - dpy get $ptr - dpy get $default-root $id - 0 0 100 100 0 - dpy get $black-pixel - dpy get $white-pixel - XCreateSimpleWindow - >>id ] -add-method - -! <window> new-empty <- init - -<window> "raw" - !( window -- dpy-ptr id ) - [ dup $dpy $ptr swap $id ] -add-method - -<window> "move" - !( window point -- window ) - [ >r dup <- raw r> first2 XMoveWindow drop ] -add-method - -<window> "set-x" !( window x -- window ) [ - over <- y 2array <-- move -] add-method - -<window> "set-y" !( window y -- window ) [ - over <- x swap 2array <-- move -] add-method - -<window> "flush" - !( window -- window ) - [ dup $dpy <- flush drop ] -add-method - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! 3 - Window Functions -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! 3.3 - Creating Windows - -<window> "destroy" !( window -- window ) - [ dup <- raw XDestroyWindow drop ] -add-method - -<window> "map" - !( window -- window ) - [ dup <- raw XMapWindow drop ] -add-method - -<window> "map-subwindows" - !( window -- window ) - [ dup <- raw XMapSubwindows drop ] -add-method - -<window> "unmap" - !( window -- window ) - [ dup <- raw XUnmapWindow drop ] -add-method - -<window> "unmap-subwindows" - !( window -- window ) - [ dup <- raw XUnmapSubwindows drop ] -add-method - -! 3.7 - Configuring Windows - -<window> "resize" - !( window size -- window ) - [ >r dup <- raw r> first2 XResizeWindow drop ] -add-method - -<window> "set-width" - !( window width -- window ) - [ over <- height 2array <-- resize ] -add-method - -<window> "set-height" - !( window height -- window ) - [ over <- width swap 2array <-- resize ] -add-method - -<window> "set-border-width" - !( window n -- window ) - [ >r dup <- raw r> XSetWindowBorderWidth drop ] -add-method - -! 3.8 Changing Window Stacking Order - -<window> "raise" - !( window -- window ) - [ dup <- raw XRaiseWindow drop ] -add-method - -<window> "lower" - !( window -- window ) - [ dup <- raw XLowerWindow drop ] -add-method - -! 3.9 - Changing Window Attributes - -! : change-window-attributes ( valuemask attr window -- ) -! -rot >r >r <- raw r> r> XChangeWindowAttributes drop ; - -<window> "change-attributes" !( window valuemask attr -- window ) [ ->r >r dup <- raw r> r> XChangeWindowAttributes drop -] add-method - -DEFER: lookup-color - -<window> "set-background" - !( window color -- window ) - [ >r dup <- raw r> lookup-color XSetWindowBackground drop ] -add-method - -<window> "set-gravity" !( window gravity -- window ) [ -CWWinGravity swap -"XSetWindowAttributes" <c-object> tuck set-XSetWindowAttributes-win_gravity -<--- change-attributes -] add-method - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! 4 - Window Information Functions -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! 4.1 - Obtaining Window Information - -<window> { - -"children" !( window -- seq ) - [ <- raw 0 <uint> 0 <uint> f <void*> 0 <uint> 2dup >r >r XQueryTree drop - r> r> swap *void* swap *uint c-uint-array> - [ dpy get swap <window> new ] map ] - -"parent" !( window -- parent ) [ - dup $dpy >r - - dup $dpy $ptr - swap $id - 0 <Window> - 0 <Window> dup >r - f <void*> - 0 <uint> - XQueryTree drop - r> *Window - r> swap - <window> new - check-window-table ] - -"size" !( window -- size ) - [ <- raw 0 <Window> 0 <int> 0 <int> - 0 <uint> 0 <uint> 2dup 2array >r - 0 <uint> 0 <uint> - XGetGeometry drop r> [ *uint ] map ] - -"width" !( window -- width ) [ <- size first ] - -"height" !( window -- height ) [ <- size second ] - -"position" !( window -- position ) - [ <- raw 0 <Window> - 0 <uint> 0 <uint> 2dup 2array >r - 0 <uint> 0 <uint> 0 <uint> 0 <uint> - XGetGeometry drop r> [ *int ] map ] - -"x" !( window -- x ) [ <- position first ] - -"y" !( window -- y ) [ <- position second ] - -"as-rect" !( window -- rect ) [ dup <- position swap <- size <rect> new ] - -"attributes" !( window -- XWindowAttributes ) - [ <- raw "XWindowAttributes" <c-object> dup >r XGetWindowAttributes drop r> ] - -"map-state" !( window -- state ) [ <- attributes XWindowAttributes-map_state ] - -"mapped?" !( window -- ? ) [ <- map-state IsUnmapped = not ] - -} add-methods - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: get-atom-name ( atom -- name ) dpy get $ptr swap XGetAtomName ; - -: intern-atom ( atom-name only-if-exists? -- atom ) -dpy get $ptr -rot XInternAtom ; - -: lookup-color ( name -- pixel ) -dpy get $ptr dpy get $colormap rot -"XColor" <c-object> dup >r "XColor" <c-object> XLookupColor drop -dpy get $ptr dpy get $colormap r> dup >r XAllocColor drop r> XColor-pixel ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! 8 - Graphics Functions -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -<window> "clear" - !( window -- window ) - [ dup <- raw XClearWindow drop ] -add-method - -<window> "draw-string" - !( window gc pos string -- ) - [ >r >r >r <- raw r> $ptr r> [ >fixnum ] map first2 r> dup length - XDrawString drop ] -add-method - -! <window> "draw-string" -! !( window gc pos string -- ) -! [ >r >r >r <- raw r> $ptr r> [ >fixnum ] map first2 r> dup length -! XDrawString drop ] -! add-method - -<window> "draw-line" - !( window gc a b -- ) - [ >r >r >r <- raw r> $ptr r> first2 r> first2 XDrawLine drop ] -add-method - -<window> "draw-rect" - !( window gc rect -- ) - [ 3dup dup <- top-left swap <- top-right <---- draw-line - 3dup dup <- top-right swap <- bottom-right <---- draw-line - 3dup dup <- bottom-left swap <- bottom-right <---- draw-line - dup <- top-left swap <- bottom-left <---- draw-line ] -add-method - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! 9 - Window and Session Manager Functions -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -<window> "reparent" - !( window parent -- window ) - [ >r dup <- raw r> $id 0 0 XReparentWindow drop ] -add-method - -<window> "add-to-save-set" !( window -- window ) [ - dup <- raw XAddToSaveSet drop -] add-method - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! 10 - Events -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: XButtonEvent-root-position ( event -- position ) -dup XButtonEvent-x_root swap XButtonEvent-y_root 2array ; - -: XMotionEvent-root-position ( event -- position ) -dup XMotionEvent-x_root swap XMotionEvent-y_root 2array ; - -! Utility words for XConfigureRequestEvent - -: XConfigureRequestEvent-position ( XConfigureRequestEvent -- position ) -dup XConfigureRequestEvent-x swap XConfigureRequestEvent-y 2array ; - -: XConfigureRequestEvent-size ( XConfigureRequestEvent -- size ) -dup XConfigureRequestEvent-width swap XConfigureRequestEvent-height 2array ; - -: bit-test ( a b -- t-or-f ) bitand 0 = not ; - -: CWX? ( XConfigureRequestEvent -- bool ) -XConfigureRequestEvent-value_mask CWX bit-test ; - -: CWY? ( XConfigureRequestEvent -- bool ) -XConfigureRequestEvent-value_mask CWY bit-test ; - -: CWWidth? ( XConfigureRequestEvent -- bool ) -XConfigureRequestEvent-value_mask CWWidth bit-test ; - -: CWHeight? ( XConfigureRequestEvent -- bool ) -XConfigureRequestEvent-value_mask CWHeight bit-test ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! 11 - Event Handling Functions -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -<window> "select-input" - !( window mask -- window ) - [ >r dup <- raw r> XSelectInput drop ] -add-method - -! 11.8 - Handling Protocol Errors - -SYMBOL: error-handler-quot - -: error-handler-callback ( -- xt ) -"void" { "Display*" "XErrorEvent*" } "cdecl" -[ error-handler-quot get call ] alien-callback ; - -: set-error-handler ( quot -- ) -error-handler-quot set error-handler-callback XSetErrorHandler drop ; - -: install-default-error-handler ( -- ) -[ "X11 : error-handler called" print flush ] set-error-handler ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! 12 - Input Device Functions -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! 12.2 - Keyboard Grabbing - -: grab-key -( keycode modifiers grab-window owner-events pointer-mode keyboard-mode -- ) ->r >r >r <- raw >r -rot r> r> r> r> XGrabKey drop ; - -! 12.5 - Controlling Input Focus - -<window> "set-input-focus" !( window revert-to time -- window ) - [ >r >r dup <- raw r> r> XSetInputFocus drop ] -add-method - -: get-input-focus ( -- window ) - dpy> $ptr - 0 <Window> dup >r - 0 <int> - XGetInputFocus drop - r> *Window - dpy> swap - create-window-from-id - check-window-table ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! 14 - Inter-Client Communication Functions -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -<window> "fetch-name" !( window -- name-or-f ) - [ <- raw f <void*> dup >r XFetchName drop r> - dup *void* [ drop f ] [ *void* ascii alien>string ] if ] -add-method - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! 16 - Application Utility Functions -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -! 16.1 - Using Keyboard Utility Functions - -! this should go in xlib.factor - -USING: alien.syntax ; - -FUNCTION: KeyCode XKeysymToKeycode ( Display* display, KeySym keysym ) ; - -FUNCTION: KeySym XKeycodeToKeysym ( Display* display, - KeyCode keycode, - int index ) ; - -FUNCTION: char* XKeysymToString ( KeySym keysym ) ; - -: keysym-to-keycode ( keysym -- keycode ) dpy get $ptr swap XKeysymToKeycode ; - -USE: strings - -: lookup-string* ( event -- keysym string ) -10 "char" <c-array> dup >r 10 0 <KeySym> dup >r f XLookupString -r> *KeySym swap r> swap c-char-array> >string ; - -: lookup-string ( event -- string ) lookup-string* nip ; - -: lookup-keysym ( event -- keysym ) lookup-string* drop ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!7 - -: event-to-keysym ( event index -- keysym ) ->r dup XKeyEvent-display swap XKeyEvent-keycode r> XKeycodeToKeysym ; - -: keysym-to-string ( keysym -- string ) XKeysymToString ; - -: key-event-to-string ( event index -- str ) event-to-keysym keysym-to-string ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! Misc -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: no-modifiers ( -- mask ) 0 ; - -: control-alt ( -- mask ) ControlMask Mod1Mask bitor ; - -: alt ( -- mask ) Mod1Mask ; - -: True 1 ; -: False 0 ; - -<window> "send-client-message" !( window message-type data -- window ) [ - -"XClientMessageEvent" <c-object> - -tuck set-XClientMessageEvent-data0 -tuck set-XClientMessageEvent-message_type -over $id over set-XClientMessageEvent-window -ClientMessage over set-XClientMessageEvent-type -32 over set-XClientMessageEvent-format -CurrentTime over set-XClientMessageEvent-data1 - ->r dup <- raw False NoEventMask r> XSendEvent drop - -] add-method \ No newline at end of file