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 void parseVimFile (const unsigned char *line) { boolean readNextLine = TRUE; while (line != NULL) { readNextLine = parseVimLine(line); if ( readNextLine ) line = readVimLine(); } }
static void findVimTags (void) { const unsigned char *line; /* TODO - change this into a structure */ line = readVimLine(); if ( strncmp ((const char*) line, "UseVimball", (size_t) 10) == 0 ) { parseVimBallFile (line); } else { parseVimFile (line); } }
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 parseVimBallFile (const unsigned char *line) { vString *fname = vStringNew (); const unsigned char *cp; int file_line_count; int i; /* * Vimball Archives follow this format * " Vimball Archiver comment * UseVimball * finish * filename * line count (n) for filename * (n) lines * filename * line count (n) for filename * (n) lines * ... */ /* Next line should be "finish" */ line = readVimLine(); if (line == NULL) { return; } while (line != NULL) { /* Next line should be a filename */ line = readVimLine(); if (line == NULL) { return; } else { cp = line; do { vStringPut (fname, (int) *cp); ++cp; } while (isalnum ((int) *cp) || *cp == '.' || *cp == '/' || *cp == '\\'); vStringTerminate (fname); makeSimpleTag (fname, VimKinds, K_FILENAME); vStringClear (fname); } file_line_count = 0; /* Next line should be the line count of the file */ line = readVimLine(); if (line == NULL) { return; } else { file_line_count = atoi( (const char *) line ); } /* Read all lines of the file */ for ( i=0; i<file_line_count; i++ ) { line = readVimballLine(); if (line == NULL) { return; } } } vStringDelete (fname); }
static boolean parseCommand (const unsigned char *line) { vString *name = vStringNew (); boolean cmdProcessed = TRUE; /* * Found a user-defined command * * They can have many options preceeded by a dash * command! -nargs=+ -complete Select :call s:DB_execSql("select " . <q-args>) * The name of the command should be the first word not preceeded by a dash * */ const unsigned char *cp = line; if ( (int) *cp == '\\' ) { /* * We are recursively calling this function is the command * has been continued on to the next line * * Vim statements can be continued onto a newline using a \ * to indicate the previous line is continuing. * * com -nargs=1 -bang -complete=customlist,EditFileComplete * \ EditFile edit<bang> <args> * * If the following lines do not have a line continuation * the command must not be spanning multiple lines and should * be synatically incorrect. */ if ((int) *cp == '\\') ++cp; while (*cp && isspace ((int) *cp)) ++cp; } else if ( (!strncmp ((const char*) line, "comp", (size_t) 4) == 0) && (!strncmp ((const char*) line, "comc", (size_t) 4) == 0) && (strncmp ((const char*) line, "com", (size_t) 3) == 0) ) { cp += 2; if ((int) *++cp == 'm' && (int) *++cp == 'a' && (int) *++cp == 'n' && (int) *++cp == 'd') ++cp; if ((int) *cp == '!') ++cp; if ((int) *cp != ' ') { /* * :command must be followed by a space. If it is not, it is * not a valid command. * Treat the line as processed and continue. */ cmdProcessed = TRUE; goto cleanUp; } while (*cp && isspace ((int) *cp)) ++cp; } else { /* * We are recursively calling this function. If it does not start * with "com" or a line continuation character, we have moved off * the command line and should let the other routines parse this file. */ cmdProcessed = FALSE; goto cleanUp; } /* * Strip off any spaces and options which are part of the command. * These should preceed the command name. */ do { if (isspace ((int) *cp)) { ++cp; } else if (*cp == '-') { /* * Read until the next space which separates options or the name */ while (*cp && !isspace ((int) *cp)) ++cp; } } while ( *cp && !isalnum ((int) *cp) ); if ( ! *cp ) { /* * We have reached the end of the line without finding the command name. * Read the next line and continue processing it as a command. */ line = readVimLine(); parseCommand(line); goto cleanUp; } do { vStringPut (name, (int) *cp); ++cp; } while (isalnum ((int) *cp) || *cp == '_'); vStringTerminate (name); makeSimpleTag (name, VimKinds, K_COMMAND); vStringClear (name); cleanUp: vStringDelete (name); return cmdProcessed; }