/extra/ctags/ctags.factor

http://github.com/abeaumont/factor · Factor · 44 lines · 30 code · 10 blank · 4 comment · 1 complexity · 82c40a0e43778fb4f6958a1627db07a0 MD5 · raw file

  1. ! Copyright (C) 2008 Alfredo Beaumont
  2. ! See http://factorcode.org/license.txt for BSD license.
  3. ! Simple Ctags generator
  4. ! Alfredo Beaumont <alfredo.beaumont@gmail.com>
  5. USING: arrays kernel sequences io io.files io.backend
  6. io.encodings.ascii math.parser vocabs definitions
  7. namespaces make words sorting present ;
  8. IN: ctags
  9. : ctag-word ( ctag -- word )
  10. first ;
  11. : ctag-path ( ctag -- path )
  12. second first ;
  13. : ctag-lineno ( ctag -- n )
  14. second second ;
  15. : ctag ( seq -- str )
  16. [
  17. dup ctag-word present %
  18. "\t" %
  19. dup ctag-path normalize-path %
  20. "\t" %
  21. ctag-lineno number>string %
  22. ] "" make ;
  23. : ctag-strings ( alist -- seq )
  24. [ ctag ] map ;
  25. : ctags-write ( seq path -- )
  26. [ ctag-strings ] dip ascii set-file-lines ;
  27. : (ctags) ( -- seq )
  28. all-words [
  29. dup where [
  30. 2array
  31. ] when*
  32. ] map [ sequence? ] filter ;
  33. : ctags ( path -- )
  34. (ctags) sort-keys swap ctags-write ;