Overview
In this section, I'll give a pair of LisPy code and corresponding Python code for each AST node. Checkout the Python AST documentation for more information about each node.
Corresponding python code is generated by l2py command in usage section.
example¶
LisPy Version
Python versionLexical syntax¶
;starts a comment that runs to the end of the line. It ends any token, so a comment may follow with no space:(print "a"); comment.- Hyphens in a name become underscores in Python:
my-varismy_var. :kw valueinside a call is the keyword argumentkw=value:(f a :kw 1 :other-kw 2)isf(a, kw=1, other_kw=2).*xand**xunpack a sequence or mapping in a call:(f *xs **kw)isf(*xs, **kw). The*or**is glued to the form.^typeis a type annotation; it follows the name it annotates:(def f [a ^int b] ^int ...)isdef f(a: int, b) -> int, and(= a ^int 1)isa: int = 1.',`,~and~@(quote, syntax-quote, unquote, unquote-splicing) are glued to the form they apply to;' xis an error.- A string may span lines: the line break is part of the string.