1 ! Copyright (C) 2008 Alfredo Beaumont
2 ! See http://factorcode.org/license.txt for BSD license.
4 ! Simple Ctags generator
5 ! Alfredo Beaumont <alfredo.beaumont@gmail.com>
7 USING: assocs definitions io.backend io.encodings.ascii io.files
8 kernel make math.parser present sequences sorting vocabs ;
13 : locations ( words -- alist )
14 [ where ] zip-with sift-values ;
16 : ctag ( word path lineno -- str )
18 [ present % CHAR: \t , ]
19 [ normalize-path % CHAR: \t , ]
20 [ number>string % ] tri*
23 : make-ctags ( alist -- seq )
24 [ first2 ctag ] { } assoc>map ;
29 all-words locations sort-keys make-ctags ;
31 : write-ctags ( path -- )
32 [ ctags ] dip ascii set-file-lines ;