ctags.rb 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Rakefile +23 -0
- data/ctags.rb.gemspec +23 -0
- data/ext/.gitignore +3 -0
- data/ext/extconf.rb +15 -0
- data/ext/vendor/exuberant-ctags/.gitignore +6 -0
- data/ext/vendor/exuberant-ctags/.indent.pro +31 -0
- data/ext/vendor/exuberant-ctags/COPYING +340 -0
- data/ext/vendor/exuberant-ctags/EXTENDING.html +386 -0
- data/ext/vendor/exuberant-ctags/FAQ +371 -0
- data/ext/vendor/exuberant-ctags/INSTALL +215 -0
- data/ext/vendor/exuberant-ctags/INSTALL.oth +73 -0
- data/ext/vendor/exuberant-ctags/MAINTAINERS +88 -0
- data/ext/vendor/exuberant-ctags/Makefile.in +222 -0
- data/ext/vendor/exuberant-ctags/NEWS +871 -0
- data/ext/vendor/exuberant-ctags/README +73 -0
- data/ext/vendor/exuberant-ctags/ant.c +42 -0
- data/ext/vendor/exuberant-ctags/argproc.c +505 -0
- data/ext/vendor/exuberant-ctags/args.c +274 -0
- data/ext/vendor/exuberant-ctags/args.h +63 -0
- data/ext/vendor/exuberant-ctags/asm.c +387 -0
- data/ext/vendor/exuberant-ctags/asp.c +328 -0
- data/ext/vendor/exuberant-ctags/awk.c +81 -0
- data/ext/vendor/exuberant-ctags/basic.c +203 -0
- data/ext/vendor/exuberant-ctags/beta.c +321 -0
- data/ext/vendor/exuberant-ctags/c.c +2932 -0
- data/ext/vendor/exuberant-ctags/cobol.c +50 -0
- data/ext/vendor/exuberant-ctags/config.h.in +277 -0
- data/ext/vendor/exuberant-ctags/configure +7704 -0
- data/ext/vendor/exuberant-ctags/configure.ac +532 -0
- data/ext/vendor/exuberant-ctags/ctags.1 +1186 -0
- data/ext/vendor/exuberant-ctags/ctags.h +28 -0
- data/ext/vendor/exuberant-ctags/ctags.html +2087 -0
- data/ext/vendor/exuberant-ctags/ctags.spec +40 -0
- data/ext/vendor/exuberant-ctags/debug.c +113 -0
- data/ext/vendor/exuberant-ctags/debug.h +70 -0
- data/ext/vendor/exuberant-ctags/descrip.mms +68 -0
- data/ext/vendor/exuberant-ctags/dosbatch.c +42 -0
- data/ext/vendor/exuberant-ctags/e_amiga.h +24 -0
- data/ext/vendor/exuberant-ctags/e_djgpp.h +47 -0
- data/ext/vendor/exuberant-ctags/e_mac.h +143 -0
- data/ext/vendor/exuberant-ctags/e_msoft.h +76 -0
- data/ext/vendor/exuberant-ctags/e_os2.h +37 -0
- data/ext/vendor/exuberant-ctags/e_qdos.h +34 -0
- data/ext/vendor/exuberant-ctags/e_riscos.h +58 -0
- data/ext/vendor/exuberant-ctags/e_vms.h +31 -0
- data/ext/vendor/exuberant-ctags/eiffel.c +1352 -0
- data/ext/vendor/exuberant-ctags/entry.c +847 -0
- data/ext/vendor/exuberant-ctags/entry.h +103 -0
- data/ext/vendor/exuberant-ctags/erlang.c +189 -0
- data/ext/vendor/exuberant-ctags/flex.c +2243 -0
- data/ext/vendor/exuberant-ctags/fortran.c +2197 -0
- data/ext/vendor/exuberant-ctags/general.h +127 -0
- data/ext/vendor/exuberant-ctags/get.c +669 -0
- data/ext/vendor/exuberant-ctags/get.h +50 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/all-wcprops +47 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/entries +112 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/README.txt.svn-base +5 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regcomp.c.svn-base +3818 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regex.c.svn-base +74 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regex.h.svn-base +575 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regex_internal.c.svn-base +1713 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regex_internal.h.svn-base +773 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regexec.c.svn-base +4338 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/README.txt +5 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/regcomp.c +3818 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/regex.c +74 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/regex.h +575 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/regex_internal.c +1713 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/regex_internal.h +773 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/regexec.c +4338 -0
- data/ext/vendor/exuberant-ctags/html.c +49 -0
- data/ext/vendor/exuberant-ctags/jscript.c +1572 -0
- data/ext/vendor/exuberant-ctags/keyword.c +258 -0
- data/ext/vendor/exuberant-ctags/keyword.h +34 -0
- data/ext/vendor/exuberant-ctags/lisp.c +139 -0
- data/ext/vendor/exuberant-ctags/lregex.c +704 -0
- data/ext/vendor/exuberant-ctags/lua.c +133 -0
- data/ext/vendor/exuberant-ctags/mac.c +273 -0
- data/ext/vendor/exuberant-ctags/magic.diff +21 -0
- data/ext/vendor/exuberant-ctags/main.c +584 -0
- data/ext/vendor/exuberant-ctags/main.h +32 -0
- data/ext/vendor/exuberant-ctags/maintainer.mak +476 -0
- data/ext/vendor/exuberant-ctags/make.c +217 -0
- data/ext/vendor/exuberant-ctags/matlab.c +44 -0
- data/ext/vendor/exuberant-ctags/mk_bc3.mak +46 -0
- data/ext/vendor/exuberant-ctags/mk_bc5.mak +49 -0
- data/ext/vendor/exuberant-ctags/mk_djg.mak +18 -0
- data/ext/vendor/exuberant-ctags/mk_manx.mak +65 -0
- data/ext/vendor/exuberant-ctags/mk_mingw.mak +31 -0
- data/ext/vendor/exuberant-ctags/mk_mpw.mak +130 -0
- data/ext/vendor/exuberant-ctags/mk_mvc.mak +40 -0
- data/ext/vendor/exuberant-ctags/mk_os2.mak +104 -0
- data/ext/vendor/exuberant-ctags/mk_qdos.mak +100 -0
- data/ext/vendor/exuberant-ctags/mk_sas.mak +63 -0
- data/ext/vendor/exuberant-ctags/mkinstalldirs +40 -0
- data/ext/vendor/exuberant-ctags/ocaml.c +1842 -0
- data/ext/vendor/exuberant-ctags/options.c +1842 -0
- data/ext/vendor/exuberant-ctags/options.h +155 -0
- data/ext/vendor/exuberant-ctags/parse.c +677 -0
- data/ext/vendor/exuberant-ctags/parse.h +129 -0
- data/ext/vendor/exuberant-ctags/parsers.h +63 -0
- data/ext/vendor/exuberant-ctags/pascal.c +267 -0
- data/ext/vendor/exuberant-ctags/perl.c +382 -0
- data/ext/vendor/exuberant-ctags/php.c +237 -0
- data/ext/vendor/exuberant-ctags/python.c +771 -0
- data/ext/vendor/exuberant-ctags/qdos.c +106 -0
- data/ext/vendor/exuberant-ctags/read.c +569 -0
- data/ext/vendor/exuberant-ctags/read.h +116 -0
- data/ext/vendor/exuberant-ctags/readtags.c +959 -0
- data/ext/vendor/exuberant-ctags/readtags.h +252 -0
- data/ext/vendor/exuberant-ctags/rexx.c +39 -0
- data/ext/vendor/exuberant-ctags/routines.c +891 -0
- data/ext/vendor/exuberant-ctags/routines.h +134 -0
- data/ext/vendor/exuberant-ctags/ruby.c +408 -0
- data/ext/vendor/exuberant-ctags/scheme.c +111 -0
- data/ext/vendor/exuberant-ctags/sh.c +115 -0
- data/ext/vendor/exuberant-ctags/slang.c +41 -0
- data/ext/vendor/exuberant-ctags/sml.c +212 -0
- data/ext/vendor/exuberant-ctags/sort.c +230 -0
- data/ext/vendor/exuberant-ctags/sort.h +32 -0
- data/ext/vendor/exuberant-ctags/source.mak +122 -0
- data/ext/vendor/exuberant-ctags/sql.c +2112 -0
- data/ext/vendor/exuberant-ctags/strlist.c +281 -0
- data/ext/vendor/exuberant-ctags/strlist.h +54 -0
- data/ext/vendor/exuberant-ctags/tcl.c +116 -0
- data/ext/vendor/exuberant-ctags/tex.c +524 -0
- data/ext/vendor/exuberant-ctags/verilog.c +340 -0
- data/ext/vendor/exuberant-ctags/vhdl.c +835 -0
- data/ext/vendor/exuberant-ctags/vim.c +636 -0
- data/ext/vendor/exuberant-ctags/vstring.c +232 -0
- data/ext/vendor/exuberant-ctags/vstring.h +85 -0
- data/ext/vendor/exuberant-ctags/yacc.c +40 -0
- data/lib/ctags/exuberant.rb +45 -0
- data/lib/ctags/version.rb +3 -0
- data/lib/ctags.rb +6 -0
- data/test/test_ctags.rb +24 -0
- metadata +233 -0
@@ -0,0 +1,103 @@
|
|
1
|
+
/*
|
2
|
+
* $Id: entry.h 443 2006-05-30 04:37:13Z darren $
|
3
|
+
*
|
4
|
+
* Copyright (c) 1998-2002, Darren Hiebert
|
5
|
+
*
|
6
|
+
* This source code is released for free distribution under the terms of the
|
7
|
+
* GNU General Public License.
|
8
|
+
*
|
9
|
+
* External interface to entry.c
|
10
|
+
*/
|
11
|
+
#ifndef _ENTRY_H
|
12
|
+
#define _ENTRY_H
|
13
|
+
|
14
|
+
/*
|
15
|
+
* INCLUDE FILES
|
16
|
+
*/
|
17
|
+
#include "general.h" /* must always come first */
|
18
|
+
|
19
|
+
#include <stdio.h>
|
20
|
+
|
21
|
+
#include "vstring.h"
|
22
|
+
|
23
|
+
/*
|
24
|
+
* MACROS
|
25
|
+
*/
|
26
|
+
#define WHOLE_FILE -1L
|
27
|
+
|
28
|
+
/*
|
29
|
+
* DATA DECLARATIONS
|
30
|
+
*/
|
31
|
+
|
32
|
+
/* Maintains the state of the tag file.
|
33
|
+
*/
|
34
|
+
typedef struct eTagFile {
|
35
|
+
char *name;
|
36
|
+
char *directory;
|
37
|
+
FILE *fp;
|
38
|
+
struct sNumTags { unsigned long added, prev; } numTags;
|
39
|
+
struct sMax { size_t line, tag, file; } max;
|
40
|
+
struct sEtags {
|
41
|
+
char *name;
|
42
|
+
FILE *fp;
|
43
|
+
size_t byteCount;
|
44
|
+
} etags;
|
45
|
+
vString *vLine;
|
46
|
+
} tagFile;
|
47
|
+
|
48
|
+
typedef struct sTagFields {
|
49
|
+
unsigned int count; /* number of additional extension flags */
|
50
|
+
const char *const *label; /* list of labels for extension flags */
|
51
|
+
const char *const *value; /* list of values for extension flags */
|
52
|
+
} tagFields;
|
53
|
+
|
54
|
+
/* Information about the current tag candidate.
|
55
|
+
*/
|
56
|
+
typedef struct sTagEntryInfo {
|
57
|
+
boolean lineNumberEntry; /* pattern or line number entry */
|
58
|
+
unsigned long lineNumber; /* line number of tag */
|
59
|
+
fpos_t filePosition; /* file position of line containing tag */
|
60
|
+
const char* language; /* language of source file */
|
61
|
+
boolean isFileScope; /* is tag visibile only within source file? */
|
62
|
+
boolean isFileEntry; /* is this just an entry for a file name? */
|
63
|
+
boolean truncateLine; /* truncate tag line at end of tag name? */
|
64
|
+
const char *sourceFileName; /* name of source file */
|
65
|
+
const char *name; /* name of the tag */
|
66
|
+
const char *kindName; /* kind of tag */
|
67
|
+
char kind; /* single character representation of kind */
|
68
|
+
struct {
|
69
|
+
const char* access;
|
70
|
+
const char* fileScope;
|
71
|
+
const char* implementation;
|
72
|
+
const char* inheritance;
|
73
|
+
const char* scope [2]; /* value and key */
|
74
|
+
const char* signature;
|
75
|
+
|
76
|
+
/* type (union/struct/etc.) and name for a variable or typedef. */
|
77
|
+
const char* typeRef [2]; /* e.g., "struct" and struct name */
|
78
|
+
|
79
|
+
} extensionFields; /* list of extension fields*/
|
80
|
+
} tagEntryInfo;
|
81
|
+
|
82
|
+
/*
|
83
|
+
* GLOBAL VARIABLES
|
84
|
+
*/
|
85
|
+
extern tagFile TagFile;
|
86
|
+
|
87
|
+
/*
|
88
|
+
* FUNCTION PROTOTYPES
|
89
|
+
*/
|
90
|
+
extern void freeTagFileResources (void);
|
91
|
+
extern const char *tagFileName (void);
|
92
|
+
extern void copyBytes (FILE* const fromFp, FILE* const toFp, const long size);
|
93
|
+
extern void copyFile (const char *const from, const char *const to, const long size);
|
94
|
+
extern void openTagFile (void);
|
95
|
+
extern void closeTagFile (const boolean resize);
|
96
|
+
extern void beginEtagsFile (void);
|
97
|
+
extern void endEtagsFile (const char *const name);
|
98
|
+
extern void makeTagEntry (const tagEntryInfo *const tag);
|
99
|
+
extern void initTagEntry (tagEntryInfo *const e, const char *const name);
|
100
|
+
|
101
|
+
#endif /* _ENTRY_H */
|
102
|
+
|
103
|
+
/* vi:set tabstop=4 shiftwidth=4: */
|
@@ -0,0 +1,189 @@
|
|
1
|
+
/*
|
2
|
+
* $Id: erlang.c 443 2006-05-30 04:37:13Z darren $
|
3
|
+
*
|
4
|
+
* Copyright (c) 2003, Brent Fulgham <bfulgham@debian.org>
|
5
|
+
*
|
6
|
+
* This source code is released for free distribution under the terms of the
|
7
|
+
* GNU General Public License.
|
8
|
+
*
|
9
|
+
* This module contains functions for generating tags for Erlang language
|
10
|
+
* files. Some of the parsing constructs are based on the Emacs 'etags'
|
11
|
+
* program by Francesco Potori <pot@gnu.org>
|
12
|
+
*/
|
13
|
+
/*
|
14
|
+
* INCLUDE FILES
|
15
|
+
*/
|
16
|
+
#include "general.h" /* must always come first */
|
17
|
+
|
18
|
+
#include <string.h>
|
19
|
+
|
20
|
+
#include "entry.h"
|
21
|
+
#include "options.h"
|
22
|
+
#include "read.h"
|
23
|
+
#include "routines.h"
|
24
|
+
#include "vstring.h"
|
25
|
+
|
26
|
+
/*
|
27
|
+
* DATA DEFINITIONS
|
28
|
+
*/
|
29
|
+
typedef enum {
|
30
|
+
K_MACRO, K_FUNCTION, K_MODULE, K_RECORD
|
31
|
+
} erlangKind;
|
32
|
+
|
33
|
+
static kindOption ErlangKinds[] = {
|
34
|
+
{TRUE, 'd', "macro", "macro definitions"},
|
35
|
+
{TRUE, 'f', "function", "functions"},
|
36
|
+
{TRUE, 'm', "module", "modules"},
|
37
|
+
{TRUE, 'r', "record", "record definitions"},
|
38
|
+
};
|
39
|
+
|
40
|
+
/*
|
41
|
+
* FUNCTION DEFINITIONS
|
42
|
+
*/
|
43
|
+
/* tagEntryInfo and vString should be preinitialized/preallocated but not
|
44
|
+
* necessary. If successful you will find class name in vString
|
45
|
+
*/
|
46
|
+
|
47
|
+
static boolean isIdentifierFirstCharacter (int c)
|
48
|
+
{
|
49
|
+
return (boolean) (isalpha (c));
|
50
|
+
}
|
51
|
+
|
52
|
+
static boolean isIdentifierCharacter (int c)
|
53
|
+
{
|
54
|
+
return (boolean) (isalnum (c) || c == '_' || c == ':');
|
55
|
+
}
|
56
|
+
|
57
|
+
static const unsigned char *skipSpace (const unsigned char *cp)
|
58
|
+
{
|
59
|
+
while (isspace ((int) *cp))
|
60
|
+
++cp;
|
61
|
+
return cp;
|
62
|
+
}
|
63
|
+
|
64
|
+
static const unsigned char *parseIdentifier (
|
65
|
+
const unsigned char *cp, vString *const identifier)
|
66
|
+
{
|
67
|
+
vStringClear (identifier);
|
68
|
+
while (isIdentifierCharacter ((int) *cp))
|
69
|
+
{
|
70
|
+
vStringPut (identifier, (int) *cp);
|
71
|
+
++cp;
|
72
|
+
}
|
73
|
+
vStringTerminate (identifier);
|
74
|
+
return cp;
|
75
|
+
}
|
76
|
+
|
77
|
+
static void makeMemberTag (
|
78
|
+
vString *const identifier, erlangKind kind, vString *const module)
|
79
|
+
{
|
80
|
+
if (ErlangKinds [kind].enabled && vStringLength (identifier) > 0)
|
81
|
+
{
|
82
|
+
tagEntryInfo tag;
|
83
|
+
initTagEntry (&tag, vStringValue (identifier));
|
84
|
+
tag.kindName = ErlangKinds[kind].name;
|
85
|
+
tag.kind = ErlangKinds[kind].letter;
|
86
|
+
|
87
|
+
if (module != NULL && vStringLength (module) > 0)
|
88
|
+
{
|
89
|
+
tag.extensionFields.scope [0] = "module";
|
90
|
+
tag.extensionFields.scope [1] = vStringValue (module);
|
91
|
+
}
|
92
|
+
makeTagEntry (&tag);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
static void parseModuleTag (const unsigned char *cp, vString *const module)
|
97
|
+
{
|
98
|
+
vString *const identifier = vStringNew ();
|
99
|
+
parseIdentifier (cp, identifier);
|
100
|
+
makeSimpleTag (identifier, ErlangKinds, K_MODULE);
|
101
|
+
|
102
|
+
/* All further entries go in the new module */
|
103
|
+
vStringCopy (module, identifier);
|
104
|
+
vStringDelete (identifier);
|
105
|
+
}
|
106
|
+
|
107
|
+
static void parseSimpleTag (const unsigned char *cp, erlangKind kind)
|
108
|
+
{
|
109
|
+
vString *const identifier = vStringNew ();
|
110
|
+
parseIdentifier (cp, identifier);
|
111
|
+
makeSimpleTag (identifier, ErlangKinds, kind);
|
112
|
+
vStringDelete (identifier);
|
113
|
+
}
|
114
|
+
|
115
|
+
static void parseFunctionTag (const unsigned char *cp, vString *const module)
|
116
|
+
{
|
117
|
+
vString *const identifier = vStringNew ();
|
118
|
+
parseIdentifier (cp, identifier);
|
119
|
+
makeMemberTag (identifier, K_FUNCTION, module);
|
120
|
+
vStringDelete (identifier);
|
121
|
+
}
|
122
|
+
|
123
|
+
/*
|
124
|
+
* Directives are of the form:
|
125
|
+
* -module(foo)
|
126
|
+
* -define(foo, bar)
|
127
|
+
* -record(graph, {vtab = notable, cyclic = true}).
|
128
|
+
*/
|
129
|
+
static void parseDirective (const unsigned char *cp, vString *const module)
|
130
|
+
{
|
131
|
+
/*
|
132
|
+
* A directive will be either a record definition or a directive.
|
133
|
+
* Record definitions are handled separately
|
134
|
+
*/
|
135
|
+
vString *const directive = vStringNew ();
|
136
|
+
const char *const drtv = vStringValue (directive);
|
137
|
+
cp = parseIdentifier (cp, directive);
|
138
|
+
cp = skipSpace (cp);
|
139
|
+
if (*cp == '(')
|
140
|
+
++cp;
|
141
|
+
|
142
|
+
if (strcmp (drtv, "record") == 0)
|
143
|
+
parseSimpleTag (cp, K_RECORD);
|
144
|
+
else if (strcmp (drtv, "define") == 0)
|
145
|
+
parseSimpleTag (cp, K_MACRO);
|
146
|
+
else if (strcmp (drtv, "module") == 0)
|
147
|
+
parseModuleTag (cp, module);
|
148
|
+
/* Otherwise, it was an import, export, etc. */
|
149
|
+
|
150
|
+
vStringDelete (directive);
|
151
|
+
}
|
152
|
+
|
153
|
+
static void findErlangTags (void)
|
154
|
+
{
|
155
|
+
vString *const module = vStringNew ();
|
156
|
+
const unsigned char *line;
|
157
|
+
|
158
|
+
while ((line = fileReadLine ()) != NULL)
|
159
|
+
{
|
160
|
+
const unsigned char *cp = line;
|
161
|
+
|
162
|
+
if (*cp == '%') /* skip initial comment */
|
163
|
+
continue;
|
164
|
+
if (*cp == '"') /* strings sometimes start in column one */
|
165
|
+
continue;
|
166
|
+
|
167
|
+
if ( *cp == '-')
|
168
|
+
{
|
169
|
+
++cp; /* Move off of the '-' */
|
170
|
+
parseDirective(cp, module);
|
171
|
+
}
|
172
|
+
else if (isIdentifierFirstCharacter ((int) *cp))
|
173
|
+
parseFunctionTag (cp, module);
|
174
|
+
}
|
175
|
+
vStringDelete (module);
|
176
|
+
}
|
177
|
+
|
178
|
+
extern parserDefinition *ErlangParser (void)
|
179
|
+
{
|
180
|
+
static const char *const extensions[] = { "erl", "ERL", "hrl", "HRL", NULL };
|
181
|
+
parserDefinition *def = parserNew ("Erlang");
|
182
|
+
def->kinds = ErlangKinds;
|
183
|
+
def->kindCount = KIND_COUNT (ErlangKinds);
|
184
|
+
def->extensions = extensions;
|
185
|
+
def->parser = findErlangTags;
|
186
|
+
return def;
|
187
|
+
}
|
188
|
+
|
189
|
+
/* vi:set tabstop=4 shiftwidth=4: */
|