Is C # used in evaluating / analyzing expressions?

Sometimes back I tried to execute the following statement in C #

i+++++i // does not compile <bt>

i++ + ++i // executed

Is there any influence in the expressions?
How do the above statements differ?

Ramacandrana

+5
source share
3 answers

First of all, let me explain how the compiler works.

, , . . , . - , - . : , .

"" - , . . +++++ i/++/++/+/i

,

                +
               / \
              ++  i
             /
            ++
           /
          i   

, (((i ++) ++) + i).

: "i ++ , - , ++ - , . ++ , ++ ." : .

, lex , , i/++/+/++/i, - . , lex , , . ; +++++ (((i ++) ++) + i) ) ((i ++) + (+ (+ i))) (i + (+ (+ (+ (+ i))) ) ... , + , , -, .

+14

.

: int a = 1; - , inta=1;

, + +a +(+(a)), 1 ( a=1). , , + ++, 2.

5 : "i" "++" "++" "+" "i"

5 : "i" "++" "+" "++" "i"

+10

C-ish (C/++/#/Java) "max munch" - .

- , . .

So, in your second example there are 5 tokens: "i" "++" "+" "++" "i"

However, in your first example, there are only three: "i" "+++++" and "i"

In addition, I should note that although your second example will be compiled under C ++, it is completely incomplete (you are not allowed to change the same value twice in one expression). This is probably also illegal in C #, although C # tends to be a little more flexible in these things.

+3
source

All Articles