ctags는 말 그대로 c 언어 파일의 keyword, identifier를 출력해 주는 툴이다.
ctags -R
을 실행하면 tags라는 파일이 생성이 된다.
source code [test.c]
command [ctags test.c]
file [tags]
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.4 //
CHARLEY test.c /^ CHARLEY,$/;" e file:
FALSE test.c /^ FALSE$/;" e file:
LINDA test.c /^ LINDA$/;" e file:
TOM test.c /^ TOM,$/;" e file:
TRUE test.c /^ TRUE,$/;" e file:
WIN32_VERSION test.c 3;" d file:
boolean test.c /^} boolean;$/;" t file:
main test.c /^int main(int argc,char argv**)$/;" f
test_int test.c /^int test_int;$/;" v
test_int_static test.c /^static int test_int_static;$/;" v file:
command [ctags -n -u test.c]
file [tags]
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 0 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.4 //
WIN32_VERSION test.c 3;" d file:
test_int_static test.c 5;" v file:
test_int test.c 6;" v
TRUE test.c 10;" e file:
FALSE test.c 11;" e file:
boolean test.c 12;" t file:
TOM test.c 16;" e file:
CHARLEY test.c 17;" e file:
LINDA test.c 18;" e file:
main test.c 21;" f
Wikipedia의 ctags file format 에 관련된 내용
Tags file formats
There are multiple tag file formats. Some of them are described below. In the
following, <\x##> represents the byte with hexadecimal representation
##.
Ctags and Exuberant Ctags
The original ctags and Exuberant Ctags have similar file
formats:[2]
Ctags
This is the format used by vi and various clones. The tags file is
normally named "tags".
The tags file is a list of lines, each line in the format:
{tagname}<Tab>{tagfile}<Tab>{tagaddress}
The fields are specified as follows:
{tagname} – Any identifier, not containing white space
<Tab> – Exactly one tab
character, although many versions of vi can handle any amount of white
space
{tagfile} – The name of the file where {tagname} is defined, relative to the
current directory
{tagaddress} – An ex mode command that will take the editor to the
location of the tag. For POSIX implementations of vi this may only be a
search or a line number.
The tags file is sorted on the {tagname} field which allows for fast
searching of the tags file.
Exuberant Ctags
This is the format used by Vim. It can generate an original ctags
file format or an extended format that attempts to retain backward
compatibility.
The fields up to and including {tagaddress} are the same as for ctags above.
Optional additional fields:
;" – semicolon + doublequote: Ends the {tagaddress} in way that looks like
the start of a comment to vi.
{tagfield}
Extended format extends the {tagaddress} field under certain circumstances to
include a set of extension fields embedded in an ex comment immediately appended
to the ex command, which leaves it backward-compatible with original vi
implementations. These extension fields are tab separated "key:value" pairs,
documented in the ctags
manual.
Etags
This is the format used by Emacs etags. The tags file is normally
named "TAGS".
The etags files consists of multiple sections—one section per input source
file. Sections are plain-text with several non-ascii characters used for special
purposes. These characters are represented as bracketed hexadecimal codes
below.
A section starts with a two line header, one line containing a single
<\x0c> character, followed by a line which consists of:
{src_file},{size_of_tag_definition_data_in_bytes}
The header is followed by tag definitions, one definition per line, with the
format:
-a Append the tags to an existing tag file.
-B Use backward searching patterns (?...?).
-e Output tag file for use with Emacs.
-f <name>
Write tags to specified file. Value of "-" writes tags to stdout
["tags"; or "TAGS" when -e supplied].
-F Use forward searching patterns (/.../) (default).
-h <list>
Specify list of file extensions to be treated as include files.
[".h.H.hh.hpp.hxx.h++"].
-I <list|@file>
A list of tokens to be specially handled is read from either the
command line or the specified file.
-L <file>
A list of source file names are read from the specified file.
If specified as "-", then standard input is read. -n Equivalent to --excmd=number.
-N Equivalent to --excmd=pattern.
-o Alternative for -f. -R Equivalent to --recurse. -u Equivalent to --sort=no.
-V Equivalent to --verbose.
-x Print a tabular cross reference file to standard output.
--append=[yes|no]
Should tags should be appended to existing tag file [no]?
--etags-include=file
Include reference to 'file' in Emacs-style tag file (requires -e).
--exclude=pattern
Exclude files and directories matching 'pattern'.
--excmd=number|pattern|mix
Uses the specified type of EX command to locate tags [mix].
--extra=[+|-]flags
Include extra tag entries for selected information (flags: "fq").
--fields=[+|-]flags
Include selected extension fields (flags: "afmikKlnsSz") [fks].
--file-scope=[yes|no]
Should tags scoped only for a single file (e.g. "static" tags
be included in the output [yes]?
--filter=[yes|no]
Behave as a filter, reading file names from standard input and
writing tags to standard output [no].
--filter-terminator=string
Specify string to print to stdout following the tags for each file
parsed when --filter is enabled.
--format=level
Force output of specified tag file format [2].
--help
Print this option summary.
--if0=[yes|no]
Should C code within #if 0 conditional branches be parsed [no]?
--langdef=name
Define a new language to be parsed with regular expressions.
--langmap=map(s)
Override default mapping of language to source file extension.
--language-force=language
Force all files to be interpreated with specified language.
--languages=[+|-]list
Restrict files scanned for tags to those mapped to langauges
specified in the comma-separated 'list'. The list can contain any
built-in or user-defined language [all].
--license
Print details of software license.
--line-directives=[yes|no]
Should #line directives be processed [no]?
--links=[yes|no]
Indicate whether symbolic links should be followed [yes].
--options=file
Specify file from which command line options should be read.
--recurse=[yes|no]
Recurse into directories supplied on command line [no].
--sort=[yes|no|foldcase]
Should tags be sorted (optionally ignoring case) [yes]?.
--tag-relative=[yes|no]
Should paths be relative to location of tag file [no; yes when -e]?
--totals=[yes|no]
Print statistics about source and tag files [no].
--verbose=[yes|no]
Enable verbose messages describing actions on each source file.
--version
Print version identifier to standard output.
The following options are used to specify which language-specific tag
types (or kinds) should be included in the tag file. "Kinds" is a group of
one-letter flags designating kinds of tags to either include or exclude from
the output. Each letter or group of letters may be preceded by either '+' to
add it to those already included, or '-' to exclude it from the output. In
the absence of any preceding '+' or '-' sign, only those kinds listed in
"kinds" will be included in the output. Below each option is a list of the
flags accepted. All kinds are enabled by default unless otherwise noted.
--asm-types=[+|-]kinds
d defines
l labels
m macros
t types
--asp-types=[+|-]kinds
f functions
s subroutines
--awk-types=[+|-]kinds
f functions
--beta-types=[+|-]kinds
f fragment definitions
p all patterns [off]
s slots (fragment uses)
v patterns (only virtual or rebound patterns are recorded)
--c-types=[+|-]kinds
c classes
d macro definitions
e enumerators (values inside an enumeration)
f function definitions
g enumeration names
m class, struct, and union members
n namespaces
p function prototypes [off]
s structure names
t typedefs
u union names
v variable definitions
x external variable declarations [off]
--c++-types=[+|-]kinds
c classes
d macro definitions
e enumerators (values inside an enumeration)
f function definitions
g enumeration names
m class, struct, and union members
n namespaces
p function prototypes [off]
s structure names
t typedefs
u union names
v variable definitions
x external variable declarations [off]
--eiffel-types=[+|-]kinds
c classes
f features
l local entities [off]
--fortran-types=[+|-]kinds
b block data
c common blocks
e entry points
f functions
i interfaces
k type components
l labels
L local and common block variables [off]
m modules
n namelists
p programs
s subroutines
t derived types
v module variables
--java-types=[+|-]kinds
c classes
f fields
i interfaces
m methods
p packages
--lisp-types=[+|-]kinds
f functions
--lua-types=[+|-]kinds
f functions
--make-types=[+|-]kinds
m macros
--pascal-types=[+|-]kinds
f functions
p procedures
--perl-types=[+|-]kinds
s subroutines
p packages
--php-types=[+|-]kinds
c classes
f functions
--python-types=[+|-]kinds
c classes
f functions
m class member
--ruby-types=[+|-]kinds
c classes
f methods
F singleton methods
m mixins
--scheme-types=[+|-]kinds
f functions
s sets
--sh-types=[+|-]kinds
f functions
--sql-types=[+|-]kinds
c cursors
d prototypes [off]
f functions
F record fields
l local variables [off]
P packages
p procedures
r records
s subtypes
t tables
T triggers
v variables
--tcl-types=[+|-]kinds
p procedures
c classes
f methods
--vera-types=[+|-]kinds
c classes
d macro definitions
e enumerators (values inside an enumeration)
f function definitions
g enumeration names
m class, struct, and union members
p programs
P function prototypes [off]
t tasks
T typedefs
v variable definitions
x external variable declarations [off]
--verilog-types=[+|-]kinds
f functions
m modules
P parameters, defines
p ports (input, output, inout)
r registers
t tasks
v variables (integer, real, time)
w wires (supply, tri, wire, wand, ...)
--vim-types=[+|-]kinds
f function definitions
v variable definitions