Kaydet (Commit) 5c4ea3ee authored tarafından Enrico Tröger's avatar Enrico Tröger

improved

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@320 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst be14d242
...@@ -24,18 +24,25 @@ ...@@ -24,18 +24,25 @@
*/ */
typedef enum { typedef enum {
K_SUBROUTINE, K_SUBROUTINE,
K_PACKAGE K_PACKAGE,
K_LOCAL,
K_MY,
K_OUR
} perlKind; } perlKind;
static kindOption PerlKinds [] = { static kindOption PerlKinds [] = {
{ TRUE, 'f', "function", "functions" }, { TRUE, 'f', "function", "functions" },
{ TRUE, 'c', "class", "packages" } { TRUE, 'c', "class", "packages" },
{ TRUE, 'l', "macro", "local variables" },
{ TRUE, 'm', "member", "my variables" },
{ TRUE, 'v', "variable", "our variables" }
}; };
/* /*
* FUNCTION DEFINITIONS * FUNCTION DEFINITIONS
*/ */
/* Algorithm adapted from from GNU etags. /* Algorithm adapted from from GNU etags.
* Perl support by Bart Robinson <lomew@cs.utah.edu> * Perl support by Bart Robinson <lomew@cs.utah.edu>
* Perl sub names: look for /^ [ \t\n]sub [ \t\n]+ [^ \t\n{ (]+/ * Perl sub names: look for /^ [ \t\n]sub [ \t\n]+ [^ \t\n{ (]+/
...@@ -73,8 +80,74 @@ static void findPerlTags (void) ...@@ -73,8 +80,74 @@ static void findPerlTags (void)
while (isspace (*cp)) while (isspace (*cp))
cp++; cp++;
if (strncmp((const char*) cp, "sub", (size_t) 3) == 0 || if (strncmp((const char*) cp, "my", (size_t) 2) == 0)
strncmp((const char*) cp, "package", (size_t) 7) == 0) {
cp += 2;
while (isspace (*cp)) cp++;
// skip something like my($bla)
if (*(const char*) cp != '$' && ! isalpha(*(const char*) cp)) continue;
cp++; // to skip the $ sign
if (! isalpha(*(const char*) cp)) continue;
while (! isspace ((int) *cp) && *cp != '\0' && *cp != '=' && *cp != ';')
{
vStringPut (name, (int) *cp);
cp++;
}
vStringTerminate (name);
if (vStringLength (name) > 0)
makeSimpleTag (name, PerlKinds, K_MY);
vStringClear (name);
}
if (strncmp((const char*) cp, "our", (size_t) 3) == 0)
{
cp += 3;
// skip something like my ($bla)
if (*(const char*) cp != '$' && ! isalpha(*(const char*) cp)) continue;
cp++; // to skip the $ sign
if (! isalpha(*(const char*) cp)) continue;
while (! isspace ((int) *cp) && *cp != '\0' && *cp != '=' && *cp != ';')
{
vStringPut (name, (int) *cp);
cp++;
}
vStringTerminate (name);
if (vStringLength (name) > 0)
makeSimpleTag (name, PerlKinds, K_OUR);
vStringClear (name);
}
if (strncmp((const char*) cp, "local", (size_t) 5) == 0)
{
cp += 5;
// skip something like my($bla)
if (*(const char*) cp != '$' && ! isalpha(*(const char*) cp)) continue;
cp++; // to skip the $ sign
if (! isalpha(*(const char*) cp)) continue;
while (! isspace ((int) *cp) && *cp != '\0' && *cp != '=' && *cp != ';')
{
vStringPut (name, (int) *cp);
cp++;
}
vStringTerminate (name);
if (vStringLength (name) > 0)
makeSimpleTag (name, PerlKinds, K_LOCAL);
vStringClear (name);
}
else if (strncmp((const char*) cp, "sub", (size_t) 3) == 0 ||
strncmp((const char*) cp, "package", (size_t) 7) == 0)
{ {
if (strncmp((const char*) cp, "sub", (size_t) 3) == 0) if (strncmp((const char*) cp, "sub", (size_t) 3) == 0)
{ {
...@@ -89,7 +162,7 @@ static void findPerlTags (void) ...@@ -89,7 +162,7 @@ static void findPerlTags (void)
while (isspace (*cp)) while (isspace (*cp))
cp++; cp++;
while (! isspace ((int) *cp) && *cp != '\0' && *cp != '{' && *cp != '(') while (! isspace ((int) *cp) && *cp != '\0' && *cp != '{' && *cp != '(' && *cp != ';')
{ {
vStringPut (name, (int) *cp); vStringPut (name, (int) *cp);
cp++; cp++;
......
...@@ -79,7 +79,7 @@ static void findRubyTags (void) ...@@ -79,7 +79,7 @@ static void findRubyTags (void)
{ {
while (isspace ((int) *cp)) while (isspace ((int) *cp))
++cp; ++cp;
while (isalnum ((int) *cp) || *cp == '_') while (isalnum ((int) *cp) || *cp == '_' || *cp == ':')
{ {
vStringPut (name, (int) *cp); vStringPut (name, (int) *cp);
++cp; ++cp;
...@@ -94,7 +94,7 @@ static void findRubyTags (void) ...@@ -94,7 +94,7 @@ static void findRubyTags (void)
cp += 3; cp += 3;
if (isspace ((int) *cp)) if (isspace ((int) *cp))
{ {
while (isspace ((int) *cp)) while (isalnum ((int) *cp) || *cp == ':')
++cp; ++cp;
/* Put the valid characters allowed in a variable name /* Put the valid characters allowed in a variable name
...@@ -134,5 +134,5 @@ extern parserDefinition* RubyParser (void) ...@@ -134,5 +134,5 @@ extern parserDefinition* RubyParser (void)
def->kindCount = KIND_COUNT (RubyKinds); def->kindCount = KIND_COUNT (RubyKinds);
def->extensions = extensions; def->extensions = extensions;
def->parser = findRubyTags; def->parser = findRubyTags;
return def; return def;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment