Slava Pestov 2008-07-06 18:08:37 -05:00
commit 3794561f0f
5 changed files with 90 additions and 0 deletions

1
extra/ctags/authors.txt Normal file
View File

@ -0,0 +1 @@
Alfredo Beaumont

View File

@ -0,0 +1,47 @@
USING: help.syntax help.markup kernel prettyprint sequences strings ;
IN: ctags
ARTICLE: "ctags" "Ctags file"
{ $emphasis "ctags" } " generates a index file of every factor word in ctags format as supported by vi and other editors. More information can be found at " { $url "http://en.wikipedia.org/wiki/Ctags" } "."
{ $subsection ctags }
{ $subsection ctags-write }
{ $subsection ctag } ;
HELP: ctags ( path -- )
{ $values { "path" "a pathname string" } }
{ $description "Generates a index file in ctags format and stores in " { $snippet "path" } "." }
{ $examples
{ $example
"USING: ctags ;"
"\"tags\" ctags-write"
""
}
} ;
HELP: ctags-write ( seq path -- )
{ $values { "seq" sequence }
{ "path" "a pathname string" } }
{ $description "Stores a " { $snippet "seq" } " in " { $snippet "path" } ". " { $snippet "seq" } " must be an association list with ctags format: key must be a valid word and value a sequence whose first element is a resource name and second element is a line number" }
{ $examples
{ $example
"USING: kernel ctags ;"
"{ { if { \"resource:extra/unix/unix.factor\" 91 } } } \"tags\" ctags-write"
""
}
}
{ $notes
{ $snippet "tags" } " file will contain a single line: if\\t/path/to/factor/extra/unix/unix.factor\\t91" } ;
HELP: ctag ( seq -- str )
{ $values { "seq" sequence }
{ "str" string } }
{ $description "Outputs a string " { $snippet "str" } " in ctag format for sequence with two elements, first one must be a valid word and second one a sequence whose first element is a resource name and second element is a line number" }
{ $examples
{ $example
"USING: kernel ctags ;"
"{ if { \"resource:extra/unix/unix.factor\" 91 } } ctag ."
"\"if\\t/path/to/factor/extra/unix/unix.factor\\t91\""
}
} ;
ABOUT: "ctags"

View File

@ -0,0 +1,7 @@
USING: kernel ctags tools.test io.backend sequences ;
IN: columns.tests
[ t ] [
"if\t" "resource:extra/unix/unix.factor" normalize-path "\t91" 3append
{ if { "resource:extra/unix/unix.factor" 91 } } ctag =
] unit-test

34
extra/ctags/ctags.factor Normal file
View File

@ -0,0 +1,34 @@
! Copyright (C) 2008 Alfredo Beaumont
! See http://factorcode.org/license.txt for BSD license.
! Simple Ctags generator
! Alfredo Beaumont <alfredo.beaumont@gmail.com>
USING: kernel sequences io io.files io.backend
io.encodings.ascii math.parser vocabs definitions
namespaces words sorting ;
IN: ctags
: ctag ( seq -- str )
[
dup first ?word-name %
"\t" %
second dup first normalize-path %
"\t" %
second number>string %
] "" make ;
: ctags-write ( seq path -- )
ascii [ [ ctag print ] each ] with-file-writer ;
: (ctags) ( -- seq )
{ } all-words [
dup where [
{ } 2sequence suffix
] [
drop
] if*
] each ;
: ctags ( path -- )
(ctags) sort-keys swap ctags-write ;

1
extra/ctags/summary.txt Normal file
View File

@ -0,0 +1 @@
Ctags generator