lispython 0.2.1__tar.gz → 0.3.1__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.
Files changed (43) hide show
  1. lispython-0.3.1/.claude/settings.local.json +11 -0
  2. lispython-0.3.1/.gitignore +324 -0
  3. lispython-0.3.1/.pre-commit-config.yaml +22 -0
  4. {lispython-0.2.1 → lispython-0.3.1}/LICENSE.md +1 -1
  5. {lispython-0.2.1 → lispython-0.3.1}/PKG-INFO +20 -11
  6. {lispython-0.2.1 → lispython-0.3.1}/README.md +5 -2
  7. lispython-0.3.1/docs/index.md +14 -0
  8. lispython-0.3.1/docs/macros.md +57 -0
  9. lispython-0.3.1/docs/syntax/expressions.md +262 -0
  10. lispython-0.3.1/docs/syntax/overview.md +14 -0
  11. lispython-0.3.1/docs/syntax/statements.md +439 -0
  12. lispython-0.3.1/docs/usage/cli.md +22 -0
  13. lispython-0.3.1/docs/usage/getting-started.md +20 -0
  14. lispython-0.3.1/docs/version_macro.py +10 -0
  15. lispython-0.3.1/docs/why-lispy.md +50 -0
  16. lispython-0.3.1/mkdocs.yml +64 -0
  17. lispython-0.3.1/pyproject.toml +52 -0
  18. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/core/compiler/expr.py +489 -489
  19. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/core/compiler/stmt.py +511 -511
  20. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/core/importer.py +24 -9
  21. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/core/macro.py +1 -1
  22. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/core/meta_functions.py +28 -8
  23. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/core/parser.py +7 -1
  24. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/core_meta_functions.lpy +68 -45
  25. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/macros/sugar.lpy +12 -0
  26. lispython-0.3.1/src/lispy/tools.lpy +217 -0
  27. lispython-0.3.1/tests/__init__.py +0 -0
  28. lispython-0.3.1/tests/test_expr.py +34 -0
  29. lispython-0.3.1/tests/test_literal.py +80 -0
  30. lispython-0.3.1/tests/test_parser.py +71 -0
  31. lispython-0.3.1/tests/test_stmt.py +92 -0
  32. lispython-0.3.1/tests/utils.py +8 -0
  33. lispython-0.3.1/uv.lock +812 -0
  34. lispython-0.2.1/pyproject.toml +0 -36
  35. lispython-0.2.1/src/lispy/tools.lpy +0 -150
  36. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/__init__.py +0 -0
  37. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/core/compiler/__init__.py +0 -0
  38. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/core/compiler/literal.py +0 -0
  39. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/core/compiler/utils.py +0 -0
  40. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/core/nodes.py +0 -0
  41. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/core/utils.py +0 -0
  42. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/macros/__init__.py +0 -0
  43. {lispython-0.2.1 → lispython-0.3.1}/src/lispy/macros/init.lpy +0 -0
@@ -0,0 +1,11 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(mike set-default:*)",
5
+ "Bash(uv run python:*)",
6
+ "Bash(uv run pytest:*)"
7
+ ],
8
+ "deny": [],
9
+ "ask": []
10
+ }
11
+ }
@@ -0,0 +1,324 @@
1
+
2
+ # Created by https://www.gitignore.io/api/vim,emacs,python,pycharm,visualstudiocode
3
+ # Edit at https://www.gitignore.io/?templates=vim,emacs,python,pycharm,visualstudiocode
4
+
5
+ ### Emacs ###
6
+ # -*- mode: gitignore; -*-
7
+ *~
8
+ \#*\#
9
+ /.emacs.desktop
10
+ /.emacs.desktop.lock
11
+ *.elc
12
+ auto-save-list
13
+ tramp
14
+ .\#*
15
+
16
+ # Org-mode
17
+ .org-id-locations
18
+ *_archive
19
+
20
+ # flymake-mode
21
+ *_flymake.*
22
+
23
+ # eshell files
24
+ /eshell/history
25
+ /eshell/lastdir
26
+
27
+ # elpa packages
28
+ /elpa/
29
+
30
+ # reftex files
31
+ *.rel
32
+
33
+ # AUCTeX auto folder
34
+ /auto/
35
+
36
+ # cask packages
37
+ .cask/
38
+ dist/
39
+
40
+ # Flycheck
41
+ flycheck_*.el
42
+
43
+ # server auth directory
44
+ /server/
45
+
46
+ # projectiles files
47
+ .projectile
48
+
49
+ # directory configuration
50
+ .dir-locals.el
51
+
52
+ # network security
53
+ /network-security.data
54
+
55
+
56
+ ### PyCharm ###
57
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
58
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
59
+
60
+ # User-specific stuff
61
+ .idea
62
+ .idea/**/workspace.xml
63
+ .idea/**/tasks.xml
64
+ .idea/**/usage.statistics.xml
65
+ .idea/**/dictionaries
66
+ .idea/**/shelf
67
+
68
+ # Generated files
69
+ .idea/**/contentModel.xml
70
+
71
+ # Sensitive or high-churn files
72
+ .idea/**/dataSources/
73
+ .idea/**/dataSources.ids
74
+ .idea/**/dataSources.local.xml
75
+ .idea/**/sqlDataSources.xml
76
+ .idea/**/dynamic.xml
77
+ .idea/**/uiDesigner.xml
78
+ .idea/**/dbnavigator.xml
79
+
80
+ # Gradle
81
+ .idea/**/gradle.xml
82
+ .idea/**/libraries
83
+
84
+ # Gradle and Maven with auto-import
85
+ # When using Gradle or Maven with auto-import, you should exclude module files,
86
+ # since they will be recreated, and may cause churn. Uncomment if using
87
+ # auto-import.
88
+ # .idea/modules.xml
89
+ # .idea/*.iml
90
+ # .idea/modules
91
+
92
+ # CMake
93
+ cmake-build-*/
94
+
95
+ # Mongo Explorer plugin
96
+ .idea/**/mongoSettings.xml
97
+
98
+ # File-based project format
99
+ *.iws
100
+
101
+ # IntelliJ
102
+ out/
103
+
104
+ # mpeltonen/sbt-idea plugin
105
+ .idea_modules/
106
+
107
+ # JIRA plugin
108
+ atlassian-ide-plugin.xml
109
+
110
+ # Cursive Clojure plugin
111
+ .idea/replstate.xml
112
+
113
+ # Crashlytics plugin (for Android Studio and IntelliJ)
114
+ com_crashlytics_export_strings.xml
115
+ crashlytics.properties
116
+ crashlytics-build.properties
117
+ fabric.properties
118
+
119
+ # Editor-based Rest Client
120
+ .idea/httpRequests
121
+
122
+ # Android studio 3.1+ serialized cache file
123
+ .idea/caches/build_file_checksums.ser
124
+
125
+ ### PyCharm Patch ###
126
+ # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
127
+
128
+ # *.iml
129
+ # modules.xml
130
+ # .idea/misc.xml
131
+ # *.ipr
132
+
133
+ # Sonarlint plugin
134
+ .idea/sonarlint
135
+
136
+ ### Python ###
137
+ # Byte-compiled / optimized / DLL files
138
+ __pycache__/
139
+ *.py[cod]
140
+ *$py.class
141
+
142
+ # C extensions
143
+ *.so
144
+
145
+ # Distribution / packaging
146
+ .Python
147
+ build/
148
+ develop-eggs/
149
+ downloads/
150
+ eggs/
151
+ .eggs/
152
+ lib/
153
+ lib64/
154
+ parts/
155
+ sdist/
156
+ var/
157
+ wheels/
158
+ share/python-wheels/
159
+ *.egg-info/
160
+ .installed.cfg
161
+ *.egg
162
+ MANIFEST
163
+
164
+ # PyInstaller
165
+ # Usually these files are written by a python script from a template
166
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
167
+ *.manifest
168
+ *.spec
169
+
170
+ # Installer logs
171
+ pip-log.txt
172
+ pip-delete-this-directory.txt
173
+
174
+ # Unit test / coverage reports
175
+ htmlcov/
176
+ .tox/
177
+ .nox/
178
+ .coverage
179
+ .coverage.*
180
+ .cache
181
+ nosetests.xml
182
+ coverage.xml
183
+ *.cover
184
+ .hypothesis/
185
+ .pytest_cache/
186
+
187
+ # Translations
188
+ *.mo
189
+ *.pot
190
+
191
+ # Django stuff:
192
+ *.log
193
+ local_settings.py
194
+ db.sqlite3
195
+
196
+ # Flask stuff:
197
+ instance/
198
+ .webassets-cache
199
+
200
+ # Scrapy stuff:
201
+ .scrapy
202
+
203
+ # Sphinx documentation
204
+ docs/_build/
205
+
206
+ # PyBuilder
207
+ target/
208
+
209
+ # Jupyter Notebook
210
+ .ipynb_checkpoints
211
+ sandbox.ipynb # to update manually
212
+
213
+ # IPython
214
+ profile_default/
215
+ ipython_config.py
216
+
217
+ # pyenv
218
+ .python-version
219
+
220
+ # celery beat schedule file
221
+ celerybeat-schedule
222
+
223
+ # SageMath parsed files
224
+ *.sage.py
225
+
226
+ # Environments
227
+ .env
228
+ .venv
229
+ env/
230
+ venv/
231
+ ENV/
232
+ env.bak/
233
+ venv.bak/
234
+
235
+ # Spyder project settings
236
+ .spyderproject
237
+ .spyproject
238
+
239
+ # Rope project settings
240
+ .ropeproject
241
+
242
+ # mkdocs documentation
243
+ /site
244
+
245
+ # mypy
246
+ .mypy_cache/
247
+ .dmypy.json
248
+ dmypy.json
249
+
250
+ # Pyre type checker
251
+ .pyre/
252
+
253
+ ### Python Patch ###
254
+ .venv/
255
+
256
+ ### Vim ###
257
+ # Swap
258
+ [._]*.s[a-v][a-z]
259
+ [._]*.sw[a-p]
260
+ [._]s[a-rt-v][a-z]
261
+ [._]ss[a-gi-z]
262
+ [._]sw[a-p]
263
+
264
+ # Session
265
+ Session.vim
266
+
267
+ # Temporary
268
+ .netrwhist
269
+ # Auto-generated tag files
270
+ tags
271
+ # Persistent undo
272
+ [._]*.un~
273
+
274
+ ### VisualStudioCode ###
275
+ .vscode
276
+ .vscode/*
277
+ !.vscode/settings.json
278
+ !.vscode/tasks.json
279
+ !.vscode/launch.json
280
+ !.vscode/extensions.json
281
+
282
+ ### VisualStudioCode Patch ###
283
+ # Ignore all local history of files
284
+ .history
285
+
286
+ ### C++ ###
287
+ # Prerequisites
288
+ *.d
289
+
290
+ # Compiled Object files
291
+ *.slo
292
+ *.lo
293
+ *.o
294
+ *.obj
295
+
296
+ # Precompiled Headers
297
+ *.gch
298
+ *.pch
299
+
300
+ # Compiled Dynamic libraries
301
+ *.so
302
+ *.dylib
303
+ *.dll
304
+
305
+ # Fortran module files
306
+ *.mod
307
+ *.smod
308
+
309
+ # Compiled Static libraries
310
+ *.lai
311
+ *.la
312
+ *.a
313
+ *.lib
314
+
315
+ # Executables
316
+ *.exe
317
+ *.out
318
+ *.app
319
+
320
+ # End of https://www.gitignore.io/api/vim,emacs,python,pycharm,visualstudiocode
321
+
322
+ poetry.lock
323
+ **test.hy
324
+ **temp*
@@ -0,0 +1,22 @@
1
+ # See https://pre-commit.com for more information
2
+ # See https://pre-commit.com/hooks.html for more hooks
3
+ repos:
4
+ - repo: https://github.com/pre-commit/pre-commit-hooks
5
+ rev: v4.5.0
6
+ hooks:
7
+ - id: trailing-whitespace
8
+ - id: end-of-file-fixer
9
+ - id: check-yaml
10
+ - id: check-added-large-files
11
+
12
+ - repo: https://github.com/astral-sh/ruff-pre-commit
13
+ rev: v0.8.0
14
+ hooks:
15
+ - id: ruff
16
+ args: ["--fix"]
17
+ - id: ruff-format
18
+
19
+ - repo: https://github.com/pre-commit/mirrors-mypy
20
+ rev: '' # Use the sha / tag you want to point at
21
+ hooks:
22
+ - id: mypy
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Jethack
3
+ Copyright (c) 2025 Jetack
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,16 +1,22 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: lispython
3
- Version: 0.2.1
3
+ Version: 0.3.1
4
4
  Summary: Lisp-like Syntax for Python with Lisp-like Macros
5
- Home-page: https://jetack.github.io/lispython
6
- License: MIT
7
- Author: Jetack
8
- Author-email: jetack23@gmail.com
9
- Requires-Python: >=3.11,<3.12
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.11
5
+ Project-URL: Homepage, https://jetack.github.io/lispython
13
6
  Project-URL: Repository, https://github.com/jetack/lispython
7
+ Author-email: Jetack <jetack23@gmail.com>
8
+ License: MIT
9
+ License-File: LICENSE.md
10
+ Requires-Python: >=3.11
11
+ Provides-Extra: dev
12
+ Requires-Dist: pre-commit>=3.6.0; extra == 'dev'
13
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
14
+ Requires-Dist: ruff>=0.8.0; extra == 'dev'
15
+ Requires-Dist: toml>=0.10.2; extra == 'dev'
16
+ Provides-Extra: docs
17
+ Requires-Dist: mike>=2.1.3; extra == 'docs'
18
+ Requires-Dist: mkdocs-macros-plugin>=1.3.7; extra == 'docs'
19
+ Requires-Dist: mkdocs-material>=9.6.14; extra == 'docs'
14
20
  Description-Content-Type: text/markdown
15
21
 
16
22
  # LisPython
@@ -61,9 +67,12 @@ lpy -m unittest
61
67
  # Todo
62
68
  ## Environment
63
69
  - [ ] Test on more python versions
64
- - [ ] Some IDE plugins like hy-mode and jedhy for better editing experience.
70
+ - [ ] REPL should track history and arrow key navigation
71
+ - [ ] REPL multi-line input support
72
+ - [ ] Better compileation error messages
65
73
  ## Macro System
66
74
  - [ ] `as->` macro for syntactic sugar
67
75
  - [ ] `gensym` for avoiding name collision
68
76
  ## Python AST
69
77
  - [ ] `type_comment` never considered. Later, it should be covered
78
+ - [ ] Any missing AST nodes in the version 3.12+
@@ -46,9 +46,12 @@ lpy -m unittest
46
46
  # Todo
47
47
  ## Environment
48
48
  - [ ] Test on more python versions
49
- - [ ] Some IDE plugins like hy-mode and jedhy for better editing experience.
49
+ - [ ] REPL should track history and arrow key navigation
50
+ - [ ] REPL multi-line input support
51
+ - [ ] Better compileation error messages
50
52
  ## Macro System
51
53
  - [ ] `as->` macro for syntactic sugar
52
54
  - [ ] `gensym` for avoiding name collision
53
55
  ## Python AST
54
- - [ ] `type_comment` never considered. Later, it should be covered
56
+ - [ ] `type_comment` never considered. Later, it should be covered
57
+ - [ ] Any missing AST nodes in the version 3.12+
@@ -0,0 +1,14 @@
1
+ # LisPython
2
+ This documentation stands for version **{{ version }}**
3
+ **Try LisPy without installing it! : [Web REPL](https://jetack.github.io/lispy-web)**
4
+
5
+ ## What is LisPython?
6
+ Lisp + Python = LisPython.
7
+ I'll use the abbreviation **LisPy** throughout this documentation.
8
+ LisPy provides a new lisp-like syntax for Python. (Thus, macro system too)
9
+
10
+ LisPy is highly inspired by [Clojure](https://clojure.org/) and [Hy](https://hylang.org/).
11
+ I started this project because I want something slightly different from Hy.
12
+ As a standalone language, Hy evolves fast.
13
+ It can be good in general.
14
+ But it's hard for me to keep track of the breaking changes in Hy.
@@ -0,0 +1,57 @@
1
+ # Macros
2
+ LisPy's macro system is highly inspired by Clojure's macro system.
3
+ You can check out the [Chapter 7](https://www.braveclojure.com/read-and-eval/) and [Chapter 8](https://www.braveclojure.com/writing-macros/) of "Brave Clojure" for more information about Clojure's macro system.
4
+ ## Expression Nodes
5
+ These nodes are defined in `src/lispython/core/nodes.py`.
6
+
7
+ You can check out how to manipulate these nodes in
8
+
9
+ - the definitions of nodes themselves
10
+ - the definitions of built-in macros in `src/lispython/macros/sugar.lpy`.
11
+
12
+ ## quote
13
+ ```python
14
+ 'expr
15
+ ```
16
+ ## syntax-quote
17
+ ```python
18
+ `expr
19
+ ```
20
+ ## unquote
21
+ ```python
22
+ ~expr
23
+ ```
24
+ ## unquote-splicing
25
+ ```python
26
+ ~@expr
27
+ ```
28
+ ## Macro Definition
29
+ Just change `def` in function definition to `defmacro`. And macros usually return a quoted expression.
30
+ ```python
31
+ (defmacro name [args*]
32
+ body*)
33
+ ```
34
+ ### Macro Example
35
+ ```python
36
+ (defmacro when [pred *body]
37
+ (return `(if ~pred
38
+ (do ~@body))))
39
+
40
+ (defmacro cond [*body]
41
+ (def recur [*body]
42
+ (if (< (len body) 4)
43
+ (return `(if ~@body))
44
+ (do (= [test then *orelse] body)
45
+ (return `(if ~test ~then ~(recur *orelse))))))
46
+ (return (recur *body)))
47
+
48
+ (defmacro -> [x *fs]
49
+ (if (== 0 (len fs))
50
+ (return x))
51
+ (= [f *rest] fs)
52
+ (if (isinstance f Paren)
53
+ (do (f.list.insert 1 x)
54
+ (return `(-> ~f ~@rest)))
55
+ (return `(-> (~f ~x) ~@rest))))
56
+ ```
57
+ You can find more in `src/lispython/macros/sugar.lpy`.