8000 GitHub - uf5/translucent: WIP Lisp -> Python transpiler.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

uf5/translucent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Translucent

WIP Clojure-flavored Lisp -> Python transpiler.

Note

The transpiler itself translates Lisp code into Python AST. Then it serializes it into JSON, which can then be used to reconstruct the Python program.

Usage:

stack run | tail -n 1 | python3 py/reconstruct_from_json.py

Example

TODO

(if (do (print "a")
        (print "b")
        (print "c")
        (= 1 1))
    (do (print "yes")
        (print (do (print "d")
                   (print "e")
                   "ok")))
    (print "no"))

Will turn into

print('a')
print('b')
print('c')
if 1 == 1:
    print('yes')
    print('d')
    print('e')
    print('ok')
else:
    print('no')

Quirks

Keywords

Because of the way keywords work in Python and in my Lisp dialect, they can be used as strings everywhere except for function arguments. Keywords in functions must have a value associated with them. This value can also be a string represented by a keyword. Examples:

{:key1 :value1 :key2 :value}

and

(print "hello " :end :world)

are fine, but

(print :hello)

will result in

(print :hi)
1:1:
  |
1 | (print :hi)
  | ^
Keyword expression has no value

About

WIP Lisp -> Python transpiler.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published
0