Esempio n. 1
0
File: parse.c Progetto: FelikZ/ctags
extern void installLanguageMapDefault (const langType language)
{
	parserDefinition* lang;
	Assert (0 <= language  &&  language < (int) LanguageCount);
	lang = LanguageTable [language];
	if (lang->currentPatterns != NULL)
		stringListDelete (lang->currentPatterns);
	if (lang->currentExtensions != NULL)
		stringListDelete (lang->currentExtensions);

	if (lang->patterns == NULL)
		lang->currentPatterns = stringListNew ();
	else
	{
		lang->currentPatterns =
			stringListNewFromArgv (lang->patterns);
	}
	if (lang->extensions == NULL)
		lang->currentExtensions = stringListNew ();
	else
	{
		lang->currentExtensions =
			stringListNewFromArgv (lang->extensions);
	}
	if (Option.verbose)
		printLanguageMap (language);
	verbose ("\n");
}
Esempio n. 2
0
File: parse.c Progetto: att/uwin
extern void installLanguageMapDefault (const langType language)
{
    Assert (language >= 0);
    if (LanguageTable [language]->currentPatterns != NULL)
	stringListDelete (LanguageTable [language]->currentPatterns);
    if (LanguageTable [language]->currentExtensions != NULL)
	stringListDelete (LanguageTable [language]->currentExtensions);

    if (LanguageTable [language]->patterns == NULL)
	LanguageTable [language]->currentPatterns = stringListNew ();
    else
    {
	LanguageTable [language]->currentPatterns =
	    stringListNewFromArgv (LanguageTable [language]->patterns);
    }
    if (LanguageTable [language]->extensions == NULL)
	LanguageTable [language]->currentExtensions = stringListNew ();
    else
    {
	LanguageTable [language]->currentExtensions =
	    stringListNewFromArgv (LanguageTable [language]->extensions);
    }
    if (Option.verbose)
	printLanguageMap (language);
    verbose ("\n");
}
Esempio n. 3
0
static void findReferences (void)
{
    ReferencedTypes = stringListNew ();
    GenericNames = stringListNew ();
    initialize (0);

    findEiffelTags ();

    stringListDelete (GenericNames);
    GenericNames = NULL;
    stringListDelete (ReferencedTypes);
    ReferencedTypes = NULL;
}
Esempio n. 4
0
File: parse.c Progetto: att/uwin
extern void addLanguagePatternMap (const langType language, const char* ptrn)
{
    vString* const str = vStringNewInit (ptrn);
    Assert (0 <= language  &&  language < (int) LanguageCount);
    if (LanguageTable [language]->currentPatterns == NULL)
	LanguageTable [language]->currentPatterns = stringListNew ();
    stringListAdd (LanguageTable [language]->currentPatterns, str);
}
Esempio n. 5
0
File: parse.c Progetto: FelikZ/ctags
extern void addLanguagePatternMap (const langType language, const char* ptrn)
{
	vString* const str = vStringNewInit (ptrn);
	parserDefinition* lang;
	Assert (0 <= language  &&  language < (int) LanguageCount);
	lang = LanguageTable [language];
	if (lang->currentPatterns == NULL)
		lang->currentPatterns = stringListNew ();
	stringListAdd (lang->currentPatterns, str);
}
Esempio n. 6
0
extern void addLanguageAlias (const langType language, const char* alias)
{
	vString* const str = vStringNewInit (alias);
	parserDefinition* lang;
	Assert (0 <= language  &&  language < (int) LanguageCount);
	lang = LanguageTable [language];
	if (lang->currentAliaes == NULL)
		lang->currentAliaes = stringListNew ();
	stringListAdd (lang->currentAliaes, str);
}
Esempio n. 7
0
static void processEtagsInclude (
		const char *const option, const char *const parameter)
{
	if (! Option.etags)
		error (FATAL, "Etags must be enabled to use \"%s\" option", option);
	else
	{
		vString *const file = vStringNewInit (parameter);
		if (Option.etagsInclude == NULL)
			Option.etagsInclude = stringListNew ();
		stringListAdd (Option.etagsInclude, file);
		FilesRequired = FALSE;
	}
}
Esempio n. 8
0
static void plistFindTagsUnderKey (xmlNode *node,
				   const struct sTagXpathRecurSpec *spec,
				   xmlXPathContext *ctx,
				   void *userData)
{
	xmlNode *current;
	xmlNode *prev;
	stringList *queue;
	vString* path;
	vString* v;
	int c;

	queue = stringListNew ();
	current = node;
	for (current = node; current; current = current->parent)
	{
		if (isCompoundElement (current)
		    && (prev = getPrevKeyElement (current)))
		{
			char* parent = (char *)xmlNodeGetContent (prev);
			if (parent)
			{
				v = vStringNewInit (parent);
				stringListAdd (queue, v);
				xmlFree (parent);
			}
		}
	}

	path = vStringNew ();
	while ((c = stringListCount (queue)) > 0)
	{
		v = stringListLast (queue);
		vStringCat (path, v);
		vStringDelete (v);
		stringListRemoveLast (queue);
		if (c != 1)
			vStringPut (path, '.');
	}
	stringListDelete (queue);

	findXMLTags (ctx, node,
		     plistXpathTableTable + TABLE_TEXT,
		     PlistKinds,
		     (vStringLength (path) > 0)? vStringValue (path): NULL);

	vStringDelete (path);
}
Esempio n. 9
0
File: make.c Progetto: jonthn/ctags
static void findMakeTags (void)
{
    stringList *identifiers = stringListNew ();
    boolean newline = TRUE;
    boolean in_define = FALSE;
    boolean in_rule = FALSE;
    boolean variable_possible = TRUE;
    int c;

    while ((c = nextChar ()) != EOF)
    {
        if (newline)
        {
            if (in_rule)
            {
                if (c == '\t' || (c = skipToNonWhite (c)) == '#')
                {
                    skipLine ();  /* skip rule or comment */
                    c = nextChar ();
                }
                else if (c != '\n')
                    in_rule = FALSE;
            }
            stringListClear (identifiers);
            variable_possible = (boolean)(!in_rule);
            newline = FALSE;
        }
        if (c == '\n')
            newline = TRUE;
        else if (isspace (c))
            continue;
        else if (c == '#')
            skipLine ();
        else if (variable_possible && c == '?')
        {
            c = nextChar ();
            ungetcToInputFile (c);
            variable_possible = (c == '=');
        }
        else if (variable_possible && c == ':' &&
                 stringListCount (identifiers) > 0)
        {
            c = nextChar ();
            ungetcToInputFile (c);
            if (c != '=')
            {
                unsigned int i;
                for (i = 0; i < stringListCount (identifiers); i++)
                    newTarget (stringListItem (identifiers, i));
                stringListClear (identifiers);
                in_rule = TRUE;
            }
        }
        else if (variable_possible && c == '=' &&
                 stringListCount (identifiers) == 1)
        {
            newMacro (stringListItem (identifiers, 0));
            skipLine ();
            in_rule = FALSE;
        }
        else if (variable_possible && isIdentifier (c))
        {
            vString *name = vStringNew ();
            readIdentifier (c, name);
            stringListAdd (identifiers, name);

            if (stringListCount (identifiers) == 1)
            {
                if (in_define && ! strcmp (vStringValue (name), "endef"))
                    in_define = FALSE;
                else if (in_define)
                    skipLine ();
                else if (! strcmp (vStringValue (name), "define"))
                {
                    in_define = TRUE;
                    c = skipToNonWhite (nextChar ());
                    vStringClear (name);
                    /* all remaining characters on the line are the name -- even spaces */
                    while (c != EOF && c != '\n')
                    {
                        vStringPut (name, c);
                        c = nextChar ();
                    }
                    if (c == '\n')
                        ungetcToInputFile (c);
                    vStringTerminate (name);
                    vStringStripTrailing (name);
                    newMacro (name);
                }
                else if (! strcmp (vStringValue (name), "export"))
                    stringListClear (identifiers);
                else if (! strcmp (vStringValue (name), "include")
                         || ! strcmp (vStringValue (name), "sinclude")
                         || ! strcmp (vStringValue (name), "-include"))
                {
                    boolean optional = (vStringValue (name)[0] == 'i')? FALSE: TRUE;
                    while (1)
                    {
                        c = skipToNonWhite (nextChar ());
                        readIdentifier (c, name);
                        vStringStripTrailing (name);
                        if (isAcceptableAsInclude(name))
                            newInclude (name, optional);

                        /* non-space characters after readIdentifier() may
                         * be rejected by the function:
                         * e.g.
                         * include $*
                         *
                         * Here, remove such characters from input stream.
                         */
                        do
                            c = nextChar ();
                        while (c != EOF && c != '\n' && (!isspace (c)));
                        if (c == '\n')
                            ungetcToInputFile (c);

                        if (c == EOF || c == '\n')
                            break;
                    }
                }
            }
        }
        else
            variable_possible = FALSE;
    }
    stringListDelete (identifiers);
}
Esempio n. 10
0
File: make.c Progetto: Monits/ctags
static void findMakeTags (void)
{
	stringList *identifiers = stringListNew ();
	boolean newline = TRUE;
	boolean in_define = FALSE;
	boolean in_rule = FALSE;
	boolean variable_possible = TRUE;
	int c;

	while ((c = nextChar ()) != EOF)
	{
		if (newline)
		{
			if (in_rule)
			{
				if (c == '\t' || (c = skipToNonWhite (c)) == '#')
				{
					skipLine ();  /* skip rule or comment */
					c = nextChar ();
				}
				else if (c != '\n')
					in_rule = FALSE;
			}
			stringListClear (identifiers);
			variable_possible = (boolean)(!in_rule);
			newline = FALSE;
		}
		if (c == '\n')
			newline = TRUE;
		else if (isspace (c))
			continue;
		else if (c == '#')
			skipLine ();
		else if (variable_possible && c == '?')
		{
			c = nextChar ();
			fileUngetc (c);
			variable_possible = (c == '=');
		}
		else if (variable_possible && c == ':' &&
				 stringListCount (identifiers) > 0)
		{
			c = nextChar ();
			fileUngetc (c);
			if (c != '=')
			{
				unsigned int i;
				for (i = 0; i < stringListCount (identifiers); i++)
					newTarget (stringListItem (identifiers, i));
				stringListClear (identifiers);
				in_rule = TRUE;
			}
		}
		else if (variable_possible && c == '=' &&
				 stringListCount (identifiers) == 1)
		{
			newMacro (stringListItem (identifiers, 0));
			skipLine ();
			in_rule = FALSE;
		}
		else if (variable_possible && isIdentifier (c))
		{
			vString *name = vStringNew ();
			readIdentifier (c, name);
			stringListAdd (identifiers, name);

			if (stringListCount (identifiers) == 1)
			{
				if (in_define && ! strcmp (vStringValue (name), "endef"))
					in_define = FALSE;
				else if (in_define)
					skipLine ();
				else if (! strcmp (vStringValue (name), "define"))
				{
					in_define = TRUE;
					c = skipToNonWhite (nextChar ());
					vStringClear (name);
					/* all remaining characters on the line are the name -- even spaces */
					while (c != EOF && c != '\n')
					{
						vStringPut (name, c);
						c = nextChar ();
					}
					if (c == '\n')
						fileUngetc (c);
					vStringTerminate (name);
					vStringStripTrailing (name);
					newMacro (name);
				}
				else if (! strcmp (vStringValue (name), "export"))
					stringListClear (identifiers);
			}
		}
		else
			variable_possible = FALSE;
	}
	stringListDelete (identifiers);
}
Esempio n. 11
0
File: ruby.c Progetto: jsvisa/ctags
static void findRubyTags (void)
{
    const unsigned char *line;
    boolean inMultiLineComment = FALSE;

    nesting = stringListNew ();

    /* FIXME: this whole scheme is wrong, because Ruby isn't line-based.
    * You could perfectly well write:
    *
    *  def
    *  method
    *   puts("hello")
    *  end
    *
    * if you wished, and this function would fail to recognize anything.
    */
    while ((line = fileReadLine ()) != NULL)
    {
        const unsigned char *cp = line;

        if (canMatch (&cp, "=begin"))
        {
            inMultiLineComment = TRUE;
            continue;
        }
        if (canMatch (&cp, "=end"))
        {
            inMultiLineComment = FALSE;
            continue;
        }

        skipWhitespace (&cp);

        /* Avoid mistakenly starting a scope for modifiers such as
        *
        *   return if <exp>
        *
        * FIXME: this is fooled by code such as
        *
        *   result = if <exp>
        *               <a>
        *            else
        *               <b>
        *            end
        *
        * FIXME: we're also fooled if someone does something heinous such as
        *
        *   puts("hello") \
        *       unless <exp>
        */
        if (canMatch (&cp, "case") || canMatch (&cp, "for") ||
            canMatch (&cp, "if") || canMatch (&cp, "unless") ||
            canMatch (&cp, "while"))
        {
            enterUnnamedScope ();
        }

        /*
        * "module M", "class C" and "def m" should only be at the beginning
        * of a line.
        */
        if (canMatch (&cp, "module"))
        {
            readAndEmitTag (&cp, K_MODULE);
        }
        else if (canMatch (&cp, "class"))
        {
            readAndEmitTag (&cp, K_CLASS);
        }
        else if (canMatch (&cp, "def"))
        {
            readAndEmitTag (&cp, K_METHOD);
        }

        while (*cp != '\0')
        {
            /* FIXME: we don't cope with here documents,
            * or regular expression literals, or ... you get the idea.
            * Hopefully, the restriction above that insists on seeing
            * definitions at the starts of lines should keep us out of
            * mischief.
            */
            if (inMultiLineComment || isspace (*cp))
            {
                ++cp;
            }
            else if (*cp == '#')
            {
                /* FIXME: this is wrong, but there *probably* won't be a
                * definition after an interpolated string (where # doesn't
                * mean 'comment').
                */
                break;
            }
            else if (canMatch (&cp, "begin") || canMatch (&cp, "do"))
            {
                enterUnnamedScope ();
            }
            else if (canMatch (&cp, "end") && stringListCount (nesting) > 0)
            {
                /* Leave the most recent scope. */
                vStringDelete (stringListLast (nesting));
                stringListRemoveLast (nesting);
            }
            else if (*cp == '"')
            {
                /* Skip string literals.
                 * FIXME: should cope with escapes and interpolation.
                 */
                do {
                    ++cp;
                } while (*cp != 0 && *cp != '"');
            }
            else if (*cp != '\0')
            {
                do
                    ++cp;
                while (isalnum (*cp) || *cp == '_');
            }
        }
    }
    stringListDelete (nesting);
}