How to understand the standard syntax of C99

I can't figure out what the syntax means in C99. Here, when I say C99, I mean ISO / IEC 9899: 1999. Well, I think that part of the grammar syntax has not changed much since ANSI C, C89.

Take for example from this question :

6.5.5 Multiplicative operators
  Syntax
    multiplicative-expression:
      cast-expression
      multiplicative-expression * cast-expression
      multiplicative-expression / cast-expression
      multiplicative-expression % cast-expression

  Constraints

Each of the operands shall have arithmetic type. The operands of the % operator
shall have integer type.

  Semantics

The usual arithmetic conversions are performed on the operands.
The result of the binary * operator is the product of the operands.
The result of the / operator is the quotient 

I wonder why in the syntax of multiplicative operators we have a "cast-expression"? And what grammar can this syntax mean? In this question, @Avi said that in

a*b*c

"c must be parsed as expression-cast," I can't figure it out.

Take another example from c99 6.6.1, syntax for constant expressions

Syntax
   constant-expression:
       conditional-expression

why does this conditional expression appear here? Can someone show me how to explain this syntax? Thanks to everyone in advance.

+3
2

, "-"?

, , (, , , , CFG, ). cast-expression multiplicative-expression; " , ".

, :

  • :

    1*2*3*4
    

    ( ):

    • 1*(2*3*4)
    • (1*2)*(3*4)
    • (1*2*3)*4

    , , , *, cast-expression, (unparenthesized) *. .

  • .

    a*b+c
    

    • (a*b)+c
    • a*(b+c)

    , , cast-expression (unparenthesized) + ( , ). .

    a+b*c
    

    , ,

    • (a+b)*c
    • a+(b*c)

    multiplicative-expression * (unparenthesized) + ( ). .

: - constant-expression s. a=b, a,b, a+=b , a+b, a[b] a(b) . , , . (a=b); , , , , .

+3

, "-"?

, , . (1 + 2, 3 * (4 - 2), 42 ..). , , , :

expression:
    term  |
    term add-op expression

term:
    factor |
    factor mul-op term

factor:
    number |
    ( expression ) 

, , add-op mul-op, .

42 - , , , . , 42 ; - .

C. - , . ; C 16 , . , , , ,

x = a * (int) b;

.

+1

All Articles