Merge branch 'master' of git://factorcode.org/git/factor
commit
b1b7fa11f0
|
|
@ -21,8 +21,8 @@ HELP: <date>
|
||||||
{ $description "Returns a timestamp object representing the start of the specified day in your current timezone." }
|
{ $description "Returns a timestamp object representing the start of the specified day in your current timezone." }
|
||||||
{ $examples
|
{ $examples
|
||||||
{ $example "USING: calendar prettyprint ;"
|
{ $example "USING: calendar prettyprint ;"
|
||||||
"2010 12 25 <date> ."
|
"2010 12 25 <date> >gmt midnight ."
|
||||||
"T{ timestamp\n { year 2010 }\n { month 12 }\n { day 25 }\n { gmt-offset T{ duration { hour -5 } } }\n}"
|
"T{ timestamp { year 2010 } { month 12 } { day 25 } }"
|
||||||
}
|
}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@ namespaces xml html.components html.forms
|
||||||
splitting unicode.categories furnace accessors ;
|
splitting unicode.categories furnace accessors ;
|
||||||
IN: html.templates.chloe.tests
|
IN: html.templates.chloe.tests
|
||||||
|
|
||||||
reset-templates
|
|
||||||
|
|
||||||
: run-template
|
: run-template
|
||||||
with-string-writer [ "\r\n\t" member? not ] filter
|
with-string-writer [ "\r\n\t" member? not ] filter
|
||||||
"?>" split1 nip ; inline
|
"?>" split1 nip ; inline
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors kernel sequences combinators kernel fry
|
USING: accessors kernel sequences combinators kernel fry
|
||||||
namespaces make classes.tuple assocs splitting words arrays
|
namespaces make classes.tuple assocs splitting words arrays io
|
||||||
memoize io io.files io.encodings.utf8 io.streams.string
|
io.files io.encodings.utf8 io.streams.string unicode.case
|
||||||
unicode.case mirrors math urls present multiline quotations xml
|
mirrors math urls present multiline quotations xml logging
|
||||||
xml.data
|
xml.data
|
||||||
html.forms
|
html.forms
|
||||||
html.elements
|
html.elements
|
||||||
|
|
@ -89,21 +89,40 @@ CHLOE-TUPLE: choice
|
||||||
CHLOE-TUPLE: checkbox
|
CHLOE-TUPLE: checkbox
|
||||||
CHLOE-TUPLE: code
|
CHLOE-TUPLE: code
|
||||||
|
|
||||||
: read-template ( chloe -- xml )
|
SYMBOL: template-cache
|
||||||
path>> ".xml" append utf8 <file-reader> read-xml ;
|
|
||||||
|
|
||||||
MEMO: template-quot ( chloe -- quot )
|
H{ } template-cache set-global
|
||||||
read-template compile-template ;
|
|
||||||
|
|
||||||
MEMO: nested-template-quot ( chloe -- quot )
|
TUPLE: cached-template path last-modified quot ;
|
||||||
read-template compile-nested-template ;
|
|
||||||
|
|
||||||
: reset-templates ( -- )
|
: load-template ( chloe -- cached-template )
|
||||||
{ template-quot nested-template-quot } [ reset-memoized ] each ;
|
path>> ".xml" append
|
||||||
|
[ ]
|
||||||
|
[ file-info modified>> ]
|
||||||
|
[ utf8 <file-reader> read-xml compile-template ] tri
|
||||||
|
\ cached-template boa ;
|
||||||
|
|
||||||
|
\ load-template DEBUG add-input-logging
|
||||||
|
|
||||||
|
: cached-template ( chloe -- cached-template/f )
|
||||||
|
template-cache get at* [
|
||||||
|
[
|
||||||
|
[ path>> file-info modified>> ]
|
||||||
|
[ last-modified>> ]
|
||||||
|
bi =
|
||||||
|
] keep and
|
||||||
|
] when ;
|
||||||
|
|
||||||
|
: template-quot ( chloe -- quot )
|
||||||
|
dup cached-template [ ] [
|
||||||
|
[ load-template dup ] keep
|
||||||
|
template-cache get set-at
|
||||||
|
] ?if quot>> ;
|
||||||
|
|
||||||
|
: reset-cache ( -- )
|
||||||
|
template-cache get clear-assoc ;
|
||||||
|
|
||||||
M: chloe call-template*
|
M: chloe call-template*
|
||||||
nested-template? get
|
template-quot assert-depth ;
|
||||||
[ nested-template-quot ] [ template-quot ] if
|
|
||||||
assert-depth ;
|
|
||||||
|
|
||||||
INSTANCE: chloe template
|
INSTANCE: chloe template
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
USING: assocs namespaces make kernel sequences accessors
|
USING: assocs namespaces make kernel sequences accessors
|
||||||
combinators strings splitting io io.streams.string present
|
combinators strings splitting io io.streams.string present
|
||||||
xml.writer xml.data xml.entities html.forms
|
xml.writer xml.data xml.entities html.forms
|
||||||
html.templates.chloe.syntax ;
|
html.templates html.templates.chloe.syntax ;
|
||||||
IN: html.templates.chloe.compiler
|
IN: html.templates.chloe.compiler
|
||||||
|
|
||||||
: chloe-attrs-only ( assoc -- assoc' )
|
: chloe-attrs-only ( assoc -- assoc' )
|
||||||
|
|
@ -98,9 +98,6 @@ DEFER: compile-element
|
||||||
reset-buffer
|
reset-buffer
|
||||||
] [ ] make ; inline
|
] [ ] make ; inline
|
||||||
|
|
||||||
: compile-nested-template ( xml -- quot )
|
|
||||||
[ compile-element ] with-compiler ;
|
|
||||||
|
|
||||||
: compile-chunk ( seq -- )
|
: compile-chunk ( seq -- )
|
||||||
[ compile-element ] each ;
|
[ compile-element ] each ;
|
||||||
|
|
||||||
|
|
@ -121,12 +118,25 @@ DEFER: compile-element
|
||||||
: compile-with-scope ( quot -- )
|
: compile-with-scope ( quot -- )
|
||||||
compile-quot [ with-scope ] [code] ; inline
|
compile-quot [ with-scope ] [code] ; inline
|
||||||
|
|
||||||
|
: if-not-nested ( quot -- )
|
||||||
|
nested-template? get swap unless ; inline
|
||||||
|
|
||||||
|
: compile-prologue ( xml -- )
|
||||||
|
[
|
||||||
|
[ before>> compile-chunk ]
|
||||||
|
[ prolog>> [ write-prolog ] [code-with] ]
|
||||||
|
bi
|
||||||
|
] compile-quot
|
||||||
|
[ if-not-nested ] [code] ;
|
||||||
|
|
||||||
|
: compile-epilogue ( xml -- )
|
||||||
|
[ after>> compile-chunk ] compile-quot
|
||||||
|
[ if-not-nested ] [code] ;
|
||||||
|
|
||||||
: compile-template ( xml -- quot )
|
: compile-template ( xml -- quot )
|
||||||
[
|
[
|
||||||
{
|
[ compile-prologue ]
|
||||||
[ prolog>> [ write-prolog ] [code-with] ]
|
[ compile-element ]
|
||||||
[ before>> compile-chunk ]
|
[ compile-epilogue ]
|
||||||
[ compile-element ]
|
tri
|
||||||
[ after>> compile-chunk ]
|
|
||||||
} cleave
|
|
||||||
] with-compiler ;
|
] with-compiler ;
|
||||||
|
|
|
||||||
|
|
@ -216,9 +216,8 @@ intel_macosx_word_size() {
|
||||||
$ECHO -n "Testing if your Intel Mac supports 64bit binaries..."
|
$ECHO -n "Testing if your Intel Mac supports 64bit binaries..."
|
||||||
sysctl machdep.cpu.extfeatures | grep EM64T >/dev/null
|
sysctl machdep.cpu.extfeatures | grep EM64T >/dev/null
|
||||||
if [[ $? -eq 0 ]] ; then
|
if [[ $? -eq 0 ]] ; then
|
||||||
WORD=32
|
WORD=64
|
||||||
$ECHO "yes!"
|
$ECHO "yes!"
|
||||||
$ECHO "Defaulting to 32bit for now though..."
|
|
||||||
else
|
else
|
||||||
WORD=32
|
WORD=32
|
||||||
$ECHO "no."
|
$ECHO "no."
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ unit-test
|
||||||
[ "-1.0e-2" string>number number>string ]
|
[ "-1.0e-2" string>number number>string ]
|
||||||
unit-test
|
unit-test
|
||||||
|
|
||||||
[ "-1.0e-12" ]
|
[ t ]
|
||||||
[ "-1.0e-12" string>number number>string ]
|
[ "-1.0e-12" string>number number>string { "-1.0e-12" "-1.0e-012" } member? ]
|
||||||
unit-test
|
unit-test
|
||||||
|
|
||||||
[ f ]
|
[ f ]
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,6 @@ SYMBOL: key-file
|
||||||
SYMBOL: dh-file
|
SYMBOL: dh-file
|
||||||
|
|
||||||
: common-configuration ( -- )
|
: common-configuration ( -- )
|
||||||
reset-templates
|
|
||||||
"concatenative.org" 25 <inet> smtp-server set-global
|
"concatenative.org" 25 <inet> smtp-server set-global
|
||||||
"noreply@concatenative.org" lost-password-from set-global
|
"noreply@concatenative.org" lost-password-from set-global
|
||||||
"website@concatenative.org" insomniac-sender set-global
|
"website@concatenative.org" insomniac-sender set-global
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ IN: regexp.dfa
|
||||||
nfa-table>> transitions>>
|
nfa-table>> transitions>>
|
||||||
[ at keys ] curry map concat
|
[ at keys ] curry map concat
|
||||||
eps swap remove ;
|
eps swap remove ;
|
||||||
! dup t member? [ t swap remove t suffix ] when ;
|
|
||||||
|
|
||||||
: add-todo-state ( state regexp -- )
|
: add-todo-state ( state regexp -- )
|
||||||
2dup visited-states>> key? [
|
2dup visited-states>> key? [
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,19 @@ IN: regexp
|
||||||
dupd match
|
dupd match
|
||||||
[ [ length ] [ length>> 1- ] bi* = ] [ drop f ] if* ;
|
[ [ length ] [ length>> 1- ] bi* = ] [ drop f ] if* ;
|
||||||
|
|
||||||
: match-head ( string regexp -- end ) match length>> 1- ;
|
: match-head ( string regexp -- end/f ) match [ length>> 1- ] [ f ] if* ;
|
||||||
|
|
||||||
|
: match-at ( string m regexp -- n/f finished? )
|
||||||
|
[
|
||||||
|
2dup swap length > [ 2drop f f ] [ tail-slice t ] if
|
||||||
|
] dip swap [ match-head f ] [ 2drop f t ] if ;
|
||||||
|
|
||||||
|
: match-range ( string m regexp -- a/f b/f )
|
||||||
|
3dup match-at over [
|
||||||
|
drop nip rot drop dupd +
|
||||||
|
] [
|
||||||
|
[ 3drop drop f f ] [ drop [ 1+ ] dip match-range ] if
|
||||||
|
] if ;
|
||||||
|
|
||||||
: initial-option ( regexp option -- regexp' )
|
: initial-option ( regexp option -- regexp' )
|
||||||
over options>> conjoin ;
|
over options>> conjoin ;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,12 @@ TUPLE: transition-table transitions start-state final-states ;
|
||||||
H{ } clone >>transitions
|
H{ } clone >>transitions
|
||||||
H{ } clone >>final-states ;
|
H{ } clone >>final-states ;
|
||||||
|
|
||||||
|
: maybe-initialize-key ( key hashtable -- )
|
||||||
|
2dup key? [ 2drop ] [ H{ } clone -rot set-at ] if ;
|
||||||
|
|
||||||
: set-transition ( transition hash -- )
|
: set-transition ( transition hash -- )
|
||||||
|
#! set the state as a key
|
||||||
|
2dup [ to>> ] dip maybe-initialize-key
|
||||||
[ [ to>> ] [ obj>> ] [ from>> ] tri ] dip
|
[ [ to>> ] [ obj>> ] [ from>> ] tri ] dip
|
||||||
2dup at* [ 2nip insert-at ]
|
2dup at* [ 2nip insert-at ]
|
||||||
[ drop >r >r H{ } clone [ insert-at ] keep r> r> set-at ] if ;
|
[ drop >r >r H{ } clone [ insert-at ] keep r> r> set-at ] if ;
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,10 @@ TUPLE: dfa-traverser
|
||||||
dup save-final-state
|
dup save-final-state
|
||||||
] when text-finished? ;
|
] when text-finished? ;
|
||||||
|
|
||||||
|
: print-flags ( dfa-traverser -- dfa-traverser )
|
||||||
|
dup [ current-state>> ] [ traversal-flags>> ] bi
|
||||||
|
;
|
||||||
|
|
||||||
: increment-state ( dfa-traverser state -- dfa-traverser )
|
: increment-state ( dfa-traverser state -- dfa-traverser )
|
||||||
[
|
[
|
||||||
[ 1+ ] change-current-index dup current-state>> >>last-state
|
[ 1+ ] change-current-index dup current-state>> >>last-state
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue