From: Konrad Eisele <eiselekd@gmail.com>
To: Christopher Li <sparse@chrisli.org>
Cc: Konrad Eisele <konrad@gaisler.com>,
Linux-Sparse <linux-sparse@vger.kernel.org>
Subject: Re: Fwd: dependency tee from c parser entities downto token
Date: Fri, 11 May 2012 23:48:27 +0200 [thread overview]
Message-ID: <4FAD892B.8070709@gmail.com> (raw)
In-Reply-To: <CANeU7Q=_uqwk+ePbErQ9gsX3x945_gATUZ_mJeYuTo2SoYhCpQ@mail.gmail.com>
On 05/11/2012 09:40 PM, Christopher Li wrote:
> On Thu, May 10, 2012 at 5:28 AM, Konrad Eisele<eiselekd@gmail.com> wrote:
>>
>>>> A change like this is bound to need some careful discussion and
>>>> planing. Yes, I am guilt of only accepting patches meet some subjective
>>>> stander of mine. But so is to any self respect project maintainers.
>>>> I would rather spend some time to do it right than commit some thing
>>>> I would regret later on.
>>>
>>>
>>> Do a B(B(x)) and your sym->parent linked-list will fail.
>
> You have a valid point that B(B(x)) will break the sym->parent list.
> I remove the sym->parent and just use a token_list to maintain the
> expanding macro. The macro is append to the list when enter and remove
> from the list when untaint token is reached. The change is in the
> same review branch.
>
> That should solve this problem?
This seems ok. expanding_macro has to be global not static to be
used... (?)
>
>> I have to revise my previous assumption though:
>>
>> #define B(y) A(x)
>> B(1)
>>
>> i thought that in the body expansion of B recursion is involved,
>> so that it would yield:
>>
>> expand_macro(A);
>> expand_macro(B);
>>
>> but that was wrong, so its
>>
>> expand_macro(B);
>> expand_macro(A);
>
> That is right. The macro expansion has 3 stages. The first stage is
> expand the arguments list while the caller macro does not consider
> "tainted" during the argument expansion. The macro can recursively
> appear in the argument list. That is some thing I haven't consider
> previously.
I think the fact that argument expansion is recursive and
body expansion is non-recursive is one of the things that
make the preprocessor kindof hard to grasp.
>
> The second stage is just replace the expanded arguments into body.
>
> The third stage is rescan the replacement string for macro expand.
> In this third stage, the macro itself is consider tainted and can't be
> expand again during the rescan.
>
> Can you take a look at this modify version will fit your need or not?
> I am curious the part weather that will remove the need to add
> empty token to the list for expansion.
I cannot say this before I've tried it.
I'd like to straighten things out a bit: My last emails
where a bit too harsh and I'd like to apologize. Sorry
for that.
The next step then is: I'll write a patch to add a
test-prog that uses this api to trace the token generation
and generate a tree for it.
For a start I'll printout for all tokens of a preprocessor
run all macros-expansions that generated them.
Now, I've learned not to run too fast towards the
goal, (which is still "dependency tee from c parser entities downto
token"), maybe you can think about how to achieve the next steps
in an API :
- An #include #ifdef #else #endif pushdown-stack
to record the nestings for each token
- How to connect all this to the AST.
-- Konrad
>
> In order words, can we design the API clever enough that you
> don't need to jump through hoops to handle the empty expansion
> token.
>
> Thanks
>
> Chris
>
next prev parent reply other threads:[~2012-05-11 21:44 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-24 9:54 dependency tee from c parser entities downto token Konrad Eisele
2012-04-25 20:10 ` [PATCH] depend.c: build up a dependency tree from c entities downto tokens: entries in the tree are: macro-depend: tree of #if nesting macro-expansions: possible macro expansion source of a token tok->macro-expansions->macro tok->macro-depend->macro c entities are linked in via [stmt|expr|sym]->start-end-token Konrad Eisele
2012-04-30 22:58 ` dependency tee from c parser entities downto token Christopher Li
2012-05-02 7:27 ` Konrad Eisele
2012-05-03 23:52 ` Christopher Li
2012-05-04 7:33 ` Konrad Eisele
2012-05-04 9:25 ` Christopher Li
2012-05-04 10:36 ` Konrad Eisele
2012-05-04 12:36 ` Konrad Eisele
2012-05-04 15:30 ` Josh Triplett
2012-05-04 20:53 ` Konrad Eisele
2012-05-04 22:30 ` Christopher Li
2012-05-05 0:32 ` Josh Triplett
2012-05-05 8:59 ` Konrad Eisele
2012-05-05 8:56 ` Konrad Eisele
2012-05-04 18:02 ` Christopher Li
2012-05-04 21:46 ` Konrad Eisele
2012-05-04 21:56 ` Konrad Eisele
2012-05-04 23:05 ` Christopher Li
2012-05-05 8:54 ` Konrad Eisele
2012-05-05 11:12 ` Christopher Li
2012-05-05 16:59 ` Konrad Eisele
[not found] ` <CANeU7Qn7vUzLQAF6JGRECro_pPDnL7MCswkrNACe1wohLHZu7g@mail.gmail.com>
2012-05-05 19:56 ` Fwd: " Christopher Li
2012-05-05 23:38 ` Konrad Eisele
2012-05-06 18:34 ` Christopher Li
2012-05-07 6:12 ` Konrad Eisele
2012-05-07 22:06 ` Christopher Li
2012-05-08 6:38 ` Konrad Eisele
2012-05-09 9:18 ` Christopher Li
2012-05-09 9:48 ` Konrad Eisele
2012-05-09 22:50 ` Christopher Li
2012-05-10 6:19 ` Konrad Eisele
2012-05-10 6:38 ` Konrad Eisele
2012-05-10 9:37 ` Christopher Li
2012-05-10 9:51 ` Konrad Eisele
2012-05-10 11:25 ` Christopher Li
2012-05-10 12:14 ` Konrad Eisele
2012-05-10 12:28 ` Konrad Eisele
2012-05-11 19:40 ` Christopher Li
2012-05-11 21:48 ` Konrad Eisele [this message]
2012-05-12 11:02 ` Christopher Li
2012-05-12 17:46 ` Konrad Eisele
2012-05-12 17:57 ` Konrad Eisele
2012-05-13 8:52 ` Konrad Eisele
2012-05-15 6:30 ` Christopher Li
2012-05-15 7:52 ` Konrad Eisele
2012-05-15 9:44 ` Christopher Li
2012-05-15 13:03 ` Konrad Eisele
2012-05-14 10:53 ` Christopher Li
2012-05-10 9:03 ` Christopher Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FAD892B.8070709@gmail.com \
--to=eiselekd@gmail.com \
--cc=konrad@gaisler.com \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).