mirror of
https://github.com/false-schemers/skint.git
synced 2024-12-26 21:58:51 +01:00
run-script, some t.scm procs moved to s.scm
This commit is contained in:
parent
0763791fe3
commit
b3567d8b61
4 changed files with 263 additions and 205 deletions
274
s.c
274
s.c
|
@ -372,6 +372,31 @@ char *s_code[] = {
|
||||||
|
|
||||||
"A", "cons*", "list*",
|
"A", "cons*", "list*",
|
||||||
|
|
||||||
|
"P", "list-diff",
|
||||||
|
"%2.0u,.0?{.0}{.2,.2q}_1?{n]2}${.3,.3d,@(y9:list-diff)[02},.1ac]2",
|
||||||
|
|
||||||
|
"P", "list-head",
|
||||||
|
"%2.1,.1,,#0.0,&1{%2.1=0?{n]2}${'1,.4-,.3d,:0^[02},.1ac]2}.!0.0^_1[22",
|
||||||
|
|
||||||
|
"P", "andmap",
|
||||||
|
"%2.1p?{${.3a,.3[01}?{.1d,.1,@(y6:andmap)[22}f]2}t]2",
|
||||||
|
|
||||||
|
"P", "ormap",
|
||||||
|
"%2.1p?{${.3a,.3[01},.0?{.0]3}.2d,.2,@(y5:ormap)[32}f]2",
|
||||||
|
|
||||||
|
"P", "memp",
|
||||||
|
"%2.1p?{${.3a,.3[01}?{.1]2}.1d,.1,@(y4:memp)[22}f]2",
|
||||||
|
|
||||||
|
"P", "assp",
|
||||||
|
"%2.1p?{${.3aa,.3[01}?{.1a]2}.1d,.1,@(y4:assp)[22}f]2",
|
||||||
|
|
||||||
|
"P", "posq",
|
||||||
|
"%2'0,.2,,#0.0,.4,&2{%2.0u?{f]2}.0a,:0q?{.1]2}'1,.2I+,.1d,:1^[22}.!0.0^"
|
||||||
|
"_1[22",
|
||||||
|
|
||||||
|
"P", "rassq",
|
||||||
|
"%2.1p?{.1a,.0d,.2q?{.0]3}.2d,.2,@(y5:rassq)[32}f]2",
|
||||||
|
|
||||||
"P", "substring->list",
|
"P", "substring->list",
|
||||||
"%3n,'1,.4I-,,#0.3,.1,.6,&3{%2:0,.1I<?{.1]2}.1,.1,:2S4c,'1,.2I-,:1^[22}"
|
"%3n,'1,.4I-,,#0.3,.1,.6,&3{%2:0,.1I<?{.1]2}.1,.1,:2S4c,'1,.2I-,:1^[22}"
|
||||||
".!0.0^_1[32",
|
".!0.0^_1[32",
|
||||||
|
@ -438,6 +463,11 @@ char *s_code[] = {
|
||||||
"1:x;;;l2:l3:y1:_;y1:x;y1:y;;l3:y10:string-cat;y1:x;y1:y;;;l2:py1:_;y1:"
|
"1:x;;;l2:l3:y1:_;y1:x;y1:y;;l3:y10:string-cat;y1:x;y1:y;;;l2:py1:_;y1:"
|
||||||
"r;;py14:%25string-append;y1:r;;;l2:y1:_;y14:%25string-append;;",
|
"r;;py14:%25string-append;y1:r;;;l2:y1:_;y14:%25string-append;;",
|
||||||
|
|
||||||
|
"P", "string-trim-whitespace",
|
||||||
|
"%1.0S3,'0,,#0.3,.1,&2{%2.1,.1<?{.0,:1S4C1}{f}?{.1,'1,.2+,:0^[22}.1,,#0"
|
||||||
|
".2,:1,.5,.3,&4{%1:3,.1>?{'1,.1-,:2S4C1}{f}?{'1,.1-,:0^[11}'0,:3=?{:1,."
|
||||||
|
"1=}{f}?{:2]1}.0,:3,:2S7]1}.!0.0^_1[21}.!0.0^_1[12",
|
||||||
|
|
||||||
"P", "subvector->list",
|
"P", "subvector->list",
|
||||||
"%3n,'1,.4I-,,#0.3,.1,.6,&3{%2:0,.1I<?{.1]2}.1,.1,:2V4c,'1,.2I-,:1^[22}"
|
"%3n,'1,.4I-,,#0.3,.1,.6,&3{%2:0,.1I<?{.1]2}.1,.1,:2V4c,'1,.2I-,:1^[22}"
|
||||||
".!0.0^_1[32",
|
".!0.0^_1[32",
|
||||||
|
@ -891,127 +921,129 @@ char *s_code[] = {
|
||||||
"tevector)[12}%x,&2{|10|21%%}@!(y15:read-bytevector)",
|
"tevector)[12}%x,&2{|10|21%%}@!(y15:read-bytevector)",
|
||||||
|
|
||||||
"P", "%read",
|
"P", "%read",
|
||||||
"%2,,,,,,,,,,,,,,,,,,,,,,,#0#1#2#3#4#5#6#7#8#9#(i10)#(i11)#(i12)#(i13)#"
|
"%2,,,,,,,,,,,,,,,,,,,,,,,,#0#1#2#3#4#5#6#7#8#9#(i10)#(i11)#(i12)#(i13)"
|
||||||
"(i14)#(i15)#(i16)#(i17)#(i18)#(i19)#(i20)#(i21)#(i22).(i23)P78.!0n.!1&"
|
"#(i14)#(i15)#(i16)#(i17)#(i18)#(i19)#(i20)#(i21)#(i22)#(i23).(i24)P78."
|
||||||
"0{%1.0,&1{%0:0z]0}]1}.!2&0{%1.0K0]1}.!3.4,&1{%1.0K0?{${.2[00},:0^[11}."
|
"!0n.!1&0{%1.0,&1{%0:0z]0}]1}.!2&0{%1.0K0]1}.!3.4,&1{%1.0K0?{${.2[00},:"
|
||||||
"0]1}.!4.5,.5,&2{%1.0p?{.0aK0?{${.2a,:0^[01},.1sa}{${.2a,:1^[01}}.0dK0?"
|
"0^[11}.0]1}.!4.5,.5,&2{%1.0p?{.0aK0?{${.2a,:0^[01},.1sa}{${.2a,:1^[01}"
|
||||||
"{${.2d,:0^[01},.1sd]1}.0d,:1^[11}.0V0?{'0,,#0.2,:0,:1,.3,&4{%1:3V3,.1I"
|
"}.0dK0?{${.2d,:0^[01},.1sd]1}.0d,:1^[11}.0V0?{'0,,#0.2,:0,:1,.3,&4{%1:"
|
||||||
"<?{.0,:3V4,.0K0?{${.2,:2^[01},.2,:3V5}{${.2,:1^[01}}_1'1,.1I+,:0^[11}]"
|
"3V3,.1I<?{.0,:3V4,.0K0?{${.2,:2^[01},.2,:3V5}{${.2,:1^[01}}_1'1,.1I+,:"
|
||||||
"1}.!0.0^_1[11}.0Y2?{.0zK0?{${.2z,:1^[01},.1sz]1}.0z,:1^[11}f]1}.!5.5,&"
|
"0^[11}]1}.!0.0^_1[11}.0Y2?{.0zK0?{${.2z,:1^[01},.1sz]1}.0z,:1^[11}f]1}"
|
||||||
"1{%1${.2,:0^[01}.0]1}.!6f.!7f.!8f.!9f.!(i10)'(y12:reader-token),l1,.0."
|
".!5.5,&1{%1${.2,:0^[01}.0]1}.!6f.!7f.!8f.!9f.!(i10)'(y12:reader-token)"
|
||||||
"!8'(s17:right parenthesis),.1c.!9'(s13:right bracket),.1c.!(i10)'(s5:%"
|
",l1,.0.!8'(s17:right parenthesis),.1c.!9'(s13:right bracket),.1c.!(i10"
|
||||||
"22 . %22),.1c.!(i11)_1.7,&1{%1.0p?{:0^,.1aq]1}f]1}.!(i11)&0{%1'(s80:AB"
|
")'(s5:%22 . %22),.1c.!(i11)_1.7,&1{%1.0p?{:0^,.1aq]1}f]1}.!(i11)&0{%1'"
|
||||||
"CDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!$%25&*/:<=>?^_~0123"
|
"(s80:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!$%25&*/:<=>?"
|
||||||
"456789+-.@),.1S8]1}.!(i12)&0{%1.0X8,'(i48),.1<!?{'(i57),.1>!}{f},.0?{."
|
"^_~0123456789+-.@),.1S8]1}.!(i12)&0{%1.0X8,'(i48),.1<!?{'(i57),.1>!}{f"
|
||||||
"0]3}'(i65),.2<!?{'(i70),.2>!}{f},.0?{.0]4}'(i97),.3<!?{'(i102),.3>!]4}"
|
"},.0?{.0]3}'(i65),.2<!?{'(i70),.2>!}{f},.0?{.0]4}'(i97),.3<!?{'(i102),"
|
||||||
"f]4}.!(i13)&0{%1.0C1,.0?{.0]2}'(c)),.2C=,.0?{.0]3}'(c(),.3C=,.0?{.0]4}"
|
".3>!]4}f]4}.!(i13)&0{%1.0C1,.0?{.0]2}'(c)),.2C=,.0?{.0]3}'(c(),.3C=,.0"
|
||||||
"'(c]),.4C=,.0?{.0]5}'(c[),.5C=,.0?{.0]6}'(c%22),.6C=,.0?{.0]7}'(c;),.7"
|
"?{.0]4}'(c]),.4C=,.0?{.0]5}'(c[),.5C=,.0?{.0]6}'(c%22),.6C=,.0?{.0]7}'"
|
||||||
"C=]7}.!(i14).(i16),.(i12),&2{%1${.2,:1^[01},.0R8?{.1,'(y5:port:),'(s22"
|
"(c;),.7C=]7}.!(i14).(i17),.(i12),&2{%1${.2,:1^[01},.0R8?{.1,'(y5:port:"
|
||||||
":unexpected end of file),@(y10:read-error)[23}${.2,:0^[01}?{.1,'(y5:po"
|
"),'(s22:unexpected end of file),@(y10:read-error)[23}${.2,:0^[01}?{.1,"
|
||||||
"rt:),.2d,'(s17:unexpected token:),@(y10:read-error)[24}.0]2}.!(i15).9,"
|
"'(y5:port:),.2d,'(s17:unexpected token:),@(y10:read-error)[24}.0]2}.!("
|
||||||
".(i13),.(i21),.3,.(i26),.(i21),.(i14),.(i24),.(i26),.(i29),.(i24),.(i1"
|
"i15).(i15),&1{%1'(c ),.1R1v?{${${.4,@(y9:read-line)[01},@(y22:string-t"
|
||||||
"4),.(i27),.(i15),.(i15),.(i39),&(i16){%1.0R0,.0R8?{.0]2}.0C1?{.1,:(i10"
|
"rim-whitespace)[01}X5]1}.0,:0^[11}.!(i16).9,.(i13),.(i22),.3,.(i20),.("
|
||||||
")^[21}'(c(),.1C=?{t,:9^,.3,.3,:8^[24}'(c)),.1C=?{:9^]2}'(c[),.1C=?{t,:"
|
"i28),.(i23),.(i15),.(i26),.(i28),.(i31),.(i25),.(i15),.(i28),.(i16),.("
|
||||||
"(i15)^,.3,.3,:8^[24}'(c]),.1C=?{:(i15)^]2}'(c'),.1C=?{${.3,:3^[01},'(y"
|
"i16),.(i41),&(i17){%1.0R0,.0R8?{.0]2}.0C1?{.1,:(i10)^[21}'(c(),.1C=?{t"
|
||||||
"5:quote),l2]2}'(c`),.1C=?{${.3,:3^[01},'(y10:quasiquote),l2]2}${.2,:(i"
|
",:9^,.3,.3,:8^[24}'(c)),.1C=?{:9^]2}'(c[),.1C=?{t,:(i16)^,.3,.3,:8^[24"
|
||||||
"14)^[01}?{.1,.1,:(i11)^[22}'(c;),.1C=?{${.3R0,,#0.5,.1,&2{%1.0R8,.0?{."
|
"}'(c]),.1C=?{:(i16)^]2}'(c'),.1C=?{${.3,:3^[01},'(y5:quote),l2]2}'(c`)"
|
||||||
"0]2}'(c%0a),.2C=,.0?{.0]3}:1R0,:0^[31}.!0.0^_1[01}.1,:(i10)^[21}'(c,),"
|
",.1C=?{${.3,:3^[01},'(y10:quasiquote),l2]2}${.2,:(i15)^[01}?{.1,.1,:(i"
|
||||||
".1C=?{.1R1,.0R8?{.2,'(y5:port:),'(s19:end of file after ,),@(y10:read-"
|
"11)^[22}'(c;),.1C=?{${.3R0,,#0.5,.1,&2{%1.0R8,.0?{.0]2}'(c%0a),.2C=,.0"
|
||||||
"error)[33}'(c@),.1C=?{.2R0${.4,:3^[01},'(y16:unquote-splicing),l2]3}${"
|
"?{.0]3}:1R0,:0^[31}.!0.0^_1[01}.1,:(i10)^[21}'(c,),.1C=?{.1R1,.0R8?{.2"
|
||||||
".4,:3^[01},'(y7:unquote),l2]3}'(c%22),.1C=?{n,,#0.3,:(i13),.2,&3{%1:2R"
|
",'(y5:port:),'(s19:end of file after ,),@(y10:read-error)[33}'(c@),.1C"
|
||||||
"0,.0R8?{:2,'(y5:port:),'(s27:end of file within a string),@(y10:read-e"
|
"=?{.2R0${.4,:3^[01},'(y16:unquote-splicing),l2]3}${.4,:3^[01},'(y7:unq"
|
||||||
"rror)[23}'(c%5c),.1C=?{${'(y6:string),:2,:1^[02},.0?{.2,.1c}{.2},:0^[3"
|
"uote),l2]3}'(c%22),.1C=?{n,,#0.3,:(i14),.2,&3{%1:2R0,.0R8?{:2,'(y5:por"
|
||||||
"1}'(c%22),.1C=?{.1A9X3]2}.1,.1c,:0^[21}.!0.0^_1[21}'(c|),.1C=?{n,,#0.3"
|
"t:),'(s27:end of file within a string),@(y10:read-error)[23}'(c%5c),.1"
|
||||||
",:(i13),.2,&3{%1:2R0,.0R8?{:2,'(y5:port:),'(s29:end of file within a |"
|
"C=?{${'(y6:string),:2,:1^[02},.0?{.2,.1c}{.2},:0^[31}'(c%22),.1C=?{.1A"
|
||||||
"symbol|),@(y10:read-error)[23}'(c%5c),.1C=?{${'(y6:symbol),:2,:1^[02},"
|
"9X3]2}.1,.1c,:0^[21}.!0.0^_1[21}'(c|),.1C=?{n,,#0.3,:(i14),.2,&3{%1:2R"
|
||||||
".0?{.2,.1c}{.2},:0^[31}'(c|),.1C=?{.1A9X3X5]2}.1,.1c,:0^[21}.!0.0^_1[2"
|
"0,.0R8?{:2,'(y5:port:),'(s29:end of file within a |symbol|),@(y10:read"
|
||||||
"1}'(c#),.1C=?{.1R1,.0R8?{.2,'(y5:port:),'(s19:end of file after #),@(y"
|
"-error)[23}'(c%5c),.1C=?{${'(y6:symbol),:2,:1^[02},.0?{.2,.1c}{.2},:0^"
|
||||||
"10:read-error)[33}'(c!),.1C=?{.2R0${.4,:3^[01},.0,'(l2:y9:fold-case;y1"
|
"[31}'(c|),.1C=?{.1A9X3X5]2}.1,.1c,:0^[21}.!0.0^_1[21}'(c#),.1C=?{.1R1,"
|
||||||
"2:no-fold-case;),.1A1?{'(y9:fold-case),.2q:!(i12):(i12)^,.5P79.4,:(i10"
|
".0R8?{.2,'(y5:port:),'(s19:end of file after #),@(y10:read-error)[33}'"
|
||||||
")^[51}.1Y0?{.1Y6]5}.4,'(y5:port:),.3,'(s24:unexpected name after #!),@"
|
"(c!),.1C=?{.2R0${.4,:(i12)^[01},.0,'(l2:y9:fold-case;y12:no-fold-case;"
|
||||||
"(y10:read-error)[54}'(ct),.1Ci=,.0?{.0}{'(cf),.2Ci=}_1?{${.4,:3^[01},."
|
"),.1A1?{'(y9:fold-case),.2q:!(i13):(i13)^,.5P79.4,:(i10)^[51}.1Y0?{.1Y"
|
||||||
"0,'(l2:y1:t;y4:true;),.1A1?{t]5}'(l2:y1:f;y5:false;),.1A1?{f]5}.4,'(y5"
|
"6]5}.4,'(y5:port:),.3,'(s24:unexpected name after #!),@(y10:read-error"
|
||||||
":port:),.3,'(s23:unexpected name after #),@(y10:read-error)[54}'(cb),."
|
")[54}'(ct),.1Ci=,.0?{.0}{'(cf),.2Ci=}_1?{${.4,:3^[01},.0,'(l2:y1:t;y4:"
|
||||||
"1Ci=,.0?{.0}{'(co),.2Ci=,.0?{.0}{'(cd),.3Ci=,.0?{.0}{'(cx),.4Ci=,.0?{."
|
"true;),.1A1?{t]5}'(l2:y1:f;y5:false;),.1A1?{f]5}.4,'(y5:port:),.3,'(s2"
|
||||||
"0}{'(ci),.5Ci=,.0?{.0}{'(ce),.6Ci=}_1}_1}_1}_1}_1?{.2,'(c#),:(i11)^[32"
|
"3:unexpected name after #),@(y10:read-error)[54}'(cb),.1Ci=,.0?{.0}{'("
|
||||||
"}'(c&),.1C=?{.2R0${.4,:3^[01}b]3}'(c;),.1C=?{.2R0${.4,:3^[01}.2,:(i10)"
|
"co),.2Ci=,.0?{.0}{'(cd),.3Ci=,.0?{.0}{'(cx),.4Ci=,.0?{.0}{'(ci),.5Ci=,"
|
||||||
"^[31}'(c|),.1C=?{.2R0${,#0.5,.1,&2{%0:1R0,.0R8?{:1,'(y5:port:),'(s25:e"
|
".0?{.0}{'(ce),.6Ci=}_1}_1}_1}_1}_1?{.2,'(c#),:(i11)^[32}'(c&),.1C=?{.2"
|
||||||
"nd of file in #| comment),@(y10:read-error)[13}'(c|),.1C=?{:1R1,.0R8?{"
|
"R0${.4,:3^[01}b]3}'(c;),.1C=?{.2R0${.4,:3^[01}.2,:(i10)^[31}'(c|),.1C="
|
||||||
":1,'(y5:port:),'(s25:end of file in #| comment),@(y10:read-error)[23}'"
|
"?{.2R0${,#0.5,.1,&2{%0:1R0,.0R8?{:1,'(y5:port:),'(s25:end of file in #"
|
||||||
"(c#),.1C=?{:1R0]2}:0^[20}'(c#),.1C=?{:1R1,.0R8?{:1,'(y5:port:),'(s25:e"
|
"| comment),@(y10:read-error)[13}'(c|),.1C=?{:1R1,.0R8?{:1,'(y5:port:),"
|
||||||
"nd of file in #| comment),@(y10:read-error)[23}'(c|),.1C=?{:1R0${:0^[0"
|
"'(s25:end of file in #| comment),@(y10:read-error)[23}'(c#),.1C=?{:1R0"
|
||||||
"0}:0^[20}:0^[20}:0^[10}.!0.0^_1[00}.2,:(i10)^[31}'(c(),.1C=?{.2R0${f,:"
|
"]2}:0^[20}'(c#),.1C=?{:1R1,.0R8?{:1,'(y5:port:),'(s25:end of file in #"
|
||||||
"9^,.6,.5,:8^[04}X1]3}'(cu),.1C=?{.2R0'(c8),.3R0q?{'(c(),.3R0q}{f}?{${."
|
"| comment),@(y10:read-error)[23}'(c|),.1C=?{:1R0${:0^[00}:0^[20}:0^[20"
|
||||||
"4,:7^[01}E1]3}.2,'(y5:port:),'(s25:invalid bytevector syntax),@(y10:re"
|
"}:0^[10}.!0.0^_1[00}.2,:(i10)^[31}'(c(),.1C=?{.2R0${f,:9^,.6,.5,:8^[04"
|
||||||
"ad-error)[33}'(c%5c),.1C=?{.2R0.2R1,.0R8?{.3,'(y5:port:),'(s20:end of "
|
"}X1]3}'(cu),.1C=?{.2R0'(c8),.3R0q?{'(c(),.3R0q}{f}?{${.4,:7^[01}E1]3}."
|
||||||
"file after #%5c),@(y10:read-error)[43}.0,'(cx)C=?{.3R0${.5R1,:5^[01}?{"
|
"2,'(y5:port:),'(s25:invalid bytevector syntax),@(y10:read-error)[33}'("
|
||||||
".0]4}f,.4,:6^[42}.0C4?{${.5,:3^[01},'1,.1X4S3=?{.1]5}.0,'(y4:null),.1v"
|
"c%5c),.1C=?{.2R0.2R1,.0R8?{.3,'(y5:port:),'(s20:end of file after #%5c"
|
||||||
"?{'0X9]6}'(y5:space),.1v?{'(c )]6}'(y5:alarm),.1v?{'(c%07)]6}'(y9:back"
|
"),@(y10:read-error)[43}.0,'(cx)C=?{.3R0${.5R1,:5^[01}?{.0]4}f,.4,:6^[4"
|
||||||
"space),.1v?{'(c%08)]6}'(y6:delete),.1v?{'(i127)X9]6}'(y6:escape),.1v?{"
|
"2}.0C4?{${.5,:3^[01},'1,.1X4S3=?{.1]5}.0,'(y4:null),.1v?{'0X9]6}'(y5:s"
|
||||||
"'(i27)X9]6}'(y3:tab),.1v?{'(c%09)]6}'(l2:y7:newline;y8:linefeed;),.1A1"
|
"pace),.1v?{'(c )]6}'(y5:alarm),.1v?{'(c%07)]6}'(y9:backspace),.1v?{'(c"
|
||||||
"?{'(c%0a)]6}'(y4:vtab),.1v?{'(c%0b)]6}'(y4:page),.1v?{'(c%0c)]6}'(y6:r"
|
"%08)]6}'(y6:delete),.1v?{'(i127)X9]6}'(y6:escape),.1v?{'(i27)X9]6}'(y3"
|
||||||
"eturn),.1v?{'(c%0d)]6}.5,'(y5:port:),.3,'(s15:unknown #%5c name),@(y10"
|
":tab),.1v?{'(c%09)]6}'(l2:y7:newline;y8:linefeed;),.1A1?{'(c%0a)]6}'(y"
|
||||||
":read-error)[64}.3R0.0]4}.0C5?{:0?{${.4,'(y5:port:),'(s44:#N=/#N# nota"
|
"4:vtab),.1v?{'(c%0b)]6}'(y4:page),.1v?{'(c%0c)]6}'(y6:return),.1v?{'(c"
|
||||||
"tion is not allowed in this mode),@(y10:read-error)[03}}n,,#0.4,.1,:4,"
|
"%0d)]6}.5,'(y5:port:),.3,'(s15:unknown #%5c name),@(y10:read-error)[64"
|
||||||
":3,:2,:1,&6{%1:5R0,.0R8?{:5,'(y5:port:),'(s32:end of file within a #N "
|
"}.3R0.0]4}.0C5?{:0?{${.4,'(y5:port:),'(s44:#N=/#N# notation is not all"
|
||||||
"notation),@(y10:read-error)[23}.0C5?{.1,.1c,:4^[21}'(c#),.1C=?{.1A9X3,"
|
"owed in this mode),@(y10:read-error)[03}}n,,#0.4,.1,:4,:3,:2,:1,&6{%1:"
|
||||||
"'(i10),.1E9,.0I0?{:0^,.1A3}{f},.0?{.0d]5}'(s22:unknown #n# reference:)"
|
"5R0,.0R8?{:5,'(y5:port:),'(s32:end of file within a #N notation),@(y10"
|
||||||
",'(y5:port:),.4,@(y10:read-error)[53}'(c=),.1C=?{.1A9X3,'(i10),.1E9,.0"
|
":read-error)[23}.0C5?{.1,.1c,:4^[21}'(c#),.1C=?{.1A9X3,'(i10),.1E9,.0I"
|
||||||
"I0~?{${'(s22:invalid #n= reference:),'(y5:port:),.5,@(y10:read-error)["
|
"0?{:0^,.1A3}{f},.0?{.0d]5}'(s22:unknown #n# reference:),'(y5:port:),.4"
|
||||||
"03}}{:0^,.1A3?{${'(s18:duplicate #n= tag:),'(y5:port:),.4,@(y10:read-e"
|
",@(y10:read-error)[53}'(c=),.1C=?{.1A9X3,'(i10),.1E9,.0I0~?{${'(s22:in"
|
||||||
"rror)[03}}{f}}fb,:0^,${.3,:1^[01},.3cc:!0${:5,:2^[01},${.2,:3^[01}?{'("
|
"valid #n= reference:),'(y5:port:),.5,@(y10:read-error)[03}}{:0^,.1A3?{"
|
||||||
"s31:#n= has another label as target),'(y5:port:),.5,@(y10:read-error)["
|
"${'(s18:duplicate #n= tag:),'(y5:port:),.4,@(y10:read-error)[03}}{f}}f"
|
||||||
"63}.0,.2sz.0]6}:5,'(y5:port:),'(s34:invalid terminator for #N notation"
|
"b,:0^,${.3,:1^[01},.3cc:!0${:5,:2^[01},${.2,:3^[01}?{'(s31:#n= has ano"
|
||||||
"),@(y10:read-error)[23}.!0.0^_1[31}.2,'(y5:port:),.2,'(s16:unknown # s"
|
"ther label as target),'(y5:port:),.5,@(y10:read-error)[63}.0,.2sz.0]6}"
|
||||||
"yntax),@(y10:read-error)[34}.1,'(y5:port:),.2,'(s22:illegal character "
|
":5,'(y5:port:),'(s34:invalid terminator for #N notation),@(y10:read-er"
|
||||||
"read),@(y10:read-error)[24}.!(i16).(i16),.(i12),.(i17),.(i13),&4{%4${."
|
"ror)[23}.!0.0^_1[31}.2,'(y5:port:),.2,'(s16:unknown # syntax),@(y10:re"
|
||||||
"3,:3^[01},:0^,.1q?{.2,'(y5:port:),'(s42:missing car -- ( immediately f"
|
"ad-error)[34}.1,'(y5:port:),.2,'(s22:illegal character read),@(y10:rea"
|
||||||
"ollowed by .),@(y10:read-error)[53}.0,,#0.0,.5,:3,:2,.(i10),:1,.(i11),"
|
"d-error)[24}.!(i17).(i17),.(i12),.(i17),.(i13),&4{%4${.3,:3^[01},:0^,."
|
||||||
":0,&8{%1.0R8?{:6,'(y5:port:),'(s41:eof inside list -- unbalanced paren"
|
"1q?{.2,'(y5:port:),'(s42:missing car -- ( immediately followed by .),@"
|
||||||
"theses),@(y10:read-error)[13}:1,.1q?{n]1}:0^,.1q?{:3?{${:6,:2^[01},${:"
|
"(y10:read-error)[53}.0,,#0.0,.5,:3,:2,.(i10),:1,.(i11),:0,&8{%1.0R8?{:"
|
||||||
"6,:5^[01},:1,.1q?{.1]3}:6,'(y5:port:),.2,'(s31:randomness after form a"
|
"6,'(y5:port:),'(s41:eof inside list -- unbalanced parentheses),@(y10:r"
|
||||||
"fter dot),@(y10:read-error)[34}:6,'(y5:port:),'(s13:dot in #(...)),@(y"
|
"ead-error)[13}:1,.1q?{n]1}:0^,.1q?{:3?{${:6,:2^[01},${:6,:5^[01},:1,.1"
|
||||||
"10:read-error)[13}${.2,:4^[01}?{:6,'(y5:port:),.2d,'(s20:error inside "
|
"q?{.1]3}:6,'(y5:port:),.2,'(s31:randomness after form after dot),@(y10"
|
||||||
"list --),@(y10:read-error)[14}${${:6,:5^[01},:7^[01},.1c]1}.!0.0^_1[51"
|
":read-error)[34}:6,'(y5:port:),'(s13:dot in #(...)),@(y10:read-error)["
|
||||||
"}.!(i17).(i16),.9,.(i13),&3{%1${.2,:2^[01},,#0.0,.3,:2,:0,:1,&5{%1.0R8"
|
"13}${.2,:4^[01}?{:6,'(y5:port:),.2d,'(s20:error inside list --),@(y10:"
|
||||||
"?{:3,'(y5:port:),'(s21:eof inside bytevector),@(y10:read-error)[13}:0^"
|
"read-error)[14}${${:6,:5^[01},:7^[01},.1c]1}.!0.0^_1[51}.!(i18).(i17),"
|
||||||
",.1q?{n]1}${.2,:1^[01}?{:3,'(y5:port:),.2d,'(s26:error inside bytevect"
|
".9,.(i13),&3{%1${.2,:2^[01},,#0.0,.3,:2,:0,:1,&5{%1.0R8?{:3,'(y5:port:"
|
||||||
"or --),@(y10:read-error)[14}.0I0~,.0?{.0}{'0,.2I<,.0?{.0}{'(i255),.3I>"
|
"),'(s21:eof inside bytevector),@(y10:read-error)[13}:0^,.1q?{n]1}${.2,"
|
||||||
"}_1}_1?{:3,'(y5:port:),.2,'(s33:invalid byte inside bytevector --),@(y"
|
":1^[01}?{:3,'(y5:port:),.2d,'(s26:error inside bytevector --),@(y10:re"
|
||||||
"10:read-error)[14}${${:3,:2^[01},:4^[01},.1c]1}.!0.0^_1[11}.!(i18).(i2"
|
"ad-error)[14}.0I0~,.0?{.0}{'0,.2I<,.0?{.0}{'(i255),.3I>}_1}_1?{:3,'(y5"
|
||||||
"0),&1{%2.0R0,.0R8?{${.3,'(y5:port:),.6,'(s20:end of file within a),@(y"
|
":port:),.2,'(s33:invalid byte inside bytevector --),@(y10:read-error)["
|
||||||
"10:read-error)[04}}'(c%5c),.1C=,.0?{.0}{'(c%22),.2C=,.0?{.0}{'(c|),.3C"
|
"14}${${:3,:2^[01},:4^[01},.1c]1}.!0.0^_1[11}.!(i19).(i21),&1{%2.0R0,.0"
|
||||||
"=}_1}_1?{.0]3}'(ca),.1C=?{'(c%07)]3}'(cb),.1C=?{'(c%08)]3}'(ct),.1C=?{"
|
"R8?{${.3,'(y5:port:),.6,'(s20:end of file within a),@(y10:read-error)["
|
||||||
"'(c%09)]3}'(cn),.1C=?{'(c%0a)]3}'(cv),.1C=?{'(c%0b)]3}'(cf),.1C=?{'(c%"
|
"04}}'(c%5c),.1C=,.0?{.0}{'(c%22),.2C=,.0?{.0}{'(c|),.3C=}_1}_1?{.0]3}'"
|
||||||
"0c)]3}'(cr),.1C=?{'(c%0d)]3}'(cx),.1C=?{t,.2,:0^[32}'(y6:string),.3q?{"
|
"(ca),.1C=?{'(c%07)]3}'(cb),.1C=?{'(c%08)]3}'(ct),.1C=?{'(c%09)]3}'(cn)"
|
||||||
".0C1}{f}?{.1R1,'(c%0a),.2C=,,#0.0,.5,&2{%2.1R8,.0?{.0}{.2C1~}_1?{.0?{f"
|
",.1C=?{'(c%0a)]3}'(cv),.1C=?{'(c%0b)]3}'(cf),.1C=?{'(c%0c)]3}'(cr),.1C"
|
||||||
"]2}:0,'(y5:port:),'(s32:no newline in line ending escape),@(y10:read-e"
|
"=?{'(c%0d)]3}'(cx),.1C=?{t,.2,:0^[32}'(y6:string),.3q?{.0C1}{f}?{.1R1,"
|
||||||
"rror)[23}.0?{'(c%0a),.2C=}{f}?{f]2}:0R0:0R1,.1,.0?{.0}{'(c%0a),.4C=}_1"
|
"'(c%0a),.2C=,,#0.0,.5,&2{%2.1R8,.0?{.0}{.2C1~}_1?{.0?{f]2}:0,'(y5:port"
|
||||||
",:1^[22}.!0.0^_1[32}.1,'(y5:port:),.2,'(y1::),.6,'(s22:invalid char es"
|
":),'(s32:no newline in line ending escape),@(y10:read-error)[23}.0?{'("
|
||||||
"cape in),@(y10:read-error)[36}.!(i19).(i14),.(i14),&2{%2,#0.1,&1{%1.0u"
|
"c%0a),.2C=}{f}?{f]2}:0R0:0R1,.1,.0?{.0}{'(c%0a),.4C=}_1,:1^[22}.!0.0^_"
|
||||||
"?{:0,'(y5:port:),'(s31:%5cx escape sequence is too short),@(y10:read-e"
|
"1[32}.1,'(y5:port:),.2,'(y1::),.6,'(s22:invalid char escape in),@(y10:"
|
||||||
"rror)[13}'(i16),.1A9X3X7X9]1}.!0'0,n,.3R1,,#0.0,.6,:0,.7,.(i10),:1,&6{"
|
"read-error)[36}.!(i20).(i14),.(i14),&2{%2,#0.1,&1{%1.0u?{:0,'(y5:port:"
|
||||||
"%3.0R8?{:1?{:4,'(y5:port:),'(s27:end of file within a string),@(y10:re"
|
"),'(s31:%5cx escape sequence is too short),@(y10:read-error)[13}'(i16)"
|
||||||
"ad-error)[33}.1,:2^[31}:1?{'(c;),.1C=}{f}?{:4R0.1,:2^[31}:1~?{${.2,:0^"
|
",.1A9X3X7X9]1}.!0'0,n,.3R1,,#0.0,.6,:0,.7,.(i10),:1,&6{%3.0R8?{:1?{:4,"
|
||||||
"[01}}{f}?{.1,:2^[31}${.2,:3^[01}~?{:4,'(y5:port:),.2,'(s37:unexpected "
|
"'(y5:port:),'(s27:end of file within a string),@(y10:read-error)[33}.1"
|
||||||
"char in %5cx escape sequence),@(y10:read-error)[34}'2,.3>?{:4,'(y5:por"
|
",:2^[31}:1?{'(c;),.1C=}{f}?{:4R0.1,:2^[31}:1~?{${.2,:0^[01}}{f}?{.1,:2"
|
||||||
"t:),'(s30:%5cx escape sequence is too long),@(y10:read-error)[33}:4R0'"
|
"^[31}${.2,:3^[01}~?{:4,'(y5:port:),.2,'(s37:unexpected char in %5cx es"
|
||||||
"1,.3+,.2,.2c,:4R1,:5^[33}.!0.0^_1[33}.!(i20)&0{%4.0,.0?{.0}{.2C5}_1?{f"
|
"cape sequence),@(y10:read-error)[34}'2,.3>?{:4,'(y5:port:),'(s30:%5cx "
|
||||||
"]4}'(s2:+i),.4Si=,.0?{.0}{'(s2:-i),.5Si=}_1?{f]4}'(s6:+nan.0),.4Si=,.0"
|
"escape sequence is too long),@(y10:read-error)[33}:4R0'1,.3+,.2,.2c,:4"
|
||||||
"?{.0}{'(s6:-nan.0),.5Si=}_1?{f]4}'(s6:+inf.0),.4Si=,.0?{.0}{'(s6:-inf."
|
"R1,:5^[33}.!0.0^_1[33}.!(i21)&0{%4.0,.0?{.0}{.2C5}_1?{f]4}'(s2:+i),.4S"
|
||||||
"0),.5Si=}_1?{f]4}'(c+),.2C=,.0?{.0}{'(c-),.3C=}_1?{.2du?{t]4}'(c.),.3d"
|
"i=,.0?{.0}{'(s2:-i),.5Si=}_1?{f]4}'(s6:+nan.0),.4Si=,.0?{.0}{'(s6:-nan"
|
||||||
"aC=?{.2ddp?{.2ddaC5~]4}f]4}.2daC5~]4}'(c.),.2C=?{.2dp?{.2daC5~]4}f]4}f"
|
".0),.5Si=}_1?{f]4}'(s6:+inf.0),.4Si=,.0?{.0}{'(s6:-inf.0),.5Si=}_1?{f]"
|
||||||
"]4}.!(i21).(i14),.(i22),.(i12),.3,.(i16),&5{%2'(c#),.1C=,.1,l1,.3R1,,#"
|
"4}'(c+),.2C=,.0?{.0}{'(c-),.3C=}_1?{.2du?{t]4}'(c.),.3daC=?{.2ddp?{.2d"
|
||||||
"0.5,.1,:0,:1,:2,:3,:4,&7{%3.0R8,.0?{.0}{${.3,:0^[01}}_1?{.1A9,.0a,.1X3"
|
"daC5~]4}f]4}.2daC5~]4}'(c.),.2C=?{.2dp?{.2daC5~]4}f]4}f]4}.!(i22).(i14"
|
||||||
",.5,.0?{.0}{.2C5,.0?{.0}{'(c+),.4C=,.0?{.0}{'(c-),.5C=,.0?{.0}{'(c.),."
|
"),.(i23),.(i12),.3,.(i16),&5{%2'(c#),.1C=,.1,l1,.3R1,,#0.5,.1,:0,:1,:2"
|
||||||
"6C=}_1}_1}_1}_1?{'(s1:.),.1S=?{:2^]6}${.2,.5,.5,.(i10),:1^[04}?{:3^?{."
|
",:3,:4,&7{%3.0R8,.0?{.0}{${.3,:0^[01}}_1?{.1A9,.0a,.1X3,.5,.0?{.0}{.2C"
|
||||||
"0SfX5]6}.0X5]6}'(i10),.1E9,.0?{.0]7}:6,'(y5:port:),.3,'(s54:unsupporte"
|
"5,.0?{.0}{'(c+),.4C=,.0?{.0}{'(c-),.5C=,.0?{.0}{'(c.),.6C=}_1}_1}_1}_1"
|
||||||
"d number syntax (implementation restriction)),@(y10:read-error)[74}:3^"
|
"?{'(s1:.),.1S=?{:2^]6}${.2,.5,.5,.(i10),:1^[04}?{:3^?{.0SfX5]6}.0X5]6}"
|
||||||
"?{.0SfX5]6}.0X5]6}'(c#),.1C=?{:6R0t,.2,.2c,:6R1,:5^[33}${.2,:4^[01}?{:"
|
"'(i10),.1E9,.0?{.0]7}:6,'(y5:port:),.3,'(s54:unsupported number syntax"
|
||||||
"6R0.2,.2,.2c,:6R1,:5^[33}:6,'(y5:port:),.2,'(s29:unexpected number/sym"
|
" (implementation restriction)),@(y10:read-error)[74}:3^?{.0SfX5]6}.0X5"
|
||||||
"bol char),@(y10:read-error)[34}.!0.0^_1[23}.!(i22)${.(i25),.(i19)^[01}"
|
"]6}'(c#),.1C=?{:6R0t,.2,.2c,:6R1,:5^[33}${.2,:4^[01}?{:6R0.2,.2,.2c,:6"
|
||||||
",${.2,.(i15)^[01}~?{.2^u?{.0](i26)}.0,.8^[(i26)1}.(i24),'(y5:port:),.2"
|
"R1,:5^[33}:6,'(y5:port:),.2,'(s29:unexpected number/symbol char),@(y10"
|
||||||
"d,'(s17:unexpected token:),@(y10:read-error)[(i26)4",
|
":read-error)[34}.!0.0^_1[23}.!(i23)${.(i26),.(i20)^[01},${.2,.(i15)^[0"
|
||||||
|
"1}~?{.2^u?{.0](i27)}.0,.8^[(i27)1}.(i25),'(y5:port:),.2d,'(s17:unexpec"
|
||||||
|
"ted token:),@(y10:read-error)[(i27)4",
|
||||||
|
|
||||||
"C", 0,
|
"C", 0,
|
||||||
"&0{%1f,.1,@(y5:%25read)[12}%x,&0{%0f,Pi,@(y5:%25read)[02}%x,&2{|00|11%"
|
"&0{%1f,.1,@(y5:%25read)[12}%x,&0{%0f,Pi,@(y5:%25read)[02}%x,&2{|00|11%"
|
||||||
|
|
52
src/s.scm
52
src/s.scm
|
@ -692,6 +692,40 @@
|
||||||
|
|
||||||
(define-syntax cons* list*)
|
(define-syntax cons* list*)
|
||||||
|
|
||||||
|
(define (list-diff l t) ; +
|
||||||
|
(if (or (null? l) (eq? l t))
|
||||||
|
'()
|
||||||
|
(cons (car l) (list-diff (cdr l) t))))
|
||||||
|
|
||||||
|
(define (list-head list index) ; +
|
||||||
|
(let loop ([list list] [index index])
|
||||||
|
(if (zero? index)
|
||||||
|
'()
|
||||||
|
(cons (car list) (loop (cdr list) (- index 1))))))
|
||||||
|
|
||||||
|
(define (andmap p l) ; +
|
||||||
|
(if (pair? l) (and (p (car l)) (andmap p (cdr l))) #t))
|
||||||
|
|
||||||
|
(define (ormap p l) ; +
|
||||||
|
(if (pair? l) (or (p (car l)) (ormap p (cdr l))) #f))
|
||||||
|
|
||||||
|
(define (memp p l) ; +
|
||||||
|
(and (pair? l) (if (p (car l)) l (memp p (cdr l)))))
|
||||||
|
|
||||||
|
(define (assp p l) ; +
|
||||||
|
(and (pair? l) (if (p (caar l)) (car l) (assp p (cdr l)))))
|
||||||
|
|
||||||
|
(define (posq x l) ; +
|
||||||
|
(let loop ([l l] [n 0])
|
||||||
|
(cond [(null? l) #f]
|
||||||
|
[(eq? x (car l)) n]
|
||||||
|
[else (loop (cdr l) (fx+ n 1))])))
|
||||||
|
|
||||||
|
(define (rassq x al) ; +
|
||||||
|
(and (pair? al)
|
||||||
|
(let ([a (car al)])
|
||||||
|
(if (eq? x (cdr a)) a (rassq x (cdr al))))))
|
||||||
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------------------------------
|
;---------------------------------------------------------------------------------------------
|
||||||
; Symbols
|
; Symbols
|
||||||
|
@ -855,6 +889,17 @@
|
||||||
[(_ . r) (%string-append . r)]
|
[(_ . r) (%string-append . r)]
|
||||||
[_ %string-append]))
|
[_ %string-append]))
|
||||||
|
|
||||||
|
(define (string-trim-whitespace s) ; +
|
||||||
|
(let floop ([from 0] [len (string-length s)])
|
||||||
|
(if (and (< from len) (char-whitespace? (string-ref s from)))
|
||||||
|
(floop (+ from 1) len)
|
||||||
|
(let tloop ([to len])
|
||||||
|
(if (and (> to from) (char-whitespace? (string-ref s (- to 1))))
|
||||||
|
(tloop (- to 1))
|
||||||
|
(if (and (= from 0) (= to len))
|
||||||
|
s
|
||||||
|
(substring s from to)))))))
|
||||||
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------------------------------
|
;---------------------------------------------------------------------------------------------
|
||||||
; Vectors
|
; Vectors
|
||||||
|
@ -1609,6 +1654,11 @@
|
||||||
(r-error p "unexpected token:" (cdr form))]
|
(r-error p "unexpected token:" (cdr form))]
|
||||||
[else form])))
|
[else form])))
|
||||||
|
|
||||||
|
(define (sub-read-shebang p)
|
||||||
|
(if (eqv? (peek-char p) #\space)
|
||||||
|
(string->symbol (string-trim-whitespace (read-line p)))
|
||||||
|
(sub-read-carefully p)))
|
||||||
|
|
||||||
(define (sub-read p)
|
(define (sub-read p)
|
||||||
(let ([c (read-char p)])
|
(let ([c (read-char p)])
|
||||||
(cond [(eof-object? c) c]
|
(cond [(eof-object? c) c]
|
||||||
|
@ -1658,7 +1708,7 @@
|
||||||
(cond [(eof-object? c) (r-error p "end of file after #")]
|
(cond [(eof-object? c) (r-error p "end of file after #")]
|
||||||
[(char=? c #\!)
|
[(char=? c #\!)
|
||||||
(read-char p)
|
(read-char p)
|
||||||
(let ([name (sub-read-carefully p)])
|
(let ([name (sub-read-shebang p)])
|
||||||
(case name
|
(case name
|
||||||
[(fold-case no-fold-case)
|
[(fold-case no-fold-case)
|
||||||
(set! fold-case? (eq? name 'fold-case))
|
(set! fold-case? (eq? name 'fold-case))
|
||||||
|
|
67
src/t.scm
67
src/t.scm
|
@ -120,17 +120,6 @@
|
||||||
(string-append (symbol->string (car args))
|
(string-append (symbol->string (car args))
|
||||||
(string-append "#" (fixnum->string gsc 10))))))))
|
(string-append "#" (fixnum->string gsc 10))))))))
|
||||||
|
|
||||||
(define (posq x l)
|
|
||||||
(let loop ([l l] [n 0])
|
|
||||||
(cond [(null? l) #f]
|
|
||||||
[(eq? x (car l)) n]
|
|
||||||
[else (loop (cdr l) (fx+ n 1))])))
|
|
||||||
|
|
||||||
(define (rassq x al)
|
|
||||||
(and (pair? al)
|
|
||||||
(let ([a (car al)])
|
|
||||||
(if (eq? x (cdr a)) a (rassq x (cdr al))))))
|
|
||||||
|
|
||||||
(define (remove! x l pred?) ; applies (pred? x (car l))
|
(define (remove! x l pred?) ; applies (pred? x (car l))
|
||||||
(let loop ([f #f] [l #f] [r l])
|
(let loop ([f #f] [l #f] [r l])
|
||||||
(cond [(not (pair? r)) (if l (begin (set-cdr! l r) f) r)]
|
(cond [(not (pair? r)) (if l (begin (set-cdr! l r) f) r)]
|
||||||
|
@ -138,17 +127,6 @@
|
||||||
[l (set-cdr! l r) (loop f r (cdr r))]
|
[l (set-cdr! l r) (loop f r (cdr r))]
|
||||||
[else (loop r r (cdr r))])))
|
[else (loop r r (cdr r))])))
|
||||||
|
|
||||||
(define (list-diff l t)
|
|
||||||
(if (or (null? l) (eq? l t))
|
|
||||||
'()
|
|
||||||
(cons (car l) (list-diff (cdr l) t))))
|
|
||||||
|
|
||||||
(define (list-head list index)
|
|
||||||
(let loop ([list list] [index index])
|
|
||||||
(if (zero? index)
|
|
||||||
'()
|
|
||||||
(cons (car list) (loop (cdr list) (- index 1))))))
|
|
||||||
|
|
||||||
(define (pair* x . more)
|
(define (pair* x . more)
|
||||||
(let loop ([x x] [r more])
|
(let loop ([x x] [r more])
|
||||||
(if (null? r) x (cons x (loop (car r) (cdr r))))))
|
(if (null? r) x (cons x (loop (car r) (cdr r))))))
|
||||||
|
@ -161,23 +139,6 @@
|
||||||
(define (string-append* l)
|
(define (string-append* l)
|
||||||
(apply string-append l))
|
(apply string-append l))
|
||||||
|
|
||||||
(define (string-trim-whitespace s)
|
|
||||||
(let floop ([from 0] [len (string-length s)])
|
|
||||||
(if (and (< from len) (char-whitespace? (string-ref s from)))
|
|
||||||
(floop (+ from 1) len)
|
|
||||||
(let tloop ([to len])
|
|
||||||
(if (and (> to from) (char-whitespace? (string-ref s (- to 1))))
|
|
||||||
(tloop (- to 1))
|
|
||||||
(if (and (= from 0) (= to len))
|
|
||||||
s
|
|
||||||
(substring s from to)))))))
|
|
||||||
|
|
||||||
(define (andmap p l)
|
|
||||||
(if (pair? l) (and (p (car l)) (andmap p (cdr l))) #t))
|
|
||||||
|
|
||||||
(define (ormap p l)
|
|
||||||
(if (pair? l) (or (p (car l)) (ormap p (cdr l))) #f))
|
|
||||||
|
|
||||||
(define (list1? x) (and (pair? x) (null? (cdr x))))
|
(define (list1? x) (and (pair? x) (null? (cdr x))))
|
||||||
(define (list1+? x) (and (pair? x) (list? (cdr x))))
|
(define (list1+? x) (and (pair? x) (list? (cdr x))))
|
||||||
(define (list2? x) (and (pair? x) (list1? (cdr x))))
|
(define (list2? x) (and (pair? x) (list1? (cdr x))))
|
||||||
|
@ -2014,6 +1975,7 @@
|
||||||
(vector-cat) (bytevector=?) (bytevector->list) (list->bytevector) (subbytevector)
|
(vector-cat) (bytevector=?) (bytevector->list) (list->bytevector) (subbytevector)
|
||||||
(standard-input-port) (standard-output-port) (standard-error-port) (tty-port?)
|
(standard-input-port) (standard-output-port) (standard-error-port) (tty-port?)
|
||||||
(port-fold-case?) (set-port-fold-case!) (rename-file) (void) (void?) (global-store)
|
(port-fold-case?) (set-port-fold-case!) (rename-file) (void) (void?) (global-store)
|
||||||
|
(run-script)
|
||||||
; temporarily here for debugging purposes
|
; temporarily here for debugging purposes
|
||||||
;(xform) (compile-and-run-core-expr) (compile-to-thunk-code) (deserialize-code)
|
;(xform) (compile-and-run-core-expr) (compile-to-thunk-code) (deserialize-code)
|
||||||
;(closure) (repl-environment)
|
;(closure) (repl-environment)
|
||||||
|
@ -2331,6 +2293,33 @@
|
||||||
; we aren't asked by the spec to call last expr tail-recursively, so this
|
; we aren't asked by the spec to call last expr tail-recursively, so this
|
||||||
(void))
|
(void))
|
||||||
|
|
||||||
|
; srfi-22 - like script processor (args is list of strings)
|
||||||
|
(define (run-script filename args)
|
||||||
|
(define env (interaction-environment))
|
||||||
|
(define ci? #f) ; do not bother setting this
|
||||||
|
(define callmain #f)
|
||||||
|
(define main-args (cons filename args))
|
||||||
|
(let* ([filepath (and (string? filename) (file-resolve-relative-to-current filename))]
|
||||||
|
[fileok? (and (string? filepath) (file-exists? filepath))])
|
||||||
|
(unless fileok? (error "cannot run script" filename filepath))
|
||||||
|
(with-current-file filepath
|
||||||
|
(lambda ()
|
||||||
|
(call-with-input-file filepath
|
||||||
|
(lambda (port)
|
||||||
|
(when ci? (set-port-fold-case! port #t))
|
||||||
|
(let ([x0 (read-code-sexp port)])
|
||||||
|
(when (shebang? x0) ; TODO: set! env depending on x?
|
||||||
|
(set! callmain #t)
|
||||||
|
(set! x0 (read-code-sexp port)))
|
||||||
|
(let loop ([x x0])
|
||||||
|
(unless (eof-object? x)
|
||||||
|
(eval x env)
|
||||||
|
(loop (read-code-sexp port))))
|
||||||
|
(when callmain
|
||||||
|
; if it is a real script, exit with main's return value
|
||||||
|
(eval `(exit (main (quote ,main-args))) env)))))))
|
||||||
|
(void)))
|
||||||
|
|
||||||
|
|
||||||
;--------------------------------------------------------------------------------------------------
|
;--------------------------------------------------------------------------------------------------
|
||||||
; REPL
|
; REPL
|
||||||
|
|
75
t.c
75
t.c
|
@ -67,24 +67,11 @@ char *t_code[] = {
|
||||||
"'0,#0.0,&1{%!0'1,:0^I+:!0.0u,.0?{.0}{.1aY0~}_1?{'(i10),:0^X6,'(s1:#)S6"
|
"'0,#0.0,&1{%!0'1,:0^I+:!0.0u,.0?{.0}{.1aY0~}_1?{'(i10),:0^X6,'(s1:#)S6"
|
||||||
"X5]1}'(i10),:0^X6,'(s1:#)S6,.1aX4S6X5]1}_1@!(y6:gensym)",
|
"X5]1}'(i10),:0^X6,'(s1:#)S6,.1aX4S6X5]1}_1@!(y6:gensym)",
|
||||||
|
|
||||||
"P", "posq",
|
|
||||||
"%2'0,.2,,#0.0,.4,&2{%2.0u?{f]2}.0a,:0q?{.1]2}'1,.2I+,.1d,:1^[22}.!0.0^"
|
|
||||||
"_1[22",
|
|
||||||
|
|
||||||
"P", "rassq",
|
|
||||||
"%2.1p?{.1a,.0d,.2q?{.0]3}.2d,.2,@(y5:rassq)[32}f]2",
|
|
||||||
|
|
||||||
"P", "remove!",
|
"P", "remove!",
|
||||||
"%3.1,f,f,,#0.0,.7,.6,&3{%3.2p~?{.1?{.2,.2sd.0]3}.2]3}${.4a,:0,:1[02}?{"
|
"%3.1,f,f,,#0.0,.7,.6,&3{%3.2p~?{.1?{.2,.2sd.0]3}.2]3}${.4a,:0,:1[02}?{"
|
||||||
".2d,.2,.2,:2^[33}.1?{.2,.2sd.2d,.3,.2,:2^[33}.2d,.3,.4,:2^[33}.!0.0^_1"
|
".2d,.2,.2,:2^[33}.1?{.2,.2sd.2d,.3,.2,:2^[33}.2d,.3,.4,:2^[33}.!0.0^_1"
|
||||||
"[33",
|
"[33",
|
||||||
|
|
||||||
"P", "list-diff",
|
|
||||||
"%2.0u,.0?{.0}{.2,.2q}_1?{n]2}${.3,.3d,@(y9:list-diff)[02},.1ac]2",
|
|
||||||
|
|
||||||
"P", "list-head",
|
|
||||||
"%2.1,.1,,#0.0,&1{%2.1=0?{n]2}${'1,.4-,.3d,:0^[02},.1ac]2}.!0.0^_1[22",
|
|
||||||
|
|
||||||
"P", "pair*",
|
"P", "pair*",
|
||||||
"%!1.0,.2,,#0.0,&1{%2.1u?{.0]2}${.3d,.4a,:0^[02},.1c]2}.!0.0^_1[22",
|
"%!1.0,.2,,#0.0,&1{%2.1u?{.0]2}${.3d,.4a,:0^[02},.1c]2}.!0.0^_1[22",
|
||||||
|
|
||||||
|
@ -94,17 +81,6 @@ char *t_code[] = {
|
||||||
"P", "string-append*",
|
"P", "string-append*",
|
||||||
"%1.0,@(y14:%25string-append),@(y13:apply-to-list)[12",
|
"%1.0,@(y14:%25string-append),@(y13:apply-to-list)[12",
|
||||||
|
|
||||||
"P", "string-trim-whitespace",
|
|
||||||
"%1.0S3,'0,,#0.3,.1,&2{%2.1,.1<?{.0,:1S4C1}{f}?{.1,'1,.2+,:0^[22}.1,,#0"
|
|
||||||
".2,:1,.5,.3,&4{%1:3,.1>?{'1,.1-,:2S4C1}{f}?{'1,.1-,:0^[11}'0,:3=?{:1,."
|
|
||||||
"1=}{f}?{:2]1}.0,:3,:2S7]1}.!0.0^_1[21}.!0.0^_1[12",
|
|
||||||
|
|
||||||
"P", "andmap",
|
|
||||||
"%2.1p?{${.3a,.3[01}?{.1d,.1,@(y6:andmap)[22}f]2}t]2",
|
|
||||||
|
|
||||||
"P", "ormap",
|
|
||||||
"%2.1p?{${.3a,.3[01},.0?{.0]3}.2d,.2,@(y5:ormap)[32}f]2",
|
|
||||||
|
|
||||||
"P", "list1?",
|
"P", "list1?",
|
||||||
"%1.0p?{.0du]1}f]1",
|
"%1.0p?{.0du]1}f]1",
|
||||||
|
|
||||||
|
@ -1112,7 +1088,7 @@ char *t_code[] = {
|
||||||
"0:*root-name-registry*),@(y11:name-lookup)[03}",
|
"0:*root-name-registry*),@(y11:name-lookup)[03}",
|
||||||
|
|
||||||
"C", 0,
|
"C", 0,
|
||||||
"${'(l482:l3:y1:*;y1:v;y1:b;;l3:y1:+;y1:v;y1:b;;l3:y1:-;y1:v;y1:b;;l4:y"
|
"${'(l483:l3:y1:*;y1:v;y1:b;;l3:y1:+;y1:v;y1:b;;l3:y1:-;y1:v;y1:b;;l4:y"
|
||||||
"3:...;y1:v;y1:u;y1:b;;l3:y1:/;y1:v;y1:b;;l3:y1:<;y1:v;y1:b;;l3:y2:<=;y"
|
"3:...;y1:v;y1:u;y1:b;;l3:y1:/;y1:v;y1:b;;l3:y1:<;y1:v;y1:b;;l3:y2:<=;y"
|
||||||
"1:v;y1:b;;l3:y1:=;y1:v;y1:b;;l4:y2:=>;y1:v;y1:u;y1:b;;l3:y1:>;y1:v;y1:"
|
"1:v;y1:b;;l3:y1:=;y1:v;y1:b;;l4:y2:=>;y1:v;y1:u;y1:b;;l3:y1:>;y1:v;y1:"
|
||||||
"b;;l3:y2:>=;y1:v;y1:b;;l2:y1:_;y1:b;;l3:y3:abs;y1:v;y1:b;;l4:y3:and;y1"
|
"b;;l3:y2:>=;y1:v;y1:b;;l2:y1:_;y1:b;;l3:y3:abs;y1:v;y1:b;;l4:y3:and;y1"
|
||||||
|
@ -1275,25 +1251,25 @@ char *t_code[] = {
|
||||||
";l1:y13:subbytevector;;l1:y19:standard-input-port;;l1:y20:standard-out"
|
";l1:y13:subbytevector;;l1:y19:standard-input-port;;l1:y20:standard-out"
|
||||||
"put-port;;l1:y19:standard-error-port;;l1:y9:tty-port?;;l1:y15:port-fol"
|
"put-port;;l1:y19:standard-error-port;;l1:y9:tty-port?;;l1:y15:port-fol"
|
||||||
"d-case?;;l1:y19:set-port-fold-case!;;l1:y11:rename-file;;l1:y4:void;;l"
|
"d-case?;;l1:y19:set-port-fold-case!;;l1:y11:rename-file;;l1:y4:void;;l"
|
||||||
"1:y5:void?;;l1:y12:global-store;;),&0{%1,,,,#0#1#2#3&0{%1.0,'(y1:w),.1"
|
"1:y5:void?;;l1:y12:global-store;;l1:y10:run-script;;),&0{%1,,,,#0#1#2#"
|
||||||
"v?{'(l2:y6:scheme;y5:write;)]2}'(y1:t),.1v?{'(l2:y6:scheme;y4:time;)]2"
|
"3&0{%1.0,'(y1:w),.1v?{'(l2:y6:scheme;y5:write;)]2}'(y1:t),.1v?{'(l2:y6"
|
||||||
"}'(y1:p),.1v?{'(l2:y6:scheme;y4:repl;)]2}'(y1:r),.1v?{'(l2:y6:scheme;y"
|
":scheme;y4:time;)]2}'(y1:p),.1v?{'(l2:y6:scheme;y4:repl;)]2}'(y1:r),.1"
|
||||||
"4:read;)]2}'(y1:v),.1v?{'(l2:y6:scheme;y4:r5rs;)]2}'(y1:u),.1v?{'(l2:y"
|
"v?{'(l2:y6:scheme;y4:read;)]2}'(y1:v),.1v?{'(l2:y6:scheme;y4:r5rs;)]2}"
|
||||||
"6:scheme;y9:r5rs-null;)]2}'(y1:d),.1v?{'(l2:y6:scheme;y4:load;)]2}'(y1"
|
"'(y1:u),.1v?{'(l2:y6:scheme;y9:r5rs-null;)]2}'(y1:d),.1v?{'(l2:y6:sche"
|
||||||
":z),.1v?{'(l2:y6:scheme;y4:lazy;)]2}'(y1:s),.1v?{'(l2:y6:scheme;y15:pr"
|
"me;y4:load;)]2}'(y1:z),.1v?{'(l2:y6:scheme;y4:lazy;)]2}'(y1:s),.1v?{'("
|
||||||
"ocess-context;)]2}'(y1:i),.1v?{'(l2:y6:scheme;y7:inexact;)]2}'(y1:f),."
|
"l2:y6:scheme;y15:process-context;)]2}'(y1:i),.1v?{'(l2:y6:scheme;y7:in"
|
||||||
"1v?{'(l2:y6:scheme;y4:file;)]2}'(y1:e),.1v?{'(l2:y6:scheme;y4:eval;)]2"
|
"exact;)]2}'(y1:f),.1v?{'(l2:y6:scheme;y4:file;)]2}'(y1:e),.1v?{'(l2:y6"
|
||||||
"}'(y1:o),.1v?{'(l2:y6:scheme;y7:complex;)]2}'(y1:h),.1v?{'(l2:y6:schem"
|
":scheme;y4:eval;)]2}'(y1:o),.1v?{'(l2:y6:scheme;y7:complex;)]2}'(y1:h)"
|
||||||
"e;y4:char;)]2}'(y1:l),.1v?{'(l2:y6:scheme;y11:case-lambda;)]2}'(y1:a),"
|
",.1v?{'(l2:y6:scheme;y4:char;)]2}'(y1:l),.1v?{'(l2:y6:scheme;y11:case-"
|
||||||
".1v?{'(l2:y6:scheme;y3:cxr;)]2}'(y1:b),.1v?{'(l2:y6:scheme;y4:base;)]2"
|
"lambda;)]2}'(y1:a),.1v?{'(l2:y6:scheme;y3:cxr;)]2}'(y1:b),.1v?{'(l2:y6"
|
||||||
"}'(y1:x),.1v?{'(l2:y6:scheme;y3:box;)]2}.1I0?{.1,'(y4:srfi),l2]2}.1,l1"
|
":scheme;y4:base;)]2}'(y1:x),.1v?{'(l2:y6:scheme;y3:box;)]2}.1I0?{.1,'("
|
||||||
"]2}.!0&0{%1${&0{%1n,'(l1:y5:begin;),V12]1},.3,@(y20:*root-name-registr"
|
"y4:srfi),l2]2}.1,l1]2}.!0&0{%1${&0{%1n,'(l1:y5:begin;),V12]1},.3,@(y20"
|
||||||
"y*),@(y11:name-lookup)[03}z]1}.!1&0{%3'1,.1V4,.0,.3A3,.0?{.4,.1sd]5}.1"
|
":*root-name-registry*),@(y11:name-lookup)[03}z]1}.!1&0{%3'1,.1V4,.0,.3"
|
||||||
",.5,.5cc,'1,.4V5]5}.!2&0{%1&0{%1.0,'(y5:const),l2]1},.1,@(y20:*root-na"
|
"A3,.0?{.4,.1sd]5}.1,.5,.5cc,'1,.4V5]5}.!2&0{%1&0{%1.0,'(y5:const),l2]1"
|
||||||
"me-registry*),@(y11:name-lookup)[13}.!3.4d,.5a,,#0.0,.6,.5,.7,.(i10),&"
|
"},.1,@(y20:*root-name-registry*),@(y11:name-lookup)[13}.!3.4d,.5a,,#0."
|
||||||
"5{%2.1u?{${.2,:0^[01},.1,${'(l1:y5:skint;),:1^[01},:3^[23}${${.4,:0^[0"
|
"0,.6,.5,.7,.(i10),&5{%2.1u?{${.2,:0^[01},.1,${'(l1:y5:skint;),:1^[01},"
|
||||||
"1},.3,${${.9a,:2^[01},:1^[01},:3^[03}.1d,.1,:4^[22}.!0.0^_1[52},@(y10:"
|
":3^[23}${${.4,:0^[01},.3,${${.9a,:2^[01},:1^[01},:3^[03}.1d,.1,:4^[22}"
|
||||||
"%25for-each1)[02}",
|
".!0.0^_1[52},@(y10:%25for-each1)[02}",
|
||||||
|
|
||||||
"C", 0,
|
"C", 0,
|
||||||
"@(y20:*root-name-registry*),${f,'(l1:y5:skint;),.4,@(y11:name-lookup)["
|
"@(y20:*root-name-registry*),${f,'(l1:y5:skint;),.4,@(y11:name-lookup)["
|
||||||
|
@ -1461,6 +1437,17 @@ char *t_code[] = {
|
||||||
"!0.0^_1[11},:0,@(y20:call-with-input-file)[02},.4,@(y17:with-current-f"
|
"!0.0^_1[11},:0,@(y20:call-with-input-file)[02},.4,@(y17:with-current-f"
|
||||||
"ile)[02}_1_1Y9]4",
|
"ile)[02}_1_1Y9]4",
|
||||||
|
|
||||||
|
"P", "run-script",
|
||||||
|
"%2,,,,#0#1#2#3${@(y23:interaction-environment)[00}.!0f.!1f.!2.5,.5c.!3"
|
||||||
|
".4S0?{${.6,@(y32:file-resolve-relative-to-current)[01}}{f},.0S0?{.0F0}"
|
||||||
|
"{f},.0~?{${.3,.9,'(s17:cannot run script),@(y5:error)[03}}${.5,.8,.6,."
|
||||||
|
"9,.7,&5{%0:1,:2,:3,:4,&4{%1:0^?{t,.1P79}${.2,@(y14:read-code-sexp)[01}"
|
||||||
|
",#0.0^Y5?{t:!3${.3,@(y14:read-code-sexp)[01}.!0}${.2^,,#0:2,.6,.2,&3{%"
|
||||||
|
"1.0R8~?{${:2^,.3,@(y4:eval)[02}${:1,@(y14:read-code-sexp)[01},:0^[11}]"
|
||||||
|
"1}.!0.0^_1[01}:3^?{:2^,n,n,n,:1^c,'(y5:quote)cc,'(y4:main)cc,'(y4:exit"
|
||||||
|
")c,@(y4:eval)[22}]2},:0,@(y20:call-with-input-file)[02},.4,@(y17:with-"
|
||||||
|
"current-file)[02}Y9]8",
|
||||||
|
|
||||||
"P", "repl-evaluate-top-form",
|
"P", "repl-evaluate-top-form",
|
||||||
"%3,,#0#1.!0${.2,&1{%!0.0:!0]1},.6,.6,&2{%0:1,:0,@(y17:evaluate-top-for"
|
"%3,,#0#1.!0${.2,&1{%!0.0:!0]1},.6,.6,&2{%0:1,:0,@(y17:evaluate-top-for"
|
||||||
"m)[02},@(y16:call-with-values)[02}.4,&1{%1:0,.1W5:0W6]1}.!1${.2^,@(y6:"
|
"m)[02},@(y16:call-with-values)[02}.4,&1{%1:0,.1W5:0W6]1}.!1${.2^,@(y6:"
|
||||||
|
|
Loading…
Reference in a new issue