How to type braces for computed gotos (was: Best "simple" C Compiler I've ever seen)

federation2005@netzero.com
Fri, 18 Jul 2014 14:44:04 -0700 (PDT)

          From comp.compilers

Related articles
Best "simple" C Compiler I've ever seen andrewchamberss@gmail.com (2014-05-04)
How to type braces for computed gotos (was: Best "simple" C Compiler I federation2005@netzero.com (2014-07-18)
Re: How to type braces for computed gotos gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-07-19)
Re: How to type braces for computed gotos ivan@ootbcomp.com (Ivan Godard) (2014-07-18)
Re: How to type braces for computed gotos (was: Best "simple" C Compil anton@mips.complang.tuwien.ac.at (2014-07-21)
Re: How to type braces for computed gotos gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-07-21)
Re: How to type braces for computed gotos federation2005@netzero.com (2014-07-21)
Re: How to type braces for computed gotos wclodius@earthlink.net (2014-07-21)
[3 later articles]
| List of all articles for this month |
From: federation2005@netzero.com
Newsgroups: comp.compilers
Date: Fri, 18 Jul 2014 14:44:04 -0700 (PDT)
Organization: Compilers Central
References: 14-05-013
Keywords: C
Posted-Date: 18 Jul 2014 21:22:52 EDT

On Sunday, May 4, 2014 8:23:05 PM UTC-5, andrewc...@gmail.com wrote:
> https://github.com/rui314/8cc
> Self hosting, extremely well written, and seems geared towards simple
> but complete code rather than being a complicated monolith.


On that count: usually when I redo a source (reformat, reanalyze the math,
make more effective use of the language, etc.) it comes out to 50% reduction
by lines 30% by bytes; which is consistent across thousands of source files.


The only exceptions I've encountered to date are stuff I earlier reduced (30%
by lines if it made use of an earlier dialect of the language), stuff from
AT&T (which does not reduce much, e.g. CFront) and the source for this
compiler.


So by that count, it's well-written and compact.


There is one feature the compiler tests for that I assume the language also
has in it that I haven't seen much of before: the computed goto. What's I
don't quite understand how the branches are being typed. A computed goto
inside a void routine has the branches typed (void *), with the individual
items accessed in effect as references to (void *).


The branches are essentially continuations. So the question here is how are
continuations being typed. From the example used in the distribution, either
(A) all continuations are typed (void *) or they are being typed (T *) when
they occur inside a function that returns type T.
[That's an extension. In standard C, you can only goto a label. -John
Perhaps it's similar to this GCC extension
https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html#Labels-as-Values]





Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.