mirror of
https://github.com/false-schemers/skint.git
synced 2024-12-25 21:58:54 +01:00
cond-expand fix; ,time repl command
This commit is contained in:
parent
1c9e8d2b32
commit
b7f0a7980d
2 changed files with 55 additions and 68 deletions
30
src/t.scm
30
src/t.scm
|
@ -965,7 +965,7 @@
|
|||
(loop (append (cdr decl) decls) code eal esps forms)]
|
||||
[(eq? (car decl) ld-cond-expand-id) ; flatten and splice
|
||||
(let ([lit=? (lambda (id sym) (and (id? id) (eq? id (id-rename-as sid sym))))])
|
||||
(loop (append (preprocess-cond-expand lit=? (cdr decl)) decls env) code eal esps forms))]
|
||||
(loop (append (preprocess-cond-expand lit=? decl env) decls) code eal esps forms))]
|
||||
[(eq? (car decl) ld-push-cf-id) ; internal
|
||||
(check-syntax decl '(<id> <string>) "invalid library declarations syntax")
|
||||
(push-current-file! (cadr decl))
|
||||
|
@ -1532,7 +1532,7 @@
|
|||
[once (gid exp)
|
||||
(codegen `(if (integrable ,(lookup-integrable 'eq?) (gref ,gid) (quote #t))
|
||||
(begin)
|
||||
(begin (gset! ,gid (quote #t)) ,exp))
|
||||
(begin (gset! ,gid (quote #t)) ,exp))
|
||||
l f s g k port)]
|
||||
[(define define-syntax define-library import) tail
|
||||
(c-error "misplaced definition form" x)]
|
||||
|
@ -2055,22 +2055,7 @@
|
|||
(define *verbose* #f)
|
||||
(define *quiet* #f)
|
||||
|
||||
#;(define (repl-compile-and-run-core-expr core)
|
||||
(when *verbose* (display "TRANSFORM =>") (newline) (write core) (newline))
|
||||
(unless (val-core? core) (x-error "unexpected transformed output" core))
|
||||
(let ([code (compile-to-thunk-code core)] [start #f])
|
||||
(when *verbose*
|
||||
(display "COMPILE-TO-STRING =>") (newline) (display code) (newline)
|
||||
(display "DECODE+EXECUTE =>") (newline)
|
||||
(set! start (current-jiffy)))
|
||||
(let* ([cl (closure (deserialize-code code))] [res (cl)])
|
||||
(when *verbose*
|
||||
(display "Elapsed time: ") (write (* 1000 (/ (- (current-jiffy) start) (jiffies-per-second))))
|
||||
(display " ms.") (newline))
|
||||
(unless (eq? res (void)) (write res) (newline)))))
|
||||
|
||||
(define (repl-compile-and-run-core-expr core)
|
||||
(define start #f)
|
||||
(define (compile-and-run core)
|
||||
(define code (compile-to-thunk-code core))
|
||||
(define cl (closure (deserialize-code code)))
|
||||
|
@ -2078,7 +2063,6 @@
|
|||
(for-each (lambda (v) (unless (void? v) (write v) (newline))) vals))
|
||||
(when *verbose* (display "TRANSFORM =>") (newline) (write core) (newline))
|
||||
(unless (val-core? core) (x-error "unexpected transformed output" core))
|
||||
(set! start (current-jiffy))
|
||||
(let loop ([cores (list core)])
|
||||
(unless (null? cores)
|
||||
(let ([first (car cores)] [rest (cdr cores)])
|
||||
|
@ -2092,10 +2076,7 @@
|
|||
(loop rest)]
|
||||
[else
|
||||
(compile-and-run first)
|
||||
(loop rest)]))))
|
||||
(when *verbose*
|
||||
(display "Elapsed time: ") (write (* 1000 (/ (- (current-jiffy) start) (jiffies-per-second))))
|
||||
(display " ms.") (newline)))
|
||||
(loop rest)])))))
|
||||
|
||||
|
||||
(define (repl-eval-top-form x env)
|
||||
|
@ -2196,6 +2177,10 @@
|
|||
[(q) (set! *quiet* #t)]
|
||||
[(quiet on) (set! *quiet* #t)]
|
||||
[(quiet off) (set! *quiet* #f)]
|
||||
[(time *) (let ([start (current-jiffy)])
|
||||
(repl-eval-top-form (car args) repl-environment)
|
||||
(format #t "Elapsed time: ~s ms.~%"
|
||||
(* 1000 (/ (- (current-jiffy) start) (jiffies-per-second)))))]
|
||||
[(help)
|
||||
(display "Available commands:\n" op)
|
||||
(display " ,say hello -- displays nice greeting\n" op)
|
||||
|
@ -2214,6 +2199,7 @@
|
|||
(display " ,unr -- show user name registry\n" op)
|
||||
(display " ,uref <name> -- lookup name in user registry\n" op)
|
||||
(display " ,urem! <name> -- remove name from user registry\n" op)
|
||||
(display " ,time <expr> -- time short expression <expr>\n" op)
|
||||
(display " ,help -- this help\n" op)]
|
||||
[else
|
||||
(display "syntax error in repl command\n" op)
|
||||
|
|
93
t.c
93
t.c
|
@ -572,24 +572,24 @@ char *t_code[] = {
|
|||
"${.(i11),.6,@(y11:adjoin-eals)[02},${.5,.(i12),@(y11:adjoin-code)[02},"
|
||||
".8,:0^[(i10)5}:(i13),.1aq?{.6,.6,.6,.6,.5,.5dL6,:0^[75}:(i12),.1aq?{:("
|
||||
"i11),&1{%2${.2,@(y3:id?)[01}?{${.3,:0,@(y12:id-rename-as)[02},.1q]2}f]"
|
||||
"2},.7,.7,.7,.7,:(i10),.7L6,${.8d,.8,@(y22:preprocess-cond-expand)[02}L"
|
||||
"6,:0^[85}:7,.1aq?{${'(s35:invalid library declarations syntax),'(l2:y4"
|
||||
":<id>;y8:<string>;),.4,@(y12:check-syntax)[03}${.2da,@(y18:push-curren"
|
||||
"t-file!)[01}.6,.6,.6,.6,.5,:0^[75}:6,.1aq?{${'(s35:invalid library dec"
|
||||
"larations syntax),'(l1:y4:<id>;),.4,@(y12:check-syntax)[03}${@(y17:pop"
|
||||
"-current-file!)[00}.6,.6,.6,.6,.5,:0^[75}:9,.1aq?{${'(s43:invalid incl"
|
||||
"ude-library-declarations syntax),'(l3:y4:<id>;y8:<string>;y3:...;),.4,"
|
||||
"@(y12:check-syntax)[03}.1,.1dA8,,#0:8,:7,:6,.3,:0,.(i11),.(i13),.(i15)"
|
||||
",.(i17),&9{%2.0u?{:0,:1,:2,:3,.5,:4^[25}${.2a,@(y32:file-resolve-relat"
|
||||
"ive-to-current)[01},.0S0?{.0F0}{f},.0?{t}{${:8,.5a,'(s27:cannot includ"
|
||||
"e declarations),@(y7:x-error)[03}},${f,.5,@(y15:read-file-sexps)[02},."
|
||||
"5,n,:6cc,.1L6,n,.5c,:7cc,.5d,:5^[62}.!0.0^_1[72}:5,.1aq?{${'(s42:inval"
|
||||
"id include library declaration syntax),'(l3:y4:<id>;y8:<string>;y3:..."
|
||||
";),.4,@(y12:check-syntax)[03}n,.1d,:4cc,.7L6,.6,.6,.6,.5,:0^[75}:3,.1a"
|
||||
"q?{${'(s45:invalid include-ci library declaration syntax),'(l3:y4:<id>"
|
||||
";y8:<string>;y3:...;),.4,@(y12:check-syntax)[03}n,.1d,:2cc,.7L6,.6,.6,"
|
||||
".6,.5,:0^[75}:1,.1aq?{${.2d,@(y17:xform-sexp->datum)[01},.7L6,.6,.6,.6"
|
||||
",.5,:0^[75}f]7}.!0.0^_1[(i17)5",
|
||||
"2},.7,.7,.7,.7,.6,${:(i10),.9,.9,@(y22:preprocess-cond-expand)[03}L6,:"
|
||||
"0^[85}:7,.1aq?{${'(s35:invalid library declarations syntax),'(l2:y4:<i"
|
||||
"d>;y8:<string>;),.4,@(y12:check-syntax)[03}${.2da,@(y18:push-current-f"
|
||||
"ile!)[01}.6,.6,.6,.6,.5,:0^[75}:6,.1aq?{${'(s35:invalid library declar"
|
||||
"ations syntax),'(l1:y4:<id>;),.4,@(y12:check-syntax)[03}${@(y17:pop-cu"
|
||||
"rrent-file!)[00}.6,.6,.6,.6,.5,:0^[75}:9,.1aq?{${'(s43:invalid include"
|
||||
"-library-declarations syntax),'(l3:y4:<id>;y8:<string>;y3:...;),.4,@(y"
|
||||
"12:check-syntax)[03}.1,.1dA8,,#0:8,:7,:6,.3,:0,.(i11),.(i13),.(i15),.("
|
||||
"i17),&9{%2.0u?{:0,:1,:2,:3,.5,:4^[25}${.2a,@(y32:file-resolve-relative"
|
||||
"-to-current)[01},.0S0?{.0F0}{f},.0?{t}{${:8,.5a,'(s27:cannot include d"
|
||||
"eclarations),@(y7:x-error)[03}},${f,.5,@(y15:read-file-sexps)[02},.5,n"
|
||||
",:6cc,.1L6,n,.5c,:7cc,.5d,:5^[62}.!0.0^_1[72}:5,.1aq?{${'(s42:invalid "
|
||||
"include library declaration syntax),'(l3:y4:<id>;y8:<string>;y3:...;),"
|
||||
".4,@(y12:check-syntax)[03}n,.1d,:4cc,.7L6,.6,.6,.6,.5,:0^[75}:3,.1aq?{"
|
||||
"${'(s45:invalid include-ci library declaration syntax),'(l3:y4:<id>;y8"
|
||||
":<string>;y3:...;),.4,@(y12:check-syntax)[03}n,.1d,:2cc,.7L6,.6,.6,.6,"
|
||||
".5,:0^[75}:1,.1aq?{${.2d,@(y17:xform-sexp->datum)[01},.7L6,.6,.6,.6,.5"
|
||||
",:0^[75}f]7}.!0.0^_1[(i17)5",
|
||||
|
||||
"P", "preprocess-library",
|
||||
"%2,#0.1,&1{%1${:0,@(y7:list2+?)[01}?{${:0da,@(y3:id?)[01}}{f}?{${.2,@("
|
||||
|
@ -1299,16 +1299,14 @@ char *t_code[] = {
|
|||
"f@!(y7:*quiet*)",
|
||||
|
||||
"P", "repl-compile-and-run-core-expr",
|
||||
"%1,,#0#1f.!0&0{%1,,,#0#1#2${.5,@(y21:compile-to-thunk-code)[01}.!0.0^U"
|
||||
"4,U91.!1${@(y4:list),.4^,@(y16:call-with-values)[02}.!2.2^,&0{%1.0Y8~?"
|
||||
"{Po,.1W5PoW6]1}]1},@(y10:%25for-each1)[42}.!1@(y9:*verbose*)?{Po,'(s12"
|
||||
":TRANSFORM =>)W4PoW6Po,.3W5PoW6}.2p~?{${.4,'(s29:unexpected transforme"
|
||||
"d output),@(y7:x-error)[02}}Z3.!0${.4,l1,,#0.0,.6,&2{%1.0u~?{.0d,.1a,'"
|
||||
"(y5:begin),.1aq?{.0d,.2,:1,&2{%!0:1,.1L6,:0^[11},@(y13:apply-to-list)["
|
||||
"32}'(y4:once),.1aq?{.0d,:1,.3,.3,:0,&4{%2${:1,:0^[01}'(y5:begin),:1san"
|
||||
",:1sd:2,:3^[21},@(y13:apply-to-list)[32}${.2,:0^[01}.1,:1^[31}]1}.!0.0"
|
||||
"^_1[01}@(y9:*verbose*)?{Po,'(s14:Elapsed time: )W4Po,Z4,.2^,Z3-/,'(i10"
|
||||
"00)*W5Po,'(s4: ms.)W4PoW6]3}]3",
|
||||
"%1,#0&0{%1,,,#0#1#2${.5,@(y21:compile-to-thunk-code)[01}.!0.0^U4,U91.!"
|
||||
"1${@(y4:list),.4^,@(y16:call-with-values)[02}.!2.2^,&0{%1.0Y8~?{Po,.1W"
|
||||
"5PoW6]1}]1},@(y10:%25for-each1)[42}.!0@(y9:*verbose*)?{Po,'(s12:TRANSF"
|
||||
"ORM =>)W4PoW6Po,.2W5PoW6}.1p~?{${.3,'(s29:unexpected transformed outpu"
|
||||
"t),@(y7:x-error)[02}}.1,l1,,#0.0,.3,&2{%1.0u~?{.0d,.1a,'(y5:begin),.1a"
|
||||
"q?{.0d,.2,:1,&2{%!0:1,.1L6,:0^[11},@(y13:apply-to-list)[32}'(y4:once),"
|
||||
".1aq?{.0d,:1,.3,.3,:0,&4{%2${:1,:0^[01}'(y5:begin),:1san,:1sd:2,:3^[21"
|
||||
"},@(y13:apply-to-list)[32}${.2,:0^[01}.1,:1^[31}]1}.!0.0^_1[21",
|
||||
|
||||
"P", "repl-eval-top-form",
|
||||
"%2.0p?{${.3,.3a,t,@(y5:xform)[03},'(y5:begin),.1q?{.1d,,#0.4,.1,&2{%1."
|
||||
|
@ -1374,24 +1372,27 @@ char *t_code[] = {
|
|||
"y7:verbose;y3:off;),@(y11:sexp-match?)[02}?{f@!(y9:*verbose*)]5}${.3^,"
|
||||
"'(l1:y1:q;),@(y11:sexp-match?)[02}?{t@!(y7:*quiet*)]5}${.3^,'(l2:y5:qu"
|
||||
"iet;y2:on;),@(y11:sexp-match?)[02}?{t@!(y7:*quiet*)]5}${.3^,'(l2:y5:qu"
|
||||
"iet;y3:off;),@(y11:sexp-match?)[02}?{f@!(y7:*quiet*)]5}${.3^,'(l1:y4:h"
|
||||
"elp;),@(y11:sexp-match?)[02}?{.4,'(s20:Available commands:%0a)W4.4,'(s"
|
||||
"42: ,say hello -- displays nice greeting%0a)W4.4,'(s40: ,peek <fna"
|
||||
"me> -- check if file exists%0a)W4.4,'(s50: ,q -- disable "
|
||||
"informational messages%0a)W4.4,'(s50: ,quiet on -- disable inform"
|
||||
"ational messages%0a)W4.4,'(s49: ,quiet off -- enable informational"
|
||||
" messages%0a)W4.4,'(s37: ,v -- turn verbosity on%0a)W4.4,'"
|
||||
"(s37: ,verbose on -- turn verbosity on%0a)W4.4,'(s38: ,verbose off "
|
||||
" -- turn verbosity off%0a)W4.4,'(s38: ,verbose off -- turn verbosit"
|
||||
"y off%0a)W4.4,'(s54: ,ref <name> -- show current denotation for <na"
|
||||
"me>%0a)W4.4,'(s43: ,rnr -- show root name registry%0a)W4.4,'"
|
||||
"(s48: ,rref <name> -- lookup name in root registry%0a)W4.4,'(s50: ,r"
|
||||
"rem! <name> -- remove name from root registry%0a)W4.4,'(s43: ,unr "
|
||||
" -- show user name registry%0a)W4.4,'(s48: ,uref <name> -- loo"
|
||||
"kup name in user registry%0a)W4.4,'(s50: ,urem! <name> -- remove name"
|
||||
" from user registry%0a)W4.4,'(s29: ,help -- this help%0a)W4]5"
|
||||
"}.4,'(s29:syntax error in repl command%0a)W4.4,'(s37:type ,help to see"
|
||||
" available commands%0a)W4]5",
|
||||
"iet;y3:off;),@(y11:sexp-match?)[02}?{f@!(y7:*quiet*)]5}${.3^,'(l2:y4:t"
|
||||
"ime;y1:*;),@(y11:sexp-match?)[02}?{Z3,${@(y16:repl-environment),.4^a,@"
|
||||
"(y18:repl-eval-top-form)[02}Z4,.1,Z3-/,'(i1000)*,'(s22:Elapsed time: ~"
|
||||
"s ms.~%25),t,@(y6:format)[63}${.3^,'(l1:y4:help;),@(y11:sexp-match?)[0"
|
||||
"2}?{.4,'(s20:Available commands:%0a)W4.4,'(s42: ,say hello -- disp"
|
||||
"lays nice greeting%0a)W4.4,'(s40: ,peek <fname> -- check if file exis"
|
||||
"ts%0a)W4.4,'(s50: ,q -- disable informational messages%0a)"
|
||||
"W4.4,'(s50: ,quiet on -- disable informational messages%0a)W4.4,'"
|
||||
"(s49: ,quiet off -- enable informational messages%0a)W4.4,'(s37: ,"
|
||||
"v -- turn verbosity on%0a)W4.4,'(s37: ,verbose on -- tu"
|
||||
"rn verbosity on%0a)W4.4,'(s38: ,verbose off -- turn verbosity off%0a"
|
||||
")W4.4,'(s38: ,verbose off -- turn verbosity off%0a)W4.4,'(s54: ,ref "
|
||||
"<name> -- show current denotation for <name>%0a)W4.4,'(s43: ,rnr "
|
||||
" -- show root name registry%0a)W4.4,'(s48: ,rref <name> -- lo"
|
||||
"okup name in root registry%0a)W4.4,'(s50: ,rrem! <name> -- remove nam"
|
||||
"e from root registry%0a)W4.4,'(s43: ,unr -- show user name r"
|
||||
"egistry%0a)W4.4,'(s48: ,uref <name> -- lookup name in user registry%"
|
||||
"0a)W4.4,'(s50: ,urem! <name> -- remove name from user registry%0a)W4."
|
||||
"4,'(s48: ,time <expr> -- time short expression <expr>%0a)W4.4,'(s29:"
|
||||
" ,help -- this help%0a)W4]5}.4,'(s29:syntax error in repl com"
|
||||
"mand%0a)W4.4,'(s37:type ,help to see available commands%0a)W4]5",
|
||||
|
||||
"P", "repl-from-port",
|
||||
"%3,#0${@(y18:current-file-stack)[00}.!0${k0,.0,${.2,.9,.(i11),.(i10),&"
|
||||
|
|
Loading…
Reference in a new issue