Sujet : Re: Writing own source disk
De : malcolm.arthur.mclean (at) *nospam* gmail.com (Malcolm McLean)
Groupes : comp.lang.cDate : 03. Jun 2024, 05:16:40
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v3jg38$3o8nk$1@dont-email.me>
References : 1 2 3
User-Agent : Mozilla Thunderbird
On 03/06/2024 00:10, bart wrote:
On 02/06/2024 23:17, Ben Bacarisse wrote:
Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>
Writing a prgram which writes its own source to standard output is a
standard programming problem. It's called a quine.
>
A quine must also not process any input.
No input at compile-time or runtime?
A compiler necessarily has to have the source code of the program as input, so what are the limitations? A C program can use #include; does that extend to directives like #embed, or is that considered cheating?
Exactly.
It's a quine. You run the progrm, and it produces its own source, as a FileSystem .xml file. Convert to a regular diretory, and compile, and you
You will get a program wich spits out exactly the same FileSystem xml file. So a quine.
It's here.
https://github.com/MalcolmMcLean/babyxrc/tree/master/Examples/BabyXFSYou need the entire repository if you want a play.
Youb need the
babyxfs_ tools to manipulate the FileSystem xml files.
And you need Baby X RC to pack up the Xml file into a compilEAble
C file, conventionally called source.c
(When you comile for the first time, make sure you have the real
source.c and not the place holder).
However if you you want to compile the programs, they are quines,
but only on the second generation. source.c is the first generation.
(And of course the program must not have a file called source.c that is not a place holder for converting to xml to produce the real source.c,
or the real source.c when you convert to the first generation).
-- Check out Basic Algorithms and my other books:https://www.lulu.com/spotlight/bgy1mm