SYMBOL: current-library
-: parse-c-type-name ( name -- word )
- dup search [ ] [ no-word ] ?if ;
-
DEFER: (parse-c-type)
ERROR: bad-array-type ;
{
{ [ "*" ?tail ] [ (parse-c-type) <pointer> ] }
{ [ CHAR: ] over member? ] [ parse-array-type ] }
- { [ dup search ] [ parse-c-type-name ] }
- [ dup search [ ] [ no-word ] ?if ]
+ { [ dup search ] [ parse-word ] }
+ [ parse-word ]
} cond ;
: c-array? ( c-type -- ? )
: new-bit-writer ( class -- bs )
new
BV{ } clone >>bytes
- 0 0 <widthed> >>widthed ; inline
+ zero-widthed >>widthed ; inline
: <msb0-bit-writer> ( -- bs )
msb0-bit-writer new-bit-writer ;
: ensure-tables ( classes -- ) [ ensure-table ] each ;
: insert-tuple ( tuple -- )
- dup class ensure-defined-persistent
- db-columns find-primary-key db-assigned-id-spec?
+ dup class ensure-defined-persistent db-assigned?
[ insert-db-assigned-statement ] [ insert-user-assigned-statement ] if ;
: update-tuple ( tuple -- )
ERROR: no-slot ;
: offset-of-slot ( string tuple -- n )
- class superclasses [ "slots" word-prop ] map concat
- slot-named dup [ no-slot ] unless offset>> ;
+ class all-slots slot-named dup [ no-slot ] unless offset>> ;
: get-slot-named ( name tuple -- value )
[ nip ] [ offset-of-slot ] 2bi slot ;
SYMBOL: edit-hook
: available-editors ( -- seq )
- "editors" child-vocabs no-roots no-prefixes [ vocab-name ] map ;
+ "editors" child-vocab-names ;
: editor-restarts ( -- alist )
available-editors
] [ drop "" like 1list ] if*
] if-empty ;
-: <farkup-state> ( string -- state ) string-lines ;
: look ( state i -- char ) swap first ?nth ;
-: take-line ( state -- state' line ) unclip-slice ;
: take-lines ( state char -- state' lines )
dupd '[ ?first _ = not ] find drop
[ trim= parse-paragraph ] dip boa ; inline
: parse-heading ( state -- state' heading )
- take-line dup count= {
+ unclip-slice dup count= {
{ 0 [ make-paragraph ] }
{ 1 [ heading1 make-heading ] }
{ 2 [ heading2 make-heading ] }
] map table boa ;
: parse-line ( state -- state' item )
- take-line dup "___" =
+ unclip-slice dup "___" =
[ drop line new ] [ make-paragraph ] if ;
: parse-list ( state char class -- state' list )
: parse-code ( state -- state' item )
dup 1 look CHAR: [ =
- [ take-line make-paragraph ] [
+ [ unclip-slice make-paragraph ] [
dup "{" take-until [
[ nip rest ] dip
"}]" take-until
[ code boa ] dip swap
- ] [ drop take-line make-paragraph ] if*
+ ] [ drop unclip-slice make-paragraph ] if*
] if ;
: parse-item ( state -- state' item )
{ CHAR: # [ parse-ol ] }
{ CHAR: [ [ parse-code ] }
{ f [ rest-slice f ] }
- [ drop take-line make-paragraph ]
+ [ drop unclip-slice make-paragraph ]
} case ;
: parse-farkup ( string -- farkup )
- <farkup-state> [ dup empty? not ] [ parse-item ] produce nip sift ;
+ string-lines [ dup empty? not ] [ parse-item ] produce nip sift ;
CONSTANT: invalid-url "javascript:alert('Invalid URL in farkup');"
PRIVATE>
-SYNTAX: IS [ dup search [ ] [ no-word ] ?if ] (INTERPOLATE) ;
+SYNTAX: IS [ parse-word ] (INTERPOLATE) ;
SYNTAX: DEFERS [ current-vocab create ] (INTERPOLATE) ;
ERROR: undefined-log-level ;\r
\r
: log-level<=> ( log-level log-level -- ? )\r
- [ log-levels at* [ undefined-log-level ] unless ] bi@ <=> ;\r
+ [ log-levels at* [ undefined-log-level ] unless ] compare ;\r
\r
: log? ( log-level -- ? )\r
log-level get log-level<=> +lt+ = not ;\r
: (merge-errors) ( a b -- c )
{
- { [ over position>> not ] [ nip ] }
- { [ dup position>> not ] [ drop ] }
- [ 2dup [ position>> ] bi@ <=> {
+ { [ over position>> not ] [ nip ] }
+ { [ dup position>> not ] [ drop ] }
+ [ 2dup [ position>> ] compare {
{ +lt+ [ nip ] }
{ +gt+ [ drop ] }
{ +eq+ [ messages>> over messages>> union [ position>> ] dip <parse-error> ] }
[ rfc822>timestamp ] [ drop rfc3339>timestamp ] recover ;
: rss1.0-entry ( tag -- entry )
- entry new
- swap {
+ <entry> swap {
[ "title" tag-named children>string >>title ]
[ "link" tag-named children>string >url >>url ]
[ "description" tag-named children>string >>description ]
} cleave ;
: rss1.0 ( xml -- feed )
- feed new
- swap [
+ <feed> swap [
"channel" tag-named
[ "title" tag-named children>string >>title ]
[ "link" tag-named children>string >url >>url ] bi
] [ "item" tags-named [ rss1.0-entry ] map set-entries ] bi ;
: rss2.0-entry ( tag -- entry )
- entry new
- swap {
+ <entry> swap {
[ "title" tag-named children>string >>title ]
[ { "link" "guid" } any-tag-named children>string >url >>url ]
[ { "description" "encoded" } any-tag-named children>string >>description ]
} cleave ;
: rss2.0 ( xml -- feed )
- feed new
- swap
- "channel" tag-named
+ <feed> swap
+ "channel" tag-named
[ "title" tag-named children>string >>title ]
[ "link" tag-named children>string >url >>url ]
[ "item" tags-named [ rss2.0-entry ] map set-entries ]
dup [ "href" attr >url ] when ;
: atom1.0-entry ( tag -- entry )
- entry new
- swap {
+ <entry> swap {
[ "title" tag-named children>string >>title ]
[ atom-entry-link >>url ]
[
! Copyright (C) 2006, 2010 Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel continuations sequences math namespaces make sets
-math.parser math.ranges assocs regexp unicode.categories arrays
-hashtables words classes quotations xmode.catalog unicode.case ;
+USING: arrays assocs classes continuations hashtables kernel
+make math math.functions math.parser math.ranges namespaces
+quotations regexp sequences sets unicode.case unicode.categories
+words xmode.catalog ;
IN: validators
: v-checkbox ( str -- ? )
>lower "on" = ;
: v-default ( str def -- str/def )
- [ drop empty? not ] 2keep ? ;
+ [ drop empty? not ] most ;
: v-required ( str -- str )
dup empty? [ "required" throw ] when ;
: luhn? ( str -- ? )
string>digits <reversed>
[ odd? [ 2 * 10 /mod + ] when ] map-index
- sum 10 mod 0 = ;
+ sum 10 divisor? ;
: v-credit-card ( str -- n )
"- " without
] [ parsing-words>> push ] bi ;
: pop-parsing-word ( -- )
- lexer get parsing-words>> pop drop ;
+ lexer get parsing-words>> pop* ;
: new-lexer ( text class -- lexer )
new
[ = ] dip 1 = and ;
: find-and-check ( args argcount string -- quot )
- dup search [ ] [ no-word ] ?if
- [ nip ] [ check-word ] 2bi
+ parse-word [ nip ] [ check-word ] 2bi
[ 1quotation compose ] [ bad-stack-effect ] if ;
: arguments-codegen ( seq -- quot )
[ . ]
[ new ]
[ get ]
+ [ "" ]
[ t ] [ f ]
[ { } ]
[ drop t ] [ drop f ] [ 2drop t ] [ 2drop f ]
: pair-generic-definition ( word -- def )
[ sorted-pair-methods [ first2 pair-method-cond ] map ]
[ [ no-pair-method ] curry suffix ] bi 1quotation
- [ 2dup [ class ] bi@ <=> +gt+ eq? ?swap ] [ cond ] surround ;
+ [ 2dup [ class ] compare +gt+ eq? ?swap ] [ cond ] surround ;
: make-pair-generic ( word -- )
dup pair-generic-definition define ;
sampled 2 cut :> ( hole2 community2 )
hole1 community community2 3append :> hand1
hole2 community community2 3append :> hand2
- hand1 hand2 [ best-holdem-hand 2array ] bi@ <=> +lt+ =
+ hand1 hand2 [ best-holdem-hand 2array ] compare +lt+ =
] count ;
:: compare-holdem-hands ( holes deck n -- seq )
: version<=> ( version1 version2 -- <=> )
[ split-version ] bi@ drop-prefix
2dup [ length 0 = ] either?
- [ [ length ] bi@ >=< ] [ [ first ] bi@ <=> ] if ;
+ [ [ length ] bi@ >=< ] [ [ first ] compare ] if ;
: version< ( version1 version2 -- ? )
version<=> +lt+ = ;