On Tue, Aug 10, 2010 at 3:55 PM, Julia Lawall <[email protected]> wrote:
> On Tue, 10 Aug 2010, Lucas De Marchi wrote:
>
>> Hi,
>>
>> I'd like to know how to deal with "already tagged token" errors. I've
>> tried several methods to accomplish the following, but either way,
>> sometimes I get this error.
>>
>> What I want to do is to fully parenthesize conditional expressions, so:
>>
>> "if (a && b && !c->test)" becomes "if ((a) && (b) && (!c->test))"
>
> && is a binary operator. I have the impression that it associates as ((a
> && b) && c). But it seems that you want only to put parentheses on things
> that don't have nested && operators?
>
> In ((a && b) && c) there are two parentheses on the a, and the outer one
> is considered to be tagging an already tagged token. There is an operator
> ++ that is supposed to allow additions to accumulate, but it doesn't seem
> to work in this case. It may be because the associated right parentheses
> are put in different places.
I still didn't get what the "already tagged token" means. Every now
and then I get this error.
Now what I am trying to do is to change expressions like "E == NULL"
to "!E", similar to what badzero.cocci does. I trimmed down my script
I my test file in order to help solving and this is what I got:
badnull.cocci
--------------------------
@fix disable is_zero,isnt_zero @
expression *E;
@@
(
- E == NULL
+ !E
|
- E != NULL
+ E
|
- NULL == E
+ !E
|
- NULL != E
+ E
)
--------------------------
Test file:
--------------------------
Eina_Inlist *
f(Eina_Inlist *list, Eina_Inlist *new_l)
{
Eina_Inlist *l;
for (l = list; (l) && (l->next); l = l->next);
return list;
}
--------------------------
It fails with:
Fatal error: exception Failure("fix: already tagged token:
C code context
File "/tmp/test.c", line 6, column 19, charpos = 96
around = 'l', whole content = for (l = list; (l) && (l->next);
l = l->next);")
Strange enough, if I remove the parenthesis around "l" or put "l !=
NULL", it works.
Any thoughts?
thanks
Lucas De Marchi
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)