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,340 @@
|
|
1
|
+
/*
|
2
|
+
* $Id: verilog.c 573 2007-06-26 05:41:27Z elliotth $
|
3
|
+
*
|
4
|
+
* Copyright (c) 2003, Darren Hiebert
|
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 the Verilog HDL
|
10
|
+
* (Hardware Description Language).
|
11
|
+
*
|
12
|
+
* Language definition documents:
|
13
|
+
* http://www.eg.bucknell.edu/~cs320/verilog/verilog-manual.html
|
14
|
+
* http://www.sutherland-hdl.com/on-line_ref_guide/vlog_ref_top.html
|
15
|
+
* http://www.verilog.com/VerilogBNF.html
|
16
|
+
* http://eesun.free.fr/DOC/VERILOG/verilog_manual1.html
|
17
|
+
*/
|
18
|
+
|
19
|
+
/*
|
20
|
+
* INCLUDE FILES
|
21
|
+
*/
|
22
|
+
#include "general.h" /* must always come first */
|
23
|
+
|
24
|
+
#include <string.h>
|
25
|
+
#include <setjmp.h>
|
26
|
+
|
27
|
+
#include "debug.h"
|
28
|
+
#include "get.h"
|
29
|
+
#include "keyword.h"
|
30
|
+
#include "parse.h"
|
31
|
+
#include "read.h"
|
32
|
+
#include "vstring.h"
|
33
|
+
|
34
|
+
/*
|
35
|
+
* DATA DECLARATIONS
|
36
|
+
*/
|
37
|
+
typedef enum eException { ExceptionNone, ExceptionEOF } exception_t;
|
38
|
+
|
39
|
+
typedef enum {
|
40
|
+
K_UNDEFINED = -1,
|
41
|
+
K_CONSTANT,
|
42
|
+
K_EVENT,
|
43
|
+
K_FUNCTION,
|
44
|
+
K_MODULE,
|
45
|
+
K_NET,
|
46
|
+
K_PORT,
|
47
|
+
K_REGISTER,
|
48
|
+
K_TASK
|
49
|
+
} verilogKind;
|
50
|
+
|
51
|
+
typedef struct {
|
52
|
+
const char *keyword;
|
53
|
+
verilogKind kind;
|
54
|
+
} keywordAssoc;
|
55
|
+
|
56
|
+
/*
|
57
|
+
* DATA DEFINITIONS
|
58
|
+
*/
|
59
|
+
static int Ungetc;
|
60
|
+
static int Lang_verilog;
|
61
|
+
static jmp_buf Exception;
|
62
|
+
|
63
|
+
static kindOption VerilogKinds [] = {
|
64
|
+
{ TRUE, 'c', "constant", "constants (define, parameter, specparam)" },
|
65
|
+
{ TRUE, 'e', "event", "events" },
|
66
|
+
{ TRUE, 'f', "function", "functions" },
|
67
|
+
{ TRUE, 'm', "module", "modules" },
|
68
|
+
{ TRUE, 'n', "net", "net data types" },
|
69
|
+
{ TRUE, 'p', "port", "ports" },
|
70
|
+
{ TRUE, 'r', "register", "register data types" },
|
71
|
+
{ TRUE, 't', "task", "tasks" }
|
72
|
+
};
|
73
|
+
|
74
|
+
static keywordAssoc VerilogKeywordTable [] = {
|
75
|
+
{ "`define", K_CONSTANT },
|
76
|
+
{ "event", K_EVENT },
|
77
|
+
{ "function", K_FUNCTION },
|
78
|
+
{ "inout", K_PORT },
|
79
|
+
{ "input", K_PORT },
|
80
|
+
{ "integer", K_REGISTER },
|
81
|
+
{ "module", K_MODULE },
|
82
|
+
{ "output", K_PORT },
|
83
|
+
{ "parameter", K_CONSTANT },
|
84
|
+
{ "real", K_REGISTER },
|
85
|
+
{ "realtime", K_REGISTER },
|
86
|
+
{ "reg", K_REGISTER },
|
87
|
+
{ "specparam", K_CONSTANT },
|
88
|
+
{ "supply0", K_NET },
|
89
|
+
{ "supply1", K_NET },
|
90
|
+
{ "task", K_TASK },
|
91
|
+
{ "time", K_REGISTER },
|
92
|
+
{ "tri0", K_NET },
|
93
|
+
{ "tri1", K_NET },
|
94
|
+
{ "triand", K_NET },
|
95
|
+
{ "tri", K_NET },
|
96
|
+
{ "trior", K_NET },
|
97
|
+
{ "trireg", K_NET },
|
98
|
+
{ "wand", K_NET },
|
99
|
+
{ "wire", K_NET },
|
100
|
+
{ "wor", K_NET }
|
101
|
+
};
|
102
|
+
|
103
|
+
/*
|
104
|
+
* FUNCTION DEFINITIONS
|
105
|
+
*/
|
106
|
+
|
107
|
+
static void initialize (const langType language)
|
108
|
+
{
|
109
|
+
size_t i;
|
110
|
+
const size_t count =
|
111
|
+
sizeof (VerilogKeywordTable) / sizeof (VerilogKeywordTable [0]);
|
112
|
+
Lang_verilog = language;
|
113
|
+
for (i = 0 ; i < count ; ++i)
|
114
|
+
{
|
115
|
+
const keywordAssoc* const p = &VerilogKeywordTable [i];
|
116
|
+
addKeyword (p->keyword, language, (int) p->kind);
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
static void vUngetc (int c)
|
121
|
+
{
|
122
|
+
Assert (Ungetc == '\0');
|
123
|
+
Ungetc = c;
|
124
|
+
}
|
125
|
+
|
126
|
+
static int vGetc (void)
|
127
|
+
{
|
128
|
+
int c;
|
129
|
+
if (Ungetc == '\0')
|
130
|
+
c = fileGetc ();
|
131
|
+
else
|
132
|
+
{
|
133
|
+
c = Ungetc;
|
134
|
+
Ungetc = '\0';
|
135
|
+
}
|
136
|
+
if (c == '/')
|
137
|
+
{
|
138
|
+
int c2 = fileGetc ();
|
139
|
+
if (c2 == EOF)
|
140
|
+
longjmp (Exception, (int) ExceptionEOF);
|
141
|
+
else if (c2 == '/') /* strip comment until end-of-line */
|
142
|
+
{
|
143
|
+
do
|
144
|
+
c = fileGetc ();
|
145
|
+
while (c != '\n' && c != EOF);
|
146
|
+
}
|
147
|
+
else if (c2 == '*') /* strip block comment */
|
148
|
+
{
|
149
|
+
c = skipOverCComment();
|
150
|
+
}
|
151
|
+
else
|
152
|
+
{
|
153
|
+
fileUngetc (c2);
|
154
|
+
}
|
155
|
+
}
|
156
|
+
else if (c == '"') /* strip string contents */
|
157
|
+
{
|
158
|
+
int c2;
|
159
|
+
do
|
160
|
+
c2 = fileGetc ();
|
161
|
+
while (c2 != '"' && c2 != EOF);
|
162
|
+
c = '@';
|
163
|
+
}
|
164
|
+
if (c == EOF)
|
165
|
+
longjmp (Exception, (int) ExceptionEOF);
|
166
|
+
return c;
|
167
|
+
}
|
168
|
+
|
169
|
+
static boolean isIdentifierCharacter (const int c)
|
170
|
+
{
|
171
|
+
return (boolean)(isalnum (c) || c == '_' || c == '`');
|
172
|
+
}
|
173
|
+
|
174
|
+
static int skipWhite (int c)
|
175
|
+
{
|
176
|
+
while (isspace (c))
|
177
|
+
c = vGetc ();
|
178
|
+
return c;
|
179
|
+
}
|
180
|
+
|
181
|
+
static int skipPastMatch (const char *const pair)
|
182
|
+
{
|
183
|
+
const int begin = pair [0], end = pair [1];
|
184
|
+
int matchLevel = 1;
|
185
|
+
int c;
|
186
|
+
do
|
187
|
+
{
|
188
|
+
c = vGetc ();
|
189
|
+
if (c == begin)
|
190
|
+
++matchLevel;
|
191
|
+
else if (c == end)
|
192
|
+
--matchLevel;
|
193
|
+
}
|
194
|
+
while (matchLevel > 0);
|
195
|
+
return vGetc ();
|
196
|
+
}
|
197
|
+
|
198
|
+
static boolean readIdentifier (vString *const name, int c)
|
199
|
+
{
|
200
|
+
vStringClear (name);
|
201
|
+
if (isIdentifierCharacter (c))
|
202
|
+
{
|
203
|
+
while (isIdentifierCharacter (c))
|
204
|
+
{
|
205
|
+
vStringPut (name, c);
|
206
|
+
c = vGetc ();
|
207
|
+
}
|
208
|
+
vUngetc (c);
|
209
|
+
vStringTerminate (name);
|
210
|
+
}
|
211
|
+
return (boolean)(name->length > 0);
|
212
|
+
}
|
213
|
+
|
214
|
+
static void tagNameList (const verilogKind kind, int c)
|
215
|
+
{
|
216
|
+
vString *name = vStringNew ();
|
217
|
+
boolean repeat;
|
218
|
+
Assert (isIdentifierCharacter (c));
|
219
|
+
do
|
220
|
+
{
|
221
|
+
repeat = FALSE;
|
222
|
+
if (isIdentifierCharacter (c))
|
223
|
+
{
|
224
|
+
readIdentifier (name, c);
|
225
|
+
makeSimpleTag (name, VerilogKinds, kind);
|
226
|
+
}
|
227
|
+
else
|
228
|
+
break;
|
229
|
+
c = skipWhite (vGetc ());
|
230
|
+
if (c == '[')
|
231
|
+
c = skipPastMatch ("[]");
|
232
|
+
c = skipWhite (c);
|
233
|
+
if (c == '=')
|
234
|
+
{
|
235
|
+
if (c == '{')
|
236
|
+
skipPastMatch ("{}");
|
237
|
+
else
|
238
|
+
{
|
239
|
+
do
|
240
|
+
c = vGetc ();
|
241
|
+
while (c != ',' && c != ';');
|
242
|
+
}
|
243
|
+
}
|
244
|
+
if (c == ',')
|
245
|
+
{
|
246
|
+
c = skipWhite (vGetc ());
|
247
|
+
repeat = TRUE;
|
248
|
+
}
|
249
|
+
else
|
250
|
+
repeat = FALSE;
|
251
|
+
} while (repeat);
|
252
|
+
vStringDelete (name);
|
253
|
+
vUngetc (c);
|
254
|
+
}
|
255
|
+
|
256
|
+
static void findTag (vString *const name)
|
257
|
+
{
|
258
|
+
const verilogKind kind = (verilogKind) lookupKeyword (vStringValue (name), Lang_verilog);
|
259
|
+
if (kind == K_CONSTANT && vStringItem (name, 0) == '`')
|
260
|
+
{
|
261
|
+
/* Bug #961001: Verilog compiler directives are line-based. */
|
262
|
+
int c = skipWhite (vGetc ());
|
263
|
+
readIdentifier (name, c);
|
264
|
+
makeSimpleTag (name, VerilogKinds, kind);
|
265
|
+
/* Skip the rest of the line. */
|
266
|
+
do {
|
267
|
+
c = vGetc();
|
268
|
+
} while (c != '\n');
|
269
|
+
vUngetc (c);
|
270
|
+
}
|
271
|
+
else if (kind != K_UNDEFINED)
|
272
|
+
{
|
273
|
+
int c = skipWhite (vGetc ());
|
274
|
+
|
275
|
+
/* Many keywords can have bit width.
|
276
|
+
* reg [3:0] net_name;
|
277
|
+
* inout [(`DBUSWIDTH-1):0] databus;
|
278
|
+
*/
|
279
|
+
if (c == '(')
|
280
|
+
c = skipPastMatch ("()");
|
281
|
+
c = skipWhite (c);
|
282
|
+
if (c == '[')
|
283
|
+
c = skipPastMatch ("[]");
|
284
|
+
c = skipWhite (c);
|
285
|
+
if (c == '#')
|
286
|
+
{
|
287
|
+
c = vGetc ();
|
288
|
+
if (c == '(')
|
289
|
+
c = skipPastMatch ("()");
|
290
|
+
}
|
291
|
+
c = skipWhite (c);
|
292
|
+
if (isIdentifierCharacter (c))
|
293
|
+
tagNameList (kind, c);
|
294
|
+
}
|
295
|
+
}
|
296
|
+
|
297
|
+
static void findVerilogTags (void)
|
298
|
+
{
|
299
|
+
vString *const name = vStringNew ();
|
300
|
+
volatile boolean newStatement = TRUE;
|
301
|
+
volatile int c = '\0';
|
302
|
+
exception_t exception = (exception_t) setjmp (Exception);
|
303
|
+
|
304
|
+
if (exception == ExceptionNone) while (c != EOF)
|
305
|
+
{
|
306
|
+
c = vGetc ();
|
307
|
+
switch (c)
|
308
|
+
{
|
309
|
+
case ';':
|
310
|
+
case '\n':
|
311
|
+
newStatement = TRUE;
|
312
|
+
break;
|
313
|
+
|
314
|
+
case ' ':
|
315
|
+
case '\t':
|
316
|
+
break;
|
317
|
+
|
318
|
+
default:
|
319
|
+
if (newStatement && readIdentifier (name, c))
|
320
|
+
findTag (name);
|
321
|
+
newStatement = FALSE;
|
322
|
+
break;
|
323
|
+
}
|
324
|
+
}
|
325
|
+
vStringDelete (name);
|
326
|
+
}
|
327
|
+
|
328
|
+
extern parserDefinition* VerilogParser (void)
|
329
|
+
{
|
330
|
+
static const char *const extensions [] = { "v", NULL };
|
331
|
+
parserDefinition* def = parserNew ("Verilog");
|
332
|
+
def->kinds = VerilogKinds;
|
333
|
+
def->kindCount = KIND_COUNT (VerilogKinds);
|
334
|
+
def->extensions = extensions;
|
335
|
+
def->parser = findVerilogTags;
|
336
|
+
def->initialize = initialize;
|
337
|
+
return def;
|
338
|
+
}
|
339
|
+
|
340
|
+
/* vi:set tabstop=4 shiftwidth=4: */
|