]> gitweb.factorcode.org Git - factor.git/blob - extra/ctags/ctags.factor
Updating code for make and fry changes
[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: arrays kernel sequences io io.files io.backend
8 io.encodings.ascii math.parser vocabs definitions
9 namespaces make words sorting ;
10 IN: ctags
11
12 : ctag-word ( ctag -- word )
13   first ;
14
15 : ctag-path ( ctag -- path )
16   second first ;
17
18 : ctag-lineno ( ctag -- n )
19   second second ;
20
21 : ctag ( seq -- str )
22   [
23     dup ctag-word ?word-name %
24     "\t" %
25     dup ctag-path normalize-path %
26     "\t" %
27     ctag-lineno number>string %
28   ] "" make ;
29
30 : ctag-strings ( seq1 -- seq2 )
31   [ ctag ] map ;
32
33 : ctags-write ( seq path -- )
34   [ ctag-strings ] dip ascii set-file-lines ;
35
36 : (ctags) ( -- seq )
37   all-words [
38     dup where [
39       2array
40     ] when*
41   ] map [ sequence? ] filter ;
42
43 : ctags ( path -- )
44   (ctags) sort-keys swap ctags-write ;