Fixed build files
parent
45493c1093
commit
97aecb01f0
23
README.md
23
README.md
|
@ -1,19 +1,22 @@
|
||||||
# Lamb: A Lambda Calculus Engine
|
# Lamb: A Lambda Calculus Engine
|
||||||
|
|
||||||
|
If you're reading this on PyPi, go [here](https://git.betalupi.com/Mark/lamb).
|
||||||
|
|
||||||
![Lamb screenshot](./misc/screenshot.png)
|
![Lamb screenshot](./misc/screenshot.png)
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### Method 1: PyPi (not yet)
|
### Method 1: PyPi [here](https://pypi.org/project/lamb-engine)
|
||||||
1. Put this on PyPi
|
1. `pip install lamb-engine`
|
||||||
2. Write these instructions
|
2. `lamb`
|
||||||
|
|
||||||
### Method 2: Git
|
### Method 2: Git
|
||||||
1. Clone this repository.
|
1. Clone this repository.
|
||||||
2. Make and enter a [virtual environment](https://docs.python.org/3/library/venv.html).
|
2. Make and enter a [virtual environment](https://docs.python.org/3/library/venv.html).
|
||||||
3. ``cd`` into this directory
|
3. ``cd`` into this directory
|
||||||
4. Run ``pip install .``
|
4. Run ``pip install .``
|
||||||
5. Run ``python .``
|
5. Run ``lamb``
|
||||||
|
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
|
@ -43,7 +46,7 @@ Numbers will automatically be converted to Church numerals. For example, the fol
|
||||||
If an expression takes too long to evaluate, you may interrupt reduction with `Ctrl-C`. \
|
If an expression takes too long to evaluate, you may interrupt reduction with `Ctrl-C`. \
|
||||||
Exit the prompt with `Ctrl-C` or `Ctrl-D`.
|
Exit the prompt with `Ctrl-C` or `Ctrl-D`.
|
||||||
|
|
||||||
There are many useful macros in [macros.lamb](./macros.lamb). Load them with the `:load` command:
|
There are many useful macros in [macros.lamb](./macros.lamb). Download the file, then load them with the `:load` command:
|
||||||
```
|
```
|
||||||
==> :load macros.lamb
|
==> :load macros.lamb
|
||||||
```
|
```
|
||||||
|
@ -86,20 +89,12 @@ The lines in a file look exactly the same as regular entries in the prompt, but
|
||||||
|
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
## Todo (pre-release, in this order):
|
|
||||||
- Write "how it works"
|
|
||||||
- PyPi package
|
|
||||||
|
|
||||||
|
|
||||||
## Todo:
|
## Todo:
|
||||||
- Prevent macro-chaining recursion
|
- Prevent macro-chaining recursion
|
||||||
- Cleanup warnings
|
- Cleanup warnings
|
||||||
- Truncate long expressions in warnings
|
- Truncate long expressions in warnings
|
||||||
- History indexing
|
|
||||||
- Show history command
|
|
||||||
- Loop detection
|
- Loop detection
|
||||||
- $\alpha$-equivalence check
|
- α-equivalence check
|
||||||
- Command-line options (load a file)
|
- Command-line options (load a file)
|
||||||
- Unchurch command: make church numerals human-readable
|
- Unchurch command: make church numerals human-readable
|
||||||
- Better Syntax highlighting
|
- Better Syntax highlighting
|
||||||
|
|
|
@ -3,4 +3,6 @@ from . import nodes
|
||||||
from . import parser
|
from . import parser
|
||||||
|
|
||||||
from .runner import Runner
|
from .runner import Runner
|
||||||
from .runner import StopReason
|
from .runner import StopReason
|
||||||
|
|
||||||
|
from .__main__ import main
|
|
@ -1,6 +1,3 @@
|
||||||
if __name__ != "__main__":
|
|
||||||
raise ImportError("lamb_engine.__main__ should never be imported. Run it directly.")
|
|
||||||
|
|
||||||
from prompt_toolkit import PromptSession
|
from prompt_toolkit import PromptSession
|
||||||
from prompt_toolkit import print_formatted_text as printf
|
from prompt_toolkit import print_formatted_text as printf
|
||||||
from prompt_toolkit.formatted_text import FormattedText
|
from prompt_toolkit.formatted_text import FormattedText
|
||||||
|
@ -9,53 +6,57 @@ from pyparsing import exceptions as ppx
|
||||||
|
|
||||||
import lamb_engine
|
import lamb_engine
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
lamb_engine.utils.show_greeting()
|
lamb_engine.utils.show_greeting()
|
||||||
|
|
||||||
|
|
||||||
r = lamb_engine.Runner(
|
r = lamb_engine.Runner(
|
||||||
prompt_session = PromptSession(
|
prompt_session = PromptSession(
|
||||||
style = lamb_engine.utils.style,
|
style = lamb_engine.utils.style,
|
||||||
lexer = lamb_engine.utils.LambdaLexer(),
|
lexer = lamb_engine.utils.LambdaLexer(),
|
||||||
key_bindings = lamb_engine.utils.bindings
|
key_bindings = lamb_engine.utils.bindings
|
||||||
),
|
),
|
||||||
prompt_message = FormattedText([
|
prompt_message = FormattedText([
|
||||||
("class:prompt", "==> ")
|
("class:prompt", "==> ")
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
i = r.prompt()
|
i = r.prompt()
|
||||||
|
|
||||||
# Catch Ctrl-C and Ctrl-D
|
# Catch Ctrl-C and Ctrl-D
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
printf("\n\nGoodbye.\n")
|
printf("\n\nGoodbye.\n")
|
||||||
break
|
break
|
||||||
except EOFError:
|
except EOFError:
|
||||||
printf("\n\nGoodbye.\n")
|
printf("\n\nGoodbye.\n")
|
||||||
break
|
break
|
||||||
|
|
||||||
# Skip empty lines
|
# Skip empty lines
|
||||||
if i.strip() == "":
|
if i.strip() == "":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Try to run an input line.
|
# Try to run an input line.
|
||||||
# Catch parse errors and point them out.
|
# Catch parse errors and point them out.
|
||||||
try:
|
try:
|
||||||
x = r.run(i)
|
x = r.run(i)
|
||||||
except ppx.ParseException as e:
|
except ppx.ParseException as e:
|
||||||
l = len(to_plain_text(r.prompt_session.message))
|
l = len(to_plain_text(r.prompt_session.message))
|
||||||
printf(FormattedText([
|
printf(FormattedText([
|
||||||
("class:err", " "*(e.loc + l) + "^\n"),
|
("class:err", " "*(e.loc + l) + "^\n"),
|
||||||
("class:err", f"Syntax error at char {e.loc}."),
|
("class:err", f"Syntax error at char {e.loc}."),
|
||||||
("class:text", "\n")
|
("class:text", "\n")
|
||||||
]), style = lamb_engine.utils.style)
|
]), style = lamb_engine.utils.style)
|
||||||
continue
|
continue
|
||||||
except lamb_engine.nodes.ReductionError as e:
|
except lamb_engine.nodes.ReductionError as e:
|
||||||
printf(FormattedText([
|
printf(FormattedText([
|
||||||
("class:err", f"{e.msg}\n")
|
("class:err", f"{e.msg}\n")
|
||||||
]), style = lamb_engine.utils.style)
|
]), style = lamb_engine.utils.style)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
printf("")
|
printf("")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
|
@ -101,7 +101,7 @@ def show_greeting():
|
||||||
"",
|
"",
|
||||||
"<_h> | _.._ _.|_",
|
"<_h> | _.._ _.|_",
|
||||||
" |_(_|| | ||_)</_h>",
|
" |_(_|| | ||_)</_h>",
|
||||||
f" <_v>{version('lamb')}</_v>",
|
f" <_v>{version('lamb_engine')}</_v>",
|
||||||
" __ __",
|
" __ __",
|
||||||
" ,-` `` `,",
|
" ,-` `` `,",
|
||||||
" (` <_l>\\</_l> )",
|
" (` <_l>\\</_l> )",
|
||||||
|
|
|
@ -1,30 +1,28 @@
|
||||||
|
[build-system]
|
||||||
|
requires = [ "setuptools>=61.0" ]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
where = [ "." ]
|
||||||
|
include = ["lamb_engine*"]
|
||||||
|
namespaces = false
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
lamb = "lamb_engine:main"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "Lamb"
|
name = "lamb_engine"
|
||||||
description = "A lambda calculus engine"
|
description = "A lambda calculus engine"
|
||||||
|
version = "1.1.5"
|
||||||
# We use the standard semantic versioning:
|
|
||||||
# maj.min.pat
|
|
||||||
#
|
|
||||||
# Major release:
|
|
||||||
# 1.0.0 is the first stable release.
|
|
||||||
# Incremented on BIG breaking changes.
|
|
||||||
#
|
|
||||||
# Minor release:
|
|
||||||
# Large bug fixes, new features
|
|
||||||
#
|
|
||||||
# Patch release:
|
|
||||||
# Small, compatible fixes.
|
|
||||||
version = "1.1.4"
|
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"prompt-toolkit==3.0.31",
|
"prompt-toolkit==3.0.31",
|
||||||
"pyparsing==3.0.9"
|
"pyparsing==3.0.9"
|
||||||
]
|
]
|
||||||
|
|
||||||
authors = [
|
authors = [
|
||||||
{ name="Mark", email="mark@betalupi.com" }
|
{ name="Mark", email="mark@betalupi.com" }
|
||||||
]
|
]
|
||||||
|
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.7"
|
requires-python = ">=3.7"
|
||||||
license = {text = "GNU General Public License v3 (GPLv3)"}
|
license = {text = "GNU General Public License v3 (GPLv3)"}
|
||||||
|
@ -35,16 +33,10 @@ classifiers = [
|
||||||
"Environment :: Console"
|
"Environment :: Console"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
"Homepage" = "https://git.betalupi.com/Mark/lamb"
|
"Homepage" = "https://git.betalupi.com/Mark/lamb"
|
||||||
|
|
||||||
|
# To build:
|
||||||
[build-system]
|
# pip install build twine
|
||||||
requires = [ "setuptools>=61.0" ]
|
# python -m build
|
||||||
build-backend = "setuptools.build_meta"
|
# python -m twine upload dist/*
|
||||||
|
|
||||||
[tool.setuptools.packages.find]
|
|
||||||
where = ["lamb_engine"]
|
|
||||||
include = ["lamb_engine*"]
|
|
||||||
namespaces = false
|
|
Reference in New Issue