Yes me again
Eddie Wyatt
edw at IUS1.CS.CMU.EDU
Fri Apr 8 02:06:41 AEST 1988
I recieved a letter by email in regards to the *a+=*b ambiguaty.
I thought would be nice to post a response to it on the net since it
sums up *my* sentiment on this issue.
> It is ambiguous because "*=" used to be written "=*" and
> lexation wants to take the longest matching string (in a
> left-to-right scan).
But isn't the larget token posible += as it scans left to right, not
=* ?
Actually I'm inclined to believe that += is tokenized as two token and
when =* is seen, it is tokenized as a single token. So the lexer
reads the input stream as follows.
stream token
*a+=*b
a+=*b *
+=*b a
=*b +
b =*
b
To which I've made the statement that tokenizing =* as a single token
is a hack! I invoke the policy of orthogonality to justify this
statement. If *= consists of two tokens (implying *= and * = are
equivalent expressions) then =* should be parsed as two tokens.
However, if =* and = * became equivalent then both *a+=*b and
*a+= *b would become equivalent statements. Kind of good
in the sense that the same behaviours will be observed in both
insistance. Bad in the sense that *a = *b would be interpetted
as what 'a' points to gets what 'a' points to times b. Probably not
what was intended.
So my overall conclusion is to kill the =(op) construct and quit trying
to support an archaic construct at the expense of "exceptions to the
rule".
--
Eddie Wyatt e-mail: edw at ius1.cs.cmu.edu
More information about the Comp.lang.c
mailing list