ctags.rb 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. data/Gemfile +2 -0
  2. data/Rakefile +23 -0
  3. data/ctags.rb.gemspec +23 -0
  4. data/ext/.gitignore +3 -0
  5. data/ext/extconf.rb +15 -0
  6. data/ext/vendor/exuberant-ctags/.gitignore +6 -0
  7. data/ext/vendor/exuberant-ctags/.indent.pro +31 -0
  8. data/ext/vendor/exuberant-ctags/COPYING +340 -0
  9. data/ext/vendor/exuberant-ctags/EXTENDING.html +386 -0
  10. data/ext/vendor/exuberant-ctags/FAQ +371 -0
  11. data/ext/vendor/exuberant-ctags/INSTALL +215 -0
  12. data/ext/vendor/exuberant-ctags/INSTALL.oth +73 -0
  13. data/ext/vendor/exuberant-ctags/MAINTAINERS +88 -0
  14. data/ext/vendor/exuberant-ctags/Makefile.in +222 -0
  15. data/ext/vendor/exuberant-ctags/NEWS +871 -0
  16. data/ext/vendor/exuberant-ctags/README +73 -0
  17. data/ext/vendor/exuberant-ctags/ant.c +42 -0
  18. data/ext/vendor/exuberant-ctags/argproc.c +505 -0
  19. data/ext/vendor/exuberant-ctags/args.c +274 -0
  20. data/ext/vendor/exuberant-ctags/args.h +63 -0
  21. data/ext/vendor/exuberant-ctags/asm.c +387 -0
  22. data/ext/vendor/exuberant-ctags/asp.c +328 -0
  23. data/ext/vendor/exuberant-ctags/awk.c +81 -0
  24. data/ext/vendor/exuberant-ctags/basic.c +203 -0
  25. data/ext/vendor/exuberant-ctags/beta.c +321 -0
  26. data/ext/vendor/exuberant-ctags/c.c +2932 -0
  27. data/ext/vendor/exuberant-ctags/cobol.c +50 -0
  28. data/ext/vendor/exuberant-ctags/config.h.in +277 -0
  29. data/ext/vendor/exuberant-ctags/configure +7704 -0
  30. data/ext/vendor/exuberant-ctags/configure.ac +532 -0
  31. data/ext/vendor/exuberant-ctags/ctags.1 +1186 -0
  32. data/ext/vendor/exuberant-ctags/ctags.h +28 -0
  33. data/ext/vendor/exuberant-ctags/ctags.html +2087 -0
  34. data/ext/vendor/exuberant-ctags/ctags.spec +40 -0
  35. data/ext/vendor/exuberant-ctags/debug.c +113 -0
  36. data/ext/vendor/exuberant-ctags/debug.h +70 -0
  37. data/ext/vendor/exuberant-ctags/descrip.mms +68 -0
  38. data/ext/vendor/exuberant-ctags/dosbatch.c +42 -0
  39. data/ext/vendor/exuberant-ctags/e_amiga.h +24 -0
  40. data/ext/vendor/exuberant-ctags/e_djgpp.h +47 -0
  41. data/ext/vendor/exuberant-ctags/e_mac.h +143 -0
  42. data/ext/vendor/exuberant-ctags/e_msoft.h +76 -0
  43. data/ext/vendor/exuberant-ctags/e_os2.h +37 -0
  44. data/ext/vendor/exuberant-ctags/e_qdos.h +34 -0
  45. data/ext/vendor/exuberant-ctags/e_riscos.h +58 -0
  46. data/ext/vendor/exuberant-ctags/e_vms.h +31 -0
  47. data/ext/vendor/exuberant-ctags/eiffel.c +1352 -0
  48. data/ext/vendor/exuberant-ctags/entry.c +847 -0
  49. data/ext/vendor/exuberant-ctags/entry.h +103 -0
  50. data/ext/vendor/exuberant-ctags/erlang.c +189 -0
  51. data/ext/vendor/exuberant-ctags/flex.c +2243 -0
  52. data/ext/vendor/exuberant-ctags/fortran.c +2197 -0
  53. data/ext/vendor/exuberant-ctags/general.h +127 -0
  54. data/ext/vendor/exuberant-ctags/get.c +669 -0
  55. data/ext/vendor/exuberant-ctags/get.h +50 -0
  56. data/ext/vendor/exuberant-ctags/gnu_regex/.svn/all-wcprops +47 -0
  57. data/ext/vendor/exuberant-ctags/gnu_regex/.svn/entries +112 -0
  58. data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/README.txt.svn-base +5 -0
  59. data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regcomp.c.svn-base +3818 -0
  60. data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regex.c.svn-base +74 -0
  61. data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regex.h.svn-base +575 -0
  62. data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regex_internal.c.svn-base +1713 -0
  63. data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regex_internal.h.svn-base +773 -0
  64. data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regexec.c.svn-base +4338 -0
  65. data/ext/vendor/exuberant-ctags/gnu_regex/README.txt +5 -0
  66. data/ext/vendor/exuberant-ctags/gnu_regex/regcomp.c +3818 -0
  67. data/ext/vendor/exuberant-ctags/gnu_regex/regex.c +74 -0
  68. data/ext/vendor/exuberant-ctags/gnu_regex/regex.h +575 -0
  69. data/ext/vendor/exuberant-ctags/gnu_regex/regex_internal.c +1713 -0
  70. data/ext/vendor/exuberant-ctags/gnu_regex/regex_internal.h +773 -0
  71. data/ext/vendor/exuberant-ctags/gnu_regex/regexec.c +4338 -0
  72. data/ext/vendor/exuberant-ctags/html.c +49 -0
  73. data/ext/vendor/exuberant-ctags/jscript.c +1572 -0
  74. data/ext/vendor/exuberant-ctags/keyword.c +258 -0
  75. data/ext/vendor/exuberant-ctags/keyword.h +34 -0
  76. data/ext/vendor/exuberant-ctags/lisp.c +139 -0
  77. data/ext/vendor/exuberant-ctags/lregex.c +704 -0
  78. data/ext/vendor/exuberant-ctags/lua.c +133 -0
  79. data/ext/vendor/exuberant-ctags/mac.c +273 -0
  80. data/ext/vendor/exuberant-ctags/magic.diff +21 -0
  81. data/ext/vendor/exuberant-ctags/main.c +584 -0
  82. data/ext/vendor/exuberant-ctags/main.h +32 -0
  83. data/ext/vendor/exuberant-ctags/maintainer.mak +476 -0
  84. data/ext/vendor/exuberant-ctags/make.c +217 -0
  85. data/ext/vendor/exuberant-ctags/matlab.c +44 -0
  86. data/ext/vendor/exuberant-ctags/mk_bc3.mak +46 -0
  87. data/ext/vendor/exuberant-ctags/mk_bc5.mak +49 -0
  88. data/ext/vendor/exuberant-ctags/mk_djg.mak +18 -0
  89. data/ext/vendor/exuberant-ctags/mk_manx.mak +65 -0
  90. data/ext/vendor/exuberant-ctags/mk_mingw.mak +31 -0
  91. data/ext/vendor/exuberant-ctags/mk_mpw.mak +130 -0
  92. data/ext/vendor/exuberant-ctags/mk_mvc.mak +40 -0
  93. data/ext/vendor/exuberant-ctags/mk_os2.mak +104 -0
  94. data/ext/vendor/exuberant-ctags/mk_qdos.mak +100 -0
  95. data/ext/vendor/exuberant-ctags/mk_sas.mak +63 -0
  96. data/ext/vendor/exuberant-ctags/mkinstalldirs +40 -0
  97. data/ext/vendor/exuberant-ctags/ocaml.c +1842 -0
  98. data/ext/vendor/exuberant-ctags/options.c +1842 -0
  99. data/ext/vendor/exuberant-ctags/options.h +155 -0
  100. data/ext/vendor/exuberant-ctags/parse.c +677 -0
  101. data/ext/vendor/exuberant-ctags/parse.h +129 -0
  102. data/ext/vendor/exuberant-ctags/parsers.h +63 -0
  103. data/ext/vendor/exuberant-ctags/pascal.c +267 -0
  104. data/ext/vendor/exuberant-ctags/perl.c +382 -0
  105. data/ext/vendor/exuberant-ctags/php.c +237 -0
  106. data/ext/vendor/exuberant-ctags/python.c +771 -0
  107. data/ext/vendor/exuberant-ctags/qdos.c +106 -0
  108. data/ext/vendor/exuberant-ctags/read.c +569 -0
  109. data/ext/vendor/exuberant-ctags/read.h +116 -0
  110. data/ext/vendor/exuberant-ctags/readtags.c +959 -0
  111. data/ext/vendor/exuberant-ctags/readtags.h +252 -0
  112. data/ext/vendor/exuberant-ctags/rexx.c +39 -0
  113. data/ext/vendor/exuberant-ctags/routines.c +891 -0
  114. data/ext/vendor/exuberant-ctags/routines.h +134 -0
  115. data/ext/vendor/exuberant-ctags/ruby.c +408 -0
  116. data/ext/vendor/exuberant-ctags/scheme.c +111 -0
  117. data/ext/vendor/exuberant-ctags/sh.c +115 -0
  118. data/ext/vendor/exuberant-ctags/slang.c +41 -0
  119. data/ext/vendor/exuberant-ctags/sml.c +212 -0
  120. data/ext/vendor/exuberant-ctags/sort.c +230 -0
  121. data/ext/vendor/exuberant-ctags/sort.h +32 -0
  122. data/ext/vendor/exuberant-ctags/source.mak +122 -0
  123. data/ext/vendor/exuberant-ctags/sql.c +2112 -0
  124. data/ext/vendor/exuberant-ctags/strlist.c +281 -0
  125. data/ext/vendor/exuberant-ctags/strlist.h +54 -0
  126. data/ext/vendor/exuberant-ctags/tcl.c +116 -0
  127. data/ext/vendor/exuberant-ctags/tex.c +524 -0
  128. data/ext/vendor/exuberant-ctags/verilog.c +340 -0
  129. data/ext/vendor/exuberant-ctags/vhdl.c +835 -0
  130. data/ext/vendor/exuberant-ctags/vim.c +636 -0
  131. data/ext/vendor/exuberant-ctags/vstring.c +232 -0
  132. data/ext/vendor/exuberant-ctags/vstring.h +85 -0
  133. data/ext/vendor/exuberant-ctags/yacc.c +40 -0
  134. data/lib/ctags/exuberant.rb +45 -0
  135. data/lib/ctags/version.rb +3 -0
  136. data/lib/ctags.rb +6 -0
  137. data/test/test_ctags.rb +24 -0
  138. 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: */