home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 13123 < prev    next >
Encoding:
Text File  |  1992-09-02  |  2.2 KB  |  56 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!utcsri!torn!watserv2.uwaterloo.ca!watmath!thinkage!dat
  3. From: dat@thinkage.on.ca (David Adrien Tanguay)
  4. Subject: Re: string concatenation (was: Re: printf question)
  5. Message-ID: <1992Sep2.180505.1971@thinkage.on.ca>
  6. Organization: Thinkage, Ltd.
  7. References: <3361@dozo.and.nl> <1SEP199221241770@eql.caltech.edu> <3370@dozo.and.nl>
  8. Date: Wed, 2 Sep 1992 18:05:05 GMT
  9. Lines: 45
  10.  
  11. jos@and.nl (Jos Horsmeier) writes:
  12. >In article <1SEP199221241770@eql.caltech.edu> rankin@eql.caltech.edu (Pat Rankin) writes:
  13. >|     Minor quibble:  string concatentation is performed by the compiler,
  14. >|not the preprocessor.
  15. [...]
  16. >Phase 6 reads:
  17. >Adjacent character string literal tokens are concatenated and adjacent
  18. >wide string literal tokens are concatenated.
  19. >
  20. >Phase 7 reads:
  21. >[ ... ] The resulting tokens are syntactically and semantically
  22. >analyzed and translated.
  23. >
  24. >So, phase 7 is the phase where the grammar comes in. On of the first
  25. >grammar rules reads:
  26. >
  27. >primary-expression:
  28. >    [ ... ]
  29. >    string-literal
  30. >
  31. >Where string literal is defined as:
  32. >
  33. >string-literal:
  34. >    "s-char sequence_opt"
  35. >    L"s-char sequence_opt"
  36. >
  37. >See? A string literal is not defined as a concatenation of one or more
  38. >string literals. That's why I thought that the process of concatenating
  39. >these things was done in the preprocessor. Well, it does so in mine ...
  40. >
  41. >Section 3.3.1 (Primary expressions) says nothing about a concatenation
  42. >of string literals either, so that made my believe that I was right
  43. >even stronger, but I've tried some other preprocessors just now and
  44. >none of them does the concatenation, so, again, you're probably right.
  45.  
  46. The standard does not define a "preprocessor" entity, only phases of
  47. translation. As has been often mentioned, there does not even have to be
  48. a separate preprocessor, or a compiler switch to only preprocess.
  49. If the implemetation decides to draw a boundary between pre-processor and
  50. parser, it is up to the implementation to decide which does the
  51. catenation (it could do it in both). Of the two compilers I regularly use,
  52. one does phase 6 in the parser and the other in the preprocessor.
  53. -- 
  54. David Tanguay       dat@Thinkage.on.ca  dat@Thinkage.com  uunet!thinkage!dat
  55. Thinkage, Ltd.           Kitchener, Ontario, Canada          [43.40N 80.47W]
  56.