lisp.c - ctags-5.8
Global variables defined
Data types defined
Functions defined
Source code
#include "general.h"
#include "parse.h"
#include "read.h"
#include "vstring.h"
typedef enum {
K_FUNCTION
} lispKind;
static kindOption LispKinds [] = {
{ TRUE, 'f', "function", "functions" }
};
static int L_isdef (const unsigned char *strp)
{
return ( (strp [1] == 'd' || strp [1] == 'D')
&& (strp [2] == 'e' || strp [2] == 'E')
&& (strp [3] == 'f' || strp [3] == 'F'));
}
static int L_isquote (const unsigned char *strp)
{
return ( (*(++strp) == 'q' || *strp == 'Q')
&& (*(++strp) == 'u' || *strp == 'U')
&& (*(++strp) == 'o' || *strp == 'O')
&& (*(++strp) == 't' || *strp == 'T')
&& (*(++strp) == 'e' || *strp == 'E')
&& isspace (*(++strp)));
}
static void L_getit (vString *const name, const unsigned char *dbp)
{
const unsigned char *p;
if (*dbp == '\'') dbp++;
else if (*dbp == '(' && L_isquote (dbp)) {
dbp += 7;
while (isspace (*dbp))
dbp++;
}
for (p=dbp ; *p!='\0' && *p!='(' && !isspace ((int) *p) && *p!=')' ; p++)
vStringPut (name, *p);
vStringTerminate (name);
if (vStringLength (name) > 0)
makeSimpleTag (name, LispKinds, K_FUNCTION);
vStringClear (name);
}
static void findLispTags (void)
{
vString *name = vStringNew ();
const unsigned char* p;
while ((p = fileReadLine ()) != NULL)
{
if (*p == '(')
{
if (L_isdef (p))
{
while (*p != '\0' && !isspace ((int) *p))
p++;
while (isspace ((int) *p))
p++;
L_getit (name, p);
}
else
{
do
p++;
while (*p != '\0' && !isspace ((int) *p)
&& *p != ':' && *p != '(' && *p != ')');
if (*p == ':')
{
do
p++;
while (*p == ':');
if (L_isdef (p - 1))
{
while (*p != '\0' && !isspace ((int) *p))
p++;
while (isspace (*p))
p++;
L_getit (name, p);
}
}
}
}
}
vStringDelete (name);
}
extern parserDefinition* LispParser (void)
{
static const char *const extensions [] = {
"cl", "clisp", "el", "l", "lisp", "lsp", NULL
};
parserDefinition* def = parserNew ("Lisp");
def->kinds = LispKinds;
def->kindCount = KIND_COUNT (LispKinds);
def->extensions = extensions;
def->parser = findLispTags;
return def;
}