PageRenderTime 21ms CodeModel.GetById 9ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

/extra/ctags/ctags.factor

http://github.com/abeaumont/factor
Unknown | 44 lines | 34 code | 10 blank | 0 comment | 0 complexity | 82c40a0e43778fb4f6958a1627db07a0 MD5 | raw file
 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
 7USING: arrays kernel sequences io io.files io.backend
 8io.encodings.ascii math.parser vocabs definitions
 9namespaces make words sorting present ;
10IN: 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 present %
24    "\t" %
25    dup ctag-path normalize-path %
26    "\t" %
27    ctag-lineno number>string %
28  ] "" make ;
29
30: ctag-strings ( alist -- seq )
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 ;