forked from universal-ctags/ctags
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for Lua language, submitted by Max Ischenko.
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
Showing
12 changed files
with
174 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters