+++ /dev/null
-! Copyright (C) 2008 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel words help.markup help.syntax ;
-IN: alias
-
-HELP: ALIAS:
-{ $syntax "ALIAS: new-word existing-word" }
-{ $values { "new-word" word } { "existing-word" word } }
-{ $description "Creates a " { $snippet "new" } " inlined word that calls the " { $snippet "existing" } " word." }
-{ $examples
- { $example "USING: alias prettyprint sequences ;"
- "IN: alias.test"
- "ALIAS: sequence-nth nth"
- "0 { 10 20 30 } sequence-nth ."
- "10"
- }
-} ;
-
-ARTICLE: "alias" "Word aliasing"
-"The " { $vocab-link "alias" } " vocabulary implements a way to make many different names for the same word. Although creating new names for words is generally frowned upon, aliases are useful for the Win32 API and other cases where words need to be renamed for symmetry." $nl
-"Make a new word that aliases another word:"
-{ $subsection define-alias }
-"Make an alias at parse-time:"
-{ $subsection POSTPONE: ALIAS: } ;
-
-ABOUT: "alias"
+++ /dev/null
-! Copyright (C) 2008 Slava Pestov.\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING: accessors words quotations kernel effects sequences\r
-parser definitions ;\r
-IN: alias\r
-\r
-PREDICATE: alias < word "alias" word-prop ;\r
-\r
-: define-alias ( new old -- )\r
- [ [ 1quotation ] [ stack-effect ] bi define-inline ]\r
- [ drop t "alias" set-word-prop ] 2bi ;\r
-\r
-: ALIAS: CREATE-WORD scan-word define-alias ; parsing\r
-\r
-M: alias reset-word\r
- [ call-next-method ] [ f "alias" set-word-prop ] bi ;\r
-\r
-M: alias stack-effect\r
- def>> first stack-effect ;\r
+++ /dev/null
-Slava Pestov
+++ /dev/null
-Defining multiple words with the same name
alien.arrays alien.strings kernel math namespaces parser
sequences words quotations math.parser splitting grouping
effects assocs combinators lexer strings.parser alien.parser
-fry ;
+fry vocabs.parser ;
IN: alien.syntax
: DLL" lexer get skip-blank parse-string dlopen parsed ; parsing
! Copyright (C) 2004, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors init namespaces words io kernel.private math
-memory continuations kernel io.files io.pathnames io.backend
-system parser vocabs sequences vocabs.loader combinators
-splitting source-files strings definitions assocs
-compiler.errors compiler.units math.parser generic sets
-command-line ;
+USING: accessors init namespaces words words.symbol io
+kernel.private math memory continuations kernel io.files
+io.pathnames io.backend system parser vocabs sequences
+vocabs.loader combinators splitting source-files strings
+definitions assocs compiler.errors compiler.units math.parser
+generic sets command-line ;
IN: bootstrap.stage2
SYMBOL: core-bootstrap-time
USING: kernel io io.binary io.files io.streams.byte-array math
math.functions math.parser namespaces splitting grouping strings
sequences byte-arrays locals sequences.private
-io.encodings.binary symbols math.bitwise checksums
+io.encodings.binary math.bitwise checksums
checksums.common checksums.stream ;
IN: checksums.md5
USING: arrays combinators kernel io io.encodings.binary io.files
io.streams.byte-array math.vectors strings sequences namespaces
make math parser sequences assocs grouping vectors io.binary
-hashtables symbols math.bitwise checksums checksums.common
+hashtables math.bitwise checksums checksums.common
checksums.stream ;
IN: checksums.sha1
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel splitting grouping math sequences namespaces make
-io.binary symbols math.bitwise checksums checksums.common
+io.binary math.bitwise checksums checksums.common
sbufs strings ;
IN: checksums.sha2
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: qualified words sequences kernel combinators
-cpu.architecture
+USING: words sequences kernel combinators cpu.architecture
compiler.cfg.hats
compiler.cfg.instructions
compiler.cfg.intrinsics.alien
sequences sequences.private quotations generic macros arrays
prettyprint prettyprint.backend prettyprint.custom
prettyprint.sections math words combinators
-combinators.short-circuit io sorting hints qualified
+combinators.short-circuit io sorting hints
compiler.tree
compiler.tree.recursive
compiler.tree.normalization
] unit-test
[ V{ POSTPONE: f } ] [
- [ { word object } declare eq? ] final-classes
+ [ { word object } declare equal? ] final-classes
] unit-test
! [ V{ string } ] [
! See http://factorcode.org/license.txt for BSD license.
USING: serialize sequences concurrency.messaging threads io
io.servers.connection io.encodings.binary
-qualified arrays namespaces kernel accessors ;
+arrays namespaces kernel accessors ;
FROM: io.sockets => host-name <inet> with-client ;
IN: concurrency.distributed
+++ /dev/null
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: parser kernel words ;
-IN: constants
-
-: CONSTANT:
- CREATE scan-object [ ] curry (( -- value ))
- define-inline ; parsing
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel words sequences lexer parser fry ;
+USING: kernel words words.symbol sequences lexer parser fry ;
IN: cpu.x86.assembler.syntax
: define-register ( name num size -- )
generic.standard vocabs init kernel.private io.encodings
accessors math.order destructors source-files parser
classes.tuple.parser effects.parser lexer compiler.errors
-generic.parser strings.parser ;
+generic.parser strings.parser vocabs.parser ;
IN: debugger
GENERIC: error. ( error -- )
! See http://factorcode.org/license.txt for BSD license.
USING: accessors parser generic kernel classes classes.tuple
words slots assocs sequences arrays vectors definitions
-math hashtables sets generalizations namespaces make ;
+math hashtables sets generalizations namespaces make
+words.symbol ;
IN: delegate
: protocol-words ( protocol -- words )
USING: kernel quotations classes.tuple make combinators generic
words interpolate namespaces sequences io.streams.string fry
classes.mixin effects lexer parser classes.tuple.parser
-effects.parser locals.types locals.parser locals.rewrite.closures ;
+effects.parser locals.types locals.parser
+locals.rewrite.closures vocabs.parser ;
IN: functors
: scan-param ( -- obj )
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays kernel combinators assocs
namespaces sequences splitting words
-fry urls multiline present qualified
+fry urls multiline present
xml
xml.data
xml.entities
! Copyright (C) 2005, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays io io.styles kernel namespaces make
-parser prettyprint sequences words assocs definitions generic
-quotations effects slots continuations classes.tuple debugger
-combinators vocabs help.stylesheet help.topics help.crossref
-help.markup sorting classes vocabs.loader ;
+parser prettyprint sequences words words.symbol assocs
+definitions generic quotations effects slots continuations
+classes.tuple debugger combinators vocabs help.stylesheet
+help.topics help.crossref help.markup sorting classes
+vocabs.loader ;
IN: help
GENERIC: word-help* ( word -- content )
io io.streams.string prettyprint definitions arrays vectors
combinators combinators.short-circuit splitting debugger
hashtables sorting effects vocabs vocabs.loader assocs editors
-continuations classes.predicate macros math sets eval ;
+continuations classes.predicate macros math sets eval
+vocabs.parser words.symbol ;
IN: help.lint
: check-example ( element -- )
USING: accessors arrays definitions generic io kernel assocs
hashtables namespaces make parser prettyprint sequences strings
io.styles vectors words math sorting splitting classes slots
-vocabs help.stylesheet help.topics vocabs.loader alias
-quotations ;
+vocabs help.stylesheet help.topics vocabs.loader quotations ;
IN: help.markup
! Simple markup language.
! Copyright (C) 2005, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays kernel parser sequences words help
-help.topics namespaces vocabs definitions compiler.units ;
+help.topics namespaces vocabs definitions compiler.units
+vocabs.parser ;
IN: help.syntax
: HELP:
io io.encodings io.encodings.iana io.encodings.binary
io.encodings.8-bit
-unicode.case unicode.categories qualified
+unicode.case unicode.categories
http.parsers ;
USING: alien alien.c-types alien.syntax generic assocs kernel
kernel.private math io.ports sequences strings sbufs threads
unix vectors io.buffers io.backend io.encodings math.parser
-continuations system libc qualified namespaces make io.timeouts
+continuations system libc namespaces make io.timeouts
io.encodings.utf8 destructors accessors summary combinators
locals unix.time fry io.backend.unix.multiplexers ;
QUALIFIED: io
io.backend.windows io.files.windows io.files.windows.nt io.files
io.pathnames io.buffers io.streams.c libc kernel math namespaces
sequences threads windows windows.errors windows.kernel32
-strings splitting qualified ascii system accessors locals ;
+strings splitting ascii system accessors locals ;
QUALIFIED: windows.winsock
IN: io.backend.windows.nt
io.files.types io.buffers io.encodings.utf16n io.ports
io.backend.windows kernel math splitting fry alien.strings
windows windows.kernel32 windows.time calendar combinators
-math.functions sequences namespaces make words symbols system
+math.functions sequences namespaces make words system
destructors accessors math.bitwise continuations windows.errors
arrays byte-arrays generalizations ;
IN: io.files.windows
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: system kernel unix math sequences qualified
+USING: system kernel unix math sequences
io.backend.unix io.ports specialized-arrays.int accessors ;
IN: io.pipes.unix
QUALIFIED: io.pipes
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel symbols namespaces continuations
+USING: accessors kernel namespaces continuations
destructors io debugger io.sockets sequences summary calendar
delegate system vocabs.loader combinators present ;
IN: io.sockets.secure
io.encodings.ascii alien.strings io.binary accessors destructors
classes byte-arrays system combinators parser
alien.c-types math.parser splitting grouping math assocs summary
-system vocabs.loader combinators present fry ;
+system vocabs.loader combinators present fry vocabs.parser ;
IN: io.sockets
<< {
io.binary io.backend.unix io.streams.duplex
io.backend io.ports io.pathnames io.files.private
io.encodings.utf8 math.parser continuations libc combinators
-system accessors qualified destructors unix locals init ;
+system accessors destructors unix locals init ;
EXCLUDE: io => read write close ;
EXCLUDE: io.sockets => accept ;
! Copyright (C) 2008 Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
-USING: lcs html.elements kernel qualified ;
+USING: lcs html.elements kernel ;
FROM: accessors => item>> ;
FROM: io => write ;
FROM: sequences => each if-empty ;
namespaces parser lexer sequences strings io.styles
vectors words generic system combinators continuations debugger
definitions compiler.units accessors colors prettyprint fry
-sets ;
+sets vocabs.parser ;
IN: listener
GENERIC: stream-read-quot ( stream -- quot/f )
USING: accessors arrays combinators effects.parser
generic.parser kernel lexer locals.errors
locals.rewrite.closures locals.types make namespaces parser
-quotations sequences splitting words ;
+quotations sequences splitting words vocabs.parser ;
IN: locals.parser
: make-local ( name -- word )
! See http://factorcode.org/license.txt for BSD license.\r
USING: logging.analysis logging.server logging smtp kernel\r
io.files io.streams.string namespaces make alarms assocs\r
-io.encodings.utf8 accessors calendar sequences qualified ;\r
+io.encodings.utf8 accessors calendar sequences ;\r
QUALIFIED: io.sockets\r
IN: logging.insomniac\r
\r
words kernel arrays shuffle tools.annotations\r
prettyprint.config prettyprint debugger io.streams.string\r
splitting continuations effects generalizations parser strings\r
-quotations fry symbols accessors ;\r
+quotations fry accessors ;\r
IN: logging\r
\r
SYMBOLS: DEBUG NOTICE WARNING ERROR CRITICAL ;\r
USING: alien alien.syntax alien.parser combinators
kernel parser sequences system words namespaces hashtables init
-math arrays assocs continuations lexer fry locals ;
+math arrays assocs continuations lexer fry locals vocabs.parser ;
IN: opengl.gl.extensions
ERROR: unknown-gl-platform ;
! This file is based on the gl.h that comes with xorg-x11 6.8.2
USING: alien alien.syntax combinators kernel parser sequences
-system words opengl.gl.extensions alias constants ;
+system words opengl.gl.extensions ;
IN: opengl.gl
! Portions copyright (C) 2008 Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.syntax combinators kernel system namespaces
-assocs parser lexer sequences words quotations math.bitwise
-alias constants ;
+assocs parser lexer sequences words quotations math.bitwise ;
IN: openssl.libssl
! Copyback (C) 2008 Daniel Ehrenberg
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel accessors math qualified ;
+USING: kernel accessors math ;
QUALIFIED: sequences
IN: persistent.deques
! 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 prettyprint.backend prettyprint.custom
+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 ;
+accessors colors parser summary vocabs.parser ;
IN: prettyprint
: make-pprint ( obj quot -- block in use )
] when drop ;
M: word see
- dup see-class
- dup class? over symbol? not and [
- nl
- ] when
- dup [ class? ] [ symbol? ] bi and
- [ drop ] [ call-next-method ] if ;
+ [ 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 ;
+++ /dev/null
-Daniel Ehrenberg
+++ /dev/null
-USING: help.markup help.syntax ;
-IN: qualified
-
-HELP: QUALIFIED:
-{ $syntax "QUALIFIED: vocab" }
-{ $description "Similar to " { $link POSTPONE: USE: } " but loads vocabulary with prefix." }
-{ $examples { $example
- "USING: prettyprint qualified ;"
- "QUALIFIED: math"
- "1 2 math:+ ." "3"
-} } ;
-
-HELP: QUALIFIED-WITH:
-{ $syntax "QUALIFIED-WITH: vocab word-prefix" }
-{ $description "Works like " { $link POSTPONE: QUALIFIED: } " but uses " { $snippet "word-prefix" } " as prefix." }
-{ $examples { $code
- "USING: prettyprint qualified ;"
- "QUALIFIED-WITH: math m"
- "1 2 m:+ ."
- "3"
-} } ;
-
-HELP: FROM:
-{ $syntax "FROM: vocab => words ... ;" }
-{ $description "Imports " { $snippet "words" } " from " { $snippet "vocab" } "." }
-{ $examples { $code
- "FROM: math.parser => bin> hex> ; ! imports only bin> and hex>" } } ;
-
-HELP: EXCLUDE:
-{ $syntax "EXCLUDE: vocab => words ... ;" }
-{ $description "Imports everything from " { $snippet "vocab" } " excluding " { $snippet "words" } "." }
-{ $examples { $code
- "EXCLUDE: math.parser => bin> hex> ; ! imports everything but bin> and hex>" } } ;
-
-HELP: RENAME:
-{ $syntax "RENAME: word vocab => newname " }
-{ $description "Imports " { $snippet "word" } " from " { $snippet "vocab" } ", but renamed to " { $snippet "newname" } "." }
-{ $examples { $example
- "USING: prettyprint qualified ;"
- "RENAME: + math => -"
- "2 3 - ."
- "5"
-} } ;
-
-ARTICLE: "qualified" "Qualified word lookup"
-"The " { $vocab-link "qualified" } " vocabulary provides a handful of parsing words which give more control over word lookup than is offered by " { $link POSTPONE: USE: } " and " { $link POSTPONE: USING: } "."
-$nl
-"These words are useful when there is no way to avoid using two vocabularies with identical word names in the same source file."
-{ $subsection POSTPONE: QUALIFIED: }
-{ $subsection POSTPONE: QUALIFIED-WITH: }
-{ $subsection POSTPONE: FROM: }
-{ $subsection POSTPONE: EXCLUDE: }
-{ $subsection POSTPONE: RENAME: } ;
-
-ABOUT: "qualified"
+++ /dev/null
-USING: tools.test qualified eval accessors parser ;
-IN: qualified.tests.foo
-: x 1 ;
-: y 5 ;
-IN: qualified.tests.bar
-: x 2 ;
-: y 4 ;
-IN: qualified.tests.baz
-: x 3 ;
-
-QUALIFIED: qualified.tests.foo
-QUALIFIED: qualified.tests.bar
-[ 1 2 3 ] [ qualified.tests.foo:x qualified.tests.bar:x x ] unit-test
-
-QUALIFIED-WITH: qualified.tests.bar p
-[ 2 ] [ p:x ] unit-test
-
-RENAME: x qualified.tests.baz => y
-[ 3 ] [ y ] unit-test
-
-FROM: qualified.tests.baz => x ;
-[ 3 ] [ x ] unit-test
-[ 3 ] [ y ] unit-test
-
-EXCLUDE: qualified.tests.bar => x ;
-[ 3 ] [ x ] unit-test
-[ 4 ] [ y ] unit-test
-
-[ "USE: qualified IN: qualified.tests FROM: qualified.tests => doesnotexist ;" eval ]
-[ error>> no-word-error? ] must-fail-with
-
-[ "USE: qualified IN: qualified.tests RENAME: doesnotexist qualified.tests => blah" eval ]
-[ error>> no-word-error? ] must-fail-with
+++ /dev/null
-! Copyright (C) 2007, 2008 Daniel Ehrenberg.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences assocs hashtables parser lexer
-vocabs words namespaces vocabs.loader sets fry ;
-IN: qualified
-
-: define-qualified ( vocab-name prefix-name -- )
- [ load-vocab vocab-words ] [ CHAR: : suffix ] bi*
- '[ [ [ _ ] dip append ] dip ] assoc-map
- use get push ;
-
-: QUALIFIED:
- #! Syntax: QUALIFIED: vocab
- scan dup define-qualified ; parsing
-
-: QUALIFIED-WITH:
- #! Syntax: QUALIFIED-WITH: vocab prefix
- scan scan define-qualified ; parsing
-
-: partial-vocab ( words vocab -- assoc )
- '[ dup _ lookup [ no-word-error ] unless* ]
- { } map>assoc ;
-
-: FROM:
- #! Syntax: FROM: vocab => words... ;
- scan dup load-vocab drop "=>" expect
- ";" parse-tokens swap partial-vocab use get push ; parsing
-
-: partial-vocab-excluding ( words vocab -- assoc )
- [ load-vocab vocab-words keys swap diff ] keep partial-vocab ;
-
-: EXCLUDE:
- #! Syntax: EXCLUDE: vocab => words ... ;
- scan "=>" expect
- ";" parse-tokens swap partial-vocab-excluding use get push ; parsing
-
-: RENAME:
- #! Syntax: RENAME: word vocab => newname
- scan scan dup load-vocab drop
- dupd lookup [ ] [ no-word-error ] ?if
- "=>" expect
- scan associate use get push ; parsing
-
+++ /dev/null
-Qualified naming for vocabularies
+++ /dev/null
-extensions
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel math math.order symbols
-words regexp.utils unicode.categories combinators.short-circuit ;
+USING: accessors kernel math math.order words regexp.utils
+unicode.categories combinators.short-circuit ;
IN: regexp.classes
SINGLETONS: any-char any-char-no-nl
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs combinators io io.streams.string
-kernel math math.parser namespaces qualified sets
-quotations sequences splitting symbols vectors math.order
+kernel math math.parser namespaces sets
+quotations sequences splitting vectors math.order
unicode.categories strings regexp.backend regexp.utils
unicode.case words locals regexp.classes ;
IN: regexp.parser
+++ /dev/null
-Slava Pestov
-Doug Coleman
+++ /dev/null
-Utility for defining multiple symbols at a time
+++ /dev/null
-USING: help.markup help.syntax ;
-IN: symbols
-
-HELP: SYMBOLS:
-{ $syntax "SYMBOLS: words... ;" }
-{ $values { "words" "a sequence of new words to define" } }
-{ $description "Creates a new word for every token until the ';'." }
-{ $examples { $example "USING: prettyprint symbols ;" "IN: scratchpad" "SYMBOLS: foo bar baz ;\nfoo . bar . baz ." "foo\nbar\nbaz" } }
-{ $see-also POSTPONE: SYMBOL: } ;
+++ /dev/null
-USING: kernel symbols tools.test parser generic words accessors
-eval ;
-IN: symbols.tests
-
-[ ] [ SYMBOLS: a b c ; ] unit-test
-[ a ] [ a ] unit-test
-[ b ] [ b ] unit-test
-[ c ] [ c ] unit-test
-
-DEFER: blah
-
-[ ] [ "IN: symbols.tests GENERIC: blah" eval ] unit-test
-[ ] [ "IN: symbols.tests USE: symbols SYMBOLS: blah ;" eval ] unit-test
-
-[ f ] [ \ blah generic? ] unit-test
-[ t ] [ \ blah symbol? ] unit-test
-
-[ "IN: symbols.tests USE: symbols SINGLETONS: blah blah blah ;" eval ]
-[ error>> error>> def>> \ blah eq? ]
-must-fail-with
-
+++ /dev/null
-! Copyright (C) 2008 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: parser lexer sequences words kernel classes.singleton
-classes.parser ;
-IN: symbols
-
-: SYMBOLS:
- ";" parse-tokens
- [ create-in dup reset-generic define-symbol ] each ;
- parsing
-
-: SINGLETONS:
- ";" parse-tokens
- [ create-class-in define-singleton-class ] each ;
- parsing
+++ /dev/null
-extensions
sequences system tools.deploy.backend tools.deploy.config
tools.deploy.config.editor assocs hashtables prettyprint
io.backend.unix cocoa io.encodings.utf8 io.backend
-cocoa.application cocoa.classes cocoa.plists qualified
+cocoa.application cocoa.classes cocoa.plists
combinators ;
IN: tools.deploy.macosx
! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors qualified io.backend io.streams.c init fry
+USING: accessors io.backend io.streams.c init fry
namespaces make assocs kernel parser lexer strings.parser vocabs
sequences words words.private memory kernel.private
continuations io vocabs.loader system strings sets
! See http://factorcode.org/license.txt for BSD license.
USING: io.files io.files.temp io words alien kernel math.parser
alien.syntax io.launcher system assocs arrays sequences
-namespaces make qualified system math io.encodings.ascii
+namespaces make system math io.encodings.ascii
accessors tools.disassembler ;
IN: tools.disassembler.gdb
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays combinators io io.files io.files.info
io.directories kernel math.parser sequences system vocabs.loader
-calendar math symbols fry prettyprint ;
+calendar math fry prettyprint ;
IN: tools.files
<PRIVATE
definitions effects fry generic help help.markup help.stylesheet
help.topics io io.files io.pathnames io.styles kernel macros
make namespaces prettyprint sequences sets sorting summary
-tools.vocabs vocabs vocabs.loader words ;
+tools.vocabs vocabs vocabs.loader words words.symbol ;
IN: tools.vocabs.browser
: vocab-status-string ( vocab -- string )
! Copyright (C) 2006, 2007 Alex Chapman.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays kernel sequences io.styles ui.gadgets ui.render
-colors colors.gray qualified accessors ;
+colors colors.gray accessors ;
QUALIFIED: colors
IN: ui.gadgets.theme
USING: accessors arrays assocs kernel math math.order models
namespaces make sequences words strings system hashtables
math.parser math.vectors classes.tuple classes boxes calendar
-alarms symbols combinators sets columns fry deques ui.gadgets ;
+alarms combinators sets columns fry deques ui.gadgets ;
IN: ui.gestures
GENERIC: handle-gesture ( gesture gadget -- ? )
ui.commands ui.gadgets ui.gadgets.editors ui.gadgets.status-bar
ui.gadgets.presentations ui.gadgets.worlds ui.gestures
definitions calendar concurrency.flags concurrency.mailboxes
-ui.tools.workspace accessors sets destructors fry ;
+ui.tools.workspace accessors sets destructors fry vocabs.parser ;
IN: ui.tools.interactor
! If waiting is t, we're waiting for user input, and invoking
tools.annotations editors tools.profiler tools.test tools.time
tools.walker ui.commands ui.gadgets.editors ui.gestures
ui.operations ui.tools.deploy vocabs vocabs.loader words
-sequences tools.vocabs classes compiler.units accessors ;
+sequences tools.vocabs classes compiler.units accessors
+vocabs.parser ;
IN: ui.tools.operations
V{ } clone operations set-global
windows.gdi32 windows.user32 windows.opengl32 windows.messages
windows.types windows.nt windows threads libc combinators fry
combinators.short-circuit continuations command-line shuffle
-opengl ui.render ascii math.bitwise locals symbols accessors
+opengl ui.render ascii math.bitwise locals accessors
math.geometry.rect math.order ascii calendar io.encodings.utf16n
;
IN: ui.windows
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 command-line qualified
+io.encodings.utf8 combinators command-line
math.vectors classes.tuple opengl.gl threads math.geometry.rect
environment ascii ;
IN: ui.x11
! Copyright (C) 2005, 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax combinators system vocabs.loader alias
-constants ;
+USING: alien.syntax combinators system vocabs.loader ;
IN: unix
CONSTANT: MAXPATHLEN 1024
-USING: alien.syntax alias constants ;
+USING: alien.syntax ;
IN: unix
: FD_SETSIZE 1024 ;
-USING: alien.syntax unix.time alias constants ;
+USING: alien.syntax unix.time ;
IN: unix
CONSTANT: FD_SETSIZE 1024
-USING: alien.syntax alien.c-types math vocabs.loader constants alias ;
+USING: alien.syntax alien.c-types math vocabs.loader ;
IN: unix
CONSTANT: FD_SETSIZE 256
-USING: alien.syntax constants alias ;
+USING: alien.syntax ;
IN: unix
CONSTANT: FD_SETSIZE 1024
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.getfsstat.freebsd
CONSTANT: MNT_WAIT 1 ! synchronously wait for I/O to complete
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.getfsstat.macosx
CONSTANT: MNT_WAIT 1 ! synchronously wait for I/O to complete
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.getfsstat.netbsd
CONSTANT: MNT_WAIT 1 ! synchronously wait for I/O to complete
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.getfsstat.openbsd
CONSTANT: MNT_WAIT 1 ! synchronously wait for I/O to complete
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.strings io.encodings.utf8
io.backend.unix kernel math sequences splitting unix strings
-combinators.short-circuit byte-arrays combinators qualified
+combinators.short-circuit byte-arrays combinators
accessors math.parser fry assocs namespaces continuations
unix.users unix.utilities ;
IN: unix.groups
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.kqueue
C-STRUCT: kevent
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax system sequences vocabs.loader words
-accessors alias constants ;
+accessors ;
IN: unix.kqueue
<< "unix.kqueue." os name>> append require >>
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.kqueue
C-STRUCT: kevent
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.kqueue
C-STRUCT: kevent
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.kqueue
C-STRUCT: kevent
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
IN: unix.linux.epoll
-USING: alien.syntax math constants ;
+USING: alien.syntax math ;
FUNCTION: int epoll_create ( int size ) ;
! Copyright (C) 2008 Slava Pestov.\r
! See http://factorcode.org/license.txt for BSD license.\r
-USING: alien.syntax math math.bitwise constants ;\r
+USING: alien.syntax math math.bitwise ;\r
IN: unix.linux.inotify\r
\r
C-STRUCT: inotify-event\r
! Copyright (C) 2005, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax alias constants ;
+USING: alien.syntax ;
IN: unix
! Linux.
USING: kernel alien.c-types alien.strings sequences math alien.syntax unix
vectors kernel namespaces continuations threads assocs vectors
-io.backend.unix io.encodings.utf8 unix.utilities constants ;
+io.backend.unix io.encodings.utf8 unix.utilities ;
IN: unix.process
! Low-level Unix process launching utilities. These are used
! Copyright (C) 2006 Patrick Mauritz.
! See http://factorcode.org/license.txt for BSD license.
IN: unix
-USING: alien.syntax system kernel layouts constants ;
+USING: alien.syntax system kernel layouts ;
! Solaris.
USING: kernel system combinators alien.syntax alien.c-types
-math io.backend.unix vocabs.loader unix constants ;
+math io.backend.unix vocabs.loader unix ;
IN: unix.stat
! File Types
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.statfs.freebsd
CONSTANT: MFSNAMELEN 16 ! length of type name including null */
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types io.encodings.utf8 io.encodings.string
kernel sequences unix.stat accessors unix combinators math
-grouping system alien.strings math.bitwise alien.syntax
-alias constants ;
+grouping system alien.strings math.bitwise alien.syntax ;
IN: unix.statfs.macosx
CONSTANT: MNT_RDONLY HEX: 00000001
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.statfs.openbsd
CONSTANT: MFSNAMELEN 16
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.statvfs.freebsd
C-STRUCT: statvfs
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.statvfs.linux
C-STRUCT: statvfs64
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.statvfs.macosx
C-STRUCT: statvfs
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.statvfs.netbsd
CONSTANT: _VFS_NAMELEN 32
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax constants ;
+USING: alien.syntax ;
IN: unix.statvfs.openbsd
C-STRUCT: statvfs
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.syntax kernel libc
sequences continuations byte-arrays strings math namespaces
-system combinators vocabs.loader qualified accessors
+system combinators vocabs.loader accessors
stack-checker macros locals generalizations unix.types
-io vocabs vocabs.loader constants ;
+io vocabs vocabs.loader ;
IN: unix
CONSTANT: PROT_NONE 0
USING: alien.c-types alien.syntax combinators continuations
io.encodings.string io.encodings.utf8 kernel sequences strings
unix calendar system accessors unix.time calendar.unix
-vocabs.loader constants ;
+vocabs.loader ;
IN: unix.utmpx
CONSTANT: EMPTY 0
-USING: alias alien.syntax kernel math windows.types math.bitwise
-constants ;
+USING: alien.syntax kernel math windows.types math.bitwise ;
IN: windows.advapi32
LIBRARY: advapi32
USING: windows.dinput windows.kernel32 windows.ole32 windows.com
windows.com.syntax alien alien.c-types alien.syntax kernel system namespaces
-combinators sequences symbols fry math accessors macros words quotations
+combinators sequences fry math accessors macros words quotations
libc continuations generalizations splitting locals assocs init
struct-arrays ;
IN: windows.dinput.constants
USING: windows.kernel32 windows.ole32 windows.com windows.com.syntax
-alien alien.c-types alien.syntax kernel system namespaces math constants
-alias ;
+alien alien.c-types alien.syntax kernel system namespaces math ;
IN: windows.dinput
<<
-USING: kernel constants ;
IN: windows.errors
CONSTANT: ERROR_SUCCESS 0
! FUNCTION: AbortDoc
! Copyright (C) 2005, 2006 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.syntax kernel windows.types alias constants ;
+USING: alien alien.syntax kernel windows.types ;
IN: windows.gdi32
! Stock Logical Objects
! Copyright (C) 2005, 2006 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.syntax kernel windows.types alias constants ;
+USING: alien alien.syntax kernel windows.types ;
IN: windows.kernel32
CONSTANT: MAX_PATH 260
! Copyright (C) 2005, 2006 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs hashtables kernel math namespaces words
-windows.types vocabs sequences constants alias ;
+windows.types vocabs sequences ;
IN: windows.messages
SYMBOL: windows-messages
USING: alien alien.c-types alien.strings alien.syntax
combinators io.encodings.utf16n io.files io.pathnames kernel
windows windows.com windows.com.syntax windows.ole32
-windows.user32 constants alias ;
+windows.user32 ;
IN: windows.shell32
CONSTANT: CSIDL_DESKTOP HEX: 00
! Copyright (C) 2005, 2006 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.syntax parser namespaces kernel math
-windows.types generalizations math.bitwise alias constants ;
+windows.types generalizations math.bitwise ;
IN: windows.user32
! HKL for ActivateKeyboardLayout
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.strings alien.syntax arrays
byte-arrays kernel math sequences windows.types windows.kernel32
-windows.errors windows math.bitwise alias io.encodings.utf16n
-alias constants ;
+windows.errors windows math.bitwise io.encodings.utf16n ;
IN: windows.winsock
USE: libc
USING: kernel arrays alien alien.c-types alien.strings
alien.syntax math math.bitwise words sequences namespaces
-continuations io io.encodings.ascii alias ;
+continuations io io.encodings.ascii ;
IN: x11.xlib
LIBRARY: xlib
! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: xmode.marker.context xmode.rules symbols accessors
+USING: xmode.marker.context xmode.rules accessors
xmode.tokens namespaces make kernel sequences assocs math ;
IN: xmode.marker.state
"PRIVATE>"
"SBUF\""
"SINGLETON:"
+ "SINGLETONS:"
"SYMBOL:"
+ "SYMBOLS:"
+ "CONSTANT:"
"TUPLE:"
"SLOT:"
"T{"
"INTERSECTION:"
"USE:"
"USING:"
+ "QUALIFIED:"
+ "QUALIFIED-WITH:"
+ "FROM:"
+ "EXCLUDE:"
+ "RENAME:"
+ "ALIAS:"
"V{"
"W{"
"["
! Copyright (C) 2004, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays definitions assocs kernel kernel.private
-slots.private namespaces make sequences strings words vectors
-math quotations combinators sorting effects graphs vocabs sets ;
+slots.private namespaces make sequences strings words words.symbol
+vectors math quotations combinators sorting effects graphs
+vocabs sets ;
IN: classes
SYMBOL: class<=-cache
ARTICLE: "singletons" "Singleton classes"
"A singleton is a class with only one instance and with no state."
{ $subsection POSTPONE: SINGLETON: }
+{ $subsection POSTPONE: SINGLETONS: }
{ $subsection define-singleton-class }
"The set of all singleton classes is itself a class:"
{ $subsection singleton-class? }
IN: compiler.errors
USING: help.markup help.syntax vocabs.loader words io
-quotations ;
+quotations words.symbol ;
ARTICLE: "compiler-errors" "Compiler warnings and errors"
"The compiler saves various notifications in a global variable:"
GENERIC: stack-effect ( word -- effect/f )
-M: symbol stack-effect drop (( -- symbol )) ;
-
M: word stack-effect
{ "declared-effect" "inferred-effect" }
swap props>> [ at ] curry map [ ] find nip ;
USING: help.markup help.syntax kernel math quotations
-math.private words ;
+math.private words words.symbol ;
IN: math.order
HELP: <=>
USING: help.markup help.syntax kernel sequences words
math strings vectors quotations generic effects classes
vocabs.loader definitions io vocabs source-files
-quotations namespaces compiler.units assocs lexer ;
+quotations namespaces compiler.units assocs lexer
+words.symbol words.alias words.constant vocabs.parser ;
IN: parser
-ARTICLE: "vocabulary-search-shadow" "Shadowing word names"
-"If adding a vocabulary to the search path results in a word in another vocabulary becoming inaccessible due to the new vocabulary defining a word with the same name, we say that the old word has been " { $emphasis "shadowed" } "."
-$nl
-"Here is an example where shadowing occurs:"
-{ $code
- "IN: foe"
- "USING: sequences io ;"
- ""
- ": append"
- " \"foe::append calls sequences:append\" print append ;"
- ""
- "IN: fee"
- ""
- ": append"
- " \"fee::append calls fee:append\" print append ;"
- ""
- "IN: fox"
- "USE: foe"
- ""
- ": append"
- " \"fox::append calls foe:append\" print append ;"
- ""
- "\"1234\" \"5678\" append print"
- ""
- "USE: fox"
- "\"1234\" \"5678\" append print"
-}
-"When placed in a source file and run, the above code produces the following output:"
-{ $code
- "foe:append calls sequences:append"
- "12345678"
- "fee:append calls foe:append"
- "foe:append calls sequences:append"
- "12345678"
-}
-"The " { $vocab-link "qualified" } " vocabulary contains some tools for helping with shadowing." ;
-
-ARTICLE: "vocabulary-search-errors" "Word lookup errors"
-"If the parser cannot not find a word in the current vocabulary search path, it attempts to look for the word in all loaded vocabularies."
-$nl
-"If " { $link auto-use? } " mode is off, a restartable error is thrown with a restart for each vocabulary in question, together with a restart which defers the word in the current vocabulary, as if " { $link POSTPONE: DEFER: } " was used."
-$nl
-"If " { $link auto-use? } " mode is on and only one vocabulary has a word with this name, the vocabulary is added to the search path and parsing continues."
-$nl
-"If any restarts were invoked, or if " { $link auto-use? } " is on, the parser will print the correct " { $link POSTPONE: USING: } " after parsing completes. This form can be copy and pasted back into the source file."
-{ $subsection auto-use? } ;
-
-ARTICLE: "vocabulary-search" "Vocabulary search path"
-"When the parser reads a token, it attempts to look up a word named by that token. The lookup is performed by searching each vocabulary in the search path, in order."
-$nl
-"For a source file the vocabulary search path starts off with one vocabulary:"
-{ $code "syntax" }
-"The " { $vocab-link "syntax" } " vocabulary consists of a set of parsing words for reading Factor data and defining new words."
-$nl
-"In the listener, the " { $vocab-link "scratchpad" } " is the default vocabulary for new word definitions. However, when loading source files, there is no default vocabulary. Defining words before declaring a vocabulary with " { $link POSTPONE: IN: } " results in an error."
-$nl
-"At the interactive listener, the default search path contains many more vocabularies. Details on the default search path and parser invocation are found in " { $link "parser" } "."
-$nl
-"Three parsing words deal with the vocabulary search path:"
-{ $subsection POSTPONE: USE: }
-{ $subsection POSTPONE: USING: }
-{ $subsection POSTPONE: IN: }
-"Private words can be defined; note that this is just a convention and they can be called from other vocabularies anyway:"
-{ $subsection POSTPONE: <PRIVATE }
-{ $subsection POSTPONE: PRIVATE> }
-{ $subsection "vocabulary-search-errors" }
-{ $subsection "vocabulary-search-shadow" }
-{ $see-also "words" "qualified" } ;
-
ARTICLE: "reading-ahead" "Reading ahead"
"Parsing words can consume input:"
{ $subsection scan }
[ ] [ f lexer set f file set "Hello world" note. ] unit-test
[ "CHAR: \\u9999999999999" eval ] must-fail
+
+SYMBOLS: a b c ;
+
+[ a ] [ a ] unit-test
+[ b ] [ b ] unit-test
+[ c ] [ c ] unit-test
+
+DEFER: blah
+
+[ ] [ "IN: symbols.tests GENERIC: blah" eval ] unit-test
+[ ] [ "IN: symbols.tests USE: symbols SYMBOLS: blah ;" eval ] unit-test
+
+[ f ] [ \ blah generic? ] unit-test
+[ t ] [ \ blah symbol? ] unit-test
+
+[ "IN: symbols.tests USE: symbols SINGLETONS: blah blah blah ;" eval ]
+[ error>> error>> def>> \ blah eq? ]
+must-fail-with
+
+IN: qualified.tests.foo
+: x 1 ;
+: y 5 ;
+IN: qualified.tests.bar
+: x 2 ;
+: y 4 ;
+IN: qualified.tests.baz
+: x 3 ;
+
+QUALIFIED: qualified.tests.foo
+QUALIFIED: qualified.tests.bar
+[ 1 2 3 ] [ qualified.tests.foo:x qualified.tests.bar:x x ] unit-test
+
+QUALIFIED-WITH: qualified.tests.bar p
+[ 2 ] [ p:x ] unit-test
+
+RENAME: x qualified.tests.baz => y
+[ 3 ] [ y ] unit-test
+
+FROM: qualified.tests.baz => x ;
+[ 3 ] [ x ] unit-test
+[ 3 ] [ y ] unit-test
+
+EXCLUDE: qualified.tests.bar => x ;
+[ 3 ] [ x ] unit-test
+[ 4 ] [ y ] unit-test
+
+[ "USE: qualified IN: qualified.tests FROM: qualified.tests => doesnotexist ;" eval ]
+[ error>> no-word-error? ] must-fail-with
+
+[ "USE: qualified IN: qualified.tests RENAME: doesnotexist qualified.tests => blah" eval ]
+[ error>> no-word-error? ] must-fail-with
! Copyright (C) 2005, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays definitions generic assocs kernel math namespaces
-sequences strings vectors words quotations io
+sequences strings vectors words words.symbol quotations io
combinators sorting splitting math.parser effects continuations
io.files io.streams.string vocabs io.encodings.utf8 source-files
classes hashtables compiler.errors compiler.units accessors sets
-lexer ;
+lexer vocabs.parser ;
IN: parser
: location ( -- loc )
"Note: " write dup print
] when drop ;
-SYMBOL: use
-SYMBOL: in
-
-: (use+) ( vocab -- )
- vocab-words use get push ;
-
-: use+ ( vocab -- )
- load-vocab (use+) ;
-
-: add-use ( seq -- ) [ use+ ] each ;
-
-: set-use ( seq -- )
- [ vocab-words ] V{ } map-as sift use set ;
-
-: check-vocab-string ( name -- name )
- dup string?
- [ "Vocabulary name must be a string" throw ] unless ;
-
-: set-in ( name -- )
- check-vocab-string dup in set create-vocab (use+) ;
-
M: parsing-word stack-effect drop (( parsed -- parsed )) ;
TUPLE: no-current-vocab ;
: CREATE-WORD ( -- word ) CREATE dup reset-generic ;
-: word-restarts ( name possibilities -- restarts )
- natural-sort
- [ [ vocabulary>> "Use the " " vocabulary" surround ] keep ] { } map>assoc
- swap "Defer word in current vocabulary" swap 2array
- suffix ;
-
-ERROR: no-word-error name ;
-
-: <no-word-error> ( name possibilities -- error restarts )
- [ drop \ no-word-error boa ] [ word-restarts ] 2bi ;
-
SYMBOL: amended-use
SYMBOL: auto-use?
USING: generic help.syntax help.markup kernel math parser words
effects classes generic.standard classes.tuple generic.math
generic.standard arrays io.pathnames vocabs.loader io sequences
-assocs ;
+assocs words.symbol words.alias words.constant ;
IN: syntax
ARTICLE: "parser-algorithm" "Parser algorithm"
{ $description "Defines a new symbol word in the current vocabulary. Symbols push themselves on the stack when executed, and are used to identify variables (see " { $link "namespaces" } ") as well as for storing crufties in word properties (see " { $link "word-props" } ")." }
{ $examples { $example "USE: prettyprint" "IN: scratchpad" "SYMBOL: foo\nfoo ." "foo" } } ;
-{ define-symbol POSTPONE: SYMBOL: } related-words
+{ define-symbol POSTPONE: SYMBOL: POSTPONE: SYMBOLS: } related-words
+
+HELP: SYMBOLS:
+{ $syntax "SYMBOLS: words... ;" }
+{ $values { "words" "a sequence of new words to define" } }
+{ $description "Creates a new symbol for every token until the " { $snippet ";" } "." }
+{ $examples { $example "USING: prettyprint ;" "IN: scratchpad" "SYMBOLS: foo bar baz ;\nfoo . bar . baz ." "foo\nbar\nbaz" } } ;
+
+HELP: SINGLETONS:
+{ $syntax "SINGLETONS: words... ;" }
+{ $values { "words" "a sequence of new words to define" } }
+{ $description "Creates a new singleton for every token until the " { $snippet ";" } "." } ;
+
+HELP: ALIAS:
+{ $syntax "ALIAS: new-word existing-word" }
+{ $values { "new-word" word } { "existing-word" word } }
+{ $description "Creates a new inlined word that calls the existing word." }
+{ $examples
+ { $example "USING: prettyprint sequences ;"
+ "IN: alias.test"
+ "ALIAS: sequence-nth nth"
+ "0 { 10 20 30 } sequence-nth ."
+ "10"
+ }
+} ;
+
+{ define-alias POSTPONE: ALIAS: } related-words
+
+HELP: CONSTANT:
+{ $syntax "CONSTANT: word value" }
+{ $values { "word" word } { "value" object } }
+{ $description "Creates a word which pushes a value on the stack." }
+{ $examples { $code "CONSTANT: magic 1" "CONSTANT: science HEX: ff0f" } } ;
+
+{ define-constant POSTPONE: CONSTANT: } related-words
HELP: \
{ $syntax "\\ word" }
{ $description "Adds a list of vocabularies to the front of the search path, with later vocabularies taking precedence." }
{ $errors "Throws an error if one of the vocabularies does not exist." } ;
+HELP: QUALIFIED:
+{ $syntax "QUALIFIED: vocab" }
+{ $description "Similar to " { $link POSTPONE: USE: } " but loads vocabulary with prefix." }
+{ $examples { $example
+ "USING: prettyprint qualified ;"
+ "QUALIFIED: math"
+ "1 2 math:+ ." "3"
+} } ;
+
+HELP: QUALIFIED-WITH:
+{ $syntax "QUALIFIED-WITH: vocab word-prefix" }
+{ $description "Works like " { $link POSTPONE: QUALIFIED: } " but uses " { $snippet "word-prefix" } " as prefix." }
+{ $examples { $code
+ "USING: prettyprint qualified ;"
+ "QUALIFIED-WITH: math m"
+ "1 2 m:+ ."
+ "3"
+} } ;
+
+HELP: FROM:
+{ $syntax "FROM: vocab => words ... ;" }
+{ $description "Imports " { $snippet "words" } " from " { $snippet "vocab" } "." }
+{ $examples { $code
+ "FROM: math.parser => bin> hex> ; ! imports only bin> and hex>" } } ;
+
+HELP: EXCLUDE:
+{ $syntax "EXCLUDE: vocab => words ... ;" }
+{ $description "Imports everything from " { $snippet "vocab" } " excluding " { $snippet "words" } "." }
+{ $examples { $code
+ "EXCLUDE: math.parser => bin> hex> ; ! imports everything but bin> and hex>" } } ;
+
+HELP: RENAME:
+{ $syntax "RENAME: word vocab => newname" }
+{ $description "Imports " { $snippet "word" } " from " { $snippet "vocab" } ", but renamed to " { $snippet "newname" } "." }
+{ $examples { $example
+ "USING: prettyprint qualified ;"
+ "RENAME: + math => -"
+ "2 3 - ."
+ "5"
+} } ;
+
HELP: IN:
{ $syntax "IN: vocabulary" }
{ $values { "vocabulary" "a new vocabulary name" } }
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien arrays byte-arrays definitions generic
hashtables kernel math namespaces parser lexer sequences strings
-strings.parser sbufs vectors words quotations io assocs
-splitting classes.tuple generic.standard generic.math
-generic.parser classes io.pathnames vocabs classes.parser
-classes.union classes.intersection classes.mixin
-classes.predicate classes.singleton classes.tuple.parser
-compiler.units combinators effects.parser slots ;
+strings.parser sbufs vectors words words.symbol words.constant
+words.alias quotations io assocs splitting classes.tuple
+generic.standard generic.math generic.parser classes
+io.pathnames vocabs vocabs.parser classes.parser classes.union
+classes.intersection classes.mixin classes.predicate
+classes.singleton classes.tuple.parser compiler.units
+combinators effects.parser slots ;
IN: bootstrap.syntax
! These words are defined as a top-level form, instead of with
"syntax" lookup t "delimiter" set-word-prop ;
: define-syntax ( name quot -- )
- [ "syntax" lookup dup ] dip define make-parsing ;
+ [ dup "syntax" lookup [ dup ] [ no-word-error ] ?if ] dip
+ define make-parsing ;
[
{ "]" "}" ";" ">>" } [ define-delimiter ] each
"USING:" [ ";" parse-tokens add-use ] define-syntax
+ "QUALIFIED:" [ scan dup add-qualified ] define-syntax
+
+ "QUALIFIED-WITH:" [ scan scan add-qualified ] define-syntax
+
+ "FROM:" [
+ scan "=>" expect ";" parse-tokens swap add-words-from
+ ] define-syntax
+
+ "EXCLUDE:" [
+ scan "=>" expect ";" parse-tokens swap add-words-excluding
+ ] define-syntax
+
+ "RENAME:" [
+ scan scan "=>" expect scan add-renamed-word
+ ] define-syntax
+
"HEX:" [ 16 parse-base ] define-syntax
"OCT:" [ 8 parse-base ] define-syntax
"BIN:" [ 2 parse-base ] define-syntax
CREATE-WORD define-symbol
] define-syntax
+ "SYMBOLS:" [
+ ";" parse-tokens
+ [ create-in dup reset-generic define-symbol ] each
+ ] define-syntax
+
+ "SINGLETONS:" [
+ ";" parse-tokens
+ [ create-class-in define-singleton-class ] each
+ ] define-syntax
+
+ "ALIAS:" [
+ CREATE-WORD scan-word define-alias
+ ] define-syntax
+
+ "CONSTANT:" [
+ CREATE scan-object define-constant
+ ] define-syntax
+
"DEFER:" [
scan current-vocab create
dup old-definitions get [ delete-at ] with each
--- /dev/null
+Daniel Ehrenberg
+Bruno Deferrari
+Slava Pestov
--- /dev/null
+USING: help.markup help.syntax parser ;
+IN: vocabs.parser
+
+ARTICLE: "vocabulary-search-shadow" "Shadowing word names"
+"If adding a vocabulary to the search path results in a word in another vocabulary becoming inaccessible due to the new vocabulary defining a word with the same name, we say that the old word has been " { $emphasis "shadowed" } "."
+$nl
+"Here is an example where shadowing occurs:"
+{ $code
+ "IN: foe"
+ "USING: sequences io ;"
+ ""
+ ": append"
+ " \"foe::append calls sequences:append\" print append ;"
+ ""
+ "IN: fee"
+ ""
+ ": append"
+ " \"fee::append calls fee:append\" print append ;"
+ ""
+ "IN: fox"
+ "USE: foe"
+ ""
+ ": append"
+ " \"fox::append calls foe:append\" print append ;"
+ ""
+ "\"1234\" \"5678\" append print"
+ ""
+ "USE: fox"
+ "\"1234\" \"5678\" append print"
+}
+"When placed in a source file and run, the above code produces the following output:"
+{ $code
+ "foe:append calls sequences:append"
+ "12345678"
+ "fee:append calls foe:append"
+ "foe:append calls sequences:append"
+ "12345678"
+}
+"The " { $vocab-link "qualified" } " vocabulary contains some tools for helping with shadowing." ;
+
+ARTICLE: "vocabulary-search-errors" "Word lookup errors"
+"If the parser cannot not find a word in the current vocabulary search path, it attempts to look for the word in all loaded vocabularies."
+$nl
+"If " { $link auto-use? } " mode is off, a restartable error is thrown with a restart for each vocabulary in question, together with a restart which defers the word in the current vocabulary, as if " { $link POSTPONE: DEFER: } " was used."
+$nl
+"If " { $link auto-use? } " mode is on and only one vocabulary has a word with this name, the vocabulary is added to the search path and parsing continues."
+$nl
+"If any restarts were invoked, or if " { $link auto-use? } " is on, the parser will print the correct " { $link POSTPONE: USING: } " after parsing completes. This form can be copy and pasted back into the source file."
+{ $subsection auto-use? } ;
+
+ARTICLE: "vocabulary-search" "Vocabulary search path"
+"When the parser reads a token, it attempts to look up a word named by that token. The lookup is performed by searching each vocabulary in the search path, in order."
+$nl
+"For a source file the vocabulary search path starts off with one vocabulary:"
+{ $code "syntax" }
+"The " { $vocab-link "syntax" } " vocabulary consists of a set of parsing words for reading Factor data and defining new words."
+$nl
+"In the listener, the " { $vocab-link "scratchpad" } " is the default vocabulary for new word definitions. However, when loading source files, there is no default vocabulary. Defining words before declaring a vocabulary with " { $link POSTPONE: IN: } " results in an error."
+$nl
+"At the interactive listener, the default search path contains many more vocabularies. Details on the default search path and parser invocation are found in " { $link "parser" } "."
+$nl
+"Three parsing words deal with the vocabulary search path:"
+{ $subsection POSTPONE: IN: }
+{ $subsection POSTPONE: USE: }
+{ $subsection POSTPONE: USING: }
+"There are some additional parsing words give more control over word lookup than is offered by " { $link POSTPONE: USE: } " and " { $link POSTPONE: USING: } ":"
+{ $subsection POSTPONE: QUALIFIED: }
+{ $subsection POSTPONE: QUALIFIED-WITH: }
+{ $subsection POSTPONE: FROM: }
+{ $subsection POSTPONE: EXCLUDE: }
+{ $subsection POSTPONE: RENAME: }
+"These words are useful when there is no way to avoid using two vocabularies with identical word names in the same source file."
+$nl
+"Private words can be defined; note that this is just a convention and they can be called from other vocabularies anyway:"
+{ $subsection POSTPONE: <PRIVATE }
+{ $subsection POSTPONE: PRIVATE> }
+{ $subsection "vocabulary-search-errors" }
+{ $subsection "vocabulary-search-shadow" }
+{ $see-also "words" } ;
+
+ABOUT: "vocabulary-search"
--- /dev/null
+! Copyright (C) 2007, 2008 Daniel Ehrenberg, Bruno Deferrari,
+! Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs hashtables kernel namespaces sequences
+sets strings vocabs sorting accessors arrays ;
+IN: vocabs.parser
+
+ERROR: no-word-error name ;
+
+: word-restarts ( name possibilities -- restarts )
+ natural-sort
+ [ [ vocabulary>> "Use the " " vocabulary" surround ] keep ] { } map>assoc
+ swap "Defer word in current vocabulary" swap 2array
+ suffix ;
+
+: <no-word-error> ( name possibilities -- error restarts )
+ [ drop \ no-word-error boa ] [ word-restarts ] 2bi ;
+
+SYMBOL: use
+SYMBOL: in
+
+: (use+) ( vocab -- )
+ vocab-words use get push ;
+
+: use+ ( vocab -- )
+ load-vocab (use+) ;
+
+: add-use ( seq -- ) [ use+ ] each ;
+
+: set-use ( seq -- )
+ [ vocab-words ] V{ } map-as sift use set ;
+
+: add-qualified ( vocab prefix -- )
+ [ load-vocab vocab-words ] [ CHAR: : suffix ] bi*
+ [ swap [ prepend ] dip ] curry assoc-map
+ use get push ;
+
+: partial-vocab ( words vocab -- assoc )
+ load-vocab vocab-words
+ [ dupd at [ no-word-error ] unless* ] curry { } map>assoc ;
+
+: add-words-from ( words vocab -- )
+ partial-vocab use get push ;
+
+: partial-vocab-excluding ( words vocab -- assoc )
+ load-vocab [ vocab-words keys swap diff ] keep partial-vocab ;
+
+: add-words-excluding ( words vocab -- )
+ partial-vocab-excluding use get push ;
+
+: add-renamed-word ( word vocab new-name -- )
+ [ load-vocab vocab-words dupd at [ ] [ no-word-error ] ?if ] dip
+ associate use get push ;
+
+: check-vocab-string ( name -- name )
+ dup string? [ "Vocabulary name must be a string" throw ] unless ;
+
+: set-in ( name -- )
+ check-vocab-string dup in set create-vocab (use+) ;
--- /dev/null
+USING: help.markup help.syntax words.alias ;
+IN: words.alias
+
+ARTICLE: "words.alias" "Word aliasing"
+"There is a syntax for defining new names for existing words. This useful for C library bindings, for example in the Win32 API, where words need to be renamed for symmetry."
+$nl
+"Define a new word that aliases another word:"
+{ $subsection POSTPONE: ALIAS: }
+"Define an alias at run-time:"
+{ $subsection define-alias } ;
+
+ABOUT: "words.alias"
--- /dev/null
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: quotations effects accessors sequences words kernel ;
+IN: words.alias
+
+PREDICATE: alias < word "alias" word-prop ;
+
+: define-alias ( new old -- )
+ [ [ 1quotation ] [ stack-effect ] bi define-inline ]
+ [ drop t "alias" set-word-prop ] 2bi ;
+
+M: alias reset-word
+ [ call-next-method ] [ f "alias" set-word-prop ] bi ;
+
+M: alias stack-effect
+ def>> first stack-effect ;
--- /dev/null
+Slava Pestov
--- /dev/null
+Defining multiple words with the same name
--- /dev/null
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors kernel sequences words ;
+IN: words.constant
+
+PREDICATE: constant < word ( obj -- ? )
+ def>> dup length 1 = [ first word? not ] [ drop f ] if ;
+
+: define-constant ( word value -- )
+ [ ] curry (( -- value )) define-inline ;
--- /dev/null
+USING: help.syntax help.markup words.symbol words compiler.units ;
+IN: words.symbol
+
+HELP: symbol
+{ $description "The class of symbols created by " { $link POSTPONE: SYMBOL: } "." } ;
+
+HELP: define-symbol
+{ $values { "word" word } }
+{ $description "Defines the word to push itself on the stack when executed. This is the run time equivalent of " { $link POSTPONE: SYMBOL: } "." }
+{ $notes "This word must be called from inside " { $link with-compilation-unit } "." }
+{ $side-effects "word" } ;
+
+ARTICLE: "words.symbol" "Symbols"
+"A symbol pushes itself on the stack when executed. By convention, symbols are used as variable names (" { $link "namespaces" } ")."
+{ $subsection symbol }
+{ $subsection symbol? }
+"Defining symbols at parse time:"
+{ $subsection POSTPONE: SYMBOL: }
+{ $subsection POSTPONE: SYMBOLS: }
+"Defining symbols at run time:"
+{ $subsection define-symbol }
+"Symbols are just compound definitions in disguise. The following two lines are equivalent:"
+{ $code
+ "SYMBOL: foo"
+ ": foo ( -- value ) \\ foo ;"
+} ;
+
+ABOUT: "words.symbol"
--- /dev/null
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel sequences accessors definitions
+words words.constant ;
+IN: words.symbol
+
+PREDICATE: symbol < constant ( obj -- ? )
+ [ def>> ] [ [ ] curry ] bi sequence= ;
+
+M: symbol definer drop \ SYMBOL: f ;
+
+M: symbol definition drop f ;
+
+: define-symbol ( word -- )
+ dup define-constant ;
$nl
"All other types of word definitions, such as " { $link "symbols" } " and " { $link "generic" } ", are just special cases of the above." ;
-ARTICLE: "symbols" "Symbols"
-"A symbol pushes itself on the stack when executed. By convention, symbols are used as variable names (" { $link "namespaces" } ")."
-{ $subsection symbol }
-{ $subsection symbol? }
-"Defining symbols at parse time:"
-{ $subsection POSTPONE: SYMBOL: }
-"Defining symbols at run time:"
-{ $subsection define-symbol }
-"Symbols are just compound definitions in disguise. The following two lines are equivalent:"
-{ $code
- "SYMBOL: foo"
- ": foo ( -- value ) \\ foo ;"
-} ;
-
ARTICLE: "primitives" "Primitives"
"Primitives are words defined in the Factor VM. They provide the essential low-level services to the rest of the system."
{ $subsection primitive }
}
"The latter is a more dynamic feature that can be used to implement code generation and such, and in fact parse time defining words are implemented in terms of run time defining words."
{ $subsection "colon-definition" }
-{ $subsection "symbols" }
+{ $subsection "words.symbol" }
+{ $subsection "words.alias" }
{ $subsection "primitives" }
{ $subsection "deferred" }
{ $subsection "declarations" }
HELP: primitive
{ $description "The class of primitive words." } ;
-HELP: symbol
-{ $description "The class of symbols created by " { $link POSTPONE: SYMBOL: } "." } ;
-
HELP: word-prop
{ $values { "word" word } { "name" "a property name" } { "value" "a property value" } }
{ $description "Retrieves a word property. Word property names are conventionally strings." } ;
{ $values { "word" word } { "start" "the word's start address" } { "end" "the word's end address" } }
{ $description "Outputs the machine code address of the word's definition." } ;
-HELP: define-symbol
-{ $values { "word" word } }
-{ $description "Defines the word to push itself on the stack when executed. This is the run time equivalent of " { $link POSTPONE: SYMBOL: } "." }
-{ $notes "This word must be called from inside " { $link with-compilation-unit } "." }
-{ $side-effects "word" } ;
-
HELP: define
{ $values { "word" word } { "def" quotation } }
{ $description "Defines the word to call a quotation when executed. This is the run time equivalent of " { $link POSTPONE: : } "." }
M: deferred definer drop \ DEFER: f ;
M: deferred definition drop f ;
-PREDICATE: symbol < word ( obj -- ? )
- [ def>> ] [ [ ] curry ] bi sequence= ;
-M: symbol definer drop \ SYMBOL: f ;
-M: symbol definition drop f ;
-
PREDICATE: primitive < word ( obj -- ? )
[ def>> [ do-primitive ] tail? ]
[ sub-primitive>> >boolean ]
: define-inline ( word def effect -- )
[ define-declared ] [ 2drop make-inline ] 3bi ;
-: define-symbol ( word -- )
- dup [ ] curry (( -- word )) define-inline ;
-
GENERIC: reset-word ( word -- )
M: word reset-word
! Copyright (C) 2008 James Cash
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences symbols fry words assocs linked-assocs tools.annotations
+USING: kernel sequences fry words assocs linked-assocs tools.annotations
coroutines lexer parser quotations arrays namespaces continuations ;
IN: advice
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays classes kernel sequences sets
-io prettyprint multi-methods symbols ;
+io prettyprint multi-methods ;
IN: boolean-expr
! Demonstrates the use of Unicode symbols in source files, and
vars colors self self.slots
random-weighted colors.hsv cfdg.gl accessors
ui.gadgets.handler ui.gestures assocs ui.gadgets macros
- qualified specialized-arrays.double ;
+ specialized-arrays.double ;
QUALIFIED: syntax
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel base64 checksums.md5 symbols sequences checksums
+USING: kernel base64 checksums.md5 sequences checksums
locals prettyprint math math.bitwise grouping io combinators
fry make combinators.short-circuit math.functions splitting ;
IN: crypto.passwd-md5
accessors
combinators.cleave
newfx
- symbols
;
IN: dns
-USING: windows.dinput windows.dinput.constants parser symbols
+USING: windows.dinput windows.dinput.constants parser
alien.c-types windows.ole32 namespaces assocs kernel arrays
vectors windows.kernel32 windows.com windows.dinput shuffle
windows.user32 windows.messages sequences combinators locals
-USING: arrays accessors continuations kernel symbols system
+USING: arrays accessors continuations kernel system
combinators.lib sequences namespaces init vocabs vocabs.loader
combinators ;
IN: game-input
continuations debugger classes.tuple namespaces make vectors
bit-arrays byte-arrays strings sbufs math.functions macros
sequences.private combinators mirrors
-combinators.short-circuit fry qualified ;
+combinators.short-circuit fry ;
RENAME: _ fry => __
IN: inverse
-USING: kernel tools.test accessors arrays sequences qualified
+USING: kernel tools.test accessors arrays sequences
io io.streams.duplex namespaces threads destructors
calendar irc.client.private irc.client irc.messages.private
concurrency.mailboxes classes assocs combinators ;
! Copyright (C) 2008 Bruno Deferrari, Doug Coleman, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: concurrency.mailboxes kernel io.sockets io.encodings.8-bit calendar
- accessors destructors namespaces io assocs arrays qualified fry
+ accessors destructors namespaces io assocs arrays fry
continuations threads strings classes combinators splitting hashtables
ascii irc.messages ;
RENAME: join sequences => sjoin
-USING: kernel tools.test accessors arrays qualified
+USING: kernel tools.test accessors arrays
irc.messages irc.messages.private ;
EXCLUDE: sequences => join ;
IN: irc.messages.tests
! Copyright (C) 2008 Bruno Deferrari
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel fry splitting ascii calendar accessors combinators qualified
+USING: kernel fry splitting ascii calendar accessors combinators
arrays classes.tuple math.order ;
RENAME: join sequences => sjoin
EXCLUDE: sequences => join ;
\r
USING: accessors kernel threads combinators concurrency.mailboxes\r
sequences strings hashtables splitting fry assocs hashtables colors\r
- sorting qualified unicode.collation math.order\r
+ sorting unicode.collation math.order\r
ui ui.gadgets ui.gadgets.panes ui.gadgets.editors\r
ui.gadgets.scrollers ui.commands ui.gadgets.frames ui.gestures\r
ui.gadgets.tabs ui.gadgets.grids ui.gadgets.packs ui.gadgets.labels\r
-USING: koszul tools.test kernel sequences assocs namespaces
-symbols ;
+USING: koszul tools.test kernel sequences assocs namespaces ;
IN: koszul.tests
[
USING: accessors arrays assocs hashtables assocs io kernel math
math.vectors math.matrices math.matrices.elimination namespaces
parser prettyprint sequences words combinators math.parser
-splitting sorting shuffle symbols sets math.order ;
+splitting sorting shuffle sets math.order ;
IN: koszul
! Utilities
! See http://factorcode.org/license.txt for BSD license.
USING: bootstrap.image continuations debugger fry
io.directories io.directories.hierarchy io.files io.launcher
-kernel mason.common namespaces qualified sequences ;
+kernel mason.common namespaces sequences ;
FROM: mason.config => target-os ;
IN: mason.release.tidy
combinators.short-circuit fry kernel locals macros
math math.blas.cblas math.blas.vectors math.blas.vectors.private
math.complex math.functions math.order functors words
-sequences sequences.merged sequences.private shuffle symbols
+sequences sequences.merged sequences.private shuffle
specialized-arrays.direct.float specialized-arrays.direct.double
specialized-arrays.float specialized-arrays.double ;
IN: math.blas.matrices
define ; parsing
! Definition protocol. We qualify core generics here
-USE: qualified
QUALIFIED: syntax
syntax:M: generic definer drop \ GENERIC: f ;
-USING: kernel sequences assocs qualified circular sets fry sequences.lib ;
+USING: kernel sequences assocs circular sets fry sequences.lib ;
USING: math multi-methods ;
io.pathnames io.streams.string kernel math math.parser
continuations namespaces pack prettyprint sequences strings
system tools.hexdump io.encodings.binary summary accessors
-io.backend symbols byte-arrays ;
+io.backend byte-arrays ;
IN: tar
: zero-checksum 256 ; inline
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: io.files io.encodings.ascii sequences generalizations
-math.parser combinators kernel memoize csv symbols summary
+math.parser combinators kernel memoize csv summary
words accessors math.order binary-search ;
IN: usa-cities
USING: tools.deploy.config ;
H{
+ { deploy-io 1 }
+ { deploy-threads? f }
+ { deploy-word-defs? f }
{ deploy-ui? f }
{ deploy-compiler? t }
+ { deploy-word-props? f }
+ { "stop-after-last-window?" t }
+ { deploy-unicode? f }
{ deploy-c-types? f }
+ { deploy-math? f }
{ deploy-reflection 1 }
{ deploy-name "WebKit demo" }
- { deploy-io 1 }
- { deploy-math? f }
- { deploy-word-props? f }
- { "stop-after-last-window?" t }
- { deploy-word-defs? f }
- { deploy-threads? f }
}