[net.lang.c] a+++b parsing according to manual

dgary@ecsvax.UUCP (04/27/84)

   The argument over whether a+++b parses as (a++)+b or a+(++b) is solved (at
least I think it's solved, but what do I know?) by reference to section 2 of
the C reference manual in K&R's The C Programming Language.  There we are
clearly told that the parser is to return the longest possible string that
could be a token, so (a++)+b has to be right.
   In addition, some people have claimed that C ignores spaces in its parses.
I think that's due to a misreading of K&R.  It clearly says that spaces are
required (by spaces I mean white space, by the way, including comments) to
separate identifiers that would otherwise be adjacent.  In addition, it asserts
that white space between tokens is syntactically meaningless, but that's
whitespace BETWEEN tokens, not within them.  The expression a+ ++b cannot be
parsed as (a++)+b because the token ++ cannot contain an imbedded blank.
   Or am I misreading this?

gwyn@brl-vgr.ARPA (Doug Gwyn ) (05/02/84)

Certainly
	a+ ++b
cannot be parsed as
	a++ + b
since "+ +" is not a valid way of writing the ++ operator.
Spaces are indeed sometimes significant, which is why they SHOULD BE USED
when writing hard-to-parse-by-eye-and-maybe-by-compiler expressions.

Here is another good one for you; Ron Natalie reminded me today of the
fellow who used the C preprocessor to form composite tokens by something like
	#define	cat( a, b )	a/**/b
Of course this is SUPPOSED to work, but it depends on careful handling of
comments by the C preprocessor lexical analyzer.  (Consider what would
happen if a preliminary "comment stripping" pass were applied blindly.)