Rework etags vocab. Remove use of local variable shuffle words, use
combinators instead. Rename some words and update testsuite accordinglydb4
parent
6c5e73898f
commit
f05aabdf28
|
@ -1,4 +1,4 @@
|
||||||
USING: kernel ctags.etags tools.test io.backend sequences arrays prettyprint hashtables assocs ;
|
USING: kernel ctags ctags.etags tools.test io.backend sequences arrays prettyprint hashtables assocs ;
|
||||||
IN: ctags.etags.tests
|
IN: ctags.etags.tests
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,27 +15,27 @@ IN: ctags.etags.tests
|
||||||
[ "path" ] [ { if { "path" 1 } } ctag-path ] unit-test
|
[ "path" ] [ { if { "path" 1 } } ctag-path ] unit-test
|
||||||
|
|
||||||
[ V{ } ]
|
[ V{ } ]
|
||||||
[ "path" H{ } clone ctag-at ] unit-test
|
[ "path" H{ } clone etag-at ] unit-test
|
||||||
|
|
||||||
[ V{ if { "path" 1 } } ]
|
[ V{ if { "path" 1 } } ]
|
||||||
[ "path" H{ { "path" V{ if { "path" 1 } } } } ctag-at ] unit-test
|
[ "path" H{ { "path" V{ if { "path" 1 } } } } etag-at ] unit-test
|
||||||
|
|
||||||
[ { if 28 } ]
|
[ { if 28 } ]
|
||||||
[ { if { "resource:core/kernel/kernel.factor" 28 } } ctag-value ] unit-test
|
[ { if { "resource:core/kernel/kernel.factor" 28 } } etag-pair ] unit-test
|
||||||
|
|
||||||
[ V{ } ] [ { if { "path" 1 } } H{ } clone ctag-hashvalue ] unit-test
|
[ V{ } ] [ { if { "path" 1 } } H{ } clone etag-vector ] unit-test
|
||||||
|
|
||||||
[ V{ if { "path" 1 } } ]
|
[ V{ if { "path" 1 } } ]
|
||||||
[ { if { "path" 1 } }
|
[ { if { "path" 1 } }
|
||||||
{ { "path" V{ if { "path" 1 } } } } >hashtable
|
{ { "path" V{ if { "path" 1 } } } } >hashtable
|
||||||
ctag-hashvalue
|
etag-vector
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ H{ { "path" V{ { if 1 } } } } ]
|
[ H{ { "path" V{ { if 1 } } } } ]
|
||||||
[ { if { "path" 1 } } H{ } clone ctag-add ] unit-test
|
[ { if { "path" 1 } } H{ } clone [ etag-add ] keep ] unit-test
|
||||||
|
|
||||||
[ H{ { "path" V{ { if 1 } } } } ]
|
[ H{ { "path" V{ { if 1 } } } } ]
|
||||||
[ { { if { "path" 1 } } } ctag-hash ] unit-test
|
[ { { if { "path" 1 } } } etag-hash ] unit-test
|
||||||
|
|
||||||
[ "if28,704" ]
|
[ "if28,704" ]
|
||||||
[ "resource:core/kernel/kernel.factor" file>lines { if 28 } etag ] unit-test
|
[ "resource:core/kernel/kernel.factor" file>lines { if 28 } etag ] unit-test
|
||||||
|
|
|
@ -8,25 +8,25 @@ io.encodings.ascii io.files math math.parser namespaces strings locals
|
||||||
shuffle io.backend arrays ;
|
shuffle io.backend arrays ;
|
||||||
IN: ctags.etags
|
IN: ctags.etags
|
||||||
|
|
||||||
: ctag-path ( alist -- path )
|
: etag-at ( key hash -- vector )
|
||||||
second first ;
|
|
||||||
|
|
||||||
: ctag-at ( key hash -- vector )
|
|
||||||
at [ V{ } clone ] unless* ;
|
at [ V{ } clone ] unless* ;
|
||||||
|
|
||||||
: ctag-hashvalue ( alist hash -- vector )
|
: etag-vector ( alist hash -- vector )
|
||||||
[ ctag-path ] dip ctag-at ;
|
[ ctag-path ] dip etag-at ;
|
||||||
|
|
||||||
: ctag-value ( ctag -- seq )
|
: etag-pair ( ctag -- seq )
|
||||||
dup [ first , second second , ] { } make ;
|
dup [
|
||||||
|
first ,
|
||||||
|
second second ,
|
||||||
|
] { } make ;
|
||||||
|
|
||||||
: ctag-add ( ctag hash -- hash )
|
: etag-add ( ctag hash -- )
|
||||||
[ ctag-hashvalue ] 2keep [
|
[ etag-vector ] 2keep [
|
||||||
dup ctag-path [ ctag-value suffix ] dip
|
[ etag-pair ] [ ctag-path ] bi [ suffix ] dip
|
||||||
] dip [ set-at ] keep ;
|
] dip set-at ;
|
||||||
|
|
||||||
: ctag-hash ( seq -- hash )
|
: etag-hash ( seq -- hash )
|
||||||
H{ } clone swap [ swap ctag-add ] each ;
|
H{ } clone swap [ swap [ etag-add ] keep ] each ;
|
||||||
|
|
||||||
: lines>bytes ( seq n -- bytes )
|
: lines>bytes ( seq n -- bytes )
|
||||||
head 0 [ length 1+ + ] reduce ;
|
head 0 [ length 1+ + ] reduce ;
|
||||||
|
@ -43,10 +43,7 @@ IN: ctags.etags
|
||||||
1- lines>bytes number>string %
|
1- lines>bytes number>string %
|
||||||
] "" make ;
|
] "" make ;
|
||||||
|
|
||||||
: etag-entry ( alist -- alist array )
|
: etag-length ( vector -- n )
|
||||||
[ first ] keep swap [ file>lines ] keep 2array ;
|
|
||||||
|
|
||||||
: vector-length ( vector -- n )
|
|
||||||
0 [ length + ] reduce ;
|
0 [ length + ] reduce ;
|
||||||
|
|
||||||
: <header> ( n path -- str )
|
: <header> ( n path -- str )
|
||||||
|
@ -60,15 +57,14 @@ IN: ctags.etags
|
||||||
normalize-path <header> prefix
|
normalize-path <header> prefix
|
||||||
1 HEX: 0c <string> prefix ;
|
1 HEX: 0c <string> prefix ;
|
||||||
|
|
||||||
SYMBOL: resource
|
|
||||||
: etag-strings ( alist -- seq )
|
: etag-strings ( alist -- seq )
|
||||||
{ } swap [
|
{ } swap [
|
||||||
etag-entry resource [
|
[
|
||||||
second [
|
[ first file>lines ]
|
||||||
resource get first swap etag
|
[ second ] bi
|
||||||
] map dup vector-length
|
[ etag ] with map
|
||||||
resource get second
|
dup etag-length
|
||||||
] with-variable
|
] keep first
|
||||||
etag-header append
|
etag-header append
|
||||||
] each ;
|
] each ;
|
||||||
|
|
||||||
|
@ -76,4 +72,4 @@ SYMBOL: resource
|
||||||
[ etag-strings ] dip ascii set-file-lines ;
|
[ etag-strings ] dip ascii set-file-lines ;
|
||||||
|
|
||||||
: etags ( path -- )
|
: etags ( path -- )
|
||||||
(ctags) sort-values ctag-hash >alist swap etags-write ;
|
[ (ctags) sort-values etag-hash >alist ] dip etags-write ;
|
Loading…
Reference in New Issue