K
kapilk
Sir,
I dont know how to use this synatx is it valid and if at all how to use it
Thanks,
kapilk
I dont know how to use this synatx is it valid and if at all how to use it
Thanks,
kapilk
kapilk said:Sir,
I dont know how to use this synatx is it valid and if at all how to use it
Thanks,
kapilk
kapilk said:Sir,
I dont know how to use this synatx is it valid and if at all how to use it
What are you trying to accomplish?
I understand that "++i" will increment the variable "i".
But I don't understand if the third '+' is a typo.
The expression "+i" does not make any sense by itself.
> Greedy lexical analysis should "gobble" up operators based upon their
> precedence.
Dik T. Winter said:Wrong. Precedence has nothing to do with it. It is parsed as:
++ +i
and as such malformed. (Some compilers allow it, gcc is one of them.)
Dik T. Winter said:Wrong. Precedence has nothing to do with it.
It is parsed as:
++ +i
and as such malformed. (Some compilers allow it, gcc is one of them.)
Mark said:Greedy lexical analysis should "gobble" up operators based upon their
precedence.
In said:Is that specified by the grammar...?
Mark said:Greedy lexical analysis should "gobble" up operators based upon their
precedence. So +++i, I believe, is +(++i) which I suppose is the positive
result of 'i' incremented. I've seen this in binary expressions but not
unary, e.g.
k=j+++i;
Of course, spaces are quite powerful here in indicating intent as in:
k = j + ++i;
So +++i, I believe, is +(++i)
which I suppose is the positive
That's nice, but not my issue.
If we have the statement:
+++i;
One of the '+' is applied to the variable 'i' (regardless of grouping
or precedence) as in:
+i;
My issue is that "+i" doesn't make sense.
1. If a zero (0) is placed in front:
0 + i;
This evaluates to just the value in 'i'.
2. The '+' in front does not change the sign of the variable.
So as a stand-alone expression "+++i" doesn't make sense.
Thomas Matthews said:The expression "+i" does not make any sense by itself.
Christopher Benson-Manica said:Is that specified by the grammar...?
Plain
+++i;
doesn't make sense
but an expression like this is valid:
a = b+++i;
What it does? It increments /i/ with one, adds the result to the value
of /b/ and puts the result of the addition in /a/.
If you want to show
off to your friends write code like this:
a = b+++++i;
This does the same as the former expression but it also increments /b/
after the result of /b/ + /++i/ has been put in /a/.
A final remark:
a = b+++i;
is a valid expression (meaning it will most likely compile just fine)
but the result is undefined (meaning it will most likely crash if you
run it on certain architectures) because the ANSI C Standard doesn't
say anything about the order in which the different parts of the
expression are evaluated.
A compiler could break it up like this:
int *temp;
temp = a + i;
++i;
*temp = b + i;
Hope this helps.
Dan Pop said:4 If the input stream has been parsed into preprocessing tokens
up to a given character, the next preprocessing token is
the longest sequence of characters that could constitute a
preprocessing token.
[Nothing quoted in the article to which I'm replying](e-mail address removed) (kapilk) wrote in message
news:<[email protected]>...
Plain
+++i;
doesn't make sense
but an expression like this is valid:
a = b+++i;
What it does? It increments /i/ with one, adds the result to the value
of /b/ and puts the result of the addition in /a/.
If you want to show
off to your friends write code like this:
a = b+++++i;
This does the same as the former expression but it also increments /b/
after the result of /b/ + /++i/ has been put in /a/.
A final remark:
a = b+++i;
is a valid expression (meaning it will most likely compile just fine)
but the result is undefined (meaning it will most likely crash if you
run it on certain architectures)
because the ANSI C Standard doesn't
say anything about the order in which the different parts of the
expression are evaluated.
A compiler could break it up like this:
int *temp;
temp = a + i;
++i;
*temp = b + i;
But it might just as well roll out like this:
int *temp;
++i;
temp = a + i;
*temp = b + i;
Mark A. Odell said:.... snip ...
Greedy lexical analysis should "gobble" up operators based upon
their precedence. So +++i, I believe, is +(++i) which I suppose
is the positive result of 'i' incremented. I've seen this in
You have it backwards. The greedy analysis produces:
++ (+i)
which is a syntax error.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.