comp.lang.c
[Top] [All Lists]

Re: Is cast operator unary or binary? How many operands?

Subject: Re: Is cast operator unary or binary? How many operands?
From: Richard Tobin
Date: 29 Apr 2008 17:18:55 GMT
Newsgroups: comp.lang.c

In article <5c21f815-e1e6-468e-8630-cc72dad60a09@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
JoseMariaSola  <JoseMariaSola@xxxxxxxxx> wrote:

>Here is part of the grammar:
>
>unary-expression:
>    postfix-expression
>    ++ unary-expression
>    -- unary-expression
>    unary-operator cast-expression
>    sizeof unary-expression
>    sizeof ( type-name )
>
>unary-operator: one of
>    & * + - ? !
>
>cast-expression:
>    unary-expression
>    ( type-name ) cast-expression
>
>
>Why sizeof, (type-name), ++ and -- aren't unary-operators?

You could include sizeof in unary-operator, but you'd still need the
special case of a type-name operand requiring parentheses, and it
seems clearer to keep them together in the list.  Similarly ++ and --
would still have to appear in postfix-expression.  Both of these are
just matters of taste really.  I don't see how you could do
(type-name), because a unary-operator is something that precedes its
operand, and the parentheses of a cast have to go around the operand.

-- Richard

-- 
:wq

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy