static void makeAsmTag ( const vString *const name, const vString *const operator, const boolean labelCandidate, const boolean nameFollows) { if (vStringLength (name) > 0) { boolean found; const AsmKind kind = operatorKind (operator, &found); if (found) { if (kind != K_NONE) makeSimpleTag (name, AsmKinds, kind); } else if (isDefineOperator (operator)) { if (! nameFollows) makeSimpleTag (name, AsmKinds, K_DEFINE); } else if (labelCandidate) { operatorKind (name, &found); if (! found) makeSimpleTag (name, AsmKinds, K_LABEL); } } }
/* * Function Definitions */ static void findFalconTags (void) { vString *name = vStringNew (); const unsigned char *line; while ((line = fileReadLine ()) != NULL) { const unsigned char *cp = line; if (*cp == '#') continue; if (strncmp ((const char*) cp, "function", (size_t) 8) == 0) { cp += 8; while (isspace ((int) *cp)) ++cp; while (isalnum ((int) *cp) || *cp == '_') { vStringPut (name, (int) *cp); ++cp; } vStringTerminate (name); makeSimpleTag (name, FalconKinds, K_FUNCTION); vStringClear (name); } else if (strncmp ((const char*) cp, "class", (size_t) 5) == 0) { cp += 5; while (isspace ((int) *cp)) ++cp; while (isalnum ((int) *cp) || *cp == '_') { vStringPut (name, (int) *cp); ++cp; } vStringTerminate (name); makeSimpleTag (name, FalconKinds, K_CLASS); vStringClear (name); } else if (strncmp ((const char*) cp, "load", (size_t) 4) == 0) { cp += 4; while (isspace ((int) *cp)) ++cp; while (isalnum ((int) *cp) || *cp == '_') { vStringPut (name, (int) *cp); ++cp; } vStringTerminate (name); makeSimpleTag (name, FalconKinds, K_NAMESPACE); vStringClear (name); } } vStringDelete (name); }
static void findSchemeTags (void) { vString *name = vStringNew (); const unsigned char *line; while ((line = readLineFromInputFile ()) != NULL) { const unsigned char *cp = line; if (cp [0] == '(' && (cp [1] == 'D' || cp [1] == 'd') && (cp [2] == 'E' || cp [2] == 'e') && (cp [3] == 'F' || cp [3] == 'f')) { while (*cp != '\0' && !isspace (*cp)) cp++; /* Skip over open parens and white space */ do { while (*cp != '\0' && (isspace (*cp) || *cp == '(')) cp++; if (*cp == '\0') cp = line = readLineFromInputFile (); else break; } while (line); if (line == NULL) break; readIdentifier (name, cp); makeSimpleTag (name, SchemeKinds, K_FUNCTION); } if (cp [0] == '(' && (cp [1] == 'S' || cp [1] == 's') && (cp [2] == 'E' || cp [2] == 'e') && (cp [3] == 'T' || cp [3] == 't') && (cp [4] == '!') && (isspace (cp [5]) || cp[5] == '\0')) { cp += 5; /* Skip over white space */ do { while (*cp != '\0' && isspace (*cp)) cp++; if (*cp == '\0') cp = line = readLineFromInputFile (); else break; } while (line); if (line == NULL) break; readIdentifier (name, cp); makeSimpleTag (name, SchemeKinds, K_SET); } } vStringDelete (name); }
static void findTag (vString *const name) { int c = '\0'; vhdlKind kind; vStringCopyToLower (Keyword, name); kind = (vhdlKind)lookupKeyword (vStringValue (Keyword), Lang_vhdl); if (kind == K_UNDEFINED) { c = skipWhite (vGetc ()); vStringCopyS(Lastname,vStringValue(name)); if (c == ':') { c = skipWhite (vGetc ()); if (isIdentifierCharacter (c)) { readIdentifier (name, c); vStringCopyToLower (Keyword, name); lookupKeyword (vStringValue (Keyword), Lang_vhdl); kind = (vhdlKind)lookupKeyword (vStringValue (Keyword), Lang_vhdl); if (kind == K_PROCESS || kind == K_BLOCK || kind == K_PORT) { makeSimpleTag (Lastname, VhdlKinds, kind); } } } else { vUngetc (c); } } else { if (kind == K_SIGNAL) { while (c!=':') { c = skipWhite (vGetc ()); if (c==',') c = vGetc (); if (isIdentifierCharacter (c)) tagNameList (kind, c); else break; c = vGetc (); } } else if (kind == K_PROCESS || kind == K_BLOCK) { vStringCopyS(TagName,"unnamed"); makeSimpleTag (TagName, VhdlKinds, kind); } else { c = skipWhite (vGetc ()); if (c=='\"') c = vGetc (); if (isIdentifierCharacter (c)) tagNameList (kind, c); } } }
static void parseAutogroup (const unsigned char *line) { vString *name = vStringNew (); /* Found Autocommand Group (augroup) */ const unsigned char *cp = line; if (isspace ((int) *cp)) { while (*cp && isspace ((int) *cp)) ++cp; if (*cp) { const unsigned char *end = skipWord (cp); /* "end" (caseless) has a special meaning and should not generate a tag */ if (end > cp && strncasecmp ((const char *) cp, "end", end - cp) != 0) { vStringNCatS (name, (const char *) cp, end - cp); vStringTerminate (name); makeSimpleTag (name, VimKinds, K_AUGROUP); vStringClear (name); } } } vStringDelete (name); }
static void parseSimpleTag (const unsigned char *cp, erlangKind kind) { vString *const identifier = vStringNew (); parseIdentifier (cp, identifier); makeSimpleTag (identifier, ErlangKinds, kind); vStringDelete (identifier); }
static void parseAutogroup (const unsigned char *line) { vString *name = vStringNew (); /* Found Autocommand Group (augroup) */ const unsigned char *cp = line + 2; if ((int) *++cp == 'r' && (int) *++cp == 'o' && (int) *++cp == 'u' && (int) *++cp == 'p') ++cp; if (isspace ((int) *cp)) { while (*cp && isspace ((int) *cp)) ++cp; if (*cp) { if (strncasecmp ((const char*) cp, "end", (size_t) 3) != 0) { do { vStringPut (name, (int) *cp); ++cp; } while (isalnum ((int) *cp) || *cp == '_'); vStringTerminate (name); makeSimpleTag (name, VimKinds, K_AUGROUP); vStringClear (name); } } } vStringDelete (name); }
static boolean readPreProc (const unsigned char *const line) { boolean result; const unsigned char *cp = line; vString *name = vStringNew (); while (isSymbolCharacter ((int) *cp)) { vStringPut (name, *cp); ++cp; } vStringTerminate (name); result = (boolean) (strcmp (vStringValue (name), "define") == 0); if (result) { while (isspace ((int) *cp)) ++cp; vStringClear (name); while (isSymbolCharacter ((int) *cp)) { vStringPut (name, *cp); ++cp; } vStringTerminate (name); makeSimpleTag (name, AsmKinds, K_DEFINE); } vStringDelete (name); return result; }
static void newMacro (vString *const name, boolean with_define_directive, boolean appending, void *data) { if (!appending) makeSimpleTag (name, MakeKinds, K_MACRO); if (newMacroCB) newMacroCB (name, with_define_directive, appending, data); }
static void findAwkTags (void) { vString *name = vStringNew (); const unsigned char *line; while ((line = readLineFromInputFile ()) != NULL) { if (strncmp ((const char*) line, "function", (size_t) 8) == 0 && isspace ((int) line [8])) { const unsigned char *cp = line + 8; while (isspace ((int) *cp)) ++cp; while (isalnum ((int) *cp) || *cp == '_') { vStringPut (name, (int) *cp); ++cp; } vStringTerminate (name); while (isspace ((int) *cp)) ++cp; if (*cp == '(') makeSimpleTag (name, AwkKinds, K_FUNCTION); vStringClear (name); if (*cp != '\0') ++cp; } } vStringDelete (name); }
static void parseLet (const unsigned char *line, int infunction) { vString *name = vStringNew (); const unsigned char *cp = line; const unsigned char *np = line; /* get the name */ if (isspace ((int) *cp)) { while (*cp && isspace ((int) *cp)) ++cp; /* * Ignore lets which set: * & - local buffer vim settings * @ - registers * [ - Lists or Dictionaries */ if (!*cp || *cp == '&' || *cp == '@' || *cp == '[' ) goto cleanUp; /* * Ignore vim variables which are read only * v: - Vim variables. */ np = cp; ++np; if ((int) *cp == 'v' && (int) *np == ':' ) goto cleanUp; /* Skip non-global vars in functions */ if (infunction && (int) *cp != 'g') goto cleanUp; /* deal with spaces, $, @ and & */ while (*cp && *cp != '$' && !isalnum ((int) *cp)) ++cp; if (!*cp) goto cleanUp; /* cp = skipPrefix (cp, &scope); */ do { if (!*cp) break; vStringPut (name, (int) *cp); ++cp; } while (isalnum ((int) *cp) || *cp == '_' || *cp == '#' || *cp == ':' || *cp == '$'); vStringTerminate (name); makeSimpleTag (name, VimKinds, K_VARIABLE); vStringClear (name); } cleanUp: vStringDelete (name); }
static void tagNameList (const vhdlKind kind, int c) { Assert (isIdentifierCharacter (c)); if (isIdentifierCharacter (c)) { readIdentifier (TagName, c); makeSimpleTag (TagName, VhdlKinds, kind); } }
static void newTarget (vString *const name) { /* Ignore GNU Make's "special targets". */ if (isSpecialTarget (name)) { return; } makeSimpleTag (name, MakeKinds, K_TARGET); }
static void add_tag(const char *token, haskellKind kind, vString *name) { int i; for (i = 0; token[i] != '\0'; ++i) vStringPut(name, token[i]); vStringTerminate(name); makeSimpleTag(name, HaskellKinds, kind); vStringClear(name); }
/* Match a ".label" style label. */ static void match_dot_label (char const *p) { if (*p == '.') { vString *name = vStringNew (); extract_name (p + 1, name); makeSimpleTag (name, BasicKinds, K_LABEL); vStringDelete (name); } }
static void parseModuleTag (const unsigned char *cp, vString *const module) { vString *const identifier = vStringNew (); parseIdentifier (cp, identifier); makeSimpleTag (identifier, ErlangKinds, K_MODULE); /* All further entries go in the new module */ vStringCopy (module, identifier); vStringDelete (identifier); }
static void parseFunction (const unsigned char *line) { vString *name = vStringNew (); /* boolean inFunction = FALSE; */ int scope; const unsigned char *cp = line + 1; if ((int) *++cp == 'n' && (int) *++cp == 'c' && (int) *++cp == 't' && (int) *++cp == 'i' && (int) *++cp == 'o' && (int) *++cp == 'n') ++cp; if ((int) *cp == '!') ++cp; if (isspace ((int) *cp)) { while (*cp && isspace ((int) *cp)) ++cp; if (*cp) { cp = skipPrefix (cp, &scope); if (isupper ((int) *cp) || scope == 's' || /* script scope */ scope == '<' || /* script scope */ scope == 'd' || /* dictionary */ scope == 'a') /* autoload */ { do { vStringPut (name, (int) *cp); ++cp; } while (isalnum ((int) *cp) || *cp == '_' || *cp == '.' || *cp == '#'); vStringTerminate (name); makeSimpleTag (name, VimKinds, K_FUNCTION); vStringClear (name); } } } /* TODO - update struct to indicate inside function */ while ((line = readVimLine ()) != NULL) { /* * Vim7 added the for/endfo[r] construct, so we must first * check for an "endfo", before a "endf" */ if ( (!strncmp ((const char*) line, "endfo", (size_t) 5) == 0) && (strncmp ((const char*) line, "endf", (size_t) 4) == 0) ) break; /* TODO - call parseVimLine */ } vStringDelete (name); }
static boolean AutomakeMakeTag (vString *const name, const char* suffix, boolean appending, int kindex, int rindex, struct sBlacklist *blacklist, void *data) { int *index = data; size_t expected_len; size_t len; char* tail; vString *subname; int i; len = vStringLength (name); expected_len = strlen (suffix); if (len <= expected_len) return FALSE; for (i = 0; blacklist[i].type != BL_END; i++) { if (bl_check (vStringValue(name), blacklist + i) == FALSE) return FALSE; } tail = vStringValue (name) + len - expected_len; if (strcmp (tail, suffix)) return FALSE; subname = vStringNew(); /* ??? dist, nodist, nobase, notrans,... */ if (strncmp (vStringValue(name), "dist_", 5) == 0) vStringNCopyS(subname, vStringValue(name) + 5, len - expected_len - 5); else vStringNCopyS(subname, vStringValue(name), len - expected_len); if (rindex == ROLE_INDEX_DEFINITION) { *index = makeSimpleTag (subname, AutomakeKinds, kindex); addAutomakeDirectory (subname, *index); } else { *index = CORK_NIL; if (appending) *index = lookupAutomakeDirectory (subname); if ((!appending) || (*index == CORK_NIL)) *index = makeSimpleRefTag (subname, AutomakeKinds, kindex, rindex); } vStringDelete (subname); return TRUE; }
/* Match a "label:" style label. */ static void match_colon_label (char const *p) { char const *end = p + strlen (p) - 1; while (isspace (*end)) end--; if (*end == ':') { vString *name = vStringNew (); vStringNCatS (name, p, end - p); makeSimpleTag (name, BasicKinds, K_LABEL); vStringDelete (name); } }
static const unsigned char *makeTclTag ( const unsigned char *cp, vString *const name, const tclKind kind) { vStringClear (name); while ((int) *cp != '\0' && ! isspace ((int) *cp)) { vStringPut (name, (int) *cp); ++cp; } makeSimpleTag (name, TclKinds, kind); return cp; }
static void found_tag_cb (const char *line, const regexMatch *matches, unsigned int count, void *userData) { if (count > 0) { vString *name = vStringNew (); vStringNCopyS (name, line + matches[1].start, matches[1].length); makeSimpleTag (name, RpmSpecKinds, K_TAG); if (count > 1) { if (strcasecmp (vStringValue (name), "name") == 0) { vString *package = vStringNew (); vStringNCopyS (package, line + matches[2].start, matches[2].length); *((int *)userData) = makeSimpleTag (package, RpmSpecKinds, K_PACKAGE); vStringDelete (package); } } vStringDelete (name); } }
static void findShTags (void) { vString *name = vStringNew (); const unsigned char *line; while ((line = fileReadLine ()) != NULL) { const unsigned char* cp = line; boolean functionFound = FALSE; if (line [0] == '#') continue; while (isspace (*cp)) cp++; if (strncmp ((const char*) cp, "function", (size_t) 8) == 0 && isspace ((int) cp [8])) { functionFound = TRUE; cp += 8; if (! isspace ((int) *cp)) continue; while (isspace ((int) *cp)) ++cp; } if (! (isalnum ((int) *cp) || *cp == '_')) continue; while (isalnum ((int) *cp) || *cp == '_') { vStringPut (name, (int) *cp); ++cp; } vStringTerminate (name); while (isspace ((int) *cp)) ++cp; if (*cp++ == '(') { while (isspace ((int) *cp)) ++cp; if (*cp == ')' && ! hackReject (name)) functionFound = TRUE; } if (functionFound) makeSimpleTag (name, ShKinds, K_FUNCTION); vStringClear (name); } vStringDelete (name); }
static void parseFunction (const unsigned char *line) { vString *name = vStringNew (); /* boolean inFunction = FALSE; */ int scope; const unsigned char *cp = line; if ((int) *cp == '!') ++cp; if (isspace ((int) *cp)) { while (*cp && isspace ((int) *cp)) ++cp; if (*cp) { cp = skipPrefix (cp, &scope); if (isupper ((int) *cp) || scope == 's' || /* script scope */ scope == '<' || /* script scope */ scope == 'd' || /* dictionary */ scope == 'a') /* autoload */ { do { vStringPut (name, (int) *cp); ++cp; } while (isalnum ((int) *cp) || *cp == '_' || *cp == '.' || *cp == '#'); vStringTerminate (name); makeSimpleTag (name, VimKinds, K_FUNCTION); vStringClear (name); } } } /* TODO - update struct to indicate inside function */ while ((line = readVimLine ()) != NULL) { if (wordMatchLen (line, "endfunction", 4)) break; parseVimLine(line, TRUE); } vStringDelete (name); }
static void createTag(docbookKind kind, const char *buf) { vString *name; if (*buf == '>') return; buf = strstr(buf, "id=\""); if (buf == NULL) return; buf += 4; if (*buf == '"') return; name = vStringNew(); do { vStringPut(name, (int) *buf); ++buf; } while ((*buf != '\0') && (*buf != '"')); makeSimpleTag(name, DocBookKinds, kind); }
static void L_getit (vString *const name, const unsigned char *dbp) { const unsigned char *p; if (*dbp == '\'') /* Skip prefix quote */ dbp++; else if (*dbp == '(' && L_isquote (dbp)) /* Skip "(quote " */ { dbp += 7; while (isspace (*dbp)) dbp++; } for (p=dbp ; *p!='\0' && *p!='(' && !isspace ((int) *p) && *p!=')' ; p++) vStringPut (name, *p); if (vStringLength (name) > 0) makeSimpleTag (name, LispKinds, K_FUNCTION); vStringClear (name); }
static void tagNameList (const verilogKind kind, int c) { vString *name = vStringNew (); bool repeat; Assert (isIdentifierCharacter (c)); do { repeat = false; if (isIdentifierCharacter (c)) { readIdentifier (name, c); makeSimpleTag (name, VerilogKinds, kind); } else break; c = skipWhite (vGetc ()); if (c == '[') c = skipPastMatch ("[]"); c = skipWhite (c); if (c == '=') { c = skipWhite (vGetc ()); if (c == '{') skipPastMatch ("{}"); else { do c = vGetc (); while (c != ',' && c != ';'); } } if (c == ',') { c = skipWhite (vGetc ()); repeat = true; } else repeat = false; } while (repeat); vStringDelete (name); vUngetc (c); }
/* Match a keyword starting at p (case insensitive). */ static int match_keyword (const char *p, KeyWord const *kw) { vString *name; size_t i; int j; for (i = 0; i < strlen (kw->token); i++) { if (tolower (p[i]) != kw->token[i]) return 0; } name = vStringNew (); p += i; for (j = 0; j < 1 + kw->skip; j++) { p = extract_name (p, name); } makeSimpleTag (name, BasicKinds, kw->kind); vStringDelete (name); return 1; }
static void extract_name (const char *begin, const char *end, vString *name) { if (begin != NULL && end != NULL && begin < end) { const char *cp; while (isspace ((int) *begin)) begin++; while (isspace ((int) *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 findTag (vString *const name) { const verilogKind kind = (verilogKind) lookupKeyword (vStringValue (name), Lang_verilog); if (kind == K_CONSTANT && vStringItem (name, 0) == '`') { /* Bug #961001: Verilog compiler directives are line-based. */ int c = skipWhite (vGetc ()); readIdentifier (name, c); makeSimpleTag (name, VerilogKinds, kind); /* Skip the rest of the line. */ do { c = vGetc(); } while (c != '\n'); vUngetc (c); } else if (kind != K_UNDEFINED) { int c = skipWhite (vGetc ()); /* Many keywords can have bit width. * reg [3:0] net_name; * inout [(`DBUSWIDTH-1):0] databus; */ if (c == '(') c = skipPastMatch ("()"); c = skipWhite (c); if (c == '[') c = skipPastMatch ("[]"); c = skipWhite (c); if (c == '#') { c = vGetc (); if (c == '(') c = skipPastMatch ("()"); } c = skipWhite (c); if (isIdentifierCharacter (c)) tagNameList (kind, c); } }
static void parseFunction (const unsigned char *line) { vString *name = vStringNew (); /* boolean inFunction = FALSE; */ int scope; const unsigned char *cp = line; int index = CORK_NIL; if (*cp == '!') ++cp; if (isspace ((int) *cp)) { while (*cp && isspace ((int) *cp)) ++cp; if (*cp) { cp = skipPrefix (cp, &scope); if (isupper ((int) *cp) || scope == 's' || /* script scope */ scope == '<' || /* script scope */ scope == 'd' || /* dictionary */ scope == 'a') /* autoload */ { char prefix[3] = { [0] = (char)scope, [1] = ':', [2] = '\0' }; if (scope == 's') vStringCatS (name, prefix); do { vStringPut (name, (int) *cp); ++cp; } while (isalnum ((int) *cp) || *cp == '_' || *cp == '.' || *cp == '#'); vStringTerminate (name); index = makeSimpleTag (name, VimKinds, K_FUNCTION); vStringClear (name); } } }