lispython 0.4.6__tar.gz → 0.4.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lispython-0.4.6 → lispython-0.4.7}/.gitignore +3 -1
- {lispython-0.4.6 → lispython-0.4.7}/PKG-INFO +1 -1
- {lispython-0.4.6 → lispython-0.4.7}/pyproject.toml +1 -1
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/compiler/expr.py +2 -1
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/macro.py +13 -8
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/nodes.py +1 -1
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/macros/sugar.lpy +2 -2
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/tools.lpy +13 -7
- {lispython-0.4.6 → lispython-0.4.7}/uv.lock +1 -1
- lispython-0.4.6/.claude/settings.local.json +0 -11
- {lispython-0.4.6 → lispython-0.4.7}/.pre-commit-config.yaml +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/.vscode/settings.json +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/LICENSE.md +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/README.md +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/docs/index.md +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/docs/macros.md +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/docs/syntax/expressions.md +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/docs/syntax/overview.md +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/docs/syntax/statements.md +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/docs/usage/cli.md +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/docs/usage/getting-started.md +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/docs/version_macro.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/docs/why-lispy.md +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/mkdocs.yml +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/__init__.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/builtins.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/compiler/__init__.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/compiler/literal.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/compiler/stmt.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/compiler/utils.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/importer.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/meta_functions.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/parser.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core/utils.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/core_meta_functions.lpy +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/lsp/__init__.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/lsp/__main__.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/lsp/server.lpy +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/macros/__init__.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/src/lispy/macros/init.lpy +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/tests/__init__.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/tests/test_as_thread.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/tests/test_expr.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/tests/test_gensym.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/tests/test_include_meta.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/tests/test_literal.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/tests/test_literal_unwrap.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/tests/test_meta_functions.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/tests/test_parser.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/tests/test_stmt.py +0 -0
- {lispython-0.4.6 → lispython-0.4.7}/tests/utils.py +0 -0
|
@@ -107,7 +107,8 @@ def ifexp_p(sexp):
|
|
|
107
107
|
|
|
108
108
|
|
|
109
109
|
def ifexp_compile(sexp):
|
|
110
|
-
[_, test, body,
|
|
110
|
+
[_, test, body, *rest] = sexp.list
|
|
111
|
+
orelse = rest[0] if rest else Constant("None", **sexp.position_info)
|
|
111
112
|
return ast.IfExp(
|
|
112
113
|
test=expr_compile(test),
|
|
113
114
|
body=expr_compile(body),
|
|
@@ -40,14 +40,19 @@ def define_macro(sexp, scope, include_meta=True):
|
|
|
40
40
|
|
|
41
41
|
def require_macro(sexp, scope, include_meta=True):
|
|
42
42
|
transformed = require_transform(sexp)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
try:
|
|
44
|
+
eval(
|
|
45
|
+
compile(
|
|
46
|
+
ast.Interactive(body=macroexpand_then_compile([transformed], include_meta=include_meta)),
|
|
47
|
+
"macro-requiring",
|
|
48
|
+
"single",
|
|
49
|
+
),
|
|
50
|
+
scope,
|
|
51
|
+
)
|
|
52
|
+
except (ModuleNotFoundError, ImportError):
|
|
53
|
+
import sys
|
|
54
|
+
module_name = str(sexp.list[1])
|
|
55
|
+
print(f"l2py: warning: could not load macros from '{module_name}' (module not found)", file=sys.stderr)
|
|
51
56
|
return transformed if include_meta else None
|
|
52
57
|
|
|
53
58
|
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
(return `(if ~test ~then (cond ~@orelse))))))
|
|
6
6
|
|
|
7
7
|
(defmacro conde [*body]
|
|
8
|
-
(if (
|
|
9
|
-
(return
|
|
8
|
+
(if (<= (len body) 2)
|
|
9
|
+
(return (sub body -1))
|
|
10
10
|
(do (= [test then *orelse] body)
|
|
11
11
|
(return `(ife ~test ~then (conde ~@orelse))))))
|
|
12
12
|
|
|
@@ -25,17 +25,21 @@
|
|
|
25
25
|
(from lispy.core.parser [parse])
|
|
26
26
|
(from lispy.core.macro [macroexpand macroexpand-then-compile])
|
|
27
27
|
|
|
28
|
+
(def has-init-file [dir-path]
|
|
29
|
+
(return (or (osp.exists (osp.join dir-path "__init__.py"))
|
|
30
|
+
(osp.exists (osp.join dir-path "__init__.lpy")))))
|
|
31
|
+
|
|
28
32
|
(def detect-package-name [:path None]
|
|
29
|
-
"Detect package name from directory by checking for __init__.py"
|
|
33
|
+
"Detect package name from directory by checking for __init__.py or __init__.lpy"
|
|
30
34
|
(= dir-path (ife (is path None)
|
|
31
35
|
(os.getcwd)
|
|
32
36
|
(osp.dirname (osp.abspath path))))
|
|
33
|
-
(if (not (
|
|
37
|
+
(if (not (has-init-file dir-path))
|
|
34
38
|
(return ""))
|
|
35
39
|
;; Walk up to find package root
|
|
36
40
|
(= parts [])
|
|
37
41
|
(= current dir-path)
|
|
38
|
-
(while (
|
|
42
|
+
(while (has-init-file current)
|
|
39
43
|
(parts.insert 0 (osp.basename current))
|
|
40
44
|
(= parent (osp.dirname current))
|
|
41
45
|
(if (== parent current)
|
|
@@ -114,9 +118,12 @@
|
|
|
114
118
|
|
|
115
119
|
(def l2py-f [file-path :include-meta False :no-lispy False :format True]
|
|
116
120
|
"Translate lispy file to Python source string (standalone with sys.path setup)"
|
|
117
|
-
|
|
118
|
-
(
|
|
119
|
-
|
|
121
|
+
;; Detect package first so we add the right directory to sys.path
|
|
122
|
+
(= pkg (detect-package-name :path file-path))
|
|
123
|
+
(if (not pkg)
|
|
124
|
+
(do (= script-dir (osp.dirname (osp.abspath file-path)))
|
|
125
|
+
(if (not (in script-dir sys.path))
|
|
126
|
+
(sys.path.insert 0 script-dir))))
|
|
120
127
|
|
|
121
128
|
;; Clear cached macro modules to ensure fresh reload
|
|
122
129
|
(= modules-to-remove [])
|
|
@@ -132,7 +139,6 @@
|
|
|
132
139
|
|
|
133
140
|
(with [(open file-path "rb") as f]
|
|
134
141
|
(= src (.decode (f.read) "utf-8")))
|
|
135
|
-
(= pkg (detect-package-name :path file-path))
|
|
136
142
|
(return (+ (l2py-s src :include-meta include_meta :fresh-scope True :package pkg :no-lispy no_lispy :format format) "\n")))
|
|
137
143
|
|
|
138
144
|
(def l2py []
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|