Why is the following syntax correct:
x = y+++y;
Where it means
y++ + y
ory + ++y
which meansy * 2 + 1
(not sure about this, though: very ambiguous)
But this syntax is incorrect:
x = y+++++y;
Which should mean
y++ + ++y
, which meansy * 2 + 2
Is there a reason for the incorrectness of this syntax? (Edit: thank you for explaining why it is invalid syntax, but that is not my intention with this question.)
(Edit: ofcourse I'm not using this in real code, purely in interest of parsers/lexers; but I wonder why the parser doesn't like this; the last example even looks less ambiguous than the first one.)
(Edit:
int i = 0;
int j = (i = 3)+++i;
Is invalid too, though it seems very unambiguous to me, (i = 3)
is a value, thus (value +
value) and then the ++i
value token.)