huge code cleanup
parent
5b26116784
commit
12a09523d4
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
+ listener/plugin:
|
+ listener/plugin:
|
||||||
|
|
||||||
|
- use decl wrong
|
||||||
- faster completion
|
- faster completion
|
||||||
- sidekick: still parsing too much
|
- sidekick: still parsing too much
|
||||||
- errors don't always disappear
|
- errors don't always disappear
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
IN: timesheet
|
IN: timesheet
|
||||||
USE: errors
|
USE: errors
|
||||||
USE: format
|
|
||||||
USE: kernel
|
USE: kernel
|
||||||
USE: lists
|
USE: lists
|
||||||
USE: math
|
USE: math
|
||||||
|
@ -31,7 +30,7 @@ USE: vectors
|
||||||
! Printing the timesheet.
|
! Printing the timesheet.
|
||||||
|
|
||||||
: hh ( duration -- str ) 60 /i ;
|
: hh ( duration -- str ) 60 /i ;
|
||||||
: mm ( duration -- str ) 60 mod unparse 2 digits ;
|
: mm ( duration -- str ) 60 mod unparse 2 "0" pad ;
|
||||||
: hh:mm ( millis -- str ) [ dup hh , ":" , mm , ] make-list ;
|
: hh:mm ( millis -- str ) [ dup hh , ":" , mm , ] make-list ;
|
||||||
|
|
||||||
: print-entry ( duration description -- )
|
: print-entry ( duration description -- )
|
||||||
|
|
|
@ -74,7 +74,6 @@ USE: stdio
|
||||||
"/library/syntax/parse-stream.factor"
|
"/library/syntax/parse-stream.factor"
|
||||||
"/library/bootstrap/init.factor"
|
"/library/bootstrap/init.factor"
|
||||||
|
|
||||||
"/library/format.factor"
|
|
||||||
"/library/syntax/unparser.factor"
|
"/library/syntax/unparser.factor"
|
||||||
"/library/io/presentation.factor"
|
"/library/io/presentation.factor"
|
||||||
"/library/io/vocabulary-style.factor"
|
"/library/io/vocabulary-style.factor"
|
||||||
|
|
|
@ -137,7 +137,7 @@ GENERIC: ' ( obj -- ptr )
|
||||||
: here-as ( tag -- pointer )
|
: here-as ( tag -- pointer )
|
||||||
here swap bitor ;
|
here swap bitor ;
|
||||||
|
|
||||||
: pad ( -- )
|
: align-here ( -- )
|
||||||
here 8 mod 4 = [ 0 emit ] when ;
|
here 8 mod 4 = [ 0 emit ] when ;
|
||||||
|
|
||||||
( Remember what objects we've compiled )
|
( Remember what objects we've compiled )
|
||||||
|
@ -162,7 +162,7 @@ M: bignum ' ( bignum -- tagged )
|
||||||
[ 0 | [ 1 0 ] ]
|
[ 0 | [ 1 0 ] ]
|
||||||
[ -1 | [ 2 1 1 ] ]
|
[ -1 | [ 2 1 1 ] ]
|
||||||
[ 1 | [ 2 0 1 ] ]
|
[ 1 | [ 2 0 1 ] ]
|
||||||
] assoc [ emit ] each pad r> ;
|
] assoc [ emit ] each align-here r> ;
|
||||||
|
|
||||||
( Special objects )
|
( Special objects )
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ M: cons ' ( c -- tagged )
|
||||||
dup str-length emit
|
dup str-length emit
|
||||||
dup hashcode emit
|
dup hashcode emit
|
||||||
pack-string
|
pack-string
|
||||||
pad ;
|
align-here ;
|
||||||
|
|
||||||
M: string ' ( string -- pointer )
|
M: string ' ( string -- pointer )
|
||||||
#! We pool strings so that each string is only written once
|
#! We pool strings so that each string is only written once
|
||||||
|
@ -286,7 +286,7 @@ M: string ' ( string -- pointer )
|
||||||
array-type >header emit
|
array-type >header emit
|
||||||
dup length emit
|
dup length emit
|
||||||
( elements -- ) [ emit ] each
|
( elements -- ) [ emit ] each
|
||||||
pad r> ;
|
align-here r> ;
|
||||||
|
|
||||||
M: vector ' ( vector -- pointer )
|
M: vector ' ( vector -- pointer )
|
||||||
dup vector>list emit-array swap vector-length
|
dup vector>list emit-array swap vector-length
|
||||||
|
@ -294,7 +294,7 @@ M: vector ' ( vector -- pointer )
|
||||||
vector-type >header emit
|
vector-type >header emit
|
||||||
emit ( length )
|
emit ( length )
|
||||||
emit ( array ptr )
|
emit ( array ptr )
|
||||||
pad r> ;
|
align-here r> ;
|
||||||
|
|
||||||
( End of the image )
|
( End of the image )
|
||||||
|
|
||||||
|
|
|
@ -64,26 +64,16 @@ USE: words
|
||||||
#!
|
#!
|
||||||
#! Arguments containing = are handled differently; they
|
#! Arguments containing = are handled differently; they
|
||||||
#! set the object path.
|
#! set the object path.
|
||||||
"=" split1 dup [
|
"=" split1 [
|
||||||
cli-var-param
|
cli-var-param
|
||||||
] [
|
] [
|
||||||
drop dup "no-" str-head? dup [
|
"no-" ?str-head not put
|
||||||
f put drop
|
] ifte* ;
|
||||||
] [
|
|
||||||
drop t put
|
|
||||||
] ifte
|
|
||||||
] ifte ;
|
|
||||||
|
|
||||||
: cli-arg ( argument -- argument )
|
: cli-arg ( argument -- argument )
|
||||||
#! Handle a command-line argument. If the argument was
|
#! Handle a command-line argument. If the argument was
|
||||||
#! consumed, returns f. Otherwise returns the argument.
|
#! consumed, returns f. Otherwise returns the argument.
|
||||||
dup f-or-"" [
|
dup f-or-"" [ "-" ?str-head [ cli-param f ] when ] unless ;
|
||||||
dup "-" str-head? dup [
|
|
||||||
cli-param drop f
|
|
||||||
] [
|
|
||||||
drop
|
|
||||||
] ifte
|
|
||||||
] unless ;
|
|
||||||
|
|
||||||
: parse-switches ( args -- args )
|
: parse-switches ( args -- args )
|
||||||
[ cli-arg ] map ;
|
[ cli-arg ] map ;
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
! :folding=indent:collapseFolds=0:
|
|
||||||
|
|
||||||
! $Id$
|
|
||||||
!
|
|
||||||
! Copyright (C) 2004 Slava Pestov.
|
|
||||||
!
|
|
||||||
! Redistribution and use in source and binary forms, with or without
|
|
||||||
! modification, are permitted provided that the following conditions are met:
|
|
||||||
!
|
|
||||||
! 1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
! this list of conditions and the following disclaimer.
|
|
||||||
!
|
|
||||||
! 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
! this list of conditions and the following disclaimer in the documentation
|
|
||||||
! and/or other materials provided with the distribution.
|
|
||||||
!
|
|
||||||
! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
||||||
! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
||||||
! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
IN: format
|
|
||||||
USE: kernel
|
|
||||||
USE: math
|
|
||||||
USE: namespaces
|
|
||||||
USE: strings
|
|
||||||
|
|
||||||
: decimal-split ( string -- string string )
|
|
||||||
#! Split a string before and after the decimal point.
|
|
||||||
dup "." index-of dup -1 = [ drop f ] [ str// ] ifte ;
|
|
||||||
|
|
||||||
: decimal-tail ( count str -- string )
|
|
||||||
#! Given a decimal, trims all but a count of decimal places.
|
|
||||||
[ str-length min ] keep str-head ;
|
|
||||||
|
|
||||||
: decimal-cat ( before after -- string )
|
|
||||||
#! If after is of zero length, return before, otherwise
|
|
||||||
#! return "before.after".
|
|
||||||
dup str-length 0 = [
|
|
||||||
drop
|
|
||||||
] [
|
|
||||||
"." swap cat3
|
|
||||||
] ifte ;
|
|
||||||
|
|
||||||
: decimal-places ( num count -- string )
|
|
||||||
#! Trims the number to a count of decimal places.
|
|
||||||
>r decimal-split dup [
|
|
||||||
r> swap decimal-tail decimal-cat
|
|
||||||
] [
|
|
||||||
r> 2drop
|
|
||||||
] ifte ;
|
|
||||||
|
|
||||||
: digits ( string count -- string )
|
|
||||||
#! Make sure string has at least count digits, padding it
|
|
||||||
#! with zeroes on the left if needed.
|
|
||||||
over str-length - dup 0 <= [
|
|
||||||
drop
|
|
||||||
] [
|
|
||||||
"0" fill swap cat2
|
|
||||||
] ifte ;
|
|
||||||
|
|
||||||
: pad-string ( len str -- str )
|
|
||||||
str-length - " " fill ;
|
|
|
@ -44,7 +44,7 @@ SYMBOL: predicate
|
||||||
\ dup , "predicate" word-property , , , \ ifte ,
|
\ dup , "predicate" word-property , , , \ ifte ,
|
||||||
] make-list ;
|
] make-list ;
|
||||||
|
|
||||||
: (predicate-method) ( vtable definition class type# -- )
|
: predicate-method ( vtable definition class type# -- )
|
||||||
>r rot r> swap [
|
>r rot r> swap [
|
||||||
vector-nth
|
vector-nth
|
||||||
( vtable definition class existing )
|
( vtable definition class existing )
|
||||||
|
@ -59,7 +59,7 @@ predicate [
|
||||||
( vtable definition class -- )
|
( vtable definition class -- )
|
||||||
dup builtin-supertypes [
|
dup builtin-supertypes [
|
||||||
( vtable definition class type# )
|
( vtable definition class type# )
|
||||||
>r 3dup r> (predicate-method)
|
>r 3dup r> predicate-method
|
||||||
] each 3drop
|
] each 3drop
|
||||||
] "add-method" set-word-property
|
] "add-method" set-word-property
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ USE: strings
|
||||||
USE: unparser
|
USE: unparser
|
||||||
|
|
||||||
: serving-path ( filename -- filename )
|
: serving-path ( filename -- filename )
|
||||||
f>"" "doc-root" get swap cat2 ;
|
[ "" ] unless* "doc-root" get swap cat2 ;
|
||||||
|
|
||||||
: file-response ( mime-type length -- )
|
: file-response ( mime-type length -- )
|
||||||
[
|
[
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
IN: html
|
IN: html
|
||||||
USE: strings
|
USE: strings
|
||||||
USE: lists
|
USE: lists
|
||||||
USE: format
|
|
||||||
USE: kernel
|
USE: kernel
|
||||||
USE: stdio
|
USE: stdio
|
||||||
USE: namespaces
|
USE: namespaces
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
IN: html
|
IN: html
|
||||||
USE: format
|
|
||||||
USE: lists
|
USE: lists
|
||||||
USE: kernel
|
USE: kernel
|
||||||
USE: namespaces
|
USE: namespaces
|
||||||
|
@ -55,7 +54,7 @@ USE: generic
|
||||||
[ dup html-entities assoc dup rot ? ] str-map ;
|
[ dup html-entities assoc dup rot ? ] str-map ;
|
||||||
|
|
||||||
: >hex-color ( triplet -- hex )
|
: >hex-color ( triplet -- hex )
|
||||||
[ >hex 2 digits ] map "#" swons cat ;
|
[ >hex 2 "0" pad ] map "#" swons cat ;
|
||||||
|
|
||||||
: fg-css, ( color -- )
|
: fg-css, ( color -- )
|
||||||
"color: " , >hex-color , "; " , ;
|
"color: " , >hex-color , "; " , ;
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
IN: httpd
|
IN: httpd
|
||||||
USE: format
|
|
||||||
USE: kernel
|
USE: kernel
|
||||||
USE: lists
|
USE: lists
|
||||||
USE: logging
|
USE: logging
|
||||||
|
|
|
@ -29,7 +29,6 @@ IN: url-encoding
|
||||||
USE: errors
|
USE: errors
|
||||||
USE: kernel
|
USE: kernel
|
||||||
USE: lists
|
USE: lists
|
||||||
USE: format
|
|
||||||
USE: math
|
USE: math
|
||||||
USE: parser
|
USE: parser
|
||||||
USE: strings
|
USE: strings
|
||||||
|
@ -37,7 +36,9 @@ USE: unparser
|
||||||
|
|
||||||
: url-encode ( str -- str )
|
: url-encode ( str -- str )
|
||||||
[
|
[
|
||||||
dup url-quotable? [ "%" swap >hex 2 digits cat2 ] unless
|
dup url-quotable? [
|
||||||
|
"%" swap >hex 2 "0" pad cat2
|
||||||
|
] unless
|
||||||
] str-map ;
|
] str-map ;
|
||||||
|
|
||||||
: catch-hex> ( str -- n )
|
: catch-hex> ( str -- n )
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
IN: ansi
|
IN: ansi
|
||||||
USE: lists
|
USE: lists
|
||||||
USE: kernel
|
USE: kernel
|
||||||
USE: format
|
|
||||||
USE: namespaces
|
USE: namespaces
|
||||||
USE: stdio
|
USE: stdio
|
||||||
USE: streams
|
USE: streams
|
||||||
|
|
|
@ -48,6 +48,13 @@ USE: strings
|
||||||
#! repeated.
|
#! repeated.
|
||||||
[ swap [ dup , ] times drop ] make-string ;
|
[ swap [ dup , ] times drop ] make-string ;
|
||||||
|
|
||||||
|
: pad ( string count char -- string )
|
||||||
|
>r over str-length - dup 0 <= [
|
||||||
|
r> 2drop
|
||||||
|
] [
|
||||||
|
r> fill swap cat2
|
||||||
|
] ifte ;
|
||||||
|
|
||||||
: str-map ( str code -- str )
|
: str-map ( str code -- str )
|
||||||
#! Apply a quotation to each character in the string, and
|
#! Apply a quotation to each character in the string, and
|
||||||
#! push a new string constructed from return values.
|
#! push a new string constructed from return values.
|
||||||
|
|
|
@ -43,9 +43,6 @@ M: sbuf = sbuf= ;
|
||||||
: f-or-"" ( obj -- ? )
|
: f-or-"" ( obj -- ? )
|
||||||
dup not swap "" = or ;
|
dup not swap "" = or ;
|
||||||
|
|
||||||
: f>"" ( str/f -- str )
|
|
||||||
[ "" ] unless* ;
|
|
||||||
|
|
||||||
: str-length< ( str str -- boolean )
|
: str-length< ( str str -- boolean )
|
||||||
#! Compare string lengths.
|
#! Compare string lengths.
|
||||||
swap str-length swap str-length < ;
|
swap str-length swap str-length < ;
|
||||||
|
@ -96,31 +93,33 @@ M: sbuf = sbuf= ;
|
||||||
#! index.
|
#! index.
|
||||||
[ swap str-head ] 2keep succ swap str-tail ;
|
[ swap str-head ] 2keep succ swap str-tail ;
|
||||||
|
|
||||||
: str-headcut ( str begin -- str str )
|
: str-head? ( str begin -- ? )
|
||||||
str-length str/ ;
|
2dup str-length< [
|
||||||
|
2drop f
|
||||||
: =? ( x y z -- z/f )
|
] [
|
||||||
#! Push z if x = y, otherwise f.
|
dup str-length rot str-head =
|
||||||
>r = r> f ? ;
|
] ifte ;
|
||||||
|
|
||||||
: str-head? ( str begin -- str )
|
|
||||||
#! If the string starts with begin, return the rest of the
|
|
||||||
#! string after begin. Otherwise, return f.
|
|
||||||
2dup str-length< [ 2drop f ] [ tuck str-headcut =? ] ifte ;
|
|
||||||
|
|
||||||
: ?str-head ( str begin -- str ? )
|
: ?str-head ( str begin -- str ? )
|
||||||
dupd str-head? dup [ nip t ] [ drop f ] ifte ;
|
2dup str-head? [
|
||||||
|
str-length swap str-tail t
|
||||||
|
] [
|
||||||
|
drop f
|
||||||
|
] ifte ;
|
||||||
|
|
||||||
: str-tailcut ( str end -- str str )
|
: str-tail? ( str end -- ? )
|
||||||
str-length >r dup str-length r> - str/ swap ;
|
2dup str-length< [
|
||||||
|
2drop f
|
||||||
|
] [
|
||||||
|
dup str-length pick str-length swap - rot str-tail =
|
||||||
|
] ifte ;
|
||||||
|
|
||||||
: str-tail? ( str end -- str )
|
: ?str-tail ( str end -- ? )
|
||||||
#! If the string ends with end, return the start of the
|
2dup str-tail? [
|
||||||
#! string before end. Otherwise, return f.
|
str-length swap [ str-length swap - ] keep str-head t
|
||||||
2dup str-length< [ 2drop f ] [ tuck str-tailcut =? ] ifte ;
|
] [
|
||||||
|
drop f
|
||||||
: ?str-tail ( str end -- str ? )
|
] ifte ;
|
||||||
dupd str-tail? dup [ nip t ] [ drop f ] ifte ;
|
|
||||||
|
|
||||||
: split1 ( string split -- before after )
|
: split1 ( string split -- before after )
|
||||||
2dup index-of dup -1 = [
|
2dup index-of dup -1 = [
|
||||||
|
@ -130,11 +129,6 @@ M: sbuf = sbuf= ;
|
||||||
rot str-head swap
|
rot str-head swap
|
||||||
] ifte ;
|
] ifte ;
|
||||||
|
|
||||||
: max-str-length ( list -- len )
|
|
||||||
#! Returns the length of the longest string in the given
|
|
||||||
#! list.
|
|
||||||
0 swap [ str-length max ] each ;
|
|
||||||
|
|
||||||
: str-each ( str [ code ] -- )
|
: str-each ( str [ code ] -- )
|
||||||
#! Execute the code, with each character of the string
|
#! Execute the code, with each character of the string
|
||||||
#! pushed onto the stack.
|
#! pushed onto the stack.
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
|
|
||||||
IN: prettyprint
|
IN: prettyprint
|
||||||
USE: errors
|
USE: errors
|
||||||
USE: format
|
|
||||||
USE: generic
|
USE: generic
|
||||||
USE: kernel
|
USE: kernel
|
||||||
USE: lists
|
USE: lists
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
IN: unparser
|
IN: unparser
|
||||||
USE: generic
|
USE: generic
|
||||||
USE: kernel
|
USE: kernel
|
||||||
USE: format
|
|
||||||
USE: lists
|
USE: lists
|
||||||
USE: math
|
USE: math
|
||||||
USE: namespaces
|
USE: namespaces
|
||||||
|
@ -142,7 +141,7 @@ M: complex unparse ( num -- str )
|
||||||
] assoc ;
|
] assoc ;
|
||||||
|
|
||||||
: ch>unicode-escape ( ch -- esc )
|
: ch>unicode-escape ( ch -- esc )
|
||||||
>hex 4 digits "\\u" swap cat2 ;
|
>hex 4 "0" pad "\\u" swap cat2 ;
|
||||||
|
|
||||||
: unparse-ch ( ch -- ch/str )
|
: unparse-ch ( ch -- ch/str )
|
||||||
dup quotable? [
|
dup quotable? [
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
IN: scratchpad
|
|
||||||
USE: format
|
|
||||||
USE: test
|
|
||||||
|
|
||||||
[ "123" ] [ 4 "123" decimal-tail ] unit-test
|
|
||||||
[ "12" ] [ 2 "123" decimal-tail ] unit-test
|
|
||||||
[ "123" ] [ "123" 2 decimal-places ] unit-test
|
|
||||||
[ "123.12" ] [ "123.12" 2 decimal-places ] unit-test
|
|
||||||
[ "123.123" ] [ "123.123" 5 decimal-places ] unit-test
|
|
||||||
[ "123" ] [ "123.123" 0 decimal-places ] unit-test
|
|
||||||
[ "05" ] [ "5" 2 digits ] unit-test
|
|
||||||
[ "666" ] [ "666" 2 digits ] unit-test
|
|
|
@ -43,13 +43,13 @@ USE: test
|
||||||
[ "goodbye" f ] [ "goodbye" " " split1 ] unit-test
|
[ "goodbye" f ] [ "goodbye" " " split1 ] unit-test
|
||||||
[ "" "" ] [ "great" "great" split1 ] unit-test
|
[ "" "" ] [ "great" "great" split1 ] unit-test
|
||||||
|
|
||||||
[ "and end" ] [ "Beginning and end" "Beginning " str-head? ] unit-test
|
[ "and end" t ] [ "Beginning and end" "Beginning " ?str-head ] unit-test
|
||||||
[ f ] [ "Beginning and end" "Beginning x" str-head? ] unit-test
|
[ "Beginning and end" f ] [ "Beginning and end" "Beginning x" ?str-head ] unit-test
|
||||||
[ f ] [ "Beginning and end" "eginning " str-head? ] unit-test
|
[ "Beginning and end" f ] [ "Beginning and end" "eginning " ?str-head ] unit-test
|
||||||
|
|
||||||
[ "Beginning" ] [ "Beginning and end" " and end" str-tail? ] unit-test
|
[ "Beginning" t ] [ "Beginning and end" " and end" ?str-tail ] unit-test
|
||||||
[ f ] [ "Beginning and end" "Beginning x" str-tail? ] unit-test
|
[ "Beginning and end" f ] [ "Beginning and end" "Beginning x" ?str-tail ] unit-test
|
||||||
[ f ] [ "Beginning and end" "eginning " str-tail? ] unit-test
|
[ "Beginning and end" f ] [ "Beginning and end" "eginning " ?str-tail ] unit-test
|
||||||
|
|
||||||
[ [ "This" "is" "a" "split" "sentence" ] ]
|
[ [ "This" "is" "a" "split" "sentence" ] ]
|
||||||
[ "This is a split sentence" " " split ]
|
[ "This is a split sentence" " " split ]
|
||||||
|
@ -62,16 +62,10 @@ unit-test
|
||||||
[ [ "a" "b" "c" "d" "e" "f" ] ]
|
[ [ "a" "b" "c" "d" "e" "f" ] ]
|
||||||
[ "aXXbXXcXXdXXeXXf" "XX" split ] unit-test
|
[ "aXXbXXcXXdXXeXXf" "XX" split ] unit-test
|
||||||
|
|
||||||
[ 6 ]
|
[ "Hello world" t ] [ "Hello world\n" "\n" ?str-tail ] unit-test
|
||||||
[
|
[ "Hello world" f ] [ "Hello world" "\n" ?str-tail ] unit-test
|
||||||
[ "One" "Two" "Little" "Piggy" "Went" "To" "The" "Market" ]
|
[ "" t ] [ "\n" "\n" ?str-tail ] unit-test
|
||||||
max-str-length
|
[ "" f ] [ "" "\n" ?str-tail ] unit-test
|
||||||
] unit-test
|
|
||||||
|
|
||||||
[ "Hello world" ] [ "Hello world\n" "\n" str-tail? ] unit-test
|
|
||||||
[ f ] [ "Hello world" "\n" str-tail? ] unit-test
|
|
||||||
[ "" ] [ "\n" "\n" str-tail? ] unit-test
|
|
||||||
[ f ] [ "" "\n" str-tail? ] unit-test
|
|
||||||
|
|
||||||
[ t ] [ CHAR: a letter? ] unit-test
|
[ t ] [ CHAR: a letter? ] unit-test
|
||||||
[ f ] [ CHAR: A letter? ] unit-test
|
[ f ] [ CHAR: A letter? ] unit-test
|
||||||
|
@ -101,3 +95,6 @@ unit-test
|
||||||
[ dup CHAR: \s = [ drop CHAR: + ] when ] str-map
|
[ dup CHAR: \s = [ drop CHAR: + ] when ] str-map
|
||||||
]
|
]
|
||||||
unit-test
|
unit-test
|
||||||
|
|
||||||
|
[ "05" ] [ "5" 2 "0" pad ] unit-test
|
||||||
|
[ "666" ] [ "666" 2 "0" pad ] unit-test
|
||||||
|
|
|
@ -78,7 +78,6 @@ USE: unparser
|
||||||
"namespaces"
|
"namespaces"
|
||||||
"generic"
|
"generic"
|
||||||
"files"
|
"files"
|
||||||
"format"
|
|
||||||
"parser"
|
"parser"
|
||||||
"parse-number"
|
"parse-number"
|
||||||
"prettyprint"
|
"prettyprint"
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
IN: inspector
|
IN: inspector
|
||||||
USE: format
|
|
||||||
USE: kernel
|
USE: kernel
|
||||||
USE: hashtables
|
USE: hashtables
|
||||||
USE: lists
|
USE: lists
|
||||||
|
@ -38,6 +37,7 @@ USE: words
|
||||||
USE: prettyprint
|
USE: prettyprint
|
||||||
USE: unparser
|
USE: unparser
|
||||||
USE: vectors
|
USE: vectors
|
||||||
|
USE: math
|
||||||
|
|
||||||
: relative>absolute-object-path ( string -- string )
|
: relative>absolute-object-path ( string -- string )
|
||||||
"object-path" get [ "'" rot cat3 ] when* ;
|
"object-path" get [ "'" rot cat3 ] when* ;
|
||||||
|
@ -60,6 +60,9 @@ USE: vectors
|
||||||
3list
|
3list
|
||||||
default-style append ;
|
default-style append ;
|
||||||
|
|
||||||
|
: pad-string ( len str -- str )
|
||||||
|
str-length - " " fill ;
|
||||||
|
|
||||||
: var-name. ( max name -- )
|
: var-name. ( max name -- )
|
||||||
tuck unparse pad-string write dup link-style
|
tuck unparse pad-string write dup link-style
|
||||||
swap unparse swap write-attr ;
|
swap unparse swap write-attr ;
|
||||||
|
@ -67,6 +70,11 @@ USE: vectors
|
||||||
: value. ( max name value -- )
|
: value. ( max name value -- )
|
||||||
>r var-name. ": " write r> . ;
|
>r var-name. ": " write r> . ;
|
||||||
|
|
||||||
|
: max-str-length ( list -- len )
|
||||||
|
#! Returns the length of the longest string in the given
|
||||||
|
#! list.
|
||||||
|
0 swap [ str-length max ] each ;
|
||||||
|
|
||||||
: name-padding ( alist -- col )
|
: name-padding ( alist -- col )
|
||||||
[ car unparse ] map max-str-length ;
|
[ car unparse ] map max-str-length ;
|
||||||
|
|
||||||
|
|
|
@ -88,10 +88,10 @@ USE: words
|
||||||
|
|
||||||
: word-file ( path -- dir file )
|
: word-file ( path -- dir file )
|
||||||
dup [
|
dup [
|
||||||
dup "resource:/" str-head? dup [
|
"resource:/" ?str-head [
|
||||||
nip resource-path swap
|
resource-path swap
|
||||||
] [
|
] [
|
||||||
swap ( f file )
|
f swap
|
||||||
] ifte
|
] ifte
|
||||||
] [
|
] [
|
||||||
f
|
f
|
||||||
|
|
|
@ -82,7 +82,7 @@ USE: math
|
||||||
: vocab-completions ( substring vocab -- list )
|
: vocab-completions ( substring vocab -- list )
|
||||||
#! Used by jEdit plugin. Like vocab-apropos, but only
|
#! Used by jEdit plugin. Like vocab-apropos, but only
|
||||||
#! matches at the start of a word name are considered.
|
#! matches at the start of a word name are considered.
|
||||||
words [ word-name over str-head? ] subset nip ;
|
words [ word-name over ?str-head nip ] subset nip ;
|
||||||
|
|
||||||
: apropos. ( substring -- )
|
: apropos. ( substring -- )
|
||||||
#! List all words that contain a string.
|
#! List all words that contain a string.
|
||||||
|
|
Loading…
Reference in New Issue