From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,47327673b9e29af0 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-13 15:55:38 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wn1feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail From: "David Thompson" Newsgroups: comp.lang.ada References: <3D0DD57A.5000402@yahoo.com> <3d0dda3d$1@pull.gecm.com> <3D0DDD18.7090501@yahoo.com> <3D2315CA.7050807@attbi.com> Subject: Re: Ada -> C or C++ translator X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: Date: Sat, 13 Jul 2002 22:55:38 GMT NNTP-Posting-Host: 12.89.149.220 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1026600938 12.89.149.220 (Sat, 13 Jul 2002 22:55:38 GMT) NNTP-Posting-Date: Sat, 13 Jul 2002 22:55:38 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:27073 Date: 2002-07-13T22:55:38+00:00 List-Id: Robert I. Eachus wrote : ... > There was a project many years ago that had us all laughing when we > found out what was going on. You could probably use the same technique... > [emacs and C macros to take subset-Ada and make it work as C] ... > I know it sounds hard, but once they got started, the #defines were easy: > > #define begin { > #define end } \/\/ > (Did I get that right? It has been so long since I did "clever" things > in cpp. The intent of course is to make everything following the end > keyword a comment.) > I doubt it, or at least not portably. At least in any standard-conforming (post 89) implementation, comments become logical whitespace _before_ macro substitution, which can't legally "construct" a comment, although many implemenations generate preprocessor output as text and re-parse it (which is not required, but often convenient) and support deferring comments to the latter stage to make the preprocessed output more informative. Plus double-slash comments didn't exist in original/traditional C or C89; they were (re)introduced in C++ in the early 1990's and migrated back to C, standardized only in C99. But most important, backslash+slash is outright illegal. Backslash escapes are legal only in character and string literals, where they are interpreted only during compilation proper (translation phase 7) after preprocessing is completed; and inside comments they are ignored. Backslashes are NOT handled differently in preprocessing directives, or macros. Line splicing using backslash+physical-end-of-line is a separate though similar looking case, technically not an escape, and is equally legal everywhere -- though it is generally only needed, and hence used, on preprocessor directives. (And in C++98 and C99 UCNs, basically Unicode escapes, are also legal in/as an identifier for alphanumeric-ish characters only.) Although a compiler, or possibly preprocessor, could use \/ for some kind of extension, I have never heard of one doing so, and certainly not turning it into a comment-introducing token as you want here. The closest you can rely on is a "function-like" (parameterized) macro that ignores/discards its argument, but usage is not transparent: #define end(x) } ... begin /*foo*/ ... end(foo) ... -- - David.Thompson 1 now at worldnet.att.net