t load-help? set-global
- [ drop ] load-vocab-hook [
+ [ vocab ] load-vocab-hook [
dictionary get values
[ docs-loaded?>> not ] filter
[ load-docs ] each
"tools.deploy.shaker" run
] [
"staging" get [
- "resource:basis/bootstrap/finish-staging.factor" run-file
+ "vocab:bootstrap/finish-staging.factor" run-file
] [
- "resource:basis/bootstrap/finish-bootstrap.factor" run-file
+ "vocab:bootstrap/finish-bootstrap.factor" run-file
] if
"output-image" get save-image-and-exit
drop
[
load-help? off
- "resource:basis/bootstrap/bootstrap-error.factor" run-file
+ "vocab:bootstrap/bootstrap-error.factor" run-file
] with-scope
] recover
: c-area-size ( -- n ) 10 bootstrap-cells ;
: lr-save ( -- n ) bootstrap-cell ;
-<< "resource:basis/cpu/ppc/bootstrap.factor" parse-file parsed >>
+<< "vocab:cpu/ppc/bootstrap.factor" parse-file parsed >>
call
: c-area-size ( -- n ) 14 bootstrap-cells ;
: lr-save ( -- n ) 2 bootstrap-cells ;
-<< "resource:basis/cpu/ppc/bootstrap.factor" parse-file parsed >>
+<< "vocab:cpu/ppc/bootstrap.factor" parse-file parsed >>
call
(JMP) drop
] rc-relative rt-primitive 1 jit-primitive jit-define
-<< "resource:basis/cpu/x86/bootstrap.factor" parse-file parsed >>
+<< "vocab:cpu/x86/bootstrap.factor" parse-file parsed >>
call
temp1 JMP ! go
] rc-absolute-cell rt-primitive 1 rex-length + jit-primitive jit-define
-<< "resource:basis/cpu/x86/bootstrap.factor" parse-file parsed >>
+<< "vocab:cpu/x86/bootstrap.factor" parse-file parsed >>
call
: stack-frame-size ( -- n ) 4 bootstrap-cells ;
: arg ( -- reg ) RDI ;
-<< "resource:basis/cpu/x86/64/bootstrap.factor" parse-file parsed >>
+<< "vocab:cpu/x86/64/bootstrap.factor" parse-file parsed >>
call
: stack-frame-size ( -- n ) 8 bootstrap-cells ;
: arg ( -- reg ) RCX ;
-<< "resource:basis/cpu/x86/64/bootstrap.factor" parse-file parsed >>
+<< "vocab:cpu/x86/64/bootstrap.factor" parse-file parsed >>
call
M: topic url-of topic>filename ;
: help-stylesheet ( -- string )
- "resource:basis/help/html/stylesheet.css" ascii file-contents
+ "vocab:help/html/stylesheet.css" ascii file-contents
[XML <style><-></style> XML] ;
: help>html ( topic -- xml )
"?>" split1 nip ; inline
: test-template ( name -- template )
- "resource:basis/html/templates/chloe/test/"
+ "vocab:html/templates/chloe/test/"
prepend <chloe> ;
[ "Hello world" ] [
IN: html.templates.fhtml.tests
: test-template ( path -- ? )
- "resource:basis/html/templates/fhtml/test/"
+ "vocab:html/templates/fhtml/test/"
prepend
[ ".fhtml" append <fhtml> [ call-template ] with-string-writer ]
[ ".html" append utf8 file-contents ] bi
<dispatcher>
add-quit-action
<dispatcher>
- "resource:basis/http/test" <static> >>default
+ "vocab:http/test" <static> >>default
"nested" add-responder
<action>
[ URL" redirect-loop" <temporary-redirect> ] >>display
>url clone "port" get >>port ;
[ t ] [
- "resource:basis/http/test/foo.html" ascii file-contents
+ "vocab:http/test/foo.html" ascii file-contents
"http://localhost/nested/foo.html" add-port http-get nip =
] unit-test
IN: images.bitmap.tests
: test-bitmap24 ( -- path )
- "resource:basis/images/test-images/thiswayup24.bmp" ;
+ "vocab:images/test-images/thiswayup24.bmp" ;
: test-bitmap8 ( -- path )
- "resource:basis/images/test-images/rgb8bit.bmp" ;
+ "vocab:images/test-images/rgb8bit.bmp" ;
: test-bitmap4 ( -- path )
- "resource:basis/images/test-images/rgb4bit.bmp" ;
+ "vocab:images/test-images/rgb4bit.bmp" ;
: test-bitmap1 ( -- path )
- "resource:basis/images/test-images/1bit.bmp" ;
+ "vocab:images/test-images/1bit.bmp" ;
[ t ]
[
} ;
: encoding-file ( file-name -- stream )
- "resource:basis/io/encodings/8-bit/" swap ".TXT"
+ "vocab:io/encodings/8-bit/" swap ".TXT"
3append ascii <file-reader> ;
: process-contents ( lines -- assoc )
VALUE: u>gb
VALUE: mapping
-"resource:basis/io/encodings/chinese/gb-18030-2000.xml"
+"vocab:io/encodings/chinese/gb-18030-2000.xml"
ascii <file-reader> xml>gb-data
[ ranges-u>gb to: u>gb ] [ ranges-gb>u to: gb>u ] bi
>biassoc to: mapping
PRIVATE>
-"resource:basis/io/encodings/iana/character-sets"
+"vocab:io/encodings/iana/character-sets"
utf8 <file-reader> make-aliases aliases set-global
n>e-table [ initial-n>e ] initialize
: make-jis ( filename -- jis )
ascii file-lines process-jis <jis> ;
-"resource:basis/io/encodings/japanese/CP932.txt"
+"vocab:io/encodings/japanese/CP932.txt"
make-jis to: windows-31j-table
-"resource:basis/io/encodings/japanese/sjis-0208-1997-std.txt"
+"vocab:io/encodings/japanese/sjis-0208-1997-std.txt"
make-jis to: shift-jis-table
: small? ( char -- ? )
[ ] [
<secure-config>
- "resource:basis/openssl/test/server.pem" >>key-file
- "resource:basis/openssl/test/dh1024.pem" >>dh-file
+ "vocab:openssl/test/server.pem" >>key-file
+ "vocab:openssl/test/dh1024.pem" >>dh-file
"password" >>password
[ ] with-secure-context
] unit-test
secure-config new
SSLv23 >>method
1024 >>ephemeral-key-bits
- "resource:basis/openssl/cacert.pem" >>ca-file
+ "vocab:openssl/cacert.pem" >>ca-file
t >>verify ;
TUPLE: secure-context config handle disposed ;
: with-test-context ( quot -- )
<secure-config>
- "resource:basis/openssl/test/server.pem" >>key-file
- "resource:basis/openssl/test/dh1024.pem" >>dh-file
+ "vocab:openssl/test/server.pem" >>key-file
+ "vocab:openssl/test/dh1024.pem" >>dh-file
"password" >>password
swap with-secure-context ; inline
IN: mime.types
MEMO: mime-db ( -- seq )
- "resource:basis/mime/types/mime.types" ascii file-lines
+ "vocab:mime/types/mime.types" ascii file-lines
[ "#" head? not ] filter [ " \t" split harvest ] map harvest ;
: nonstandard-mime-types ( -- assoc )
openssl secure-socket-backend [
[ ] [
<secure-config>
- "resource:basis/openssl/test/server.pem" >>key-file
- "resource:basis/openssl/test/root.pem" >>ca-file
- "resource:basis/openssl/test/dh1024.pem" >>dh-file
+ "vocab:openssl/test/server.pem" >>key-file
+ "vocab:openssl/test/root.pem" >>ca-file
+ "vocab:openssl/test/dh1024.pem" >>dh-file
"password" >>password
[ ] with-secure-context
] unit-test
[
<secure-config>
- "resource:basis/openssl/test/server.pem" >>key-file
- "resource:basis/openssl/test/root.pem" >>ca-file
+ "vocab:openssl/test/server.pem" >>key-file
+ "vocab:openssl/test/root.pem" >>ca-file
"wrong password" >>password
[ ] with-secure-context
] must-fail
[ "mate" ] [ "mate" step5 "" like ] unit-test
[ { } ] [
- "resource:basis/porter-stemmer/test/voc.txt" utf8 file-lines
+ "vocab:porter-stemmer/test/voc.txt" utf8 file-lines
[ stem ] map
- "resource:basis/porter-stemmer/test/output.txt" utf8 file-lines
+ "vocab:porter-stemmer/test/output.txt" utf8 file-lines
[ 2array ] 2map [ first2 = not ] filter
] unit-test
f
}
}
-} ] [ "resource:basis/syndication/test/rss1.xml" load-news-file ] unit-test
+} ] [ "vocab:syndication/test/rss1.xml" load-news-file ] unit-test
[ T{
feed
f
T{ timestamp f 2003 12 13 8 29 29 T{ duration f 0 0 0 -4 0 0 } }
}
}
-} ] [ "resource:basis/syndication/test/atom.xml" load-news-file ] unit-test
-[ ] [ "resource:basis/syndication/test/atom.xml" load-news-file feed>xml xml>string drop ] unit-test
+} ] [ "vocab:syndication/test/atom.xml" load-news-file ] unit-test
+[ ] [ "vocab:syndication/test/atom.xml" load-news-file feed>xml xml>string drop ] unit-test
M: integer foo + ;
-"resource:basis/tools/crossref/test/foo.factor" run-file
+"vocab:tools/crossref/test/foo.factor" run-file
[ t ] [ integer \ foo method \ + usage member? ] unit-test
[ t ] [ \ foo usage [ pathname? ] any? ] unit-test
[ ] [\r
<dispatcher>\r
add-quot-responder\r
- "resource:basis/http/test" <static> >>default\r
+ "vocab:http/test" <static> >>default\r
\r
test-httpd\r
] unit-test\r
: strip-debugger ( -- )
strip-debugger? "debugger" vocab and [
"Stripping debugger" show
- "resource:basis/tools/deploy/shaker/strip-debugger.factor"
+ "vocab:tools/deploy/shaker/strip-debugger.factor"
run-file
] when ;
: strip-libc ( -- )
"libc" vocab [
"Stripping manual memory management debug code" show
- "resource:basis/tools/deploy/shaker/strip-libc.factor"
+ "vocab:tools/deploy/shaker/strip-libc.factor"
run-file
] when ;
: strip-cocoa ( -- )
"cocoa" vocab [
"Stripping unused Cocoa methods" show
- "resource:basis/tools/deploy/shaker/strip-cocoa.factor"
+ "vocab:tools/deploy/shaker/strip-cocoa.factor"
run-file
] when ;
dup next-method-quot "next-method-quot" set-word-prop
] assoc-each
] each
- "resource:basis/tools/deploy/shaker/next-methods.factor" run-file ;
+ "vocab:tools/deploy/shaker/next-methods.factor" run-file ;
: strip ( -- )
init-stripper
swap [ "." glue ] with map\r
] unless-empty ;\r
\r
+: vocab-dir? ( root name -- ? )\r
+ over\r
+ [ ".factor" vocab-dir+ append-path exists? ]\r
+ [ 2drop f ]\r
+ if ;\r
+\r
: vocabs-in-dir ( root name -- )\r
dupd (all-child-vocabs) [\r
2dup vocab-dir? [ dup >vocab-link , ] when\r
dup last-grapheme head last-grapheme ] unit-test
: grapheme-break-test ( -- filename )
- "resource:basis/unicode/breaks/GraphemeBreakTest.txt" ;
+ "vocab:unicode/breaks/GraphemeBreakTest.txt" ;
: word-break-test ( -- filename )
- "resource:basis/unicode/breaks/WordBreakTest.txt" ;
+ "vocab:unicode/breaks/WordBreakTest.txt" ;
: parse-test-file ( file-name -- tests )
utf8 file-lines
VALUE: word-break-table
-"resource:basis/unicode/data/WordBreakProperty.txt" load-script
+"vocab:unicode/data/WordBreakProperty.txt" load-script
to: word-break-table
C-ENUM: wOther wCR wLF wNewline wExtend wFormat wKatakana wALetter wMidLetter
IN: unicode.collation.tests\r
\r
: parse-test ( -- strings )\r
- "resource:basis/unicode/collation/CollationTest_SHIFTED.txt"\r
+ "vocab:unicode/collation/CollationTest_SHIFTED.txt"\r
utf8 file-lines 5 tail\r
[ ";" split1 drop " " split [ hex> ] "" map-as ] map ;\r
\r
lines filter-comments\r
[ parse-line ] H{ } map>assoc ;\r
\r
-"resource:basis/unicode/collation/allkeys.txt"\r
+"vocab:unicode/collation/allkeys.txt"\r
ascii <file-reader> parse-ducet to: ducet\r
\r
! Fix up table for long contractions\r
ascii file-lines [ split-; ] map ;
: load-data ( -- data )
- "resource:basis/unicode/data/UnicodeData.txt" data ;
+ "vocab:unicode/data/UnicodeData.txt" data ;
: filter-comments ( lines -- lines )
[ "#@" split first ] map harvest ;
[ " " split [ hex> ] map ] assoc-map ;
: exclusions-file ( -- filename )
- "resource:basis/unicode/data/CompositionExclusions.txt" ;
+ "vocab:unicode/data/CompositionExclusions.txt" ;
: exclusions ( -- set )
exclusions-file utf8 file-lines
! Extra properties
: properties-lines ( -- lines )
- "resource:basis/unicode/data/PropList.txt"
+ "vocab:unicode/data/PropList.txt"
ascii file-lines ;
: parse-properties ( -- {{[a,b],prop}} )
! Special casing data
: load-special-casing ( -- special-casing )
- "resource:basis/unicode/data/SpecialCasing.txt" data
+ "vocab:unicode/data/SpecialCasing.txt" data
[ length 5 = ] filter
[ [ set-code-point ] each ] H{ } make-assoc ;
[ "\u00d55c" ] [ "\u001112\u001161\u0011ab" nfc ] unit-test
: parse-test ( -- tests )
- "resource:basis/unicode/normalize/NormalizationTest.txt"
+ "vocab:unicode/normalize/NormalizationTest.txt"
utf8 file-lines filter-comments
[ ";" split 5 head [ " " split [ hex> ] "" map-as ] map ] map ;
VALUE: script-table
-"resource:basis/unicode/script/Scripts.txt" load-script
+"vocab:unicode/script/Scripts.txt" load-script
to: script-table
: script-of ( char -- script )
: get-html ( -- table )
{ "lat1" "special" "symbol" } [
- "resource:basis/xml/entities/html/xhtml-"
+ "vocab:xml/entities/html/xhtml-"
swap ".ent" 3append read-entities-file
] map first3 assoc-union assoc-union ;
USING: xml xml.data xml.traversal tools.test accessors kernel
io.encodings.8-bit ;
-[ "\u000131" ] [ "resource:basis/xml/tests/latin5.xml" file>xml children>string ] unit-test
-[ "\u0000e9" ] [ "resource:basis/xml/tests/latin1.xml" file>xml children>string ] unit-test
-[ "\u0000e9" ] [ "resource:basis/xml/tests/spaces.xml" file>xml children>string ] unit-test
-[ "\u0000e9" ] [ "resource:basis/xml/tests/utf8.xml" file>xml children>string ] unit-test
-[ "\u0000e9" ] [ "resource:basis/xml/tests/utf16.xml" file>xml children>string ] unit-test
-[ "\u0000e9" ] [ "resource:basis/xml/tests/utf16be.xml" file>xml children>string ] unit-test
-[ "\u0000e9" ] [ "resource:basis/xml/tests/utf16le.xml" file>xml children>string ] unit-test
-[ "\u0000e9" ] [ "resource:basis/xml/tests/utf16be-bom.xml" file>xml children>string ] unit-test
-[ "\u0000e9" ] [ "resource:basis/xml/tests/utf16le-bom.xml" file>xml children>string ] unit-test
-[ "\u0000e9" ] [ "resource:basis/xml/tests/prologless.xml" file>xml children>string ] unit-test
-[ "e" ] [ "resource:basis/xml/tests/ascii.xml" file>xml children>string ] unit-test
-[ "\u0000e9" "x" ] [ "resource:basis/xml/tests/unitag.xml" file>xml [ name>> main>> ] [ children>string ] bi ] unit-test
+[ "\u000131" ] [ "vocab:xml/tests/latin5.xml" file>xml children>string ] unit-test
+[ "\u0000e9" ] [ "vocab:xml/tests/latin1.xml" file>xml children>string ] unit-test
+[ "\u0000e9" ] [ "vocab:xml/tests/spaces.xml" file>xml children>string ] unit-test
+[ "\u0000e9" ] [ "vocab:xml/tests/utf8.xml" file>xml children>string ] unit-test
+[ "\u0000e9" ] [ "vocab:xml/tests/utf16.xml" file>xml children>string ] unit-test
+[ "\u0000e9" ] [ "vocab:xml/tests/utf16be.xml" file>xml children>string ] unit-test
+[ "\u0000e9" ] [ "vocab:xml/tests/utf16le.xml" file>xml children>string ] unit-test
+[ "\u0000e9" ] [ "vocab:xml/tests/utf16be-bom.xml" file>xml children>string ] unit-test
+[ "\u0000e9" ] [ "vocab:xml/tests/utf16le-bom.xml" file>xml children>string ] unit-test
+[ "\u0000e9" ] [ "vocab:xml/tests/prologless.xml" file>xml children>string ] unit-test
+[ "e" ] [ "vocab:xml/tests/ascii.xml" file>xml children>string ] unit-test
+[ "\u0000e9" "x" ] [ "vocab:xml/tests/unitag.xml" file>xml [ name>> main>> ] [ children>string ] bi ] unit-test
USING: xml xml.writer io.files io.encodings.utf8 tools.test kernel ;
[ t ] [
- "resource:basis/xml/tests/funny-dtd.xml" utf8 file-contents string>xml
+ "vocab:xml/tests/funny-dtd.xml" utf8 file-contents string>xml
dup xml>string string>xml =
] unit-test
[ assemble-data ] map ;
[ "http://www.foxnews.com/oreilly/" ] [
- "resource:basis/xml/tests/soap.xml" file>xml
+ "vocab:xml/tests/soap.xml" file>xml
parse-result first first
] unit-test
SYMBOL: xml-file
[ ] [
- "resource:basis/xml/tests/test.xml"
+ "vocab:xml/tests/test.xml"
[ file>xml ] with-html-entities xml-file set
] unit-test
[ t ] [
- "resource:basis/xml/tests/test.xml" binary file-contents
+ "vocab:xml/tests/test.xml" binary file-contents
[ bytes>xml ] with-html-entities xml-file get =
] unit-test
[ "1.0" ] [ xml-file get prolog>> version>> ] unit-test
: parse-tests ( xml -- tests )
"TEST" tags-named [ >xml-test ] map ;
-: base "resource:basis/xml/tests/xmltest/" ;
+: base "vocab:xml/tests/xmltest/" ;
MACRO: drop-output ( quot -- newquot )
dup infer out>> '[ @ _ ndrop ] ;
IN: xml.tests
[ t ] [
- "resource:basis/xmode/xmode.dtd" file>dtd dtd?
+ "vocab:xmode/xmode.dtd" file>dtd dtd?
] unit-test
[ "<foo> bar </foo>" string>xml pprint-xml>string ] unit-test
[ "<foo'>" ] [ "<foo'>" <unescaped> xml>string ] unit-test
-: test-file "resource:basis/xml/writer/test.xml" ;
+: test-file "vocab:xml/writer/test.xml" ;
[ ] [ "<?xml version='1.0' encoding='UTF-16BE'?><x/>" string>xml test-file utf8 [ write-xml ] with-file-writer ] unit-test
[ "x" ] [ test-file file>xml body>> name>> main>> ] unit-test
] keep ;
MEMO: modes ( -- modes )
- "resource:basis/xmode/modes/catalog"
+ "vocab:xmode/modes/catalog"
file>xml parse-modes-tag ;
MEMO: mode-names ( -- modes )
MEMO: (load-mode) ( name -- rule-sets )
modes at [
file>>
- "resource:basis/xmode/modes/" prepend
+ "vocab:xmode/modes/" prepend
utf8 <file-reader> parse-mode
] [
"text" (load-mode)
"PUBLIC"
}
] [
- "resource:basis/xmode/utilities/test.xml"
+ "vocab:xmode/utilities/test.xml"
file>xml parse-company-tag
] unit-test
H{ } clone sub-primitives set
-"resource:core/bootstrap/syntax.factor" parse-file
+"vocab:bootstrap/syntax.factor" parse-file
-"resource:basis/cpu/" architecture get {
+"vocab:cpu/" architecture get {
{ "x86.32" "x86/32" }
{ "winnt-x86.64" "x86/64/winnt" }
{ "unix-x86.64" "x86/64/unix" }
{ "arm" "arm" }
} at "/bootstrap.factor" 3append parse-file
-"resource:core/bootstrap/layouts/layouts.factor" parse-file
+"vocab:bootstrap/layouts/layouts.factor" parse-file
! Now we have ( syntax-quot arch-quot layouts-quot ) on the stack
"Bootstrap stage 1..." print flush
-"resource:core/bootstrap/primitives.factor" run-file
+"vocab:bootstrap/primitives.factor" run-file
load-help? off
{ "resource:core" } vocab-roots set
"bootstrap.layouts" require
[
- "resource:basis/bootstrap/stage2.factor"
+ "vocab:bootstrap/stage2.factor"
dup exists? [
run-file
] [
IN: io.streams.encodings.tests
[ { } ]
-[ "resource:core/io/test/empty-file.txt" ascii <file-reader> lines ]
+[ "vocab:io/test/empty-file.txt" ascii <file-reader> lines ]
unit-test
: lines-test ( stream -- line1 line2 )
"This is a line."
"This is another line."
] [
- "resource:core/io/test/windows-eol.txt"
+ "vocab:io/test/windows-eol.txt"
ascii <file-reader> lines-test
] unit-test
"This is a line."
"This is another line."
] [
- "resource:core/io/test/mac-os-eol.txt"
+ "vocab:io/test/mac-os-eol.txt"
ascii <file-reader> lines-test
] unit-test
"This is a line."
"This is another line."
] [
- "resource:core/io/test/unix-eol.txt"
+ "vocab:io/test/unix-eol.txt"
ascii <file-reader> lines-test
] unit-test
[
"This is a line.\rThis is another line.\r"
] [
- "resource:core/io/test/mac-os-eol.txt" latin1 <file-reader>
+ "vocab:io/test/mac-os-eol.txt" latin1 <file-reader>
[ 500 read ] with-input-stream
] unit-test
[
255
] [
- "resource:core/io/test/binary.txt" latin1 <file-reader>
+ "vocab:io/test/binary.txt" latin1 <file-reader>
[ read1 ] with-input-stream >fixnum
] unit-test
IN: io.tests
[ f ] [
- "resource:core/io/test/no-trailing-eol.factor" run-file
+ "vocab:io/test/no-trailing-eol.factor" run-file
"foo" "io.tests" lookup
] unit-test
-! Copyright (C) 2004, 2008 Slava Pestov, Doug Coleman.
+! Copyright (C) 2004, 2009 Slava Pestov, Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators io.backend kernel math math.order
namespaces sequences splitting strings system ;
[ f ]
} cond ;
+: special-path? ( path -- rest ? )
+ {
+ { [ "resource:" ?head ] [ t ] }
+ { [ "vocab:" ?head ] [ t ] }
+ [ f ]
+ } cond ;
+
: absolute-path? ( path -- ? )
{
{ [ dup empty? ] [ f ] }
- { [ dup "resource:" head? ] [ t ] }
+ { [ dup special-path? nip ] [ t ] }
{ [ os windows? ] [ windows-absolute-path? ] }
{ [ dup first path-separator? ] [ t ] }
[ f ]
dup root-directory? [
trim-tail-separators
dup last-path-separator [ 1+ tail ] [
- drop "resource:" ?head [ file-name ] when
+ drop special-path? [ file-name ] when
] if
] unless ;
: resource-path ( path -- newpath )
"resource-path" get prepend-path ;
+GENERIC: vocab-path ( path -- newpath )
+
GENERIC: (normalize-path) ( path -- path' )
M: string (normalize-path)
trim-head-separators resource-path
(normalize-path)
] [
- current-directory get prepend-path
+ "vocab:" ?head [
+ trim-head-separators vocab-path
+ (normalize-path)
+ ] [
+ current-directory get prepend-path
+ ] if
] if ;
M: object normalize-path ( path -- path' )
[ t ] [ "foo" "parser.tests" lookup symbol? ] unit-test
] times
-[ "resource:core/parser/test/assert-depth.factor" run-file ]
+[ "vocab:parser/test/assert-depth.factor" run-file ]
[ got>> { 1 2 3 } sequence= ]
must-fail-with
-! Copyright (C) 2007, 2008 Eduardo Cavazos, Slava Pestov.
+! Copyright (C) 2007, 2009 Eduardo Cavazos, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: namespaces make sequences io io.files io.pathnames kernel
assocs words vocabs definitions parser continuations hashtables
: add-vocab-root ( root -- )
vocab-roots get adjoin ;
-: vocab-dir ( vocab -- dir )
- vocab-name { { CHAR: . CHAR: / } } substitute ;
-
-: vocab-dir+ ( vocab str/f -- path )
- [ vocab-name "." split ] dip
- [ [ dup peek ] dip append suffix ] when*
- "/" join ;
-
-: vocab-dir? ( root name -- ? )
- over
- [ ".factor" vocab-dir+ append-path exists? ]
- [ 2drop f ]
- if ;
-
SYMBOL: root-cache
-H{ } clone root-cache set-global
+root-cache [ H{ } clone ] initialize
+
+ERROR: not-found-in-roots path ;
<PRIVATE
-: (find-vocab-root) ( name -- path/f )
- vocab-roots get swap [ vocab-dir? ] curry find nip ;
+: find-root-for ( path -- path/f )
+ vocab-roots get [ prepend-path exists? ] with find nip ;
+
+M: string vocab-path ( string -- path/f )
+ dup find-root-for [ prepend-path ] [ not-found-in-roots ] if* ;
PRIVATE>
+: vocab-dir ( vocab -- dir )
+ vocab-name { { CHAR: . CHAR: / } } substitute ;
+
+: vocab-dir+ ( vocab str/f -- path )
+ [ vocab-name "." split ] dip
+ [ [ dup peek ] dip append suffix ] when*
+ "/" join ;
+
: find-vocab-root ( vocab -- path/f )
- vocab-name dup root-cache get at [ ] [ (find-vocab-root) ] ?if ;
+ vocab-name dup root-cache get at
+ [ ] [ ".factor" vocab-dir+ find-root-for ] ?if ;
: vocab-append-path ( vocab path -- newpath )
swap find-vocab-root dup [ prepend-path ] [ 2drop f ] if ;
: add-to-blacklist ( error vocab -- )
vocab-name blacklist get dup [ set-at ] [ 3drop ] if ;
-GENERIC: (load-vocab) ( name -- )
+GENERIC: (load-vocab) ( name -- vocab )
M: vocab (load-vocab)
[
dup source-loaded?>> +parsing+ eq? [
dup source-loaded?>> [ dup load-source ] unless
dup docs-loaded?>> [ dup load-docs ] unless
- ] unless drop
+ ] unless
] [ [ swap add-to-blacklist ] keep rethrow ] recover ;
M: vocab-link (load-vocab)
M: string (load-vocab)
create-vocab (load-vocab) ;
-[
- [
- dup vocab-name blacklist get at* [ rethrow ] [
- drop dup find-vocab-root
- [ [ (load-vocab) ] with-compiler-errors ]
- [ dup vocab [ drop ] [ no-vocab ] if ]
- if
- ] if
- ] with-compiler-errors
-] load-vocab-hook set-global
-
PRIVATE>
-: vocab-where ( vocab -- loc )
- vocab-source-path dup [ 1 2array ] when ;
-
-M: vocab where vocab-where ;
+[
+ dup vocab-name blacklist get at* [ rethrow ] [
+ drop dup find-vocab-root
+ [ [ (load-vocab) ] with-compiler-errors ]
+ [ dup vocab [ ] [ no-vocab ] ?if ]
+ if
+ ] if
+] load-vocab-hook set-global
-M: vocab-link where vocab-where ;
+M: vocab-spec where vocab-source-path dup [ 1 2array ] when ;
-! Copyright (C) 2007, 2008 Eduardo Cavazos, Slava Pestov.
+! Copyright (C) 2007, 2009 Eduardo Cavazos, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs strings kernel sorting namespaces
sequences definitions ;
swap >>name
H{ } clone >>words ;
-GENERIC: vocab-name ( vocab-spec -- name )
+TUPLE: vocab-link name ;
-GENERIC: vocab ( vocab-spec -- vocab )
+C: <vocab-link> vocab-link
-M: vocab vocab ;
+UNION: vocab-spec vocab vocab-link ;
-M: object vocab ( name -- vocab ) vocab-name dictionary get at ;
+GENERIC: vocab-name ( vocab-spec -- name )
M: vocab vocab-name name>> ;
+M: vocab-link vocab-name name>> ;
+
M: string vocab-name ;
+GENERIC: vocab ( vocab-spec -- vocab )
+
+M: vocab vocab ;
+
+M: object vocab ( name -- vocab ) vocab-name dictionary get at ;
+
GENERIC: vocab-words ( vocab-spec -- words )
M: vocab vocab-words words>> ;
ERROR: no-vocab name ;
-SYMBOL: load-vocab-hook ! ( name -- )
-
-: load-vocab ( name -- vocab )
- dup load-vocab-hook get call vocab ;
-
: vocabs ( -- seq )
dictionary get keys natural-sort ;
: child-vocabs ( vocab -- seq )
vocab-name vocabs [ child-vocab? ] with filter ;
-TUPLE: vocab-link name ;
-
-: <vocab-link> ( name -- vocab-link )
- vocab-link boa ;
-
-M: vocab-link hashcode* name>> hashcode* ;
-
-M: vocab-link vocab-name name>> ;
-
-UNION: vocab-spec vocab vocab-link ;
-
GENERIC: >vocab-link ( name -- vocab )
M: vocab-spec >vocab-link ;
vocab-name dictionary get delete-at ;
M: vocab-spec forget* forget-vocab ;
+
+SYMBOL: load-vocab-hook ! ( name -- vocab )
+
+: load-vocab ( name -- vocab ) load-vocab-hook get call ;
\ No newline at end of file
: crc32-file ( -- )
10 [
- "resource:basis/mime/multipart/multipart-tests.factor"
+ "vocab:mime/multipart/multipart-tests.factor"
crc32 checksum-file drop
] times ;
IN: benchmark.md5
: md5-file ( -- )
- "resource:basis/mime/multipart/multipart-tests.factor" md5 checksum-file drop ;
+ "vocab:mime/multipart/multipart-tests.factor" md5 checksum-file drop ;
MAIN: md5-file
IN: benchmark.sha1
: sha1-file ( -- )
- "resource:basis/mime/multipart/multipart-tests.factor" sha1 checksum-file drop ;
+ "vocab:mime/multipart/multipart-tests.factor" sha1 checksum-file drop ;
MAIN: sha1-file
IN: benchmark.xml
: xml-benchmark ( -- )
- "resource:basis/xmode/modes/" [
+ "vocab:xmode/modes/" [
[ utf8 <file-reader> read-xml drop ] each
] with-directory-files ;
: <todo-secure-config> ( -- config )
! This is only suitable for testing!
<secure-config>
- "resource:basis/openssl/test/dh1024.pem" >>dh-file
- "resource:basis/openssl/test/server.pem" >>key-file
+ "vocab:openssl/test/dh1024.pem" >>dh-file
+ "vocab:openssl/test/server.pem" >>key-file
"password" >>password ;
: <todo-app> ( -- responder )
init-factor-db ;
: init-testing ( -- )
- "resource:basis/openssl/test/dh1024.pem" dh-file set-global
- "resource:basis/openssl/test/server.pem" key-file set-global
+ "vocab:openssl/test/dh1024.pem" dh-file set-global
+ "vocab:openssl/test/server.pem" key-file set-global
"password" key-password set-global
common-configuration
<factor-website>