compiler construction - C operator precedence -


this question has answer here:

for compiler class, gradually creating pseudo-pascal compiler. does, however, follow same precedence c. being said, in section create prefix , postfix operators, 0 for

int = 1; int b = 2; ++a - b++ - --b + a-- 

when c returns 1. don't understand how can 1. doing straight prefix first, answer should 2. , doing postfix first, answer should -2. doing left right, zero.

my question is, should precedence of operators return 1?

operator precedence tells example whether ++a - b means (++a) - b or ++(a - b). should former since latter isn't valid. in implementation it's former (or wouldn't getting result @ all), implemeneted operator precedence correctly.

operator precedence has nothing order in subexpressions evaluated. in fact order in operator operands + , - evaluated unspecified in c , code modifies same variable twice without sequence point in between invokes undefined behavior. whichever order choose fine , 0 valid result other value.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -