To setup Vast you first need to clone it with
git clone https://github.com/jnpn/vast.git
cd vast
Now that you have it cloned, Vast can be used either as a REPL,
python src/main.py repl
>>> def f(x): return x + 1 RET
;; elisp output
Or Vast can be passed a file to transpile,
python src/main.py load-file "</path/to/file.py>"
which will then print out the transpiled code into the terminal as well as write it to
a file with the same filename, but ending in .el
.
pytest
DONE | ternary if | |
DONE | varargs | |
DONE | multiline repl | |
TODO | implement list, set, map python API | rely on dash.el as a starting point ? |
TODO | desugar python idioms into FP | |
TODO | isomorphic Visitor from ~FP tree to Lisp | |
TODO | Add prelude generation |
(defun list-slice (l &optional beg end ...step?)
(-drop beg (-take end l)))
slice =lisp. drop beg (take end)
append =lisp. append
update =lisp. nth . rplaca
pop =lisp. cdr
push =lisp. cons
- Guarantees presence of a strict subset of ast nodes.
- No more ListComp, SetComp, Aug…, …
[fun gen...]
gen* [fst (name iter pred) ...] ->
(map (lambda (<lisp name>)
<gen* ...>
)
(filter <lisp pred> <lisp iter>))
gen* [] -> <lisp fun>
- bootstrap generic python operation add, not, is, in, …
- prepend to emacs lisp generation.
add, iadd, sub… as generic-<op>
(defun generic-add(a b)
(cond ((and (numberp a) (numberp b)) (+ a b))
((and (stringp a) (stringp b)) (string-join a b))
((and (floatp a) (floatp b)) (+ a b))
((and (characterp a) (characterp b)) (string-join a b))
((and (consp a) (consp b)) (append a b))
(t (error "non supported combination" a b))))
;;; or transpile a table of monomorphic relations
'((numberp . +)
(floatp . +)
(stringp . string-join)
(characterp . (lambda (&rest chars)
(string-join
(mapcar #'char-to-string chars))))
(consp . append))
def f(a, b):
return a + b
(defun f(a b)
(generic-add a b))