]> gitweb.factorcode.org Git - factor.git/blob - extra/ctags/ctags.factor
Update actions, because Node.js 16 actions are deprecated, to Node.js 20
[factor.git] / extra / ctags / ctags.factor
1 ! Copyright (C) 2008 Alfredo Beaumont
2 ! See http://factorcode.org/license.txt for BSD license.
3
4 ! Simple Ctags generator
5 ! Alfredo Beaumont <alfredo.beaumont@gmail.com>
6
7 USING: assocs definitions io.backend io.encodings.ascii io.files
8 kernel make math.parser present sequences sorting vocabs ;
9 IN: ctags
10
11 <PRIVATE
12
13 : locations ( words -- alist )
14     [ where ] zip-with sift-values ;
15
16 : ctag ( word path lineno -- str )
17     [
18         [ present % CHAR: \t , ]
19         [ normalize-path % CHAR: \t , ]
20         [ number>string % ] tri*
21     ] "" make ;
22
23 : make-ctags ( alist -- seq )
24     [ first2 ctag ] { } assoc>map ;
25
26 PRIVATE>
27
28 : ctags ( -- ctags )
29     all-words locations sort-keys make-ctags ;
30
31 : write-ctags ( path -- )
32     [ ctags ] dip ascii set-file-lines ;