Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #148144

Re: curiosity about compiler phases

Subject Re: curiosity about compiler phases
Newsgroups comp.lang.c
References <9585199f-546a-46f8-ac2a-de27cc08a3f5@googlegroups.com> <FcZBF.211$rX6.122@fx22.am4> <f8d8fd96-c9b9-4fc9-b1be-ebefa2142fbb@googlegroups.com>
From Bart <bc@freeuk.com>
Message-ID <GUcCF.1484$mg5.754@fx31.am4> (permalink)
Organization virginmedia.com
Date 2019-11-23 16:13 +0000

Show all headers | View raw


On 23/11/2019 14:28, Thiago Adams wrote:
> On Friday, November 22, 2019 at 7:22:39 PM UTC-3, Bart wrote:

>> With the line continuation in the middle of tokens, I simply took the
>> decision that is was too ridiculous to implement. The fewer compilers
>> that pander to it, the less likely it is that any programs will come to
>> depend on it.
> 
> In my transpiler this is another item that makes live difficult.
> I have implemented in the wrong phase and I will fix this someday.

You could just add a line-splicing pass as I mentioned, such as the 
following function, which takes an entire, just-loaded source file 
represented as one string, and returns another string:

   char* splicelines(char * s) {
       char *t,*u;

       t = u = malloc(strlen(s)+1);
       if (t == NULL) return NULL;

       while (*s) {
           if (*s == '\\' && *(s+1) == 10) s += 2;
           else if (*s == '\\' && *(s+1) == 13 && *(s+2) == 10) s += 3;
           else *t++ = *s++;
       }
       *t = 0;

       return u;
   }


If I write a version of this for my compiler, and add these lines just 
after a source file has been loaded:

     if dolinesplicing then
         s := splicelines(s)     # (uses different allocation call)
     fi

then it will compile the examples I posted. But I won't keep it, as I 
think it is largely a waste of time. This was just to show I can support 
the feature if I have to. (It also slows down compilation but by 3-12% 
depending on how it is built.)

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

curiosity about compiler phases Thiago Adams <thiago.adams@gmail.com> - 2019-11-07 05:28 -0800
  Re: curiosity about compiler phases Nick Bowler <nbowler@draconx.ca> - 2019-11-22 19:25 +0000
  Re: curiosity about compiler phases "A. K." <minforth@arcor.de> - 2019-11-22 12:19 -0800
  Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-22 22:22 +0000
    Typo? (Was: curiosity about compiler phases) gazelle@shell.xmission.com (Kenny McCormack) - 2019-11-22 22:34 +0000
      Re: Typo? (Was: curiosity about compiler phases) Bart <bc@freeuk.com> - 2019-11-22 23:49 +0000
        Re: Typo? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2019-11-22 19:26 -0700
    Re: curiosity about compiler phases scott@slp53.sl.home (Scott Lurndal) - 2019-11-22 23:12 +0000
      Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-23 00:06 +0000
        Re: curiosity about compiler phases Richard Damon <Richard@Damon-Family.org> - 2019-11-22 20:34 -0500
        Re: curiosity about compiler phases Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-11-23 01:47 +0000
          Re: curiosity about compiler phases Richard Damon <Richard@Damon-Family.org> - 2019-11-22 21:21 -0500
            Re: curiosity about compiler phases Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-11-24 03:26 +0000
              Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-24 11:29 +0000
                Re: curiosity about compiler phases Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-11-24 16:49 +0000
          Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-23 12:21 +0000
            Re: curiosity about compiler phases Richard Damon <Richard@Damon-Family.org> - 2019-11-23 10:08 -0500
            Re: curiosity about compiler phases scott@slp53.sl.home (Scott Lurndal) - 2019-11-23 15:49 +0000
              Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-23 16:21 +0000
                Re: curiosity about compiler phases Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-11-24 03:37 +0000
                Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-24 11:25 +0000
                Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-25 14:06 +0000
    Re: curiosity about compiler phases Keith Thompson <kst-u@mib.org> - 2019-11-22 21:25 -0800
      Beyond our pay grade (Was: curiosity about compiler phases) gazelle@shell.xmission.com (Kenny McCormack) - 2019-11-23 07:43 +0000
    Re: curiosity about compiler phases Thiago Adams <thiago.adams@gmail.com> - 2019-11-23 06:28 -0800
      Re: curiosity about compiler phases Thiago Adams <thiago.adams@gmail.com> - 2019-11-23 06:39 -0800
      Re: curiosity about compiler phases Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2019-11-23 09:46 -0500
        Re: curiosity about compiler phases Richard Damon <Richard@Damon-Family.org> - 2019-11-23 10:16 -0500
      Re: curiosity about compiler phases Bart <bc@freeuk.com> - 2019-11-23 16:13 +0000
        Re: curiosity about compiler phases Thiago Adams <thiago.adams@gmail.com> - 2019-11-25 03:24 -0800
  Re: curiosity about compiler phases Bonita Montero <Bonita.Montero@gmail.com> - 2019-11-23 08:43 +0100

csiph-web