home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!utcsri!torn!watserv2.uwaterloo.ca!watmath!thinkage!dat
- From: dat@thinkage.on.ca (David Adrien Tanguay)
- Subject: Re: string concatenation (was: Re: printf question)
- Message-ID: <1992Sep2.180505.1971@thinkage.on.ca>
- Organization: Thinkage, Ltd.
- References: <3361@dozo.and.nl> <1SEP199221241770@eql.caltech.edu> <3370@dozo.and.nl>
- Date: Wed, 2 Sep 1992 18:05:05 GMT
- Lines: 45
-
- jos@and.nl (Jos Horsmeier) writes:
- >In article <1SEP199221241770@eql.caltech.edu> rankin@eql.caltech.edu (Pat Rankin) writes:
- >| Minor quibble: string concatentation is performed by the compiler,
- >|not the preprocessor.
- [...]
- >Phase 6 reads:
- >Adjacent character string literal tokens are concatenated and adjacent
- >wide string literal tokens are concatenated.
- >
- >Phase 7 reads:
- >[ ... ] The resulting tokens are syntactically and semantically
- >analyzed and translated.
- >
- >So, phase 7 is the phase where the grammar comes in. On of the first
- >grammar rules reads:
- >
- >primary-expression:
- > [ ... ]
- > string-literal
- >
- >Where string literal is defined as:
- >
- >string-literal:
- > "s-char sequence_opt"
- > L"s-char sequence_opt"
- >
- >See? A string literal is not defined as a concatenation of one or more
- >string literals. That's why I thought that the process of concatenating
- >these things was done in the preprocessor. Well, it does so in mine ...
- >
- >Section 3.3.1 (Primary expressions) says nothing about a concatenation
- >of string literals either, so that made my believe that I was right
- >even stronger, but I've tried some other preprocessors just now and
- >none of them does the concatenation, so, again, you're probably right.
-
- The standard does not define a "preprocessor" entity, only phases of
- translation. As has been often mentioned, there does not even have to be
- a separate preprocessor, or a compiler switch to only preprocess.
- If the implemetation decides to draw a boundary between pre-processor and
- parser, it is up to the implementation to decide which does the
- catenation (it could do it in both). Of the two compilers I regularly use,
- one does phase 6 in the parser and the other in the preprocessor.
- --
- David Tanguay dat@Thinkage.on.ca dat@Thinkage.com uunet!thinkage!dat
- Thinkage, Ltd. Kitchener, Ontario, Canada [43.40N 80.47W]
-