Пример #1
0
static void findAsmTags (void)
{
    vString *name = vStringNew ();
    vString *operator = vStringNew ();
    const unsigned char *line;
    boolean inCComment = FALSE;

    while ((line = readLineFromInputFile ()) != NULL)
    {
        const unsigned char *cp = line;
        boolean labelCandidate = (boolean) (! isspace ((int) *cp));
        boolean nameFollows = FALSE;
        const boolean isComment = (boolean)
                                  (*cp != '\0' && strchr (";*@", *cp) != NULL);

        /* skip comments */
        if (strncmp ((const char*) cp, "/*", (size_t) 2) == 0)
        {
            inCComment = TRUE;
            cp += 2;
        }
        if (inCComment)
        {
            do
            {
                if (strncmp ((const char*) cp, "*/", (size_t) 2) == 0)
                {
                    inCComment = FALSE;
                    cp += 2;
                    break;
                }
                ++cp;
            } while (*cp != '\0');
        }
        if (isComment || inCComment)
            continue;

        /* read preprocessor defines */
        if (*cp == '#')
        {
            ++cp;
            readPreProc (cp);
            continue;
        }

        /* skip white space */
        while (isspace ((int) *cp))
            ++cp;

        /* read symbol */
        cp = readSymbol (cp, name);
        if (vStringLength (name) > 0  &&  *cp == ':')
        {
            labelCandidate = TRUE;
            ++cp;
        }

        if (! isspace ((int) *cp)  &&  *cp != '\0')
            continue;

        /* skip white space */
        while (isspace ((int) *cp))
            ++cp;

        /* skip leading dot */
#if 0
        if (*cp == '.')
            ++cp;
#endif

        cp = readOperator (cp, operator);

        /* attempt second read of symbol */
        if (vStringLength (name) == 0)
        {
            while (isspace ((int) *cp))
                ++cp;
            cp = readSymbol (cp, name);
            nameFollows = TRUE;
        }
        makeAsmTag (name, operator, labelCandidate, nameFollows);
    }
    vStringDelete (name);
    vStringDelete (operator);
}
Пример #2
0
static void findAsmTags (void)
{
	vString *name = vStringNew ();
	vString *operator = vStringNew ();
	const unsigned char *line;

	cppInit (false, false, false, false,
			 KIND_GHOST_INDEX, 0, KIND_GHOST_INDEX, 0, 0);

	unsigned int lastMacroCorkIndex = CORK_NIL;

	while ((line = asmReadLineFromInputFile ()) != NULL)
	{
		const unsigned char *cp = line;
		bool labelCandidate = (bool) (! isspace ((int) *cp));
		bool nameFollows = false;
		bool directive = false;
		const bool isComment = (bool)
				(*cp != '\0' && strchr (";*@", *cp) != NULL);

		/* skip comments */
		if (isComment)
			continue;

		/* skip white space */
		while (isspace ((int) *cp))
			++cp;

		/* read symbol */
		if (*cp == '.')
		{
			directive = true;
			labelCandidate = false;
			++cp;
		}

		cp = readSymbol (cp, name);
		if (vStringLength (name) > 0  &&  *cp == ':')
		{
			labelCandidate = true;
			++cp;
		}

		if (! isspace ((int) *cp)  &&  *cp != '\0')
			continue;

		/* skip white space */
		while (isspace ((int) *cp))
			++cp;

		/* skip leading dot */
#if 0
		if (*cp == '.')
			++cp;
#endif

		cp = readOperator (cp, operator);

		/* attempt second read of symbol */
		if (vStringLength (name) == 0)
		{
			while (isspace ((int) *cp))
				++cp;
			cp = readSymbol (cp, name);
			nameFollows = true;
		}
		makeAsmTag (name, operator, labelCandidate, nameFollows, directive,
					&lastMacroCorkIndex);
	}

	cppTerminate ();

	vStringDelete (name);
	vStringDelete (operator);
}