Skip to content

Commit

Permalink
Added support for Lua language, submitted by Max Ischenko.
Browse files Browse the repository at this point in the history
git-svn-id: https://ctags.svn.sourceforge.net/svnroot/ctags/trunk@43 c5d04d22-be80-434c-894e-aa346cc9e8e8
  • Loading branch information
Darren Hiebert committed Dec 20, 2001
1 parent 3e23242 commit dfb2141
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 6 deletions.
3 changes: 2 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Current Version: @@VERSION@@

ctags-5.1.1 (Sun Dec 16 2001)
ctags-5.2 (Sun Dec 16 2001)
* Portabilitiy fixes [HP-UX, Solaris, VMS, OS/2].
* Made code compilable by a C++ compiler.
* Changed reading of option files to ignore blank lines.
* Changed and enhanced interface to readtags library (see readtags.h).
* Added support for Lua language, submitted by Max Ischenko.
* Added instructions to man page on using tags with NEdit.
* Fixed regex tag problem which left newlines in back-references.
* Fixed missing class-qualified tags [Eiffel].
Expand Down
6 changes: 3 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ because most were easily fooled by a number of preprocessor contructs.
Exuberant Ctags offers the following features:

1. It supports the following languages: Assembler, AWK, ASP, BETA,
Bourne/Korn/Z Shell, C, C++, COBOL, Eiffel, Fortran, Java, Lisp,
Makefile, Pascal, Perl, PHP, Python, REXX, Ruby, S-Lang, Scheme,
Tcl, and Vim.
Bourne/Korn/Z Shell, C, C++, COBOL, Eiffel, Fortran, Java, Lisp, Lua,
Makefile, Pascal, Perl, PHP, Python, REXX, Ruby, S-Lang, Scheme, Tcl,
and Vim.

2. It is capable of generating tags for virtually all C language constructs.

Expand Down
14 changes: 14 additions & 0 deletions Test/simple.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
test = {}

function test.me_12a(one, two)
print"me_12a"
end


test.i_123 = function (x)
print"i_123"
end


test.me_12a(1,2)
test.i_123(1)
14 changes: 14 additions & 0 deletions ctags.1
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ names are mapped to languages according to the following default mappings
.B Lisp
*.cl *.clisp *.el *.l *.lisp *.lsp *.ml
.TP 9
.B Lua
*.lua
.TP 9
.B Make
*.mak [Mm]akefile*
.TP 9
Expand Down Expand Up @@ -1045,6 +1048,17 @@ functions
.PD 1
.RE

.TP 5
Lua
.RS 5
.PD 0
.TP 4
.I f
functions
.RE
.PD 1
.RE

.TP 5
Make
.RS 5
Expand Down
4 changes: 2 additions & 2 deletions ctags.lsm
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Entered-date: @@LSMDATE@@
Description: An improved ctags with multilanguage support.
Keywords: tag tags ctags etags ftags ptags Exuberant Assembler ASP AWK
Bourne sh BETA C C++ COBOL Eiffel Fortran Java Korn ksh Lisp
Makefile Pascal Perl PHP Python REXX Ruby Scheme SLang S-Lang
Tcl Vim tool utility source index zsh
Lua Makefile Pascal Perl PHP Python REXX Ruby Scheme SLang
S-Lang Tcl Vim tool utility source index zsh
Author: darren@hiebert.com (Darren Hiebert)
Primary-site: http://ctags.sourceforge.net
215kB ctags-@@VERSION@@.tar.gz
Expand Down
131 changes: 131 additions & 0 deletions lua.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
* $Id$
*
* Copyright (c) 2000-2001, Max Ischenko <mfi@ukr.net>.
*
* This source code is released for free distribution under the terms of the
* GNU General Public License.
*
* This module contains functions for generating tags for Lua language.
*/

/*
* INCLUDE FILES
*/
#include "general.h" /* must always come first */

#include <string.h>

#include "main.h"
#include "options.h"
#include "parse.h"
#include "read.h"
#include "vstring.h"

/*
* DATA DEFINITIONS
*/
typedef enum {
K_FUNCTION
} luaKind;

static kindOption LuaKinds [] = {
{ TRUE, 'f', "function", "functions" }
};

/*
* FUNCTION DEFINITIONS
*/

/* for debugging purposes */
static void __unused__ print_string (char *p, char *q)
{
for ( ; p != q; p++)
fprintf(stderr, "%c", *p);
fprintf(stderr, "\n");
}

/*
* Helper function.
* Returns 1 if line looks like a line of Lua code.
*
* TODO: Recognize UNIX bang notation.
* (Lua treat first line as a comment if it starts with #!)
*
*/
static boolean is_a_code_line (const unsigned char *line)
{
boolean result;
if (line [0] == '\0')
result = FALSE;
else if (line [0] == '-' && line [1] == '-')
result = FALSE;
else
result = TRUE;
return result;
}

static void extract_name (const char *begin, const char *end, vString *name)
{
if (begin != NULL && end != NULL && begin < end)
{
const char *cp;

while (isspace (*begin))
begin++;
while (isspace (*end))
end--;
if (begin < end)
{
for (cp = begin ; cp != end; cp++)
vStringPut (name, (int) *cp);
vStringTerminate (name);

makeSimpleTag (name, LuaKinds, K_FUNCTION);
vStringClear (name);
}
}
}

static void findLuaTags (void)
{
vString *name = vStringNew ();
const unsigned char *line;

while ((line = fileReadLine ()) != NULL)
{
const char *p, *q;

if (! is_a_code_line (line))
continue;

p = (const char*) strstr ((const char*) line, "function");
if (p == NULL)
continue;

q = strchr ((const char*) line, '=');

if (q == NULL) {
p = p + 9; /* skip the `function' word */
q = strchr ((const char*) p, '(');
extract_name (p, q, name);
} else {
p = (const char*) &line[0];
extract_name (p, q, name);
}
}
vStringDelete (name);
}

extern parserDefinition* LuaParser (void)
{
static const char* const extensions [] = { "lua", NULL };
parserDefinition* def = parserNew ("Lua");
def->kinds = LuaKinds;
def->kindCount = KIND_COUNT (LuaKinds);
def->extensions = extensions;
def->parser = findLuaTags;
return def;
}

/* vi:set tabstop=8 shiftwidth=4: */
1 change: 1 addition & 0 deletions mk_manx.mak
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ OBJECTS = \
get.$(OBJEXT) \
keyword.$(OBJEXT) \
lisp.$(OBJEXT) \
lua.$(OBJEXT) \
main.$(OBJEXT) \
make.$(OBJEXT) \
options.$(OBJEXT) \
Expand Down
2 changes: 2 additions & 0 deletions mk_mpw.mak
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ SOURCES =
get.c ¶
keyword.c ¶
lisp.c ¶
lua.c ¶
main.c ¶
make.c ¶
options.c ¶
Expand Down Expand Up @@ -60,6 +61,7 @@ OBJ =
get.o ¶
keyword.o ¶
lisp.o ¶
lua.o ¶
main.o ¶
make.o ¶
options.o ¶
Expand Down
1 change: 1 addition & 0 deletions mk_qdos.mak
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ OBJECTS = \
get.$(OBJEXT) \
keyword.$(OBJEXT) \
lisp.$(OBJEXT) \
lua.$(OBJEXT) \
main.$(OBJEXT) \
make.$(OBJEXT) \
options.$(OBJEXT) \
Expand Down
1 change: 1 addition & 0 deletions mk_sas.mak
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ OBJECTS = \
get.$(OBJEXT) \
keyword.$(OBJEXT) \
lisp.$(OBJEXT) \
lua.$(OBJEXT) \
main.$(OBJEXT) \
make.$(OBJEXT) \
options.$(OBJEXT) \
Expand Down
1 change: 1 addition & 0 deletions parsers.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
FortranParser, \
JavaParser, \
LispParser, \
LuaParser, \
MakefileParser, \
PascalParser, \
PerlParser, \
Expand Down
2 changes: 2 additions & 0 deletions source.mak
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ SOURCES = \
get.c \
keyword.c \
lisp.c \
lua.c \
main.c \
make.c \
options.c \
Expand Down Expand Up @@ -56,6 +57,7 @@ OBJECTS = \
get.$(OBJEXT) \
keyword.$(OBJEXT) \
lisp.$(OBJEXT) \
lua.$(OBJEXT) \
main.$(OBJEXT) \
make.$(OBJEXT) \
options.$(OBJEXT) \
Expand Down

0 comments on commit dfb2141

Please sign in to comment.