lambda-repl 1.2.0__tar.gz → 1.2.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 (28) hide show
  1. lambda_repl-1.2.1/.flake8 +3 -0
  2. lambda_repl-1.2.1/.gitignore +164 -0
  3. {lambda_repl-1.2.0 → lambda_repl-1.2.1}/PKG-INFO +7 -4
  4. {lambda_repl-1.2.0 → lambda_repl-1.2.1}/README.md +1 -0
  5. lambda_repl-1.2.1/codecov +0 -0
  6. lambda_repl-1.2.1/codecov.SHA256SUM +1 -0
  7. lambda_repl-1.2.1/codecov.SHA256SUM.sig +16 -0
  8. {lambda_repl-1.2.0 → lambda_repl-1.2.1}/pyproject.toml +38 -9
  9. {lambda_repl-1.2.0 → lambda_repl-1.2.1/src}/lambda_repl/__init__.py +2 -2
  10. lambda_repl-1.2.1/src/lambda_repl/grammar.lark +13 -0
  11. {lambda_repl-1.2.0 → lambda_repl-1.2.1/src}/lambda_repl/parsing.py +12 -7
  12. lambda_repl-1.2.1/tests/__init__.py +0 -0
  13. {lambda_repl-1.2.0 → lambda_repl-1.2.1}/tests/test_parsing.py +4 -0
  14. lambda_repl-1.2.0/lambda_repl/grammar.lark +0 -11
  15. lambda_repl-1.2.0/lambda_repl.egg-info/PKG-INFO +0 -57
  16. lambda_repl-1.2.0/lambda_repl.egg-info/SOURCES.txt +0 -19
  17. lambda_repl-1.2.0/lambda_repl.egg-info/dependency_links.txt +0 -1
  18. lambda_repl-1.2.0/lambda_repl.egg-info/entry_points.txt +0 -2
  19. lambda_repl-1.2.0/lambda_repl.egg-info/requires.txt +0 -2
  20. lambda_repl-1.2.0/lambda_repl.egg-info/top_level.txt +0 -1
  21. lambda_repl-1.2.0/setup.cfg +0 -4
  22. {lambda_repl-1.2.0 → lambda_repl-1.2.1}/LICENSE +0 -0
  23. {lambda_repl-1.2.0 → lambda_repl-1.2.1/src}/lambda_repl/__main__.py +0 -0
  24. {lambda_repl-1.2.0 → lambda_repl-1.2.1/src}/lambda_repl/aliases.py +0 -0
  25. {lambda_repl-1.2.0 → lambda_repl-1.2.1/src}/lambda_repl/main.py +0 -0
  26. {lambda_repl-1.2.0 → lambda_repl-1.2.1/src}/lambda_repl/py.typed +0 -0
  27. {lambda_repl-1.2.0 → lambda_repl-1.2.1}/tests/test_aliases.py +0 -0
  28. {lambda_repl-1.2.0 → lambda_repl-1.2.1}/tests/test_repl.py +0 -0
@@ -0,0 +1,3 @@
1
+ [flake8]
2
+ max-line-length = 100
3
+ extend-ignore = E221,E501
@@ -0,0 +1,164 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ .direnv
126
+ env/
127
+ venv/
128
+ ENV/
129
+ env.bak/
130
+ venv.bak/
131
+
132
+ # Spyder project settings
133
+ .spyderproject
134
+ .spyproject
135
+
136
+ # Rope project settings
137
+ .ropeproject
138
+
139
+ # mkdocs documentation
140
+ /site
141
+
142
+ # mypy
143
+ .mypy_cache/
144
+ .dmypy.json
145
+ dmypy.json
146
+
147
+ # Pyre type checker
148
+ .pyre/
149
+
150
+ # pytype static type analyzer
151
+ .pytype/
152
+
153
+ # Cython debug symbols
154
+ cython_debug/
155
+
156
+ # PyCharm
157
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
158
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
159
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
160
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
161
+ #.idea/
162
+
163
+ # VSCode
164
+ .vscode/
@@ -1,10 +1,11 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: lambda_repl
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: REPL for the lambda calculus
5
- Author-email: Eric Niklas Wolf <eric_niklas.wolf@mailbox.tu-dresden.de>
6
5
  Project-URL: Repository, https://github.com/Deric-W/lambda_repl
7
6
  Project-URL: Bugtracker, https://github.com/Deric-W/lambda_repl/issues
7
+ Author-email: Eric Niklas Wolf <eric_niklas.wolf@mailbox.tu-dresden.de>
8
+ License-File: LICENSE
8
9
  Classifier: Intended Audience :: Education
9
10
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
10
11
  Classifier: Operating System :: OS Independent
@@ -13,11 +14,13 @@ Classifier: Topic :: Education
13
14
  Classifier: Topic :: Utilities
14
15
  Classifier: Typing :: Typed
15
16
  Requires-Python: >=3.10
17
+ Requires-Dist: lambda-calculus~=3.0
18
+ Requires-Dist: lark~=1.0
16
19
  Description-Content-Type: text/markdown
17
- License-File: LICENSE
18
20
 
19
21
  # lambda_repl
20
22
 
23
+ [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch)
21
24
  ![Tests](https://github.com/Deric-W/lambda_repl/actions/workflows/Tests.yaml/badge.svg)
22
25
  [![codecov](https://codecov.io/gh/Deric-W/lambda_repl/branch/main/graph/badge.svg?token=SU3982mC17)](https://codecov.io/gh/Deric-W/lambda_repl)
23
26
 
@@ -1,5 +1,6 @@
1
1
  # lambda_repl
2
2
 
3
+ [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch)
3
4
  ![Tests](https://github.com/Deric-W/lambda_repl/actions/workflows/Tests.yaml/badge.svg)
4
5
  [![codecov](https://codecov.io/gh/Deric-W/lambda_repl/branch/main/graph/badge.svg?token=SU3982mC17)](https://codecov.io/gh/Deric-W/lambda_repl)
5
6
 
Binary file
@@ -0,0 +1 @@
1
+ 8930c4bb30254a42f3d8c340706b1be340885e20c0df5160a24efa2e030e662b codecov
@@ -0,0 +1,16 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+
3
+ iQIzBAABCgAdFiEEJwNOf9uFDgu8LGL/gGuyiu13mGkFAmnnz8MACgkQgGuyiu13
4
+ mGnysA/7Byxt7YmTKIwMRW8+VOoUCp0mKosnlZMvDyc/lVS1K2xpMxXOl/mIMzPD
5
+ OZT7ApPZ70A2hDrsz631yMMxM9/xDAFPEmWfM3aepoQNsrZjyW8Qh9SSQQPvu+sh
6
+ v6cnZhLBwWty1fvdZTS9RWWBaqheCYSXmrLocLXgrh4TzlHeXxA2dAjNKWXZb5H6
7
+ M6FXnSTuQ5+kckijzzuaZJ7sA9IWQI4CtVXc+n850YPAOpg35xc7aR3vLOL5dlmW
8
+ jICLk0T2DX0PDE7Nw9mQhnRXZsGHifQUPrNsDu2CqRmHMaiP/9dL2LcD8A4bIR46
9
+ R48LTqDu75BueDIGerQya5SH38JZk3E2YAQb7tZMdviDp0yOGeYhNMfxUd8mxs8Q
10
+ oxLhZW73CFOjapQnRxyYaGi27f9ldCQ4w5KrxwM9YaFBr335cFYG183jDDFUYjr2
11
+ gzRi+jwKowr6h0Edx+teoB5B7FO0Gvx5gWhyI8xuoeklIu3iLaDYAyHxmUjHRfMx
12
+ D3ioTVwm+vkq+eIXJfDe0sAlJjTHMo/udsc4aKYmxtgj7Um0Xe8IUmPkopn09F+5
13
+ E5X0yncFG5CPLFHY5xZklEW2pZI2WdkXp/fXwfKUxgME4ntr1C1/y9x2j71bbRtu
14
+ neus07LhjRdYfDb3/9opafzxSJ8sTvkGnMaSfDshYo15dfTU+1g=
15
+ =SKRh
16
+ -----END PGP SIGNATURE-----
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "lambda_repl"
3
- version = "1.2.0"
3
+ version = "1.2.1"
4
4
  description = "REPL for the lambda calculus"
5
5
  requires-python = ">=3.10"
6
6
  keywords = []
@@ -14,7 +14,7 @@ classifiers = [
14
14
  "Typing :: Typed"
15
15
  ]
16
16
  dependencies = [
17
- "lambda-calculus ~= 2.0",
17
+ "lambda-calculus ~= 3.0",
18
18
  "lark ~= 1.0"
19
19
  ]
20
20
 
@@ -34,15 +34,36 @@ Bugtracker = "https://github.com/Deric-W/lambda_repl/issues"
34
34
  lambda-repl = "lambda_repl.main:main_cli"
35
35
 
36
36
  [build-system]
37
- requires = ["setuptools >= 61.0.0"]
38
- build-backend = "setuptools.build_meta"
37
+ requires = ["hatchling"]
38
+ build-backend = "hatchling.build"
39
39
 
40
- [tool.setuptools.package-data]
41
- lambda_repl = [
42
- "py.typed",
43
- "grammar.lark"
40
+ [tool.hatch.envs.hatch-test]
41
+ installer = "pip"
42
+
43
+ [[tool.hatch.envs.hatch-test.matrix]]
44
+ python = ["3.10", "3.11", "3.12", "3.13", "3.14"]
45
+
46
+ [tool.hatch.envs.lint]
47
+ dependencies = [
48
+ "mypy >= 1.0.0",
49
+ "pylint >= 2.12.2",
50
+ "flake8 >= 5.0.0",
51
+ "isort >= 5.10.1"
44
52
  ]
45
53
 
54
+ [tool.hatch.envs.lint.scripts]
55
+ lint = [
56
+ "- flake8 src/lambda_repl",
57
+ "- pylint src/lambda_repl"
58
+ ]
59
+ typecheck = "mypy -p lambda_repl"
60
+ release = [
61
+ "typecheck"
62
+ ]
63
+
64
+ [tool.hatch.build.targets.sdist]
65
+ exclude = ["/.github"]
66
+
46
67
  [tool.mypy]
47
68
  disallow_any_unimported = true
48
69
  disallow_any_generics = true
@@ -52,4 +73,12 @@ strict_optional = true
52
73
  warn_redundant_casts = true
53
74
  warn_unused_ignores = true
54
75
  warn_return_any = true
55
- warn_unreachable = true
76
+ warn_unreachable = true
77
+
78
+ [tool.pylint]
79
+ max-line-length = 100
80
+
81
+ [tool.coverage.run]
82
+ source_pkgs = ["lambda_repl"]
83
+ branch = true
84
+ parallel = true
@@ -15,7 +15,7 @@ from lark.exceptions import UnexpectedInput
15
15
  from .parsing import LambdaTransformer
16
16
  from .aliases import Aliases
17
17
 
18
- __version__ = "1.2.0"
18
+ __version__ = "1.2.1"
19
19
  __author__ = "Eric Niklas Wolf"
20
20
  __email__ = "eric_niklas.wolf@mailbox.tu-dresden.de"
21
21
  __all__ = (
@@ -57,7 +57,7 @@ class LambdaREPL(Cmd):
57
57
  module, _, name = location.strip().rpartition(".")
58
58
  try:
59
59
  term = getattr(import_module(module), name)
60
- except Exception as error:
60
+ except Exception as error: # pylint: disable=W0718
61
61
  self.stdout.write(f"Error while importing: {error}\n")
62
62
  return None
63
63
  if not isinstance(term, Term):
@@ -0,0 +1,13 @@
1
+ _WHITESPACE: /\s+/
2
+
3
+ VARIABLE: /[^\s().λ\\]+/
4
+
5
+ abstraction: ("\\" | "λ") VARIABLE "." term
6
+
7
+ application: _application_term _WHITESPACE (abstraction | _simple_term)
8
+
9
+ ?term: abstraction | _application_term
10
+
11
+ _application_term: application | _simple_term
12
+
13
+ _simple_term: VARIABLE | "(" term ")"
@@ -4,7 +4,7 @@
4
4
 
5
5
  from __future__ import annotations
6
6
  from collections import deque
7
- from collections.abc import Iterator, Sequence
7
+ from collections.abc import Iterator
8
8
  from itertools import chain
9
9
  from lambda_calculus.terms import Abstraction, Application, Term, Variable
10
10
  from lark import Lark, Token
@@ -52,10 +52,10 @@ class LambdaTransformer(Transformer[Token, Term[str]]):
52
52
  """parse a string and return the transformed lambda term"""
53
53
  # the parser sometimes return tokens directly instead of a tree
54
54
  match PARSER.parse(string):
55
- case Token(type="VARIABLE") as name: # type: ignore
56
- return self.VARIABLE(name) # type: ignore
57
- case Token() as token: # type: ignore
58
- raise UnexpectedToken(token, {"VARIABLE",})
55
+ case Token(type="VARIABLE") as name:
56
+ return self.VARIABLE(name)
57
+ case Token() as token:
58
+ raise UnexpectedToken(token, {"VARIABLE", })
59
59
  case tree:
60
60
  return self.transform(tree)
61
61
 
@@ -63,6 +63,10 @@ class LambdaTransformer(Transformer[Token, Term[str]]):
63
63
  """handle unknown nodes"""
64
64
  raise UnexpectedInput(f"unknown node: {data}")
65
65
 
66
+ def __default_token__(self, token: Token) -> Token:
67
+ """handle unknown tokens"""
68
+ raise UnexpectedInput(f"unknown token: {token}")
69
+
66
70
  def VARIABLE(self, name: Token) -> Variable[str]:
67
71
  """transform a variable node"""
68
72
  return Variable(name.value)
@@ -72,9 +76,10 @@ class LambdaTransformer(Transformer[Token, Term[str]]):
72
76
  """transform an abstraction"""
73
77
  return Abstraction(variable.name, body)
74
78
 
75
- def application(self, children: Sequence[Term[str]]) -> Application[str]:
79
+ @v_args(inline=True)
80
+ def application(self, abstraction: Term[str], argument: Term[str]) -> Application[str]:
76
81
  """transform an application"""
77
- return Application.with_arguments(children[0], children[1:])
82
+ return Application(abstraction, argument)
78
83
 
79
84
 
80
85
  PARSER = Lark.open_from_package(
File without changes
@@ -73,6 +73,10 @@ class ParsingTest(TestCase):
73
73
  .apply_to(Variable("b"), Variable("c"))
74
74
  .abstract("a", "b")
75
75
  )
76
+ self.assertEqual(
77
+ self.transformer.transform_string("a λa.a b c"),
78
+ Variable("a").apply_to(Variable("a").apply_to(Variable("b"), Variable("c")).abstract("a"))
79
+ )
76
80
 
77
81
  def test_brackets(self) -> None:
78
82
  """test bracket parsing"""
@@ -1,11 +0,0 @@
1
- _WHITESPACE: /\s+/
2
-
3
- VARIABLE: /[^\s().λ\\]+/
4
-
5
- abstraction: ("\\" | "λ") VARIABLE "." term
6
-
7
- application: ( abstraction | VARIABLE | brackets ) ( _WHITESPACE ( abstraction | VARIABLE | brackets ) )+
8
-
9
- ?brackets: "(" term ")"
10
-
11
- ?term: abstraction | application | VARIABLE | brackets
@@ -1,57 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: lambda-repl
3
- Version: 1.2.0
4
- Summary: REPL for the lambda calculus
5
- Author-email: Eric Niklas Wolf <eric_niklas.wolf@mailbox.tu-dresden.de>
6
- Project-URL: Repository, https://github.com/Deric-W/lambda_repl
7
- Project-URL: Bugtracker, https://github.com/Deric-W/lambda_repl/issues
8
- Classifier: Intended Audience :: Education
9
- Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
10
- Classifier: Operating System :: OS Independent
11
- Classifier: Programming Language :: Python :: 3 :: Only
12
- Classifier: Topic :: Education
13
- Classifier: Topic :: Utilities
14
- Classifier: Typing :: Typed
15
- Requires-Python: >=3.10
16
- Description-Content-Type: text/markdown
17
- License-File: LICENSE
18
-
19
- # lambda_repl
20
-
21
- ![Tests](https://github.com/Deric-W/lambda_repl/actions/workflows/Tests.yaml/badge.svg)
22
- [![codecov](https://codecov.io/gh/Deric-W/lambda_repl/branch/main/graph/badge.svg?token=SU3982mC17)](https://codecov.io/gh/Deric-W/lambda_repl)
23
-
24
- The `lambda_repl` package contains a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)
25
- for the [lambda calculus](https://en.wikipedia.org/wiki/Lambda_calculus).
26
-
27
- To use it, execute `lambda-repl` or `python3 -m lambda_repl` and enter commands.
28
-
29
- ## Requirements
30
-
31
- Python >= 3.10 and the packages [`lambda_calculus`](https://github.com/Deric-W/lambda_calculus)
32
- and [`lark`](https://github.com/lark-parser/lark) are required to use this package.
33
-
34
- ## Installation
35
-
36
- ```sh
37
- python3 -m pip install lambda-repl
38
- ```
39
-
40
- ## Examples
41
-
42
- ```
43
- python3 -m lambda_repl
44
- Welcome to the the Lambda REPL, type 'help' for help
45
- λ alias I = \x.x
46
- λ alias K = λx.λy.x
47
- λ import SUCC = lambda_calculus.terms.arithmetic.SUCCESSOR
48
- λ aliases
49
- I = (λx.x)
50
- K = (λx.(λy.x))
51
- SUCC = (λn.(λf.(λx.(f ((n f) x)))))
52
- λ trace K a b
53
- β ((λy.a) b)
54
- β a
55
- λ exit
56
- Exiting REPL...
57
- ```
@@ -1,19 +0,0 @@
1
- LICENSE
2
- README.md
3
- pyproject.toml
4
- lambda_repl/__init__.py
5
- lambda_repl/__main__.py
6
- lambda_repl/aliases.py
7
- lambda_repl/grammar.lark
8
- lambda_repl/main.py
9
- lambda_repl/parsing.py
10
- lambda_repl/py.typed
11
- lambda_repl.egg-info/PKG-INFO
12
- lambda_repl.egg-info/SOURCES.txt
13
- lambda_repl.egg-info/dependency_links.txt
14
- lambda_repl.egg-info/entry_points.txt
15
- lambda_repl.egg-info/requires.txt
16
- lambda_repl.egg-info/top_level.txt
17
- tests/test_aliases.py
18
- tests/test_parsing.py
19
- tests/test_repl.py
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- lambda-repl = lambda_repl.main:main_cli
@@ -1,2 +0,0 @@
1
- lambda-calculus~=2.0
2
- lark~=1.0
@@ -1 +0,0 @@
1
- lambda_repl
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
File without changes