gnu@hoptoad.uucp (John Gilmore) (01/02/87)
In article <1971@emory.UUCP>, arnold@emory.UUCP writes: > #define CTRL(X) (' ## X ## ' & 037) /* ascii only */ > ...uses the token concatenation operator to produce the character > constant.... > I am sure someone will correct me if I am wrong. I thought he was wrong, but I looked again at the standard. I didn't believe that a single quote would be considered a preprocessing token; I figured it would parse as #define CTRL(X) (string & 037) where string is: ' ## X ## ' (Of course multiple character '...' constants are legal in the draft proposed standard, but let's not get off the track...) The definition of preprocessor-token is (pg 74, sec 3.8): preprocessing-token: header-name (only within a #include directive) identifier constant string-literal operator punctuator each non-white-space character that cannot be one of the above Aha! Since a lone quote is not any of the above, it must be one of those "each non white space characters", and it must be a preprocessing-token. Right? Phooey. There should be specific instructions in the standard on lexical analysis of C programs, e.g. an algorithm for parsing, rather than this vague English rubbish. This applies to section 2.1.1.2 ("The source file is decomposed into preprocessing tokens...") too. I can see my source files slowly decomposing in there now... -- John Gilmore {sun,ptsfa,lll-crg,ihnp4}!hoptoad!gnu gnu@ingres.berkeley.edu I forsee a day when there are two kinds of C compilers: standard ones and useful ones ... just like Pascal and Fortran. Are we making progress yet? -- ASC:GUTHERY%slb-test.csnet
decot@hpisod2.HP (Dave Decot) (01/11/87)
> In article <1971@emory.UUCP>, arnold@emory.UUCP writes: > > #define CTRL(X) (' ## X ## ' & 037) /* ascii only */ > > ...uses the token concatenation operator to produce the character > > constant.... > > I am sure someone will correct me if I am wrong. > > preprocessing-token: > header-name (only within a #include directive) > identifier > constant > string-literal > operator > punctuator > each non-white-space character that cannot be one of the above > > Aha! Since a lone quote is not any of the above, it must be one of those > "each non white space characters", and it must be a preprocessing-token. > Right? ' ## X ## ' comes under the heading of "constant". > Phooey. There should be specific instructions in the standard on > lexical analysis of C programs, e.g. an algorithm for parsing, rather > than this vague English rubbish. I agree. It is possible to accurately describe anything in English. It is not always possible to accurately describe things in vague English. Dave Decot hpda!decot