diff --git a/Makefile b/Makefile index f47a1bd7..a9cb8fe9 100644 --- a/Makefile +++ b/Makefile @@ -95,7 +95,7 @@ QR.sml: QR.nut @echo "## 8: Squirrel -> Standard ML ##" @echo "##################################" @echo - squirrel3 QR.nut > QR.sml + squirrel QR.nut > QR.sml QR.sq: QR.sml @echo diff --git a/QR.rb b/QR.rb index 59678dee..5966f944 100644 --- a/QR.rb +++ b/QR.rb @@ -1,59 +1,59 @@ eval$s=%q(eval(%w(B=92.chr;g=32.chr;puts(eval(%q(N=10.chr;n=0;e=->s{Q[Q[s,B],?"].K(N,B+?n)};E=->s{'("'+e[s]+'")'};d=->s,t=?"{s.K(t){t+t}};def~f(s,n)s.K(/.{1,#{n*255}}/m){yield$S=E[$s=$&]}end;Q=->s,t=?${s.K(t){B+ -$&}};R=";return~0;";V=->s,a,z{s.K(/(#{B*4})+/){a+"#{$&.size/2}"+z}};C=%w(System.Console~Write);$C=C*?.;$D="program~QR";$G="~contents~of"+$F="~the~mix!g~bowl";$L="public~static";"object~QR~extends~App{#{f(%((disp -lay~"#{e[%(#{f(%[echo~-En~"#{Q[e[e["Transcript~show:~'#{d["Z"+E[%(fun~p~n=Z(Int.toSJ~n`x5e"~");p~0;p~0;p~130;List.tabulate(127,p);SJ.map(fn~c=>(p(3+ord~c);Z"-1~0~";c))#{E[%(proc~f~{n}~{sJ~repeat~"Y"~$n};puts~a:: -=`x7e[reK~-all~{.}~"#{V[Q[e["!t~mX{Z#{d[E[%(module~QR;!itial~beg!~#{f(%(Module~QR:Sub~MX:Dim~s,n,i,c~As~Object:n=Chr(10):For~Each~c~!"#{d["<#{U="xsl:template"}~match='/'><`x21[CDATA[#{%(H,format="#{y="";f("^H{-}{txt}{#{Q[E[%(with~Ada.Text_Io;proced -ure~qr~is~beg!~Ada.Text_Io.Put_L!e("#{d[%(Z"#{e[%W[STRINGz:=~226+~153,a:=z+~166,b:=a+"2"+z+~160,c:=b+"8"+z+~165,t:="#{d["H('#{Q[e["implement~ma!0()=Z"+E[%(BEGIN{s=#{E[(s="#!clude`n!t~mX{std::cout<<#{E[ -"class~Program{#$L~void~MX{#{$C+E[(%(let~f(c ~:Int):La t!1=if~c=127then""else(sJ_of~c@"~g~caffe!e~"@sJ_of~c@"`n")@f(c+1)!~Z("Qu!e~Relay~Coffee.`n`nIngredients.`n"@f~10@"`nMethod.`n");let~g(SJ~->[])`n[c;t]->Z("P -ut~caffe!e~"@sJ_of(!t_of_char~c)@ "~!to# $F.` n");g~t` n|_~->Z("Liquify#$G.`nPour#$G~!to~the~bak!g~dish.`n`nServes~1.`n")!~g#{E[%((doseq[s(lazy-cat["IDENTIFICATION~DIVISION.""PROGRAM-ID.~QR.""PROCEDU -RE~DIVISION."'DISPLA`x59](map~# (st r "~~~~^""(.replace~%1"^"""^"^"")"^"&")(re-seq~#".{1,45}""#{e["(f=(n)->Array(n+1).jo!~ 'Y');console.log('%s',#{V[E[%((H-l!e"#{e["imp -ort~std.stdio;void~mX{H(`x60# {% (method~MX{Z(@"#{d["[#{%(class~QR:Application{void~f(SJ~const~s ,!t~n){for(Pr!t(s);n;n--)Pr!t("Y");}v -oid~MX{#{f("IO.puts"+E[%((p r!c~"#{e["`nma!(_)->`nio:fH#{E['Zfn("""'+d[?"+%(~:~A~."#{g*9 }"~;~:~B~A~."~WRITE(*,*)'"~A~;~: -~C~B~T`x59PE~."~'"~CR~;~:~ D~S"~#$D"~C~S^"~Z~^"(&"~C~S^"~#{e[%(Z"#{e["s:=Out putTextUser();WriteAll(s,#{E -[f('set~Z"-";Z'+E[%(packa ge~ma!;import(F"fmt";S"sJs");func~t(s~sJ)s J{r:="";for~i,n:=range~s{ -if~n<48{r+="v"}else{r+= S.Repeat("Ww"[i%2:i%2+1],!t(n)-48)}};retu rn~r};func~mX{s:=t("01 -3141")+S.Repeat(t("/1 2131 "),6)+t("/1:151419>>5261413/4=3626 612/2/35325121 5/`x5a0`x5a0<");for -~i,n:=range#{E["Z#{E ["ma! =putStr"+E["class~QR{#$L~fun ction~mX{neko.Lib.Z#{E[%(pro cedure~mX;i:=c:=0; -s:=#{E[%(.class~pub lic~ QR`n.super~#{$T="java/io/Pr !tStream"}`n.method~#$L~ma!([L#{S="jav a/lang/S"}J;)V~; -]`n.limit~stack~2`n getstatic~#{S}ystem/ou t~L#$T;`nldc~"#{e[%(cl ass~QR{#$L~void~ma!(SJ[]v){SJ~c[]=new~SJ[999 99],y="",z=y,s -="#{z=t=(0..r=q=126 ).ma p{|n|[n,[]]};a="";b=->n{a<<(n%78+5 5)%84+42};("conso le.log('%s',#{E[E[%(A=Z;A("k`x60");[(A("`x60`x60s" `x5e8*"i");fo -r~j=6:-1:0;x=(Int(c)> >j)%2+1;A("`x60"*"kki"[x:x+1])end)for~c~!~jo!(["S ection`x48ead er+name:=QR;SectionPublic-ma!<-(";["^"$(replace(replac e(s,"Y","YY -"),"^"","Y^""))^". Z;"for~s=matchall(r".{1,99}",#{Q[E[%(@s=global[#{i= (s=%(`x48AI~ 1.2`nVISIBLE~"#{"x=sJ.K(#{V[E["all:`n`t@echo~'#{d["l!el:99 999;Z#{E[" -solve~satisfy;o utput~[#{E[%(.assembly~t{}.method~#$L~void~MX{.entrypo!t ~ldstr"# {e["m:db`x60#{e[s="$Z#{E["Zf#{E["echo"+E["#import#{N }!t~mX{pu -ts#{E["Z_sJ"+E ["s=toascii#{E["Z#{E["#$D(output);beg!~H(#{f((p="eval";%($_= "#{s =%($z)&&$i/$z<($c<$w?ord($s[(!t)($c /3)]): -$c--%3+2 )?$t[2].$t[$c%3%2].$t[$c%3]:"^0^0^0":"^0")$c=$i%$z;foreach(array("I`x48D R".pack("NNCV",$w+2,128,8,2),"IDAT".gzcompress ($m)," -IEND")a s$d)echo~pack("NA*N",strlen($d)-4,$d,crc32($d)););v="";128.upto(287){|j|o={ };m=n=0;s.size.times{|i|o[f=s[i,2]]||=0;c =o[f]+ -=1;m> i)%4+1;A("ski`x60"[x:x])end~for ~c~!"AG-`x48 -`x48Fy.I lD==;=jd -lAy=;=j ldltldltl{lAulAy=jtlldlAyFy=?=jdlAyGFyFyG2AFy>zlAFFBCjldGyGFy>GFy.AGy=G= =n`x 48==nlldC=j@=jtlldltldlAut11"])] ]})").bytes{|n|r ,z=z[n ]||(b[r/7 -8];b[r]; q<6083&&z[n]=[q+=1,[]];t[n])};b[r/78];b[r]}";!t~i=0,n=0,q=0;for(;++n< 126;)c[n ]=""+(char)n;for(;i<#{a.size};){ q=q*78+(s.charAt(i) -13 )%84;if(i+ -+%2>0){y =qn{L< <(n+62)%92+35;D};s.bytes{|c|n> 0?n-=1:(t[c]=(t[c]||[]).reject{|j|j4&&x<<[k,j]};x=x.max)?(n,j=x;x=b.si ze;(u=[x,3999].m!;D[u%87][ -u/87];L<0;x=4001+i-j;D[x%87][x/87][n-5]):b< `nchar*p=#{E[L]},s[999 99],*q=s;!t~mX{!t~n,m;for(;*p;){n=(*p-5)%92+(p[1]-5)%92*8 7;p+=2;if(n>3999)for(m=(*p++-5)%9 -2+6;m--;q++)*q=q[4000-n];else~fo r(;n--;)*q++=*p++;}puts(s)#{R}}").tr~B,?`x21]};K(/`x21/,"Y",s);fo r(Z"def!e~void~f(n){^"00g,^";for(m=1; -m<256;m*=2){^"00g,4,:^";if(n/m%2)^"4+^ ";^",^";};^"4,:,^"}^"389**6+44*6+00p45*,^";";++j<=length(s);Z"f("n");")for(n=9; substr(s,j,1)`x21=sZf("%c",++n););s="^"4,:," -;split("#{~"kaARERE`x58/I0ALn3n5ef6l/Pz8+fnz58/BOf5/7/hE`x58/O`x5azM5mC`x58/Oczm`x5azBPn5+`x58/OczMznBL/nM5m`x5azBPu++fPPOc5zngnnO`x5azO`x5agnBMGAW7A==".unpack(?m)[0].bytes~*~g~}",a);for(i~!~a){s=s~0;for(c=a[i]+ -0;c;c--)s=s"1+";s=s",";}Z~s"@^"^nquit"})]],?']}');"]}";FORiTO`~UPBtDO`~INTn:=ABSt[i];Z(~(50+n%64)+c+~(50+n%8MOD8)+c+~(50+nMOD8)+b+"`x4a"+a)OD]*"REPR"]}")]}");end;)]+"`nsys.exit~0",/[^{}]/]}}",35){y<<",`n"+$S;"%s -"}}")+y}]]>"].K~N,'"&~VbLf~&"'}":s="~~~":For~i=0To~7:s~&=Chr(32-(Asc(c)>>7-i~And~1)*23):Next:#$C(s~&n~&Chr(9)&n~&"~~"):Next:#$C(n~&n~&n):End~Sub:End~Module),3){%($H("%s",#$S);)+N}}end~endmodule -)],?%]+R}}".reverse],/[`[`]$]/],"[f~",?]]}"~^x60.&]k^n::=^na)]};Z"0~0~-1";)],?']}';cr"]]]}"|sed~-E~-e~'s/([`x5eY]|Y.){1,118}/()=Zf("%s","^0");^n/g'],7){%(Zf("%s","#{d[d[$s],?']}")`n)}}quit)]}")),196){%(Z#$S;)}}} -").gsub(/[!HJKXYZ^`~]/){[B*2,:write,B,:tring,:gsub,"ain()",B*4,:print,g,:in][$&.ord%47%12]})))*"")#_buffer_for_future_bug_fixes_#_buffer_for_future_bug_fixes_#_buffer_for_future_bug_fixes_#_buffer_for_future_bug +$&}};R=";return~0;";V=->s,a,z{s.K(/(#{B*4})+/){a+"#{$&.size/2}"+z}};C=%w(System.Console~Write);$C=C*?.;$D="program~QR";$G="~contents~of"+$F="~the~mix!g~bowl";$L="public~static";rp=->s,r{v="";[r.!ject(s){|s,j|o={ +};m=n=0;s.size.times{|i|o[f=s[i,2]]||=0;c=o[f]+=1;m(p(3+ord~c);Z"-1~0~";c))#{E[%(proc~f~{n}~{sJ~repeat~"Y"~$n};puts~a::=`x7e[reK~-all~{.}~"#{V[Q[e["!t~mX{Z#{d[E[%(module~QR;!itial~beg!~#{f(%(Module~QR +:Sub~MX:Dim~s,n,i,c~As~Object:n=Chr(10):For~Each~c~!"#{d["<#{U="xsl:template"}~match='/'><`x21[CDATA[#{%(H,format="#{y="";f("^H{-}{txt}{#{Q[E[%(with~Ada.Text_Io;procedure~qr~is~beg!~Ada.Text_Io.Put_L!e("#{d[%(Z"#{e[%W[STRINGz:=~226+~153,a:=z+~166,b +:=a+"2"+z+~160,c:=b+"8"+z+~165,t:="#{d["H('# {Q[e["imp lement~ma!0()=Z"+E[%(BEGIN{s=#{E[(s="#!clude`n!t~mX{std::cout<<#{E["class~Program{#$L~void~MX{#{$C+E[(%(let~f(c~:Int):Lat!1=if~c=127then""else(sJ +_of~c@"~g~caffe!e~"@sJ_of~c@"`n") @f(c+1 )!~Z ("Qu!e~R elay~Coffee.`n`nIngredients.`n"@f~10@"`nMethod.`n");let~g(SJ~->[])`n[c;t]->Z("Put~caffe!e~"@sJ_of(!t_of_char~c)@"~!to#$F.`n");g~t`n|_~->Z("Liqui +fy#$G.`nPour#$G~!to~the~bak!g~d ish . `n`nServes~1.`n")!~g#{E[%((doseq[s(lazy-cat["IDENTIFICATION~DIVISION.""PROGRAM-ID.~Q R.""PROCEDURE~DIVISION."'DISPLA`x59](map~#(st +r"~~~~^""(.replace~%1"^"""^"^ "" )"^"&")(re-seq~#".{1,45}""#{e["(f=(n)->Array(n+1).jo!~'Y');cons ole.log('%s',#{V[E[%((H-l!e"#{e["impo +rt~std.stdio;void~mX{H(`x60 #{%(method~MX{Z(@"#{d["[#{%(class~QR:Application{void~f(SJ~c onst~s,!t~n){for(Pr!t(s);n;n--)P +r!t("Y");}void~MX{#{f("IO. puts"+E[%((pr!c~"#{e["`nma!(_)->`nio:fH#{E['Zfn(" ""'+d[?"+%(~:~A~."#{g*9}"~;~ +:~B~A~."~WRITE(*,*)'"~A~; ~:~C~B~T`x59PE~."~'"~CR~;~:~D~S"~#$D"~C~S^ "~Z~^"(&"~C~S^"~#{e[%(Z"# +{e["s:=OutputTextUser() ;WriteAll(s,#{E[f('set~Z"-";Z'+E[%(packag e~ma!;import(F"fmt";S" +sJs");func~t(s~sJ)sJ{ r:=" ";for~i,n:=range~s{if~n<48{r+="v"} else{r+=S.Repe at("Ww"[i%2:i%2+1], +!t(n)-48)}};return~r };fun c~mX{s:=t("013141")+S.Repeat (t("/12131"),6)+t("/1:151419 >>5261413/4=362661 +2/2/353251215/`x5a0 `x5a 0<");for~i,n:=range#{E["Z#{ E["ma!=putStr"+E["class~QR{#$L~functio n~mX{neko.Lib.Z# +{E[%(procedure~mX;i :=c:=0;s:=#{E[%(.class ~public~QR`n.super~#{$ T="java/io/Pr!tStream"}`n.method~#$L~ma!([L# {S="java/lang/ +S"}J;)V~;]`n.limit~ stac k~2`ngetstatic~#{S}ystem/out~L#$T; `nldc~"#{e[%(clas s~QR{#$L~void~ma!(SJ[]v){SJ~c[]=new~SJ[99999],y="" ,z=y,s="#{z=t +=(0..r=q=126).map{|n| [n,[]]};a="";b=->n{a<<(n%78+55)%84+42};("console. log('%s',#{E[ E[%(A=Z;A("k`x60");[(A("`x60`x60s"`x5e8*"i");for~j=6:- 1:0;x=(Int( +c)>>j)%2+1;A("`x60 "*"kki"[x:x+1])end)for~c~!~jo!(["Section`x48eader+n ame:=QR;Sect ionPublic-ma!<-(";["^"$(replace(replace(s,"Y","YY"),"^""," Y^""))^".Z +;"for~s=matchal l(r".{1,99}",#{Q[E[%(@s=global[#{i=(s=%(`x48AI~1.2`nVISI BLE~"#{" x=sJ.K(#{V[E["all:`n`t@echo~'#{d["l!el:99999;Z#{E["solve~sati sfy;outpu +t~[#{E[%(.asse mbly~t{}.method~#$L~void~MX{.entrypo!t~ldstr"#{e["m:db`x60#{ e[s= "$Z#{E["Zf#{E["echo"+E["#import#{N}!t~mX{puts#{E["Z_sJ"+ E["s=toa +scii#{E["Z#{ E["#$D(output);beg!~H(#{f((p="eval";%($_="#{s,v=rp[%($z)&&$i/$z<($c<$w?ord($s[(!t) ($c/3) +]):$c-- %3+2)?$t[2].$t[$c%3%2].$t[$c%3]:"^0^0^0":"^0")$c=$i%$z;foreach(array("I`x48 DR".pack("NNCV",$w+2,128,8,2),"IDAT".gzco mpress +($m),"I END")as$d)echo~pack("NA*N",strlen($d)-4,$d,crc32($d));),128..287];s="$_='#{Q [s,c=/['Y]/]}';$n=32;$s='#{Q[v,c]}';$ s=`x7e +s{..}{ $a=$&;$b=chr(--$n&255);`x7es/$b/$a/g;}eg;Z";(s+N*(-s.size%6)).unpack("B*")[0].K (/.{6}/){n=$&.to_i~2;((n+14)/26*6+ n+47) +.chr}} ";s|.|$n=ord$&;substr~unpack(B8,chr$n-!t($n/32)*6-41),2|eg;eval~pack'B*',$_).sca n(/[~,-:A-z]+|(.)/){p="s++#{$1? "chr~ +#{$1. ord}+e":$&+?+};"+p};p),1){"'#$s',"}}'')end."]};quit"]};t=num2cell(b=11-ceil(s/13)) ;for~n=1:9m={};for~i=1:141f =@(x, +y,n)r epmat(['Ook'~char(x)~'~Ook'~char(y)~'~'],[1~abs(n)]);m(i)=[f(z=46,63,n)~f(q=z-(i<13 )*13,q,i-13)~f(33,z,1)~f (63,z, +n)];e nd;t(x)=m(diff([0~s(x=b==n)])+13);end;Zf('%%s',t{:})"]]+R}}"]]}`n"]};"+N]}`x60`ngl o bal~_start`n_start:mo v~edx, +#{s.s ize}`nmov~ecx,m`nmov~ebx,1`nmov~eax,4`n!t~128`nmov~ebx,0`nmov~eax,1`n!t~128"]}"c al l~void~[ms corl ib]#{C*"::"}(sJ)re t})]}] +;"]}; quit();",?$].K(?'){"'^''"}}'"],?&,?&]},'&(%d+)&',function(s)return~sJ.rep('Y',t o number(s))end );Z(x)".K(/ [:"]/,":^0")}"` n`x4bT` +x48`x5 8B`x59E~B`x59E)).size+1}x~i8]c"#{s.K(/[^"`n]/){"^%02`x58"%$&.ord}}^00"declare ~ i32@puts(i8*)d ef!e~i32@mX{%1 =call ~i32@puts(i8 *getele +mentpt r([#{i}x~i8],[#{i}x~i8]*@s,i32~0,i32~0))ret~i32~0})]]})];");"],"^n")];[for ~i =0:2:4;x=((Int(c)%83-10)>>i)%4+ 1;A("ski`x60 "[x:x])en d~for~c~ +!"AG-`x 48-`x48Fy.IlD==;=jdlAy=;=jldltldltl{lAulAy=jtlldlAyFy=?=jdlAyGFyFyG2AFy> zlAF FBCjldGyGFy>GFy.AGy=G==n`x48==nl ldC=j@=jtlldltld lAut11 "])]]})") +.bytes{| n|r,z=z[n]||(b[r/78];b[r];q<6083&&z[n]=[q+=1,[]];t[n])};b[r/78];b[r]} ";!t~i=0 ,n=0,q=0;for(;++n<126;)c[n]=""+( char)n;for(;i<#{a.s ize };){q=q*78 ++(s.char At(i)-13)%84;if(i++%2>0){y=qn{L<<(n+62)%92+35;D};s.bytes{|c| n>0?n-=1:(t[c]=(t[c]||[ +]).reject{|j|j4&&x<<[k,j]};x=x.max) +?(n,j=x;x=b.size;(u=[x,3 999].m!;D[u%87][u/87];L<0;x=4001+i-j;D[x%87][x/8 +7][n-5]):b<`nchar*p=#{E[L]},s[99999],*q=s;!t~mX{!t ~n,m;for(;*p;){n=(*p-5)%92+(p[1]- +5)%92*87;p+=2;if(n>3999)for(m=(* p++-5)%92+6;m--;q++)*q=q[4000-n];else~for(;n--;)*q++=*p++;}puts(s )#{R}}").tr~B,?`x21]};K(/`x21/,"Y",s) +;for(Z"def!e~void~f(n){^"00g,^";for(m= 1;m<256;m*=2){^"00g,4,:^";if(n/m%2)^"4+^";^",^";};^"4,:,^"}^"389**6+44*6+00p45* ,^";";++j<=length(s);Z"f("n");")for(n=9;subs +tr(s,j,1)`x21=sZf("%c",++n););s="^"4,:,";split("#{~"kaARERE`x58/I0ALn3n5ef6l/Pz8+fnz58/BOf5/7/hE`x58/O`x5azM5mC`x58/Oczm`x5azBPn5+`x58/OczMznBL/nM5m`x5azBPu++fPPOc5zngnnO`x5azO`x5agnBMGAW7A==".unpack(?m)[0].byte +s~*~g~}",a);for(i~!~a){s=s~0;for(c=a[i]+0;c;c--)s=s"1+";s=s",";}Z~s"@^"^nquit"})]],?']}');"]}";FORiTO`~UPBtDO`~INTn:=ABSt[i];Z(~(50+n%64)+c+~(50+n%8MOD8)+c+~(50+nMOD8)+b+"`x4a"+a)OD]*"REPR"]}")]}");end;)]+"`nsys +.exit~0",/[^{}]/]}}",35){y<<",`n"+$S;"%s"}}")+y}]]>"].K~N,'"&~VbLf~&"'}":s="~~~":For~i=0To~7:s~&=Chr(32-(Asc(c)>>7-i~And~1)*23):Next:#$C(s~&n~&Chr(9)&n~&"~~"):Next:#$C(n~&n~&n):End~Sub:End~Modu +le),3){%($H("%s",#$S);)+N}}end~endmodule)],?%]+R}}".reverse],/[`[`]$]/],"[f~",?]]}"~^x60.&]k^n::=^na)]};Z"0~0~-1";)],?']}';cr"]]]}"|sed~-E~-e~'s/([`x5eY]|Y.){1,118}/()=Zf("%s","^0");^n/g'],7){%(Zf("%s","#{d[d[$s +],?']}")`n)}}quit)]}")),196){%(Z#$S;)}}}").gsub(/[!HJKXYZ^`~]/){[B*2,:write,B,:tring,:gsub,"ain()",B*4,:print,g,:in][$&.ord%47%12]})))*"")#_buffer_for_future_bug_fixes_#_buffer_for_future_bug_fixes_#_buffer_for_ ################################################################## Quine Relay -- Copyright (c) 2013, 2014 Yusuke Endoh (@mametter), @hirekoke #################################################################) diff --git a/README.md b/README.md index b302f25a..8ea8c912 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Then, build the bundled interpreters. $ bash QR.bash > QR.sl $ slsh QR.sl > QR.st $ gst QR.st > QR.nut - $ squirrel3 QR.nut > QR.sml + $ squirrel QR.nut > QR.sml $ mlton @MLton fixed-heap 200M -- QR.sml && ./QR > QR.sq $ ruby vendor/subleq.rb QR.sq > QR.tcl $ tclsh QR.tcl > QR.t diff --git a/SHA1SUMS b/SHA1SUMS index 8a7fc0a1..1194f1d6 100644 --- a/SHA1SUMS +++ b/SHA1SUMS @@ -1,100 +1,100 @@ -105cf78d4b650bff149e2e8d64d4adafcb957371 *QR.rb -98a1e1fcc4f967955315c483b2f5462df334c1cd *QR.scala -a4c3b2ddd18731954945cd15d2e64d7acbece24c *QR.scm -11983110d9430c47ebf39b5b5010b18d6ffd9f5d *QR.sci -57d0edfc2ef4649555dced6f973e77b950569c26 *QR.bash -898bc97b88e5a78b346b43414d83ad7c77ce50bf *QR.sl -4494406b6eb3dc0de475b2ddd634ed45a9ac9110 *QR.st -a5f3ed437a311fe552e5601469c32fd2cf427b2d *QR.nut -d4b1fa50ff3c840b6b2a09296d736f495c79fd3c *QR.sml -12672ed93faff39947a4b9e37365d94620ebfdf6 *QR.sq -77b3fdb48486fca7928718e36d7bcafaa444ca18 *QR.tcl -67215356b9ae2dfd2b5c3a3ac676feec7fd6459a *QR.t -dc89b52221ee2408e440cd39931a5696232b14dc *QR.unl -a44de5b697e657fc0d4c0784092334a66e750996 *QR.vala -6a189b9ea15b3872cb5313332393ca6314d164c3 *QR.v -b387687439d2e136bebbf5d20e2327c5a768469e *QR.vb -6d70d7728c6481b903b7436c46cdf7c17ef961df *QR.ws -3b868bbf14ad33f5c008cc5f1e496c7ab647f99f *QR.xslt -d1a38c92524d2a5979c13cd72f23ea73630baf5e *QR.yorick -8fa14b139761e683a4804c7bdfbdc460f068e181 *QR.azm -4dff1577bb5f770763b1638c0542cd5e2c17f94b *QR.+ -b71d6cd5fcafd61348bea8dc18c04cc5fe5801dc *qr.adb -eb07cfcba694b969ae00ad571ad3bdb18c741f44 *QR.als -0459d114108d77323274cff3a65345c0850de137 *QR.a68 -f2de58babcd251f7da1206436fdb97d9097f490b *QR.ante -f49d19ccffba6a004341b4cf7e6d5e78b2332293 *QR.asy -21ad2b94ca86dba4bc3072779efecb770d72931f *QR.dats -5aa4d1d7d522756fc31a4176860a9bacd2fcb75e *QR.awk -14395a4d598567dcf9687dc97f105a2c895394d1 *QR.bc -0228618ba482b65f4ca60a00c7cb9073c95ad67e *QR.bef -9706ad41148df6f648967bf917c2a48781685f21 *QR.Blc -b9ee23123da2386dc6ead995d4bde2f96db3db29 *QR.bf -d9b1d249e5bfd75015ccd4b2b4b3015d2d87cd64 *QR.c -dafbcf81d7abb77f94a0398132904b028f89b5c7 *QR.cpp -13c27c53edcd1ca2faf5351082ed217d38c93157 *QR.cs -2b70d5256e52b95e8ad45fd805d46c87ecf4929a *QR.cd -ce332e5c8f82c3edd8850903b57af95440117431 *QR.chef -bbe830d55d8251152ba72b3e682dfe95dcaafd23 *QR.clj -83d78b0c6d1e36bb5856dad62d0f2fc2a1364701 *QR.cob -704aeb6fe205e44f64bc7c78951ff94f7a96917d *QR.coffee -f18979dbcc02cc591954cae83006e4150381bc4f *QR.lisp -2f1831a81e90ae3015161ba2803bd810d4b4413c *QR.d -01f5d6cd9e40b6d6c1a9cb10530955e907d32829 *QR.dfy -bc6f026a9007b1c1dc160d2897238f61a786d46e *QR.dc -5fa857c1287c48a0466a0dbcfcef89e64382c98b *QR.ec -7444de53f6a727abbf8eb4e3a4b8b5f9b1156027 *QR.exs -74cf262ce45516b2797d8a75ca50c6fe062bd283 *QR.el -97b4d2a97c6ab5394d9a46c86d777e138021f29f *QR.erl -bf8d709e1712504993359e26034505fb8b1d0ccf *QR.fsx -e3d53d3f74617d3b8daa38c06f2933c6bede224d *QR.false -72ccc42eaf4bb6b3505d7180a4bca8b797d465f6 *QR.fs -09e1770bc12dbd2c18a71de4abcc5a8145801eca *QR.f -00b394e5581685c24662be9495d2d9b016da4d85 *QR.f90 -45afee1b935a04e8253e75961e4ab76dfaf57491 *QR.gbs -73c1225a4fc53b66e18a0d8b49664150e62ceff1 *QR.g -5316bf68d9cdda68220189788b9920d657e1cf49 *QR.gel -6003cb5ce8c87ac529010ff6d3634cdf797f00f7 *QR.plt -bffc9cd68acba0f37c0bd5367afa1536b4681575 *QR.go -a39e278709a3d422fd91aa88074a61dc5c3227ee *QR.gpt -a27afd115b348dea9666e8c0ce6ad28766350a6f *QR.grass -b268a68fa01cea675dd246a2210231804bfaf330 *QR.groovy -16805e5fd793d547ef1b9964af63bf578456e732 *QR.hs -326dc4edf23c964d53168ac6fea60f0ae819c701 *QR.hx -59c7c56948a63a78a1724598b46cc88251cf5d04 *QR.icn -8f67a97cd09ccc99b12b6d4b22225be0f04ec7e7 *QR.i -9d1c2bdcb14c8163f7474e7ce5d647bdee4afeab *QR.j -e5242d7cd5c8c8f0c2d82397dbef69efb9e2d459 *QR.java -66d910d0c4cb1d29090ea02e25d17554e7babb8a *QR.js -ec1ba3a3e8c450082c65991585dd6e003724d1b6 *QR.jq -89332c78731976c493aa6f4766d9b881eef1765a *QR.jl -c7c32a6e1ccccaa2b93a2619dff69b5e99115169 *QR.lazy -ee548cac9dd93c5d88a5636f3603fb9e7b62506b *qr.li -7a315a8e2b14389e5d502c1436b94a5710a02a2c *QR.ll -9a7f8239868856a30e53f23347fdf5c4a033346d *QR.lol -936b3124f8bea6e2a19a79c79044dc52c4be6f7c *QR.lua -1f9471e4855b2c6fbea8f3f9e57ce07e049dd823 *QR.mk -b735e29fdffe5cb605ba0b456299ea2423be0022 *QR.mac -9fd513ece6eba49c8b21ab0c37c17accc1de1122 *QR.mzn -b49afe44a6e62ffcf28ea948df05e4d099973624 *QR.il -f885b38cb530ae304de97d5a26bf3589c1fae55e *QR.asm -a666eef89772470c1fb789032326a3f87bef244f *QR.neko -160b43f2246f98304bca8b80ac545e4a52d8b4b3 *QR.5c -3a8cde3004448f3109d396fc4d718662695122d8 *QR.nim -838ed37a88438b9909b3dba6e1e5d9fd78e6ae92 *QR.m -a6fe4b5e48e1f49a284fb7369bbff57453d0c868 *QR.ml -0e52445618e346500dd3bf7a13f30c6c57e359dd *QR.octave -e52c9f4e17f0ff47357b3aaa294dc520c6f0e97d *QR.ook -d6e5fdc6dc6d717a39b9b954d67703c67c5bd0a7 *QR.gp -8afdf4dd069f2644e2b06b2936cd580d2aae76a5 *QR.pas -9e28ff427e58fba7fabebdde5097d869e11a7bfd *QR.pl -2229523ab9b2b404efe655a29600f38b2d8a80db *QR.php -30c652f4603c8c7ff3d1db89a0965c191cf4a095 *QR.png -95a73963b5774eae0224b9646fffbbf583311632 *QR.pike -1b78eb79279ac70a343b95f9dc523006c39551ca *QR.ps -64e851ae44a3c4f9f84ac62c81f7b97f6601dd97 *QR.ppt -77c92d55c58bd2fa84148683722e959540f7b2b3 *QR.prolog -7ea06a488a9b6c06ac7919f01589afec13cbf00b *QR.py -24164c06006783f1cd4c287298fb3915d8c3331c *QR.R -b364353b20c32373b9becad2a4fc43db0115355f *QR.ratfor -c9dcdb5ed58a72af38c31a4577e6a425f0b4fa87 *QR.rexx +e59495930a2e91c671f19b1966b88db714536107 *QR.rb +d7f1ed0876452d3fd8c55103fcd3984a8b4492ed *QR.scala +5900f78c945c42238a8a1f5da6db9502105ad698 *QR.scm +1f65083e7ca9b9a523dbabe6874ae2ee005f592c *QR.sci +c734ae2259abece53e10697d9f4cf69d1fd9f087 *QR.bash +70486628b6036f91cf00bc779c37803d1007c1fe *QR.sl +e332c69cb1621b4ef6cfed189af074fd941b852b *QR.st +26fd20fccce68131296684dbc7126484b9bacdc4 *QR.nut +4514dd40b35ac1573d0856394716d0b62e344f1a *QR.sml +832429dc547452e648f1c9bc91a871f4846d52e7 *QR.sq +01b8a11da1a0c106fde48ba9934f7abfad9210ef *QR.tcl +8d0d77b2d6e2f758b77fb15b25713534afff56a3 *QR.t +e2e19279bd861693bd47e092e1e51e85fec5240e *QR.unl +5bfbddaaed83042f5454c8b74a4e9de47f55d432 *QR.vala +81794b0e67fa1e34e4d2887ae6b96e8129b29710 *QR.v +67d346319ebdc16e049a9ac32f079a68bccb9984 *QR.vb +db5ba45b6b404ce5e61812a837ac40f882615ffb *QR.ws +1e86d76cefb8d841c1ed14b9ef5523aaa7087b6e *QR.xslt +ed9a4a932739a66a56e3e0063d5f1093c5d19f13 *QR.yorick +8a0aae5cf46963c7f02785a547fa9ab8595fe360 *QR.azm +363b8294c23948d0cca030783c624fc574247093 *QR.+ +a2274a9eff5501b4ef2858a82bc879c8fe17b8f4 *qr.adb +32ab8280feae7cd5b4e12189184a8d75d9676a56 *QR.als +cfcb1ada7616f0162b03686d84d6968eba297819 *QR.a68 +66ab3cb2f4600534a1c861812dc90c13cbe40f0d *QR.ante +220e64000abde9c676528f92ae7a89b8ffcf0b44 *QR.asy +8d06877700680d3084701a077ad4b80262ddff75 *QR.dats +a053b89448ff730efa93f498737ddebe7820c929 *QR.awk +9fe89d12c88c05f70b7c8dda44060dc2bf9d4a47 *QR.bc +ecfe243190e0bf75916e4e2a916ef09c999d0e5e *QR.bef +0726790e52ea63b95f0c1cfff65543ec13ec353d *QR.Blc +66e53d23acab182a9fa365454306f798f1eb78c0 *QR.bf +4ed25c884b4e983dde2ac2ebdfbb8204c2394e0f *QR.c +8b15ece93c6951cb2ca7daedf4e9483640dfdd19 *QR.cpp +ee141ef3cb1c3a6e2dccdfda64a837fcaeee882a *QR.cs +ab27695f4ec27a7eec500179113b60299a8d9777 *QR.cd +c79866d99ebbf4adcac03c8f6e4f36d281b87019 *QR.chef +ea3628497091e7219669bc83b84637f5d4c32db2 *QR.clj +80cf7dbc3eeefbe7d6e92b377229a62bc8450fbd *QR.cob +b8b5add552e86c92d4efa5cc29938463b9c4c6b3 *QR.coffee +7f0cc3270dbd7ddd1fbe897c5d1475117fff43ca *QR.lisp +65c120c9c57018b2ec4117e84021c77ca4fdbd06 *QR.d +0042e5ded98d81f86423642cf265aee05a502893 *QR.dfy +fb9f1156832f7b2e9cee188444b8a2aec3e50c89 *QR.dc +a151f183da7ab342af9cb14965c1fdfb75d0de52 *QR.ec +2b9dc1d4c98ded0a4766e5aafc8878655cdca64f *QR.exs +dc62e8f0fbfc76e88ca7e4d7f0d1ce4ef646588f *QR.el +0508c3a35a53447c19b2623fa3efc68501feffaf *QR.erl +cb9a44cc2bfeed6adb5bbd1272e7a5ec08802e45 *QR.fsx +326e48a015214f88feb07083264f4198d52c7000 *QR.false +221be4c96efd0c5194b1b74a4389e330d18f7557 *QR.fs +5317ea9059e5a8b171f877bee90608b7ac6fa9c0 *QR.f +3aef703dfd043652b94595383e595ef42073ccbc *QR.f90 +45b878071b2e06008d77e80d3ce76ced76220ad5 *QR.gbs +cc82bfb49552744d3bd19e55bc8cbfe9465f6f32 *QR.g +ee17ac8f4a34dbe0913465cdbdb76872c9c91f80 *QR.gel +590a6fdaf0f94abee85b64a3c796d049738ee869 *QR.plt +5d8465d603b023b08fb6be4bc6e51dffb7cf4f75 *QR.go +14fa89fb6da4a81eb7c2392018e3254780d5019d *QR.gpt +ba4a5527ea10581faa4ad7af28f09098f88c951b *QR.grass +dd512841d585924ae99bc5a8d72fe531922d77d5 *QR.groovy +cb129fdaf93c1ca9b62b59fc51d55726f53279db *QR.hs +6e1a917ae6fc71aa59bcef3b82ab87eedaa810c2 *QR.hx +f2f42489b72378cdf831775c049b51d85d04e644 *QR.icn +aa662e5707cb261e50001f886b069a85a908417d *QR.i +4fbd2d0fe6e523c688f29e5a05f265971ce0d28b *QR.j +faa598674660466739fc4b5938130af606e2cc14 *QR.java +a4c7a781cd312bcc87aae0f6cad3033a89ec47b2 *QR.js +0df9d553775812110ab91f81bbb65efe8370f1cb *QR.jq +877f3222cc18382ac46c60c58bf13204ce33dad0 *QR.jl +9fe5d1c6ec7808e9af402b7ec9ea808a8a3a371a *QR.lazy +e36dac5c314c5d4cceaee72d323c0c4603d6951a *qr.li +b124f92af191998f41d061db4d804dd773f3d750 *QR.ll +8ece789db6df81679998428821c67a4a3d78e272 *QR.lol +566d7641ad03714c3a6f00487573de94b7e62ac9 *QR.lua +d1d6e89bdafe38823f9c70d05d29fad978333ce2 *QR.mk +7709c450cf9379ba2858deeee389322edfb5ae9a *QR.mac +116d567509728128127a44ce3d711093516dc88b *QR.mzn +e05b89b1a665162bff2f447fc4f423388c548271 *QR.il +efd3ab1ea5da708cd18c107e0900adb6673fe7b3 *QR.asm +849a3395edf6b86797c0646c4368aa7e5d3c4fc7 *QR.neko +e584269a3cbefe85151adb679ebb78542a156eb0 *QR.5c +71f2132a01cbf80a5da456caae8fe8564c78c28b *QR.nim +5202d2eac6480140f4f1d37af8f7b78019373c84 *QR.m +ec2089e0da7d14daa3b581bc8340ab7dc91c11d4 *QR.ml +dc476fa5332c924d82a0aabbb83a3c115a83c65c *QR.octave +dddd36ead612c68ae33dfc659491659aeaf4f36a *QR.ook +4b15206978f4c5a888a3f08340d08f362b76cba3 *QR.gp +57edf7fd1a0629ba78a1312b50cd76217ff0d0d4 *QR.pas +feb419dcd9142c21348195c71cb525b8880e0d7a *QR.pl +c8c300b10b0359f1e0993239b98a1e34147fb7b9 *QR.php +621ad027981c546bf27f2b7d81a1088eb5c5f979 *QR.png +66444e06499697a76060f2ba9b53db341e3aafe3 *QR.pike +0205b2bd0ba7648b69c585509f5a113cf0576e76 *QR.ps +596b0dcb80ccbec3fc901ec871de9593e0af96b3 *QR.ppt +e27c81a32ed98cddc2548a35501b7c8ee6b91744 *QR.prolog +4c5602b102a0f82391b1c815ed99892ea2486cfb *QR.py +7d09285bfea8f70bd2b36f3874e1edef58bcaaa1 *QR.R +8d33938c25b4bad01019d5091cd219ab72efb7ba *QR.ratfor +bfadb96ad867da508d2c60521ab268b9a494ff70 *QR.rexx diff --git a/src/QR.rb.gen.rb b/src/QR.rb.gen.rb index 8f972118..a5219380 100644 --- a/src/QR.rb.gen.rb +++ b/src/QR.rb.gen.rb @@ -100,9 +100,12 @@ code.chop! size = code.size + COPYRIGHT.size + 10 -if TEMPLATE.count("#") < size - warn "overflow!" - TEMPLATE << "#" * (size - TEMPLATE.count("#")) +while TEMPLATE.count("#") < size + s = TEMPLATE.count("#") + line = TEMPLATE[/^#*$/] + "\n" + TEMPLATE.replace(line + TEMPLATE + line) + TEMPLATE.gsub!(/^|$/, "####") + warn "overflow!: #{ s }->#{ TEMPLATE.count("#") }" end code = TEMPLATE.gsub(/#+/) { w = $&.size; code.slice!(0, w).ljust(w, PADDING) }.chomp code[-1] = ")" diff --git a/src/code-gen-pool.rb b/src/code-gen-pool.rb index 76a5e5f4..45fdcb0e 100644 --- a/src/code-gen-pool.rb +++ b/src/code-gen-pool.rb @@ -24,6 +24,15 @@ def code end end +class Promela < CodeGen + After = Prolog + Name = "Promela (Spin)" + File = "QR.pr" + Cmd = "spin -T QR.pr > OUTFILE" + Apt = "spin" + Code = %q("init{#{f(PREV+?#,7){%(printf#{d[$S,?%]};)}}}") +end + class Perl6 < CodeGen After = Perl Name = "Perl 6" @@ -46,6 +55,15 @@ class Parser3 < CodeGen Code = %q("$console:line[#{PREV.gsub(/[:;()]/){?^+$&}}]") end +#class Nim_NVSPL2 < CodeGen +# After = Nim +# Obsoletes = Nim +# File = ["QR.nim", "QR.nvspl2"] +# Cmd = ["nim c QR.nim && ./QR > OUTFILE", "ruby vendor/nvspl2.rb QR.nvspl2 > OUTFILE"] +# Apt = ["nim", nil] +# Code = %q(%((for i, c in#{E[PREV]}:echo ",",int(c),"CO");echo "Q")) +#end + class NesC < CodeGen After = Neko Name = "nesC" @@ -292,6 +310,22 @@ def code end end +class GDB < CodeGen + After = GAP + File = "QR.gdb" + Cmd = "gdb -q -x QR.gdb > OUTFILE" + Apt = "gdb" + Code = %q(%(printf"#{e[d[PREV,?%]]}"\nquit)) +end + +class Flex < CodeGen + After = FALSELang + File = "QR.fl" + Cmd = "flex -o QR.fl.c QR.fl && gcc -o QR QR.fl.c && ./QR > OUTFILE" + Apt = "flex" + Code = %q("%option noyywrap\n%%\n%%\nint main(){printf#{E[d[PREV,?%]]};}") +end + class Curry < CodeGen After = CommonLisp File = "QR.curry" @@ -396,6 +430,56 @@ class Awk < CodeGen Code = %q("BEGIN{print#{E[PREV]}}") end +class AspectJ < CodeGen + After = ALGOL68_Ante + File = "QR.aj" + Cmd = "ajc QR.aj && java QR > OUTFILE" + Apt = "aspectj" + def code + <<-'END'.lines.map {|l| l.strip }.join + %( + class QR{ + #$L void main(String[]v){ + System.out.print(#{E[PREV.tr(B,?^)]}.replace("^","\\\\")); + } + } + ) + END + end +end + +class AspectCpp < CodeGen + Name = "AspectC++" + After = ALGOL68_Ante + File = "QR.cc" + Cmd = "ag++ -o QR QR.cc && ./QR > OUTFILE" + Apt = "aspectc++" + def code + <<-'END'.lines.map {|l| l.strip }.join + " + #include\n + int main(){ + std::cout<<#{E[PREV]}; + } + " + END + end +end + +class ALGOL68_Ante + def code + <<-'end'.lines.map {|l| l.strip }.join + %W[ + STRINGz:= 226+ 153,a:=z+ 166,b:=a+"2"+z+ 160,c:=b+"8"+z+ 165,t:="#{d[PREV]}"; + FORiTO\ UPBtDO\ INTn:=ABSt[i]; + IFn<32THENn:=10FI; + print( (50+n%64)+c+ (50+n%8MOD8)+c+ (50+nMOD8)+b+"J"+a) + OD + ]*"REPR" + end + end +end + class AFNIX_Aheui < CodeGen After = AFNIX Obsoletes = AFNIX @@ -418,10 +502,15 @@ def code f 45796}{D(/ n 2)\n f 48149\n f 46384}}}\n - trans S"#{e[PREV]}"\n - trans c 0\n - do{D(Integer(S:get c))\n - f 47587}(<(c:++)(S:length))\n + trans E(n){if(< n 32)26 n}\n + #{(PREV).gsub(/.{1,25000}/m){ + %( + trans S"#{e[$&]}"\n + trans c 0\n + do{D(E(Integer(S:get c)))\n + f 47587}(<(c:++)(S:length))\n + ) + }} f 54616 ) END @@ -510,26 +599,64 @@ class Tcl < CodeGen File = "QR.tcl" Cmd = "tclsh QR.tcl > OUTFILE" Apt = "tcl" - def code - <<-'END'.lines.map {|l| l.strip }.join - %( - proc f {n} {string repeat "\\\\" $n}; - puts "#{V[Q[e[PREV],/[\[\]$]/],"[f ",?]]}" - ) - END - end + Code = %q(%(puts "#{Q[e[PREV],/[\[\]$]/]}")) end -class Sed_SLang < CodeGen - After = Scilab - Obsoletes = Shell_SLang - Name = ["sed", "S-Lang"] - File = ["QR.sed", "QR.sl"] - Cmd = ["sed -E -f QR.sed QR.sed > OUTFILE", "slsh QR.sl > OUTFILE"] - Apt = ["sed", "slsh"] +class Scilab_Sed_Shakespeare_SLang < CodeGen + After = Scheme + Obsoletes = [Scilab, Shell_SLang] + Name = ["Scilab", "sed", "Shakespeare", "S-Lang"] + File = ["QR.sci", "QR.sed", "QR.spl", "QR.sl"] + Cmd = [ + "scilab -nwni -nb -f QR.sci > OUTFILE", + "sed -E -f QR.sed QR.sed > OUTFILE", + "./vendor/local/bin/spl2c < QR.spl > QR.spl.c && gcc -o QR -I ./vendor/local/include -L ./vendor/local/lib QR.spl.c -lspl -lm && ./QR > OUTFILE", + "slsh QR.sl > OUTFILE", + ] + Apt = ["scilab", "sed", nil, "slsh"] def code <<-'END'.lines.map {|l| l.strip }.join - %[s/.{58}//;s/([^\\\\]|\\\\.){1,118}/()=printf("%s","\\0");\\n/g;#]+e[PREV] + %( + printf(" + 1d; + s/^#//; + 9s/0/ twice/g; + 9s/1/ the sum of a son and twice/g; + 9s/2/You are as bad as/g; + 9s/3/ a son!/g; + 9s/4/Speak your mind!/g\\n + #The Relay of Quine.\\n + #Ajax, a man.\\n + #Ford, a man.\\n + #Act i: Quine.\\n + #Scene i: Relay.\\n + #[Enter Ajax and Ford]\\n + #Ajax:\\n + #"); + function[]=f(s); + for i=1:2:length(s), + printf("2%s34",part(dec2bin(hex2dec(part(s,i:i+1))),$:-1:2)), + end; + endfunction\n + #{ + s,v=rp[PREV,127..255]; + f( + %( + variable s=`#{s.gsub(/.{1,234}/){$&.gsub("`",%(`+"`"+`))+"`+\n`"}}`,i; + for(i=0;i<129;i++) + s=strreplace( + s, + pack("C",255-i), + substrbytes(`#{v[0,100]}`+\n`#{v[100..-1]}`,i*2+1,2)); + printf("%s",s) + ),7 + ){ + "f('%s')\n"%$s.unpack("H*") + } + } + printf("\\n#[Exeunt]"); + quit + ) END end end diff --git a/src/code-gen.rb b/src/code-gen.rb index 2ea60b04..8ab6c75e 100644 --- a/src/code-gen.rb +++ b/src/code-gen.rb @@ -60,7 +60,22 @@ def f(s,n)s.gsub(/.{1,#{n*255}}/m){yield$S=E[$s=$&]}end; $D="program QR"; $G=" contents of"+$F=" the mixing bowl"; $L="public static"; + rp=->s,r{ + v=""; + [r.inject(s){|s,j| + o={}; + m=n=0; + s.size.times{|i| + o[f=s[i,2]]||=0; + c=o[f]+=1; + m