9.1
rkt-pythonize
| (require rkt-pythonize) | package: rkt-pythonize |
My Scheme2Python Compiler. The interpreter is tested against CPython(3.10-3.14), PyPy(3.10-3.11) and mypy 1.18.
1 Supported Features
Named let
TCO(Tail-Call Optimization)
Stream
Inlining
Partial evaluation
Scripting
2 Syntax
(define-language L13 (entry Expr) (terminals (arity (ar)) (name (nm)) (constant (c)) (variable (x)) (datum (d))) (Expr (e body) (throw e) (with-handler e body ...) (cond (e0 e1 ...) ... el) (stream-cdr e) (stream-car e) (stream-cons e0 e1) (#%scm-procedure e ar) (#%vm-procedure e ar) (=>! e0 nm* ... nm0 e1) (=> e0 nm* ...) (if e0 e1) (if e0 e1 e2) (or e* ...) (and e* ...) (let x ((x* e*) ...) body* ...) (letrec ((x e) ...) body ...) (let ((x e) ...) body ...) c (let/cc x body* ...) (lambda (x* ...) body* ...) x (begin e* ...) (set! x e) 'd (closure d0 d1 e) (e0 e* ...)) (Argument (a) x (box x)) (Else (el) (else e* ...)))
(define-language LS (entry Script) (terminals (arity (ar)) (name (nm)) (constant (c)) (variable (x)) (datum (d))) (Expr (e body) (throw e) (with-handler e body ...) (cond (e0 e1 ...) ... el) (stream-cdr e) (stream-car e) (stream-cons e0 e1) (#%scm-procedure e ar) (#%vm-procedure e ar) (=>! e0 nm* ... nm0 e1) (=> e0 nm* ...) (if e0 e1) (if e0 e1 e2) (or e* ...) (and e* ...) (let x ((x* e*) ...) body* ...) (letrec ((x e) ...) body ...) (let ((x e) ...) body ...) c (let/cc x body* ...) (lambda (x* ...) body* ...) x (begin e* ...) (set! x e) 'd (closure d0 d1 e) (e0 e* ...)) (Argument (a) x (box x)) (Else (el) (else e* ...)) (Definition (def) (define x e)) (Statement (st) def e) (Script (sc) (#%script-begin st ...)))
3 Default Primitives
'(print apply make-procedure make-python-procedure vm-apply dynamic-require get-attribute set-attribute! raise error none ! @ ? <! length set-box! unbox box cons car cdr null not equal? eq? + - * / quotient modulo negate > < is-a? object-type stream-type box-type closure-type exn-type str-type int-type linked-list-type)
4 Examples
5 Functions
parameter
(current-primitives) → (listof symbol?)
(current-primitives primitives) → void? primitives : (listof symbol?)
language
L : any/c
language
LS : any/c
compiler
(compile-scheme-code code dest [ #:raw? raw? #:script? script?]) → any code : any/c dest : path-string? raw? : boolean? = #f script? : boolean? = #f
parser
(parse-L code) → any
code : any/c
unparser
(unparse-L s-exp) → any
s-exp : any/c
parser
(parse-LS code) → any
code : any/c
unparser
(unparse-LS s-exp) → any
s-exp : any/c