Example #1
0
/* macro_scan ---
 ** return the next token for a macro expanion, handling macro args
 */
static int macro_scan(MacroInputSrc *in, yystypepp * yylvalpp)
{
	int i;
	int token = ReadToken(in->mac->body, yylvalpp);
	if (token == CPP_IDENTIFIER) {
		for (i = in->mac->argc - 1; i >= 0; i--)
			if (in->mac->args[i] == yylvalpp->sc_ident)
				break;
		if (i >= 0) {
			ReadFromTokenStream(in->args[i], yylvalpp->sc_ident, 0);
			return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
		}
	}
	if (token > 0)
		return token;
	in->mac->busy = 0;
	cpp->currentInput = in->base.prev;
	if (in->args) {
		for (i = in->mac->argc - 1; i >= 0; i--)
			DeleteTokenStream(in->args[i]);
		free(in->args);
	}
	free(in);
	return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
} /* macro_scan */
Example #2
0
static TokenStream *PrescanMacroArg(TokenStream *a, yystypepp * yylvalpp)
{
	int token;
	TokenStream *n;
	RewindTokenStream(a);
	do {
		token = ReadToken(a, yylvalpp);
		if (token == CPP_IDENTIFIER && LookUpSymbol(macros, yylvalpp->sc_ident))
			break;
	} while (token > 0);
	if (token <= 0)
		return a;
	n = NewTokenStream("macro arg", 0);
	PushEofSrc();
	ReadFromTokenStream(a, 0, 0);
	while ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) > 0) {
		if (token == CPP_IDENTIFIER
				&& MacroExpand(yylvalpp->sc_ident, yylvalpp))
			continue;
		RecordToken(n, token, yylvalpp);
	}
	PopEofSrc();
	DeleteTokenStream(a);
	return n;
} /* PrescanMacroArg */
Example #3
0
File: Pp.cpp Project: 3dcl/glslang
TPpContext::TokenStream* TPpContext::PrescanMacroArg(TokenStream *a, TPpToken * yylvalpp)
{
    int token;
    TokenStream *n;
    RewindTokenStream(a);
    do {
        token = ReadToken(a, yylvalpp);
        if (token == CPP_IDENTIFIER && LookUpSymbol(macros, yylvalpp->atom))
            break;
    } while (token > 0);
    if (token <= 0) return a;
    n = NewTokenStream("macro arg", 0);
    PushEofSrc();
    ReadFromTokenStream(a, 0, 0);
    while ((token = currentInput->scan(this, currentInput, yylvalpp)) > 0) {
        if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp->atom, yylvalpp, 0) == 1)
            continue;
        RecordToken(n, token, yylvalpp);
    }
    PopEofSrc();
    DeleteTokenStream(a);
    return n;
} // PrescanMacroArg
Example #4
0
void FreeMacro(MacroSymbol *s) {
    DeleteTokenStream(s->body);
}
Example #5
0
File: Pp.cpp Project: 3dcl/glslang
void TPpContext::FreeMacro(MacroSymbol *s) {
    DeleteTokenStream(s->body);
}