HELP: no-c-type
{ $values { "name" c-type-name } }
{ $description "Throws a " { $link no-c-type } " error." }
-{ $error-description "Thrown by " { $link c-type } " if a given string does not name a C type. When thrown during compile time, indicates a typo in an " { $link alien-invoke } " or " { $link alien-callback } " form." } ;
+{ $error-description "Thrown by " { $link c-type } " if a given word is not a C type." } ;
HELP: c-type
{ $values { "name" c-type-name } { "c-type" c-type } }
USING: accessors alien alien.accessors arrays byte-arrays
classes combinators compiler.units cpu.architecture delegate
fry kernel layouts locals macros math math.order quotations
-sequences system words words.symbol ;
+sequences system words words.symbol summary ;
QUALIFIED: math
IN: alien.c-types
: <c-type> ( -- c-type )
\ c-type new ; inline
-ERROR: no-c-type name ;
+ERROR: no-c-type word ;
+
+M: no-c-type summary drop "Not a C type" ;
! C type protocol
GENERIC: c-type ( name -- c-type ) foldable
{ "quot" quotation }
{ "newquot" quotation }
}
-{ $description "Infers the number or outputs from the quotation and constructs an array from those outputs." }
+{ $description "Infers the number of outputs from the quotation and constructs an array from those outputs." }
{ $examples
{ $example
"USING: combinators combinators.smart math prettyprint ;
dup handle>> sqlite-result-set new-result-set
dup advance-row ;
-M: sqlite-db-connection <insert-db-assigned-statement> ( tuple -- statement )
+M: sqlite-db-connection <insert-db-assigned-statement> ( class -- statement )
[
"insert into " 0% 0%
"(" 0%
");" 0%
] query-make ;
-M: sqlite-db-connection <insert-user-assigned-statement> ( tuple -- statement )
+M: sqlite-db-connection <insert-user-assigned-statement> ( class -- statement )
<insert-db-assigned-statement> ;
M: sqlite-db-connection bind# ( spec obj -- )
{ $values
{ "query/tuple" tuple }
{ "tuples" "an array of tuples" } }
-{ $description "A SQL query is constructed from the slots of the exemplar tuple that are not " { $link f } ". Returns a multiple tuples from the database that match the query constructed from the exemplar tuple." } ;
+{ $description "A SQL query is constructed from the slots of the exemplar tuple that are not " { $link f } ". Returns an array of multiple tuples from the database that match the query constructed from the exemplar tuple." } ;
HELP: count-tuples
{ $values
USING: accessors arrays assocs fry help.markup help.topics io
kernel make math math.parser namespaces sequences sorting
summary tools.completion vocabs.hierarchy help.vocabs
-vocabs words unicode.case help ;
+vocabs words unicode.case help unicode.categories ;
IN: help.apropos
: $completions ( seq -- )
INSTANCE: apropos topic
: apropos ( str -- )
- <apropos> print-topic nl ;
+ [ blank? ] trim <apropos> print-topic nl ;
fry generic hashtables help.stylesheet help.topics io io.styles
kernel make math namespaces parser present prettyprint
prettyprint.stylesheet quotations see sequences sets slots
-sorting splitting strings vectors vocabs vocabs.loader words
-words.symbol ;
+sorting splitting strings urls vectors vocabs vocabs.loader
+words words.symbol ;
FROM: prettyprint.sections => with-pprint ;
FROM: namespaces => set ;
IN: help.markup
[ strong-style get print-element* ] ($span) ;
: $url ( children -- )
- [
- dup first href associate url-style get assoc-union
- print-element*
+ first dup >url [
+ dup present href associate url-style get assoc-union
+ [ write-object ] with-style
] ($span) ;
: $nl ( children -- )
"To make it convenient to have a long string which uses regexp operators, a special syntax is provided. If a substring begins with " { $snippet "\\Q" } " then everything until " { $snippet "\\E" } " is quoted (escaped). For example, " { $snippet "R/ \\Qfoo\\bar|baz()\\E/" } " matches exactly the string " { $snippet "\"foo\\bar|baz()\"" } "."
{ $heading "Unsupported features" }
{ $subheading "Group capture" }
-{ $subheading "Reluctant and posessive quantifiers" }
+{ $subheading "Reluctant and possessive quantifiers" }
{ $subheading "Backreferences" }
"Backreferences were omitted because of a design decision to allow only regular expressions following the formal theory of regular languages. For more information, see " { $link { "regexp" "theory" } } "."
$nl
tool "common" f {
{ T{ key-down f { A+ } "w" } close-window }
+ { T{ key-down f { A+ } "F" } toggle-fullscreen }
{ T{ key-down f { A+ } "q" } com-exit }
{ T{ key-down f f "F2" } refresh-all }
{ T{ key-down f f "F3" } show-error-list }
-} define-command-map
\ No newline at end of file
+} define-command-map
HELP: pprint-xml>string
{ $values { "xml" "an XML document" } { "string" "a string" } }
-{ $description "converts an XML document into a string in a prettyprinted form." }
+{ $description "Converts an XML document into a string in a prettyprinted form." }
{ $notes "This does not preserve what type of quotes were used or what data was omitted from version declaration, as that information isn't present in the XML data representation. The whitespace in the text nodes of the original document is preserved." } ;
HELP: write-xml
{ $values { "xml" "an XML document" } }
-{ $description "prints the contents of an XML document to " { $link output-stream } "." }
+{ $description "Prints the contents of an XML document to " { $link output-stream } "." }
{ $notes "This does not preserve what type of quotes were used or what data was omitted from version declaration, as that information isn't present in the XML data representation. The whitespace in the text nodes of the original document is preserved." } ;
HELP: pprint-xml
{ $values { "xml" "an XML document" } }
-{ $description "prints the contents of an XML document to " { $link output-stream } " in a prettyprinted form." }
+{ $description "Prints the contents of an XML document to " { $link output-stream } " in a prettyprinted form." }
{ $notes "This does not preserve what type of quotes were used or what data was omitted from version declaration, as that information isn't present in the XML data representation. Whitespace is also not preserved." } ;
{ xml>string write-xml pprint-xml pprint-xml>string } related-words
{ $description "Reads lines of text until from the " { $link input-stream } " until it is exhausted, collecting them in a sequence of strings." } ;
HELP: each-line
-{ $values { "quot" { $quotation "( str -- )" } } }
+{ $values { "quot" { $quotation "( ... line -- ... )" } } }
{ $description "Calls the quotation with successive lines of text, until the current " { $link input-stream } " is exhausted." } ;
HELP: each-block
-{ $values { "quot" { $quotation "( block -- )" } } }
+{ $values { "quot" { $quotation "( ... block -- ... )" } } }
{ $description "Calls the quotation with successive blocks of data, until the current " { $link input-stream } " is exhausted." } ;
HELP: stream-contents
PRIVATE>
-: each-stream-line ( stream quot -- )
+: each-stream-line ( ... stream quot: ( ... line -- ... ) -- ... )
swap [ stream-readln ] curry each-morsel ; inline
-: each-line ( quot -- )
+: each-line ( ... quot: ( ... line -- ... ) -- ... )
input-stream get swap each-stream-line ; inline
: stream-lines ( stream -- seq )
: lines ( -- seq )
input-stream get stream-lines ; inline
+: each-stream-block ( ... stream quot: ( ... block -- ... ) -- ... )
+ swap 65536 swap [ stream-read-partial ] 2curry each-morsel ; inline
+
+: each-block ( ... quot: ( ... block -- ... ) -- ... )
+ input-stream get swap each-stream-block ; inline
+
: stream-contents ( stream -- seq )
[
- [ [ 65536 swap stream-read-partial dup ] curry [ ] produce nip ]
+ [ [ ] collector [ each-stream-block ] dip { } like ]
[ stream-element-exemplar concat-as ] bi
] with-disposal ;
: contents ( -- seq )
input-stream get stream-contents ; inline
-: each-stream-block ( stream quot: ( block -- ) -- )
- swap [ 8192 swap stream-read-partial ] curry each-morsel ; inline
-
-: each-block ( quot: ( block -- ) -- )
- input-stream get swap each-stream-block ; inline
-
: stream-copy ( in out -- )
[ [ [ write ] each-block ] with-output-stream ]
curry with-input-stream ;
"10 3 < [ \"Math is broken\" print ] [ \"Math is good\" print ] if"
"Math is good"
}
-} ;
+}
+{ $notes { $snippet "if" } " is executed as a primitive when preceded by two literal quotations. The below definition is not executed unless one of its arguments is a non-literal quotation, such as a quotation constructed with " { $link curry } " or " { $link compose } ", or for " { $link "fry" } " or quotations including " { $link "locals" } "." } ;
HELP: when
{ $values { "?" "a generalized boolean" } { "true" quotation } }
{ $description "Removes " { $snippet "x" } " from the datastack, calls " { $snippet "quot" } ", and restores " { $snippet "x" } " to the top of the datastack when " { $snippet "quot" } " is finished." }
{ $examples
{ $example "USING: arrays kernel math prettyprint ;" "10 20 30 [ / ] dip 2array ." "{ 1/2 30 }" }
-} ;
+}
+{ $notes { $snippet "dip" } " is executed as a primitive when preceded by a literal quotation. The below definition is not executed unless its argument is a non-literal quotation, such as a quotation constructed with " { $link curry } " or " { $link compose } ", or for " { $link "fry" } " or quotations including " { $link "locals" } "." } ;
HELP: 2dip
{ $values { "x" object } { "y" object } { "quot" quotation } }
{ $code "'[ 2 _ + ]" } ;
ARTICLE: "namespaces-make" "Making sequences with variables"
-"The " { $vocab-link "make" } " vocabulary implements a facility for constructing sequences by holding an collector sequence in a variable. Storing the collector sequence in a variable rather than the stack may allow code to be written with less stack manipulation."
+"The " { $vocab-link "make" } " vocabulary implements a facility for constructing sequences by holding a collector sequence in a variable. Storing the collector sequence in a variable rather than the stack may allow code to be written with less stack manipulation."
$nl
"Sequence construction is wrapped in a combinator:"
{ $subsections make }
! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs calendar fry kernel parser sequences
-shuffle vocabs words memoize ;
+USING: accessors assocs calendar fry kernel locals parser
+sequences vocabs words memoize ;
IN: calendar.holidays
SINGLETONS: all world commonwealth-of-nations ;
parse-definition (( timestamp/n -- timestamp )) define-declared ;
SYNTAX: HOLIDAY-NAME:
- scan-word "holiday" word-prop scan-word scan-object spin set-at ;
+ [let scan-word "holiday" word-prop :> holidays scan-word :> name scan-object :> value
+ value name holidays set-at ] ;
>>
GENERIC: holidays ( n singleton -- seq )
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs calendar calendar.holidays
calendar.holidays.private combinators combinators.short-circuit
-fry kernel lexer math namespaces parser sequences shuffle
+fry kernel lexer math namespaces parser sequences
vocabs words ;
IN: calendar.holidays.us
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs http.client images.loader
images.loader.private images.viewer io.pathnames kernel
-namespaces sequences ;
+namespaces present sequences ;
IN: images.http
<PRIVATE
PRIVATE>
: load-http-image ( path -- image )
- [ http-get swap content-type ] [ file-extension ] bi or
+ [ http-get swap content-type ]
+ [ present file-extension ] bi or
(image-class) load-image* ;
: http-image. ( path -- )
TUPLE: ast-number value ;
TUPLE: ast-local name ;
TUPLE: ast-array name index ;
+TUPLE: ast-slice name from to ;
TUPLE: ast-function name arguments ;
TUPLE: ast-op left right op ;
TUPLE: ast-negation term ;
"[let { 1 2 3 4 } :> myarr [infix myarr[4/2]*3 infix] ] ."
"9"
}
+$nl
+"You can create sub-" { $vocab-link "sequences" } " inside infix expressions using " { $snippet "arr[from:to]" } " notation."
+{ $example
+ "USING: arrays locals infix ;"
+ "[let \"foobar\" :> s [infix s[0:3] infix] ] ."
+ "\"foo\""
+}
;
ABOUT: "infix"
[ 10 ] [ [infix stupid_function (0, 1, 2, 3, 4) infix] ] unit-test
[ -1 ] [ [let 1 :> a [infix -a infix] ] ] unit-test
+
+[ CHAR: f ] [ [let "foo" :> s [infix s[0] infix] ] ] unit-test
+[ CHAR: r ] [ [let "bar" :> s [infix s[-1] infix] ] ] unit-test
+[ "foo" ] [ [let "foobar" :> s [infix s[0:3] infix] ] ] unit-test
+[ "foo" ] [ [let "foobar" :> s [infix s[:3] infix] ] ] unit-test
+[ "bar" ] [ [let "foobar" :> s [infix s[-3:] infix] ] ] unit-test
+[ "foobar" ] [ [let "foobar" :> s [infix s[:] infix] ] ] unit-test
+[ "bar" ] [ [let "foobar" :> s [infix s[-3:100] infix] ] ] unit-test
+[ "foobar" ] [ [let "foobar" :> s [infix s[-100:100] infix] ] ] unit-test
+
! Copyright (C) 2009 Philipp Brüschweiler
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs combinators combinators.short-circuit
-effects fry infix.parser infix.ast kernel locals.parser
-locals.types math multiline namespaces parser quotations
-sequences summary words vocabs.parser ;
+effects fry infix.parser infix.ast kernel locals locals.parser
+locals.types math math.order multiline namespaces parser
+quotations sequences summary words vocabs.parser ;
+
IN: infix
<PRIVATE
M: ast-local infix-codegen
name>> >local-word ;
+:: infix-nth ( n seq -- elt )
+ n dup 0 < [ seq length + ] when seq nth ;
+
M: ast-array infix-codegen
[ index>> infix-codegen prepare-operand ]
- [ name>> >local-word ] bi '[ @ _ nth ] ;
+ [ name>> >local-word ] bi '[ @ _ infix-nth ] ;
+
+:: infix-subseq ( from to seq -- subseq )
+ seq length :> len
+ from 0 or dup 0 < [ len + ] when
+ to [ dup 0 < [ len + ] when ] [ len ] if*
+ [ 0 len clamp ] bi@ dupd max seq subseq ;
+
+M: ast-slice infix-codegen
+ [ from>> [ infix-codegen prepare-operand ] [ [ f ] ] if* ]
+ [ to>> [ infix-codegen prepare-operand ] [ [ f ] ] if* ]
+ [ name>> >local-word ] tri '[ @ @ _ infix-subseq ] ;
M: ast-op infix-codegen
[ left>> infix-codegen ] [ right>> infix-codegen ]
Number = . ?[ ast-number? ]?
Identifier = . ?[ string? ]?
Array = Identifier:i "[" Sum:s "]" => [[ i s ast-array boa ]]
+Slice = Identifier:i "[" Sum?:s ":" Sum?:t "]" => [[ i s t ast-slice boa ]]
Function = Identifier:i "(" FunArgs?:a ")" => [[ i a [ V{ } ] unless* ast-function boa ]]
FunArgs = FunArgs:a "," Sum:s => [[ s a push a ]]
Terminal = ("-"|"+"):op Terminal:term => [[ term op "-" = [ ast-negation boa ] when ]]
| "(" Sum:s ")" => [[ s ]]
- | Number | Array | Function
+ | Number | Array | Slice | Function
| Identifier => [[ ast-local boa ]]
Product = Product:p ("*"|"/"|"%"):op Terminal:term => [[ p term op ast-op boa ]]
Name = NameFirst NameRest* => [[ first2 swap prefix >string ]]
Special = [+*/%(),] | "-" => [[ CHAR: - ]]
| "[" => [[ CHAR: [ ]] | "]" => [[ CHAR: ] ]]
+ | ":" => [[ CHAR: : ]]
Tok = Spaces (Name | Number | Special )
End = !(.)
Toks = Tok* Spaces End
{ [ os unix? ] [ "libopenal.so" ] }
} cond cdecl add-library >>
-<< os macosx? [ "openal" deploy-library ] unless >>
+<< os unix? [ "openal" deploy-library ] unless >>
LIBRARY: openal
USING: accessors furnace.actions furnace.redirection
html.forms http http.server http.server.dispatchers
io.directories io.encodings.utf8 io.files io.pathnames
-kernel math.parser multiline namespaces sequences urls ;
+kernel math.parser multiline namespaces sequences urls
+math ;
IN: webapps.imagebin
TUPLE: imagebin < dispatcher path n ;
: next-image-path ( -- path )
imagebin get
- [ path>> ] [ n>> number>string ] bi append-path ;
+ [ path>> ] [ [ 1 + ] change-n n>> number>string ] bi append-path ;
M: imagebin call-responder*
[ imagebin set ] [ call-next-method ] bi ;
: move-image ( mime-file -- )
- next-image-path
+ [ next-image-path dup exists? ] [ drop ] while
[ [ temporary-path>> ] dip move-file ]
[ [ filename>> ] dip ".txt" append utf8 set-file-contents ] 2bi ;
%>
" Vim syntax file
-" Language: factor
+" Language: Factor
" Maintainer: Alex Chapman <chapman.alex@gmail.com>
-" Last Change: 2009 May 19
-" To run: USE: html.templates.fhtml "resource:misc/factor.vim.fgen" <fhtml> call-template
+" Last Change: 2011 Mar 21
+" To run: USING: html.templates html.templates.fhtml ; "resource:misc/factor.vim.fgen" <fhtml> call-template
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
set iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255
endif
-syn cluster factorCluster contains=factorComment,factorFryDirective,factorKeyword,factorRepeat,factorConditional,factorBoolean,factorCompileDirective,factorString,factorTriString,factorSbuf,@factorNumber,@factorNumErr,factorDelimiter,factorChar,factorBackslash,factorLiteral,factorLiteralBlock,@factorWordOps,factorAlien,factorTuple,factorStruct
+syn cluster factorCluster contains=factorComment,factorFrySpecifier,factorKeyword,factorRepeat,factorConditional,factorBoolean,factorBreakpoint,factorDeclaration,factorCallQuotation,factorExecute,factorCallNextMethod,factorString,factorTriString,factorSbuf,@factorNumber,@factorNumErr,factorDelimiter,factorChar,factorBackslash,factorLiteral,factorLiteralBlock,@factorWordOps,factorAlien,factorSlot,factorTuple,factorError,factorStruct
syn match factorTodo /\(TODO\|FIXME\|XXX\):\=/ contained
-syn match factorComment /\<#!\>.*/ contains=factorTodo
-syn match factorComment /\<!\>.*/ contains=factorTodo
+syn match factorComment /\<!\>\s.*/ contains=factorTodo,@Spell
+syn match factorComment /\<#!\>\s.*/ contains=factorTodo,@Spell
+syn match factorShebang /\%\^#!\s.*/ display
+syn match factorShebangErr /\%\^#!\S\+/
syn cluster factorDefnContents contains=@factorCluster,factorStackEffect,factorLiteralStackEffect,factorArray0,factorQuotation0
syn keyword factorBoolean f t
-syn match factorFryDirective /\<\(@\|_\)\>/ contained
-syn keyword factorCompileDirective inline foldable recursive
+syn keyword factorBreakpoint B
+syn keyword factorFrySpecifier @ _ contained
+syn keyword factorDeclaration delimiter deprecated final flushable foldable inline recursive
+syn match factorCallQuotation /\<call(\s\(.*\s\)\?--\(\s.*\)\?\s)\>/
+syn match factorExecute /\<execute(\s\(.*\s\)\?--\(\s.*\)\?\s)\>/
+syn keyword factorCallNextMethod call-next-method
<%
syn region factorUsing start=/\<USING:\>/ end=/;/
syn match factorQualified /\<QUALIFIED:\s\+\S\+\>/
syn match factorQualifiedWith /\<QUALIFIED-WITH:\s\+\S\+\s\+\S\+\>/
+syn region factorExclude start=/\<EXCLUDE:\>/ end=/;/
syn region factorFrom start=/\<FROM:\>/ end=/;/
+syn match factorRename /\<RENAME:\s\+\S\+\s\+\S\+\s=>\s\+\S\+\>/
syn region factorSingletons start=/\<SINGLETONS:\>/ end=/;/
syn match factorSymbol /\<SYMBOL:\s\+\S\+\>/
syn region factorSymbols start=/\<SYMBOLS:\>/ end=/;/
syn region factorConstructor2 start=/\<CONSTRUCTOR:\?/ end=/;/
+syn region factorIntersection start=/\<INTERSECTION:\>/ end=/\<;\>/
syn region factorTuple start=/\<TUPLE:\>/ end=/\<;\>/
+syn region factorError start=/\<ERROR:\>/ end=/\<;\>/
+syn region factorUnion start=/\<UNION:\>/ end=/\<;\>/
syn region factorStruct start=/\<\(UNION-STRUCT:\|STRUCT:\)\>/ end=/\<;\>/
syn match factorConstant /\<CONSTANT:\s\+\S\+\>/
-syn match factorAlias /\<ALIAS:\s\+\S\+\>/
+syn match factorAlias /\<ALIAS:\s\+\S\+\s\+\S\+\>/
syn match factorSingleton /\<SINGLETON:\s\+\S\+\>/
syn match factorPostpone /\<POSTPONE:\s\+\S\+\>/
syn match factorDefer /\<DEFER:\s\+\S\+\>/
syn match factorMain /\<MAIN:\s\+\S\+\>/
syn match factorConstructor /\<C:\s\+\S\+\s\+\S\+\>/
syn match factorAlien /\<ALIEN:\s\+[0-9a-fA-F]\([0-9a-fA-F,]*[0-9a-fA-F]\)\?\>/
+syn match factorSlot /\<SLOT:\s\+\S\+\>/
syn cluster factorWordOps contains=factorConstant,factorAlias,factorSingleton,factorSingletons,factorSymbol,factorSymbols,factorPostpone,factorDefer,factorForget,factorMixin,factorInstance,factorHook,factorMain,factorConstructor
" LIBRARY:
"#\ "
-syn region factorString start=/\<"/ skip=/\\"/ end=/"/
-syn region factorTriString start=/\<"""/ skip=/\\"/ end=/"""/
-syn region factorSbuf start=/\<SBUF"\>/ skip=/\\"/ end=/"/
+syn match factorEscape /\\\([\\stnr0e\"]\|u\x\{6}\|u{\S\+}\)/ contained display
+syn region factorString start=/\<"/ skip=/\\"/ end=/"/ contains=factorEscape
+syn region factorTriString start=/\<"""/ skip=/\\"/ end=/"""/ contains=factorEscape
+syn region factorSbuf start=/\<[-a-zA-Z0-9]\+"\>/ skip=/\\"/ end=/"/
syn region factorMultiString matchgroup=factorMultiStringDelims start=/\<STRING:\s\+\S\+\>/ end=/^;$/ contains=factorMultiStringContents
syn match factorMultiStringContents /.*/ contained
"syn match factorStackEffectErr /\<)\>/
"syn region factorStackEffectErr start=/\<(\>/ end=/\<)\>/
"syn region factorStackEffect start=/\<(\>/ end=/\<)\>/ contained
-syn match factorStackEffect /\<( .*--.* )\>/ contained
-syn match factorLiteralStackEffect /\<(( .*--.* ))\>/
+syn match factorStackEffect /\<(\s\(.*\s\)\?--\(\s.*\)\?\s)\>/ contained
+syn match factorLiteralStackEffect /\<((\s\(.*\s\)\?--\(\s.*\)\?\s))\>/
"adapted from lisp.vim
-if exists("g:factor_norainbow")
+if exists("g:factor_norainbow")
syn region factorQuotation matchgroup=factorDelimiter start=/\<\(\(\('\|\$\|\)\[\)\|\[\(let\||\)\)\>/ matchgroup=factorDelimiter end=/\<\]\>/ contains=ALL
else
- syn region factorQuotation0 matchgroup=hlLevel0 start=/\<\(\(\('\|\$\|\)\[\)\|\[\(let\||\)\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation1,factorArray1
+ syn region factorQuotation0 matchgroup=hlLevel0 start=/\<\(\(\('\|\$\|\)\[\)\|\[\(let\||\)\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation1,factorArray1
syn region factorQuotation1 contained matchgroup=hlLevel1 start=/\<\(\(\('\|\$\|\)\[\)\|\[\(let\||\)\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation2,factorArray2
syn region factorQuotation2 contained matchgroup=hlLevel2 start=/\<\(\(\('\|\$\|\)\[\)\|\[\(let\||\)\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation3,factorArray3
syn region factorQuotation3 contained matchgroup=hlLevel3 start=/\<\(\(\('\|\$\|\)\[\)\|\[\(let\||\)\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation4,factorArray4
syn region factorQuotation9 contained matchgroup=hlLevel9 start=/\<\(\(\('\|\$\|\)\[\)\|\[\(let\||\)\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation0,factorArray0
endif
-if exists("g:factor_norainbow")
+if exists("g:factor_norainbow")
syn region factorArray matchgroup=factorDelimiter start=/\<\(\$\|[-a-zA-Z0-9]\+\)\?{\>/ matchgroup=factorDelimiter end=/\<}\>/ contains=ALL
else
syn region factorArray0 matchgroup=hlLevel0 start=/\<\(\$\|[-a-zA-Z0-9]\+\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray1,factorQuotation1
endif
HiLink factorComment Comment
+ HiLink factorShebang PreProc
+ HiLink factorShebangErr Error
HiLink factorStackEffect Typedef
HiLink factorLiteralStackEffect Typedef
HiLink factorTodo Todo
HiLink factorRepeat Repeat
HiLink factorConditional Conditional
HiLink factorKeyword Keyword
+ HiLink factorCallQuotation Keyword
+ HiLink factorExecute Keyword
+ HiLink factorCallNextMethod Keyword
HiLink factorOperator Operator
- HiLink factorFryDirective Operator
+ HiLink factorFrySpecifier Operator
HiLink factorBoolean Boolean
+ HiLink factorBreakpoint Debug
HiLink factorDefnDelims Typedef
HiLink factorMethodDelims Typedef
HiLink factorGenericDelims Typedef
HiLink factorPrivateMethodDelims Special
HiLink factorPGenericDelims Special
HiLink factorPGenericNDelims Special
+ HiLink factorEscape SpecialChar
HiLink factorString String
HiLink factorTriString String
HiLink factorSbuf String
HiLink factorUsing Include
HiLink factorQualified Include
HiLink factorQualifiedWith Include
+ HiLink factorExclude Include
HiLink factorFrom Include
+ HiLink factorRename Include
HiLink factorUse Include
HiLink factorUnuse Include
HiLink factorIn Define
HiLink factorBackslash Special
HiLink factorLiteral Special
HiLink factorLiteralBlock Special
- HiLink factorCompileDirective Typedef
+ HiLink factorDeclaration Typedef
HiLink factorSymbol Define
+ HiLink factorSymbols Define
HiLink factorConstant Define
+ HiLink factorAlias Define
HiLink factorSingleton Define
HiLink factorSingletons Define
HiLink factorMixin Typedef
HiLink factorDefer Define
HiLink factorForget Define
HiLink factorAlien Define
+ HiLink factorSlot Define
+ HiLink factorIntersection Typedef
HiLink factorTuple Typedef
+ HiLink factorError Typedef
+ HiLink factorUnion Typedef
HiLink factorStruct Typedef
if &bg == "dark"
let b:current_syntax = "factor"
-set sw=4
-set sts=4
-set expandtab
-set autoindent " annoying?
-
-" vim: syntax=vim
+" vim:set ft=vim sw=4:
+++ /dev/null
-Vim support for Factor
-----------------------
-
-This directory contains various support files that make editing Factor code
-more pleasant in Vim. The file-layout exactly matches the Vim runtime
-structure, so you can install them by copying the contents of this directory
-into ~/.vim/ or the equivalent path on other platforms (Open Vim and type
-":help 'runtimepath'" for details).
-
-The current set of files is as follows:
-
- ftdetect/factor.vim
- Teach Vim when to load Factor support files.
- ftplugin/factor_settings.vim
- Teach Vim to follow the Factor Coding Style guidelines.
- plugin/factor.vim
- Teach Vim some commands for navigating Factor source code. See below.
- syntax/factor.vim
- Syntax highlighting for Factor code.
-
-The "plugin/factor.vim" file implements the following commands for
-navigating Factor source:
-
- :FactorVocab factor.vocab.name
- Opens the source file implementing the "factor.vocab.name"
- vocabulary.
- :NewFactorVocab factor.vocab.name
- Creates a new factor vocabulary under the working vocabulary root.
- :FactorVocabImpl
- Opens the main implementation file for the current vocabulary
- (name.factor). The keyboard shortcut "\fi" is bound to this
- command.
- :FactorVocabDocs
- Opens the documentation file for the current vocabulary
- (name-docs.factor). The keyboard shortcut "\fd" is bound to this
- command.
- :FactorVocabTests
- Opens the unit test file for the current vocabulary
- (name-tests.factor). The keyboard shortcut "\ft" is bound to this
- command.
-
-In order for the ":FactorVocab" command to work, you'll need to set some
-variables in your vimrc file:
- g:FactorRoot
- This variable should be set to the root of your Factor
- installation. The default value is "~/factor".
- g:FactorVocabRoots
- This variable should be set to a list of Factor vocabulary roots.
- The paths may be either relative to g:FactorRoot or absolute paths.
- The default value is ["core", "basis", "extra", "work"].
- g:FactorNewVocabRoot
- This variable should be set to the vocabulary root in which
- vocabularies created with NewFactorVocab should be created. The
- default value is "work".
-
-Note: The syntax-highlighting file is automatically generated to include the
-names of all the vocabularies Factor knows about. To regenerate it manually,
-run the following code in the listener:
-
- "editors.vim.generate-syntax" run
-
-...or run it from the command line:
-
- factor -run=editors.vim.generate-syntax
--- /dev/null
+Vim support for Factor
+======================
+
+This directory contains various support files that make editing Factor code
+more pleasant in Vim.
+
+## Installation
+
+The file-layout exactly matches the Vim runtime
+structure, so you can install them by copying the contents of this directory
+into `~/.vim/` or the equivalent path on other platforms (Open Vim and type
+`:help 'runtimepath'` for details).
+
+## File organization
+
+The current set of files is as follows:
+
+* ftdetect/factor.vim - Teach Vim when to load Factor support files.
+* ftplugin/factor_settings.vim - Teach Vim to follow the Factor Coding Style guidelines.
+* plugin/factor.vim - Teach Vim some commands for navigating Factor source code. See below.
+* syntax/factor.vim - Syntax highlighting for Factor code.
+
+## Commands
+
+The `plugin/factor.vim` file implements the following commands for navigating Factor source.
+
+### :FactorVocab factor.vocab.name
+
+Opens the source file implementing the `factor.vocab.name` vocabulary.
+
+### :NewFactorVocab factor.vocab.name
+
+Creates a new factor vocabulary under the working vocabulary root.
+
+### :FactorVocabImpl
+
+Opens the main implementation file for the current vocabulary
+(name.factor). The keyboard shortcut `<Leader>fi` is bound to this command.
+
+### :FactorVocabDocs
+
+Opens the documentation file for the current vocabulary
+(name-docs.factor). The keyboard shortcut `<Leader>fd` is bound to this command.
+
+### :FactorVocabTests
+
+Opens the unit test file for the current vocabulary
+(name-tests.factor). The keyboard shortcut `<Leader>ft` is bound to this command.
+
+## Configuration
+
+In order for the `:FactorVocab` command to work, you'll need to set some variables in your vimrc file.
+
+### g:FactorRoot
+
+This variable should be set to the root of your Factor
+installation. The default value is `~/factor`.
+
+### g:FactorVocabRoots
+
+This variable should be set to a list of Factor vocabulary roots.
+The paths may be either relative to g:FactorRoot or absolute paths.
+The default value is `["core", "basis", "extra", "work"]`.
+
+### g:FactorNewVocabRoot
+
+This variable should be set to the vocabulary root in which
+vocabularies created with NewFactorVocab should be created.
+The default value is `work`.
+
+## Note
+
+The syntax-highlighting file is automatically generated to include the
+names of all the vocabularies Factor knows about. To regenerate it manually,
+run the following code in the listener:
+
+ "editors.vim.generate-syntax" run
+
+or run it from the command line:
+
+ factor -run=editors.vim.generate-syntax
function! FactorVocabFile(root, vocab, mustexist)
let vocabpath = substitute(a:vocab, "\\.", "/", "g")
let vocabfile = FactorVocabRoot(a:root) . vocabpath . "/" . fnamemodify(vocabpath, ":t") . ".factor"
-
+
if !a:mustexist || getftype(vocabfile) != ""
return vocabfile
else
-
" Vim syntax file
-" Language: factor
+" Language: Factor
" Maintainer: Alex Chapman <chapman.alex@gmail.com>
-" Last Change: 2009 May 19
-" To run: USE: html.templates.fhtml "resource:misc/factor.vim.fgen" <fhtml> call-template
+" Last Change: 2011 Mar 21
+" To run: USING: html.templates html.templates.fhtml ; "resource:misc/factor.vim.fgen" <fhtml> call-template
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
set iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255
endif
-syn cluster factorCluster contains=factorComment,factorFryDirective,factorKeyword,factorRepeat,factorConditional,factorBoolean,factorCompileDirective,factorString,factorTriString,factorSbuf,@factorNumber,@factorNumErr,factorDelimiter,factorChar,factorBackslash,factorLiteral,factorLiteralBlock,@factorWordOps,factorAlien,factorTuple,factorStruct
+syn cluster factorCluster contains=factorComment,factorFrySpecifier,factorKeyword,factorRepeat,factorConditional,factorBoolean,factorBreakpoint,factorDeclaration,factorCallQuotation,factorExecute,factorCallNextMethod,factorString,factorTriString,factorSbuf,@factorNumber,@factorNumErr,factorDelimiter,factorChar,factorBackslash,factorLiteral,factorLiteralBlock,@factorWordOps,factorAlien,factorSlot,factorTuple,factorError,factorStruct
syn match factorTodo /\(TODO\|FIXME\|XXX\):\=/ contained
-syn match factorComment /\<#!\>.*/ contains=factorTodo
-syn match factorComment /\<!\>.*/ contains=factorTodo
+syn match factorComment /\<!\>\s.*/ contains=factorTodo,@Spell
+syn match factorComment /\<#!\>\s.*/ contains=factorTodo,@Spell
+syn match factorShebang /\%\^#!\s.*/ display
+syn match factorShebangErr /\%\^#!\S\+/
syn cluster factorDefnContents contains=@factorCluster,factorStackEffect,factorLiteralStackEffect,factorArray0,factorQuotation0
syn keyword factorBoolean f t
-syn match factorFryDirective /\<\(@\|_\)\>/ contained
-syn keyword factorCompileDirective inline foldable recursive
+syn keyword factorBreakpoint B
+syn keyword factorFrySpecifier @ _ contained
+syn keyword factorDeclaration delimiter deprecated final flushable foldable inline recursive
+syn match factorCallQuotation /\<call(\s\(.*\s\)\?--\(\s.*\)\?\s)\>/
+syn match factorExecute /\<execute(\s\(.*\s\)\?--\(\s.*\)\?\s)\>/
+syn keyword factorCallNextMethod call-next-method
syn keyword factorKeyword or 2bi 2tri while wrapper nip 4dip wrapper? bi* callstack>array both? hashcode die dupd callstack callstack? 3dup tri@ pick curry build ?execute 3bi prepose >boolean ?if clone eq? tri* ? = swapd 2over 2keep 3keep clear 2dup when not tuple? dup 2bi* 2tri* call tri-curry object bi@ do unless* if* loop bi-curry* drop when* assert= retainstack assert? -rot execute 2bi@ 2tri@ boa with either? 3drop bi curry? datastack until 3dip over 3curry tri-curry* tri-curry@ swap and 2nip throw bi-curry (clone) hashcode* compose 2dip if 3tri unless compose? tuple keep 2curry equal? assert tri 2drop most <wrapper> boolean? identity-hashcode identity-tuple? null new dip bi-curry@ rot xor identity-tuple boolean
syn keyword factorKeyword ?at assoc? assoc-clone-like assoc= delete-at* assoc-partition extract-keys new-assoc value? assoc-size map>assoc push-at assoc-like key? assoc-intersect assoc-refine update assoc-union assoc-combine at* assoc-empty? at+ set-at assoc-all? assoc-subset? assoc-hashcode change-at assoc-each assoc-diff zip values value-at rename-at inc-at enum? at cache assoc>map <enum> assoc assoc-map enum value-at* assoc-map-as >alist assoc-filter-as clear-assoc assoc-stack maybe-set-at substitute assoc-filter 2cache delete-at assoc-find keys assoc-any? unzip
syn region factorUsing start=/\<USING:\>/ end=/;/
syn match factorQualified /\<QUALIFIED:\s\+\S\+\>/
syn match factorQualifiedWith /\<QUALIFIED-WITH:\s\+\S\+\s\+\S\+\>/
+syn region factorExclude start=/\<EXCLUDE:\>/ end=/;/
syn region factorFrom start=/\<FROM:\>/ end=/;/
+syn match factorRename /\<RENAME:\s\+\S\+\s\+\S\+\s=>\s\+\S\+\>/
syn region factorSingletons start=/\<SINGLETONS:\>/ end=/;/
syn match factorSymbol /\<SYMBOL:\s\+\S\+\>/
syn region factorSymbols start=/\<SYMBOLS:\>/ end=/;/
syn region factorConstructor2 start=/\<CONSTRUCTOR:\?/ end=/;/
+syn region factorIntersection start=/\<INTERSECTION:\>/ end=/\<;\>/
syn region factorTuple start=/\<TUPLE:\>/ end=/\<;\>/
+syn region factorError start=/\<ERROR:\>/ end=/\<;\>/
+syn region factorUnion start=/\<UNION:\>/ end=/\<;\>/
syn region factorStruct start=/\<\(UNION-STRUCT:\|STRUCT:\)\>/ end=/\<;\>/
syn match factorConstant /\<CONSTANT:\s\+\S\+\>/
-syn match factorAlias /\<ALIAS:\s\+\S\+\>/
+syn match factorAlias /\<ALIAS:\s\+\S\+\s\+\S\+\>/
syn match factorSingleton /\<SINGLETON:\s\+\S\+\>/
syn match factorPostpone /\<POSTPONE:\s\+\S\+\>/
syn match factorDefer /\<DEFER:\s\+\S\+\>/
syn match factorMain /\<MAIN:\s\+\S\+\>/
syn match factorConstructor /\<C:\s\+\S\+\s\+\S\+\>/
syn match factorAlien /\<ALIEN:\s\+[0-9a-fA-F]\([0-9a-fA-F,]*[0-9a-fA-F]\)\?\>/
+syn match factorSlot /\<SLOT:\s\+\S\+\>/
syn cluster factorWordOps contains=factorConstant,factorAlias,factorSingleton,factorSingletons,factorSymbol,factorSymbols,factorPostpone,factorDefer,factorForget,factorMixin,factorInstance,factorHook,factorMain,factorConstructor
" LIBRARY:
"#\ "
-syn region factorString start=/\<"/ skip=/\\"/ end=/"/
-syn region factorTriString start=/\<"""/ skip=/\\"/ end=/"""/
+syn match factorEscape /\\\([\\stnr0e\"]\|u\x\{6}\|u{\S\+}\)/ contained display
+syn region factorString start=/\<"/ skip=/\\"/ end=/"/ contains=factorEscape
+syn region factorTriString start=/\<"""/ skip=/\\"/ end=/"""/ contains=factorEscape
syn region factorSbuf start=/\<[-a-zA-Z0-9]\+"\>/ skip=/\\"/ end=/"/
syn region factorMultiString matchgroup=factorMultiStringDelims start=/\<STRING:\s\+\S\+\>/ end=/^;$/ contains=factorMultiStringContents
"syn match factorStackEffectErr /\<)\>/
"syn region factorStackEffectErr start=/\<(\>/ end=/\<)\>/
"syn region factorStackEffect start=/\<(\>/ end=/\<)\>/ contained
-syn match factorStackEffect /\<( .*--.* )\>/ contained
-syn match factorLiteralStackEffect /\<(( .*--.* ))\>/
+syn match factorStackEffect /\<(\s\(.*\s\)\?--\(\s.*\)\?\s)\>/ contained
+syn match factorLiteralStackEffect /\<((\s\(.*\s\)\?--\(\s.*\)\?\s))\>/
"adapted from lisp.vim
-if exists("g:factor_norainbow")
+if exists("g:factor_norainbow")
syn region factorQuotation matchgroup=factorDelimiter start=/\<\(\(\('\|\$\|\)\[\)\|\[\(let\||\)\)\>/ matchgroup=factorDelimiter end=/\<\]\>/ contains=ALL
else
- syn region factorQuotation0 matchgroup=hlLevel0 start=/\<\(\(\('\|\$\|\)\[\)\|\[\(let\||\)\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation1,factorArray1
+ syn region factorQuotation0 matchgroup=hlLevel0 start=/\<\(\(\('\|\$\|\)\[\)\|\[\(let\||\)\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation1,factorArray1
syn region factorQuotation1 contained matchgroup=hlLevel1 start=/\<\(\(\('\|\$\|\)\[\)\|\[\(let\||\)\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation2,factorArray2
syn region factorQuotation2 contained matchgroup=hlLevel2 start=/\<\(\(\('\|\$\|\)\[\)\|\[\(let\||\)\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation3,factorArray3
syn region factorQuotation3 contained matchgroup=hlLevel3 start=/\<\(\(\('\|\$\|\)\[\)\|\[\(let\||\)\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation4,factorArray4
syn region factorQuotation9 contained matchgroup=hlLevel9 start=/\<\(\(\('\|\$\|\)\[\)\|\[\(let\||\)\)\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation0,factorArray0
endif
-if exists("g:factor_norainbow")
+if exists("g:factor_norainbow")
syn region factorArray matchgroup=factorDelimiter start=/\<\(\$\|[-a-zA-Z0-9]\+\)\?{\>/ matchgroup=factorDelimiter end=/\<}\>/ contains=ALL
else
syn region factorArray0 matchgroup=hlLevel0 start=/\<\(\$\|[-a-zA-Z0-9]\+\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray1,factorQuotation1
endif
HiLink factorComment Comment
+ HiLink factorShebang PreProc
+ HiLink factorShebangErr Error
HiLink factorStackEffect Typedef
HiLink factorLiteralStackEffect Typedef
HiLink factorTodo Todo
HiLink factorRepeat Repeat
HiLink factorConditional Conditional
HiLink factorKeyword Keyword
+ HiLink factorCallQuotation Keyword
+ HiLink factorExecute Keyword
+ HiLink factorCallNextMethod Keyword
HiLink factorOperator Operator
- HiLink factorFryDirective Operator
+ HiLink factorFrySpecifier Operator
HiLink factorBoolean Boolean
+ HiLink factorBreakpoint Debug
HiLink factorDefnDelims Typedef
HiLink factorMethodDelims Typedef
HiLink factorGenericDelims Typedef
HiLink factorPrivateMethodDelims Special
HiLink factorPGenericDelims Special
HiLink factorPGenericNDelims Special
+ HiLink factorEscape SpecialChar
HiLink factorString String
HiLink factorTriString String
HiLink factorSbuf String
HiLink factorUsing Include
HiLink factorQualified Include
HiLink factorQualifiedWith Include
+ HiLink factorExclude Include
HiLink factorFrom Include
+ HiLink factorRename Include
HiLink factorUse Include
HiLink factorUnuse Include
HiLink factorIn Define
HiLink factorBackslash Special
HiLink factorLiteral Special
HiLink factorLiteralBlock Special
- HiLink factorCompileDirective Typedef
+ HiLink factorDeclaration Typedef
HiLink factorSymbol Define
+ HiLink factorSymbols Define
HiLink factorConstant Define
+ HiLink factorAlias Define
HiLink factorSingleton Define
HiLink factorSingletons Define
HiLink factorMixin Typedef
HiLink factorDefer Define
HiLink factorForget Define
HiLink factorAlien Define
+ HiLink factorSlot Define
+ HiLink factorIntersection Typedef
HiLink factorTuple Typedef
+ HiLink factorError Typedef
+ HiLink factorUnion Typedef
HiLink factorStruct Typedef
if &bg == "dark"
let b:current_syntax = "factor"
-set sw=4
-set sts=4
-set expandtab
-set autoindent " annoying?
-
-" vim: syntax=vim
-
+" vim:set ft=vim sw=4:
package, or checked out Factor sources from the GIT repository.</p>
<ul>
-<li><a href="http://concatenative.org/wiki/view/Factor/Getting%20started">Getting started</a></li>
+<li><a href="http://concatenative.org/wiki/view/Factor/Learning">Learning Factor</a></li>
<li><a href="http://concatenative.org/wiki/view/Factor/Requirements">System requirements</a></li>
<li><a href="http://concatenative.org/wiki/view/Factor/Building%20Factor">Building Factor from source</a> (don't do this if you're using a binary package)</li>
</ul>