tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] tcc stringize patch


From: Harald van Dijk
Subject: [Tinycc-devel] tcc stringize patch
Date: Tue, 8 May 2007 02:33:13 +0200
User-agent: Mutt/1.5.15 (2007-04-06)

Hi,

Here's a patch to handle spacing during stringizing. It saves an extra
integer per token in token strings, containing the token's flags. This
can include TOK_FLAG_BOW (beginning of word), indicating that a space
needs to be inserted in front. Since this is the only flag of relevance,
it wastes space. You might be able to move this flag into a bit in the
token number, if the waste concerns you.

During macro expansion and macro argument expansion, the token flag of
the first token in the replacement is replaced with the token flag of
the macro or argument name. This ensures that

#define macro replacement
#define mkstr(x) str(x)
#define str(x) #x
mkstr(.macro)

becomes ".replacement", despite the space in front of "replacement".
Similarly, it ensures that

#define macro()replacement
#define mkstr(x) str(x)
#define str(x) #x
mkstr(. macro())

becomes ". replacement".

The BOW flag of the result of the # operator is copied from the
operator. The BOW flag of the result of the ## operator is copied from
its first operand. This makes sure spacing in front of #a and a##b gets
preserved. Spacing in between does not need preserving. Spacing after
#a or a##b is saved as spacing in front of the next token.

The patch can be applied to tinycc-rl-1.0.0. It may also be applied to
tcc-0.9.23, but I have not tested that.

If you find a case that is not handled correctly by this patch, I would
very much appreciate it if you let me know about it.

Attachment: tcc-stringize.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]