Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Really Hard /prog/ Challenge

Name: Anonymous 2010-07-24 16:33

Write a C compiler. It doesn't have to follow any rules/syntax/standards except to compile "hello world" and fibs.

Name: Anonymous 2010-07-24 16:46

#!/usr/bin/perl
# Compiles (and automatically runs) C programs
# according to which purpose the program has,
# with no intermediate executable.
# Not to be confused with the C interpreter
# that this program is identical to.
my ($file, $option) = @ARGV;
die "Error 404: File not found: $file" unless -e $file;
if ($option eq "--hello-world") {
  print "200 OK: Hello, World!";
} elsif ($option eq "--fibs") {
  print "200 OK: ";
  my $i = 0;
  while (rand > 0.1) {
    print int ($i * (1 + sqrt 5)) + 0.5) . " ";
    $i += 0.5;
  }
} else {
  die "Error 500: Internal server error (syntax)\n";
}

Name: Anonymous 2010-07-24 16:53


#include <string.h>

int main(int argc, char **argv) {
    if (!strcmp(argv[1], "hello_world.c"))
        puts("compiled");
    else if (!strcmp(argv[1], "fibs.c"))
        puts("compiled");
    else
        puts("failed");
    return 0;
}

Name: Anonymous 2010-07-24 16:59

compile my           anus         

Name: Anonymous 2010-07-24 18:00

int
main(int argc, char* argv[])
{
    if (file =~ fib) /* Left as an exercise for the reader. */
        output_fibs_bin(); /* Generated by a m4 macro. */
    else if (file =~ hello)
        output_hello_bin();
    return 0;
}

Name: Anonymous 2010-07-25 2:38

Just wrote this one:
http://pastebin.com/z8eW9ZZP

- Reads from stdin, and writes Intel-style 80386 assembler to a.s
- No type checking. No pointer support
- Only 32bit signed int is available
- Limited program control(only if, for, and while available)

Compiles this:
http://pastebin.com/nnFC7fae
To this:
http://pastebin.com/BcQfbQPj

Name: Anonymous 2010-07-25 2:40

>>6
Hmm, I made it in less than 10 hours, I see. Can anyone make a better one?

Name: Anonymous 2010-07-25 2:44

My compiler compiles to C
#include "void.h" //adds predefined utility macros,includes, and functions
int main(int argc,char**argv){
#include "program" //can be customized to fibs or hello world.
;return 0;}

Name: Anonymous 2010-07-25 3:04

#include <stdio.h>
#define k *(int*)
#define a if(
#define c ad()
#define i else
#define p while(
#define x *(char*)
#define b ==
#define V =calloc(1,99999)
#define f ()
#define J return
#define l ae(
#define n e)
#define u d!=
#define F int
#define y (j)
#define r m=
#define t +4
F d,z,C,h,P,K,ac,q,G,v,Q,R,D,L,W,M;E(n{x D++=e;}o f{a L){h=x L++;a h b 2){L=0;h=W;}}i h=fgetc(Q);}X f{J isalnum(h)|h b 95;}
Y f{a h b 92){o f;a h b 110)h=10;}}c{F e,j,m;p isspace(h)|h b 35){a h b 35){o f;c;a d b 536){c;E(32);k d=1;k(d t)=D;}p h!=10){
E(h);o f;}E(h);E(2);}o f;}C=0;d=h;a X f){E(32);M=D;p X f){E(h);
o f;}a isdigit(d)){z=strtol(M,0,0);d=2;}i{x D=32;d=strstr(R,M-)-R;x D=0;d=d*8+256;a d>536){d=P+d;a k d b 1){L=k(d t);W=h;o f;
c;}}}}i{o f;a d b 39){d=2;Y f;z=h;o f;o f;}i a d b 47&h b 42){o
f;p h){p h!=42)o f;o f;a h b 47)h=0;}o f;c;}i{e="++#m--%am*@R<^1c/@%[_[H3c%@%[_[H3c+@.B#d-@%:_^BKd<<Z/03e>>`/03e<=0f>=/f<@.f>@1f==&g!='g&&k||#l&@.BCh^@.BSi|@.B+j~@/%Yd!@&d*@b";
p j=x e++){r x e++;z=0;p(C=x e++-98)<0)z=z*64+C+64;a j b d&(m b h|m b 64)){a m b h){o f;d=1;}break;}}}}}
l g){p g&&g!=-1){x q++=g;g=g>>8;}}A(n{F g;p n{g=k e;k e=q-e-4;
e=g;}}s(g,n{l g);k q=e;e=q;q=q t;J e;}H(n{s(184,n;}B(n{J s233,n;
}S(j,n{l 1032325);J s(132+j,n;}Z(n{l 49465);H(0);l 15);l e+144);
l 192);}N(j,n{l j+131);s((e<512)<<7|5,n;}T y{F g,e,m,aa;g=1;a d b 34){H(v);
p h!=34){Y f;x v++=h;o f;}x v=0;v=v t&-4;o f;c;}i{aa=C;r z;
e=d;c;a e b 2){H(m);}i a aa b 2){T(0);s(185,0);a e b 33)Z(m);
i l m);}i a e b 40){w f;c;}i a e b 42){c;e=d;c;c;a d b 42){
c;c;c;c;e=0;}c;T(0);a d b 61){c;l 80);w f;l 89);l 392+(e b 56));
}i a n{a e b 256)l 139);i l 48655);q++;}}i a e b 38){N(10,k d);
c;}i{g=k e;a!g)g=dlsym(0,M);a d b 61&j){c;w f;N(6,g);}i a u 40){
N(8,g);a C b 11){N(0,g);l z);c;}}}}a d b 40){a g b 1)l 80);
r s(60545,0);c;j=0;p u 41){w f;s(2393225,j);a d b 44)c;j=j t;
}k r j;c;a!g){e=e t;k e=s(232,k n;}i a g b 1){s(2397439,j);j=j t;}i{s(232,g-q-5);}a j)s(50305,j);}}O y{F e,g,m;a j--b 1)T(1);i{
O y;r 0;p j b C){g=d;e=z;c;a j>8){r S(e,m);O y;}i{l 80);O y;l 89);
a j b 4|j b 5){Z(n;}i{l n;a g b 37)l 146);}}}a m&&j>8){r S(e,m);
H(e^1);B(5);A(m);H(n;}}}w f{O(11);}U f{w f;J S(0,0);}I y{F ,g,e;
a d b 288){c;c;r U f;c;I y;a d b 312){c;g=B(0);A(m);I y;A(g);}
i{A(m);}}i a d b 352|d b 504){e=d;c;c;a e b 352){g=q;r U f;}i{
a u 59)w f;c;g=q;r 0;a u 59)r U f;c;a u 41){e=B(0);w f;B(g-q-5);
A(n;g=e t;}}c;I(&m);B(g-q-5);A(m);}i a d b 123){c;ab(1);p u 125)I y;c;}i{a d b 448){c;a u 59)w f;K=B(K);}i a d b 400){c;k j=B(k j);}i a u 59)w f;c;}}ab y{F m;p d b 256|u-1&!j){a d b 256){c;
p u 59){a j){G=G t;k d=-G;}i{k d=v;v=v t;}c;a d b 44)c;}c;}i{
A(k(d t));k d=q;c;c;r 8;p u 41){k d=m;r m t;c;a d b 44)c;}c;
K=G=0;l 15042901);r s(60545,0);I(0);A(K);l 50121);k r G;}}}
main(g,n{Q=stdin;a g-->1){e=e t;Q=fopen(k e,"r");}
D=strcpy(R V," int if else while break return for define main ")+48;v V;q=ac V;P V;o f;c;ab(0);J(*(int(*)f)k(P+592))(g,n;}

Name: Anonymous 2010-07-25 3:09

http://pastebin.com/RGipn5pr
Secret source:
requires
..\gcc -C to binary
void.h - Abstraction layer above C
programname - %1 - text file with C commands and Void.h macros

Name: Anonymous 2010-07-25 4:28

>>10
What about declaring functions/data outside main?

Name: Anonymous 2010-07-25 4:32

>>11
Thats unpythonic.

Name: Anonymous 2010-07-25 5:06

I'll write one but i'm not sure in which language it should be.

Name: Anonymous 2010-07-25 9:00

I did this when i was 12 and repeat it ever since at the same date which is August 9th. There is no reason to do it now.

Name: Anonymous 2010-07-25 12:49

>>9
yousuck.c:24:67: error: expected expression before ‘)’ token
yousuck.c:29:62: error: ‘s233’ undeclared (first use in this function)
yousuck.c:29:67: error: expected ‘;’ before ‘)’ token
yousuck.c:29:67: error: expected statement before ‘)’ token
yousuck.c:43:64: error: expected identifier or ‘(’ before ‘,’ token
yousuck.c:44:20: error: ‘m’ undeclared (first use in this function)
yousuck.c:44:45: error: ‘g’ undeclared (first use in this function)
yousuck.c:45:35: error: ‘e’ undeclared (first use in this function)

Name: Anonymous 2010-07-25 13:12

>>15
shiitchansucks.cpp:1:1: error: your gay found where your wrong bitch expected

Name: Anonymous 2010-07-25 20:51

Where is Xarn?
Might the absence of a reply by the all mighty be caused because the unencessity of linking to Allegro?

Name: Anonymous 2010-07-25 21:12

>>17
Don't you have an imageboard to get back to?

Name: Anonymous 2010-07-25 21:35

>>18
Don't you have a ``Fuck off, ``faggot''.'' to reply to?

Name: Anonymous 2010-07-25 21:39

>>19
Fuck off, ``faggot''.

Name: Anonymous 2010-07-25 22:39

>>18
GO BACK TO MY ANUS

Name: Anonymous 2010-07-25 22:48

>>18 see >>20

Name: Anonymous 2010-07-25 22:50

ITT: Spaghetti posts.

Name: Anonymous 2010-07-25 23:12

>>22
Referring posts to later posts is unpythonic.

Name: Anonymous 2010-07-25 23:20

>>24
See >>2001

Name: Anonymous 2010-07-26 0:35

Name: Anonymous 2010-07-26 0:46

>>26
1. It is possible to have a thread with over 2000 posts.
2. The thread limits are not a shiichan limitation.
3. (Supplemental.) 2001 posts will not cause a problem for PHP while viewing an entire thread, however I suspect the number you have quoted would end in a timeout.

Name: Anonymous 2010-07-26 1:21

>>27
The use of persistent connections places no requirements on the length (or existence) of this time-out for either the client or the server.
Obviously even having that many rows in a database would instantly crash the machine and probably the entire internet, but "SELECT * FROM posts WHERE threadid = 1280003629 AND postid = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" should not, in principle, cause a timeout anywhere.

Name: Anonymous 2010-07-26 2:18

>>28
You think I was talking about MySQL. How cute.

Name: Anonymous 2010-07-26 2:28

>>29
No, I didn't. I thought you were implying something about processing and displaying that query would cause a timeout. It wouldn't.

Name: Anonymous 2010-07-26 3:20

>>30
>>27 means to imply nothing about queries.

Name: Anonymous 2010-07-26 6:02

>>31
He is stating there will be a timeout somewhere. As demonstrated, necessarily, the client can't timeout after the connection has been successfully opened. By this we deduce he means there will be a server side timeout, i.e.: max_execution_time is exceeded. I found a SQL query to be the most convenient way to show what the server would be doing in this case, and why it wouldn't timeout.

Name: Anonymous 2010-07-26 9:31

>>28
No, you were talking about PHP, whereas Shiitchan runs on Glorious Perl.

Name: Anonymous 2010-07-26 10:19

>>33
Hm?

Name: Anonymous 2010-07-26 10:53

ITT: Distractions

Don't change these.
Name: Email:
Entire Thread Thread List