Skip to content

Commit

Permalink
Restore Scilab 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
mame committed Oct 21, 2019
1 parent ba54b4e commit 382c355
Showing 1 changed file with 37 additions and 27 deletions.
64 changes: 37 additions & 27 deletions src/code-gen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1417,16 +1417,16 @@ class Smalltalk < CodeGen
Code = %q("Transcript show: '#{d[PREV,?']}';cr")
end

class Scheme_Sed_Shakespeare_SLang < CodeGen
Name = ["Scheme", "sed", "Shakespeare", "S-Lang"]
File = ["QR.scm", "QR.sed", "QR.spl", "QR.sls"]
class Scilab_Sed_Shakespeare_SLang < CodeGen
Name = ["Scilab", "sed", "Shakespeare", "S-Lang"]
File = ["QR.sci", "QR.sed", "QR.spl", "QR.sl"]
Cmd = [
"$(SCHEME) QR.scm > OUTFILE",
"scilab-cli -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.sls > OUTFILE",
"slsh QR.sl > OUTFILE",
]
Apt = ["guile-2.0", "sed", nil, "slsh"]
Apt = ["scilab-cli", "sed", nil, "slsh"]
def code
# NOTE: This code does not work for a short or simple text.
# This assumes the input is so complex enough that
Expand All @@ -1437,7 +1437,7 @@ def code
# * The S-Lang program includes 8-bit characters and decompress the compression.
<<-'END'.lines.map {|l| l.strip }.join
%(
(display"
printf("
1d;
s/.//;
s/1/ the sum of a son and0/g;
Expand All @@ -1451,32 +1451,42 @@ def code
#Scene i: Relay.\\n
#[Enter Ajax and Ford]\\n
#Ajax:\\n
#")
(define(f n m)
(if(= n 1)
(display(+(* m 10)3))
(f(quotient n 2)(+(* m 10)(modulo n 2)))))
(define(g _ n)
(if(> n 0)
(g(f(modulo n 256)2)(quotient n 256))))
(g 0(string->number"#{
#");
function[]=f(s);
for i=1:2:length(s),
printf("2%s3",part(dec2bin(hex2dec(part(s,i:i+1))),$:-1:2)),
end;
endfunction\n
#{
s,v=rp[PREV,127..255];
%(
variable s=`#{s.gsub(/.{1,234}/){$&+"`+\n`"}}`,i;
for(i=0;i<129;i++)
s=strreplace(
s,
pack(`C`,255-i),
substrbytes(`#{v[0,99]}`+\n`#{v[99..-1]}`,i*2+1,2));
printf(`%s`,s)
).reverse.unpack1("H*")
}"16))
(display"\\n#[Exeunt]")
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,99]}`+\n`#{v[99..-1]}`,i*2+1,2));
printf("%s",s)
),7
){
"f('%s')\n"%$s.unpack("H*")
}
}
printf("\\n#[Exeunt]");
quit
)
END
end
end

class Scheme < CodeGen
File = "QR.scm"
Cmd = "$(SCHEME) QR.scm > OUTFILE"
Apt = "guile-2.0"
Code = %q(%((display "#{e[PREV]}")))
end

class Scala < CodeGen
File = "QR.scala"
Cmd = "scalac QR.scala && scala QR > OUTFILE"
Expand Down

0 comments on commit 382c355

Please sign in to comment.