PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: [Cs223] Precedence of line splices v. escape sequences
Date: Friday, 31 Jan 2020, 21:27:48


    > Message Posted By: Unknown
    >
    > I'm a little confused on the logic for this example in a previous post.
    >
    > =====
    >
    >     > Case 1:
    >     > "example\\
    >     > \
    >     > \
    >     > "end"
    >
    > After the three line splices are removed, the input is
    >
    >   "example\"end"
    >
    > which is a string.  Thus Cxref outputs nothing.
    >
    > =====
    >
    > Is the \\ in "example\\ not treated as an escape sequence? Why does the
    > line splice take precedence? ...

No, because as stated in the excerpts from Appendix A of K&R,

  Preprocessing itself takes place in several logically successive phases that
  may, in a particular implementation, be condensed.
  ...
  2. Each occurrence of a backslash character \ followed by a newline is
     deleted, thus splicing lines (Section A12.2).

  3. The program is split into tokens separated by white-space characters;
     comments are replaced by a single space.  Then preprocessing directives
     are obeyed, and macros (Sections A12.3-A12.10) are expanded.

That is, splices are removed BEFORE identifiers are parsed.

--Stan-
PREV INDEX NEXT