Compare commits
30 Commits
78cc118bfc
...
master
Author | SHA1 | Date | |
---|---|---|---|
5bff77e4a7 | |||
8c8ea69890 | |||
6d14333e52 | |||
ab9057148a | |||
c07edf1b50 | |||
1bb0b91e20
|
|||
b20604de5c | |||
d2f8b1c8fb
|
|||
3022c2ffc0
|
|||
acbc247e10
|
|||
907d2d9e79
|
|||
73f4c60c06 | |||
fe7e6fca13
|
|||
866cb64485
|
|||
09a389857a
|
|||
da997b80c7
|
|||
1b951813f4
|
|||
12d6176f63
|
|||
787dbd9091
|
|||
67b2332e1c
|
|||
115b7289e7
|
|||
69bf43f295
|
|||
495c947441
|
|||
b26d968884
|
|||
e8bd6997b9
|
|||
97aecb01f0
|
|||
45493c1093
|
|||
a30bd7b870
|
|||
f3d02721ad
|
|||
48e7d405dd
|
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,7 +1,13 @@
|
||||
# Python dev files
|
||||
venv
|
||||
__pycache__
|
||||
|
||||
# Python build files
|
||||
*.egg-info
|
||||
*.spec
|
||||
build
|
||||
dist
|
||||
dist
|
||||
|
||||
# Misc
|
||||
*.gif
|
||||
misc/secrets.sh
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -1,5 +1,6 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"appendleft",
|
||||
"autochurch",
|
||||
"delmac",
|
||||
"Endnodes",
|
||||
@ -7,6 +8,7 @@
|
||||
"mdel",
|
||||
"onefile",
|
||||
"Packrat",
|
||||
"printables",
|
||||
"pyparsing",
|
||||
"rlimit",
|
||||
"runstatus",
|
||||
|
83
README.md
83
README.md
@ -1,26 +1,43 @@
|
||||
# Lamb: A Lambda Calculus Engine
|
||||
# 🐑 Lamb: A Lambda Calculus Engine
|
||||
|
||||

|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
### Method 1: PyPi (not yet)
|
||||
1. Put this on PyPi
|
||||
2. Write these instructions
|
||||
|
||||
## :brain: What is lambda calculus?
|
||||
|
||||
- [video 1](https://www.youtube.com/watch?v=3VQ382QG-y4): Introduction and boolean logic. The first few minutes are a bit confusing, but it starts to make sense at about [`6:50`](https://youtu.be/3VQ382QG-y4?t=400)
|
||||
|
||||
- [video 2](https://www.youtube.com/watch?v=pAnLQ9jwN-E): Continuation of video 1. Features combinators and numerals.
|
||||
|
||||
- [blog](https://www.driverlesscrocodile.com/technology/lambda-calculus-for-people-a-step-behind-me-1): Another introduction. Moves slower than the two videos above and doesn't assume CS knowledge. Four-part series.
|
||||
|
||||
- [handout](https://static.betalupi.com/ormc/Advanced/Lambda%20Calculus.pdf): A handout I've written on lambda calculus.
|
||||
|
||||
## :package: Installation
|
||||
|
||||
### Method 1: [PyPi](https://pypi.org/project/lamb-engine)
|
||||
1. *(Optional but recommended)* make and enter a [venv](https://docs.python.org/3/library/venv.html)
|
||||
- **On Windows, run the following in cmd or powershell:**
|
||||
- `cd Desktop`
|
||||
- `python -m venv lamb`
|
||||
- `.\Scripts\activate`
|
||||
2. `pip install lamb-engine`
|
||||
3. `lamb`
|
||||
|
||||
### Method 2: Git
|
||||
1. Clone this repository.
|
||||
2. Make and enter a [virtual environment](https://docs.python.org/3/library/venv.html).
|
||||
3. ``cd`` into this directory
|
||||
4. Run ``pip install .``
|
||||
5. Run ``python .``
|
||||
5. Run ``lamb``
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
## Usage
|
||||
## 📖 Usage
|
||||
|
||||
|
||||
Type lambda expressions into the prompt, and Lamb will evaluate them. \
|
||||
Type expressions into the prompt, and Lamb will evaluate them. \
|
||||
Use your `\` (backslash) key to type a `λ`. \
|
||||
To define macros, use `=`. For example,
|
||||
```
|
||||
@ -43,35 +60,47 @@ 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`. \
|
||||
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
|
||||
```
|
||||
|
||||
You can also pass files to lamb directly to have them loaded at startup:
|
||||
```
|
||||
lamb file1 file2
|
||||
```
|
||||
|
||||
Use your up/down arrows to recall history.
|
||||
|
||||
Have fun!
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
## Commands
|
||||
## :card_file_box: Commands
|
||||
|
||||
Lamb understands many commands. Prefix them with a `:` in the prompt.
|
||||
|
||||
`:help` Prints a help message
|
||||
`:help` Print a help message
|
||||
|
||||
`:clear` Clear the screen
|
||||
|
||||
`:rlimit [int | None]` Set maximum reduction limit. `:rlimit none` sets no limit.
|
||||
|
||||
`:macros` List macros in the current environment.
|
||||
`:macros` List macros.
|
||||
|
||||
`:mdel [macro]` Delete a macro
|
||||
|
||||
`:step [yes | no]` Enable or disable step-by-step reduction. Toggle if no argument is given.
|
||||
`:delmac` Delete all macros
|
||||
|
||||
`:step [yes | no]` Enable or disable step-by-step reduction. Toggle if no argument is given. When reducing by steps, the prompt tells you what kind of reduction was done last:
|
||||
|
||||
- `M`: Macro expansion
|
||||
- `C`: Church expansion
|
||||
- `H`: History expansion
|
||||
- `F`: Function application
|
||||
|
||||
`:expand [yes | no]` Enable or disable full expansion. Toggle if no argument is given. If full expansion is enabled, ALL macros will be expanded when printing output.
|
||||
|
||||
`:delmac` Delete all macros
|
||||
|
||||
`:save [filename]` \
|
||||
`:load [filename]` \
|
||||
Save or load macros from a file.
|
||||
@ -79,26 +108,12 @@ The lines in a file look exactly the same as regular entries in the prompt, but
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
|
||||
## Todo (pre-release, in this order):
|
||||
- History queue
|
||||
- Prevent macro-chaining recursion
|
||||
- Update screenshot
|
||||
- Update documentation
|
||||
- Write "how it works"
|
||||
- PyPi package
|
||||
|
||||
|
||||
## Todo:
|
||||
- Prevent macro-chaining recursion
|
||||
- Cleanup warnings
|
||||
- Syntax highlight printouts
|
||||
- Truncate long expressions in warnings
|
||||
- History indexing
|
||||
- Show history command
|
||||
- Loop detection
|
||||
- $\alpha$-equivalence check
|
||||
- Command-line options (load a file)
|
||||
- Unchurch command: make church numerals human-readable
|
||||
- Better Syntax highlighting
|
||||
- Complete file names and commands
|
||||
- Tests
|
||||
- Better syntax highlighting
|
||||
- Tab-complete file names and commands
|
||||
- Load default macros without manually downloading `macros.lamb` (via `requests`, maybe?)
|
10
build_bin.py
10
build_bin.py
@ -1,10 +0,0 @@
|
||||
import PyInstaller.__main__
|
||||
|
||||
# Run this file to build a standalone executable.
|
||||
# pyinstaller does not build cross-platform.
|
||||
|
||||
PyInstaller.__main__.run([
|
||||
"lamb/__main__.py",
|
||||
"--onefile",
|
||||
"--console"
|
||||
])
|
@ -1,61 +0,0 @@
|
||||
if __name__ != "__main__":
|
||||
raise ImportError("lamb.__main__ should never be imported. Run it directly.")
|
||||
|
||||
from prompt_toolkit import PromptSession
|
||||
from prompt_toolkit import print_formatted_text as printf
|
||||
from prompt_toolkit.formatted_text import FormattedText
|
||||
from prompt_toolkit.formatted_text import to_plain_text
|
||||
from pyparsing import exceptions as ppx
|
||||
|
||||
import lamb
|
||||
|
||||
|
||||
lamb.utils.show_greeting()
|
||||
|
||||
|
||||
r = lamb.Runner(
|
||||
prompt_session = PromptSession(
|
||||
style = lamb.utils.style,
|
||||
lexer = lamb.utils.LambdaLexer(),
|
||||
key_bindings = lamb.utils.bindings
|
||||
),
|
||||
prompt_message = FormattedText([
|
||||
("class:prompt", "==> ")
|
||||
])
|
||||
)
|
||||
|
||||
while True:
|
||||
try:
|
||||
i = r.prompt()
|
||||
|
||||
# Catch Ctrl-C and Ctrl-D
|
||||
except KeyboardInterrupt:
|
||||
printf("\n\nGoodbye.\n")
|
||||
break
|
||||
except EOFError:
|
||||
printf("\n\nGoodbye.\n")
|
||||
break
|
||||
|
||||
# Skip empty lines
|
||||
if i.strip() == "":
|
||||
continue
|
||||
|
||||
# Try to run an input line.
|
||||
# Catch parse errors and point them out.
|
||||
try:
|
||||
x = r.run(i)
|
||||
except ppx.ParseException as e:
|
||||
l = len(to_plain_text(r.prompt_session.message))
|
||||
printf(FormattedText([
|
||||
("class:err", " "*(e.loc + l) + "^\n"),
|
||||
("class:err", f"Syntax error at char {e.loc}."),
|
||||
("class:text", "\n")
|
||||
]), style = lamb.utils.style)
|
||||
continue
|
||||
except lamb.nodes.ReductionError as e:
|
||||
printf(FormattedText([
|
||||
("class:err", f"{e.msg}\n")
|
||||
]), style = lamb.utils.style)
|
||||
continue
|
||||
|
||||
printf("")
|
@ -3,4 +3,6 @@ from . import nodes
|
||||
from . import parser
|
||||
|
||||
from .runner import Runner
|
||||
from .runner import StopReason
|
||||
from .runner import StopReason
|
||||
|
||||
from .__main__ import main
|
79
lamb_engine/__main__.py
Executable file
79
lamb_engine/__main__.py
Executable file
@ -0,0 +1,79 @@
|
||||
from prompt_toolkit import PromptSession
|
||||
from prompt_toolkit import print_formatted_text as printf
|
||||
from prompt_toolkit.formatted_text import FormattedText
|
||||
from prompt_toolkit.formatted_text import to_plain_text
|
||||
from pyparsing import exceptions as ppx
|
||||
import sys
|
||||
|
||||
import lamb_engine
|
||||
|
||||
def main():
|
||||
|
||||
lamb_engine.utils.show_greeting()
|
||||
|
||||
|
||||
r = lamb_engine.Runner(
|
||||
prompt_session = PromptSession(
|
||||
style = lamb_engine.utils.style,
|
||||
lexer = lamb_engine.utils.LambdaLexer(),
|
||||
key_bindings = lamb_engine.utils.bindings
|
||||
),
|
||||
prompt_message = FormattedText([
|
||||
("class:prompt", "==> ")
|
||||
])
|
||||
)
|
||||
|
||||
# Load files passed as arguments
|
||||
if len(sys.argv) > 1:
|
||||
for i in range(1, len(sys.argv)):
|
||||
try:
|
||||
printf(FormattedText([
|
||||
("class:warn", "\nLoading file "),
|
||||
("class:code", sys.argv[i]),
|
||||
]), style = lamb_engine.utils.style)
|
||||
r.run(":load " + sys.argv[i])
|
||||
except:
|
||||
printf(FormattedText([
|
||||
("class:err", "Error. Does this file exist?"),
|
||||
]), style = lamb_engine.utils.style)
|
||||
|
||||
print("")
|
||||
|
||||
while True:
|
||||
try:
|
||||
i = r.prompt()
|
||||
|
||||
# Catch Ctrl-C and Ctrl-D
|
||||
except KeyboardInterrupt:
|
||||
printf("\n\nGoodbye.\n")
|
||||
break
|
||||
except EOFError:
|
||||
printf("\n\nGoodbye.\n")
|
||||
break
|
||||
|
||||
# Skip empty lines
|
||||
if i.strip() == "":
|
||||
continue
|
||||
|
||||
# Try to run an input line.
|
||||
# Catch parse errors and point them out.
|
||||
try:
|
||||
x = r.run(i)
|
||||
except ppx.ParseException as e:
|
||||
l = len(to_plain_text(r.prompt_session.message))
|
||||
printf(FormattedText([
|
||||
("class:err", " "*(e.loc + l) + "^\n"),
|
||||
("class:err", f"Syntax error at char {e.loc}."),
|
||||
("class:text", "\n")
|
||||
]), style = lamb_engine.utils.style)
|
||||
continue
|
||||
except lamb_engine.nodes.ReductionError as e:
|
||||
printf(FormattedText([
|
||||
("class:err", f"{e.msg}\n")
|
||||
]), style = lamb_engine.utils.style)
|
||||
continue
|
||||
|
||||
printf("")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -1,5 +1,5 @@
|
||||
import lamb
|
||||
import lamb.nodes as lbn
|
||||
import lamb_engine
|
||||
import lamb_engine.nodes as lbn
|
||||
|
||||
def print_node(node: lbn.Node, *, export: bool = False) -> str:
|
||||
if not isinstance(node, lbn.Node):
|
||||
@ -28,7 +28,7 @@ def print_node(node: lbn.Node, *, export: bool = False) -> str:
|
||||
i = -1
|
||||
p = o
|
||||
while o in bound_subs.values():
|
||||
o = p + lamb.utils.subscript(i := i + 1)
|
||||
o = p + lamb_engine.utils.subscript(i := i + 1)
|
||||
bound_subs[n.input.identifier] = o
|
||||
else:
|
||||
bound_subs[n.input.identifier] = n.input.print_value()
|
||||
@ -162,14 +162,13 @@ def prepare(root: lbn.Root, *, ban_macro_name = None) -> list:
|
||||
it = iter(root)
|
||||
for s, n in it:
|
||||
if isinstance(n, lbn.History):
|
||||
if len(root.runner.history) == 0:
|
||||
if root.runner.history[0] == None:
|
||||
raise lbn.ReductionError("There isn't any history to reference.")
|
||||
else:
|
||||
warnings += [
|
||||
("class:code", "$"),
|
||||
("class:warn", " will be expanded to "),
|
||||
("class:code", f"{n.expand()[1]}\n"),
|
||||
]
|
||||
("class:warn", " will be expanded to ")
|
||||
] + lamb_engine.utils.lex_str(str(n.expand()[1]))
|
||||
|
||||
# If this expression is part of a macro,
|
||||
# make sure we don't reference it inside itself.
|
||||
@ -209,7 +208,7 @@ def prepare(root: lbn.Root, *, ban_macro_name = None) -> list:
|
||||
raise lbn.ReductionError(f"Bound variable name conflict: \"{n.input.name}\"")
|
||||
else:
|
||||
bound_variables[n.input.name] = lbn.Bound(
|
||||
lamb.utils.remove_sub(n.input.name),
|
||||
lamb_engine.utils.remove_sub(n.input.name),
|
||||
macro_name = n.input.name
|
||||
)
|
||||
n.input = bound_variables[n.input.name]
|
@ -1,5 +1,5 @@
|
||||
import lamb
|
||||
import lamb.nodes as lbn
|
||||
import lamb_engine
|
||||
import lamb_engine.nodes as lbn
|
||||
|
||||
class TreeWalker:
|
||||
"""
|
||||
@ -77,12 +77,12 @@ class Node:
|
||||
self.parent_side: Direction = None # type: ignore
|
||||
|
||||
# Left and right nodes, None if empty
|
||||
self._left: Node | None = None
|
||||
self._right: Node | None = None
|
||||
self._left = None
|
||||
self._right = None
|
||||
|
||||
# The runner this node is attached to.
|
||||
# Set by Node.set_runner()
|
||||
self.runner: lamb.runner.Runner = None # type: ignore
|
||||
self.runner: lamb_engine.runner.Runner = None # type: ignore
|
||||
|
||||
def __iter__(self):
|
||||
return TreeWalker(self)
|
||||
@ -321,12 +321,12 @@ class History(ExpandableEndNode):
|
||||
def expand(self) -> tuple[lbn.ReductionType, Node]:
|
||||
# We shouldn't ever get here, prepare()
|
||||
# catches empty history.
|
||||
if len(self.runner.history) == 0:
|
||||
if self.runner.history[0] == None:
|
||||
raise Exception(f"Tried to expand empty history.")
|
||||
# .left is VERY important!
|
||||
# self.runner.history will contain Root nodes,
|
||||
# and we don't want those *inside* our tree.
|
||||
return lbn.ReductionType.HIST_EXPAND, lbn.clone(self.runner.history[-1].left)
|
||||
return lbn.ReductionType.HIST_EXPAND, lbn.clone(self.runner.history[0].left)
|
||||
|
||||
def copy(self):
|
||||
return History(runner = self.runner)
|
||||
@ -341,7 +341,7 @@ class Bound(EndNode):
|
||||
# The name of the macro this bound came from.
|
||||
# Always equal to self.name, unless the macro
|
||||
# this came from had a subscript.
|
||||
self.macro_name: str | None = macro_name
|
||||
self.macro_name = macro_name
|
||||
|
||||
if forced_id is None:
|
||||
self.identifier = bound_counter
|
||||
@ -381,9 +381,9 @@ class Func(Node):
|
||||
Func.from_parse(result)
|
||||
)
|
||||
|
||||
def __init__(self, input: Macro | Bound, output: Node, *, runner = None) -> None:
|
||||
def __init__(self, input, output: Node, *, runner = None) -> None:
|
||||
super().__init__()
|
||||
self.input: Macro | Bound = input
|
||||
self.input = input
|
||||
self.left: Node = output
|
||||
self.right: None = None
|
||||
self.runner = runner # type: ignore
|
@ -56,7 +56,7 @@ class LambdaParser:
|
||||
(self.lp + self.pp_history + self.rp)
|
||||
)
|
||||
|
||||
self.pp_command = pp.Suppress(":") + pp.Word(pp.alphas + "_") + pp.Word(pp.alphas + pp.nums + "_.")[0, ...]
|
||||
self.pp_command = pp.Suppress(":") + pp.Word(pp.alphas + "_") + pp.Word(pp.printables)[0, ...]
|
||||
|
||||
|
||||
self.pp_all = (
|
@ -7,14 +7,14 @@ from prompt_toolkit import prompt
|
||||
import os.path
|
||||
from pyparsing import exceptions as ppx
|
||||
|
||||
import lamb
|
||||
import lamb_engine
|
||||
|
||||
commands = {}
|
||||
help_texts = {}
|
||||
|
||||
def lamb_command(
|
||||
*,
|
||||
command_name: str | None = None,
|
||||
command_name = None,
|
||||
help_text: str
|
||||
):
|
||||
"""
|
||||
@ -38,7 +38,7 @@ def cmd_step(command, runner) -> None:
|
||||
HTML(
|
||||
f"<err>Command <code>:{command.name}</code> takes no more than one argument.</err>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -53,7 +53,7 @@ def cmd_step(command, runner) -> None:
|
||||
HTML(
|
||||
f"<err>Usage: <code>:step [yes|no]</code></err>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -63,7 +63,7 @@ def cmd_step(command, runner) -> None:
|
||||
HTML(
|
||||
f"<warn>Enabled step-by-step reduction.</warn>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
runner.step_reduction = True
|
||||
else:
|
||||
@ -71,7 +71,7 @@ def cmd_step(command, runner) -> None:
|
||||
HTML(
|
||||
f"<warn>Disabled step-by-step reduction.</warn>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
runner.step_reduction = False
|
||||
|
||||
@ -85,7 +85,7 @@ def cmd_expand(command, runner) -> None:
|
||||
HTML(
|
||||
f"<err>Command <code>:{command.name}</code> takes no more than one argument.</err>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -100,7 +100,7 @@ def cmd_expand(command, runner) -> None:
|
||||
HTML(
|
||||
f"<err>Usage: <code>:expand [yes|no]</code></err>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -110,7 +110,7 @@ def cmd_expand(command, runner) -> None:
|
||||
HTML(
|
||||
f"<warn>Enabled complete expansion.</warn>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
runner.full_expansion = True
|
||||
else:
|
||||
@ -118,7 +118,7 @@ def cmd_expand(command, runner) -> None:
|
||||
HTML(
|
||||
f"<warn>Disabled complete expansion.</warn>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
runner.full_expansion = False
|
||||
|
||||
@ -133,7 +133,7 @@ def cmd_save(command, runner) -> None:
|
||||
HTML(
|
||||
f"<err>Command <code>:{command.name}</code> takes exactly one argument.</err>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -144,7 +144,7 @@ def cmd_save(command, runner) -> None:
|
||||
("class:warn", "File exists. Overwrite? "),
|
||||
("class:text", "[yes/no]: ")
|
||||
]),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
).lower()
|
||||
|
||||
if confirm != "yes":
|
||||
@ -152,7 +152,7 @@ def cmd_save(command, runner) -> None:
|
||||
HTML(
|
||||
"<err>Cancelled.</err>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -165,7 +165,7 @@ def cmd_save(command, runner) -> None:
|
||||
HTML(
|
||||
f"Wrote {len(runner.macro_table)} macros to <code>{target}</code>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
|
||||
|
||||
@ -179,7 +179,7 @@ def cmd_load(command, runner):
|
||||
HTML(
|
||||
f"<err>Command <code>:{command.name}</code> takes exactly one argument.</err>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -189,7 +189,7 @@ def cmd_load(command, runner):
|
||||
HTML(
|
||||
f"<err>File {target} doesn't exist.</err>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -215,18 +215,18 @@ def cmd_load(command, runner):
|
||||
("class:err", l[e.loc]),
|
||||
("class:code", l[e.loc+1:])
|
||||
]),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
if not isinstance(x, lamb.runner.runner.MacroDef):
|
||||
if not isinstance(x, lamb_engine.runner.runner.MacroDef):
|
||||
printf(
|
||||
FormattedText([
|
||||
("class:warn", f"Skipping line {i+1:02}: "),
|
||||
("class:code", l),
|
||||
("class:warn", f" is not a macro definition.")
|
||||
]),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -234,10 +234,9 @@ def cmd_load(command, runner):
|
||||
|
||||
printf(
|
||||
FormattedText([
|
||||
("class:ok", f"Loaded {x.label}: "),
|
||||
("class:code", str(x.expr))
|
||||
]),
|
||||
style = lamb.utils.style
|
||||
("class:ok", f"Loaded {x.label}: ")
|
||||
] + lamb_engine.utils.lex_str(str(x.expr))),
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
|
||||
|
||||
@ -250,7 +249,7 @@ def mdel(command, runner) -> None:
|
||||
HTML(
|
||||
f"<err>Command <code>:{command.name}</code> takes exactly one argument.</err>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -260,7 +259,7 @@ def mdel(command, runner) -> None:
|
||||
HTML(
|
||||
f"<warn>Macro \"{target}\" is not defined</warn>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -275,7 +274,7 @@ def delmac(command, runner) -> None:
|
||||
("class:warn", "Are you sure? "),
|
||||
("class:text", "[yes/no]: ")
|
||||
]),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
).lower()
|
||||
|
||||
if confirm != "yes":
|
||||
@ -283,7 +282,7 @@ def delmac(command, runner) -> None:
|
||||
HTML(
|
||||
"<err>Cancelled.</err>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -298,7 +297,7 @@ def macros(command, runner) -> None:
|
||||
printf(FormattedText([
|
||||
("class:warn", "No macros are defined."),
|
||||
]),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
else:
|
||||
printf(FormattedText([
|
||||
@ -308,7 +307,7 @@ def macros(command, runner) -> None:
|
||||
("class:text", f"\t{name} \t {exp}\n")
|
||||
for name, exp in runner.macro_table.items()
|
||||
]),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
|
||||
@lamb_command(
|
||||
@ -316,7 +315,7 @@ def macros(command, runner) -> None:
|
||||
)
|
||||
def clear(command, runner) -> None:
|
||||
clear_screen()
|
||||
lamb.utils.show_greeting()
|
||||
lamb_engine.utils.show_greeting()
|
||||
|
||||
@lamb_command(
|
||||
help_text = "Get or set reduction limit"
|
||||
@ -328,14 +327,14 @@ def rlimit(command, runner) -> None:
|
||||
HTML(
|
||||
"<ok>No reduction limit is set</ok>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
else:
|
||||
printf(
|
||||
HTML(
|
||||
f"<ok>Reduction limit is {runner.reduction_limit:,}</ok>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -344,7 +343,7 @@ def rlimit(command, runner) -> None:
|
||||
HTML(
|
||||
f"<err>Command <code>:{command.name}</code> takes exactly one argument.</err>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -355,7 +354,7 @@ def rlimit(command, runner) -> None:
|
||||
HTML(
|
||||
f"<ok>Removed reduction limit</ok>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -366,7 +365,7 @@ def rlimit(command, runner) -> None:
|
||||
HTML(
|
||||
"<err>Reduction limit must be a positive integer or \"none\".</err>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -375,7 +374,7 @@ def rlimit(command, runner) -> None:
|
||||
HTML(
|
||||
"<err>Reduction limit must be at least 50.</err>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
return
|
||||
|
||||
@ -384,7 +383,7 @@ def rlimit(command, runner) -> None:
|
||||
HTML(
|
||||
f"<ok>Set reduction limit to {t:,}</ok>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
|
||||
|
||||
@ -417,5 +416,5 @@ def help(command, runner) -> None:
|
||||
"<muted>Detailed documentation can be found on this project's git page.</muted>" +
|
||||
"</text>"
|
||||
),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
@ -1,5 +1,5 @@
|
||||
import enum
|
||||
import lamb
|
||||
import lamb_engine
|
||||
|
||||
class StopReason(enum.Enum):
|
||||
BETA_NORMAL = ("class:text", "β-normal form")
|
||||
@ -16,7 +16,7 @@ class MacroDef:
|
||||
result[1]
|
||||
)
|
||||
|
||||
def __init__(self, label: str, expr: lamb.nodes.Node):
|
||||
def __init__(self, label: str, expr: lamb_engine.nodes.Node):
|
||||
self.label = label
|
||||
self.expr = expr
|
||||
|
@ -3,16 +3,16 @@ from prompt_toolkit.formatted_text import FormattedText
|
||||
from prompt_toolkit.key_binding import KeyBindings
|
||||
from prompt_toolkit import prompt
|
||||
from prompt_toolkit import print_formatted_text as printf
|
||||
import enum
|
||||
import collections
|
||||
import math
|
||||
import time
|
||||
|
||||
import lamb
|
||||
import lamb_engine
|
||||
|
||||
from lamb.runner.misc import MacroDef
|
||||
from lamb.runner.misc import Command
|
||||
from lamb.runner.misc import StopReason
|
||||
from lamb.runner import commands as cmd
|
||||
from lamb_engine.runner.misc import MacroDef
|
||||
from lamb_engine.runner.misc import Command
|
||||
from lamb_engine.runner.misc import StopReason
|
||||
from lamb_engine.runner import commands as cmd
|
||||
|
||||
|
||||
# Keybindings for step prompt.
|
||||
@ -32,21 +32,21 @@ class Runner:
|
||||
self.macro_table = {}
|
||||
self.prompt_session = prompt_session
|
||||
self.prompt_message = prompt_message
|
||||
self.parser = lamb.parser.LambdaParser(
|
||||
action_func = lamb.nodes.Func.from_parse,
|
||||
action_bound = lamb.nodes.Macro.from_parse,
|
||||
action_macro = lamb.nodes.Macro.from_parse,
|
||||
action_call = lamb.nodes.Call.from_parse,
|
||||
action_church = lamb.nodes.Church.from_parse,
|
||||
self.parser = lamb_engine.parser.LambdaParser(
|
||||
action_func = lamb_engine.nodes.Func.from_parse,
|
||||
action_bound = lamb_engine.nodes.Macro.from_parse,
|
||||
action_macro = lamb_engine.nodes.Macro.from_parse,
|
||||
action_call = lamb_engine.nodes.Call.from_parse,
|
||||
action_church = lamb_engine.nodes.Church.from_parse,
|
||||
action_macro_def = MacroDef.from_parse,
|
||||
action_command = Command.from_parse,
|
||||
action_history = lamb.nodes.History.from_parse
|
||||
action_history = lamb_engine.nodes.History.from_parse
|
||||
)
|
||||
|
||||
# Maximum amount of reductions.
|
||||
# If None, no maximum is enforced.
|
||||
# Must be at least 1.
|
||||
self.reduction_limit: int | None = 1_000_000
|
||||
self.reduction_limit = 1_000_000
|
||||
|
||||
# Ensure bound variables are unique.
|
||||
# This is automatically incremented whenever we make
|
||||
@ -58,7 +58,10 @@ class Runner:
|
||||
# so that all digits appear to be changing.
|
||||
self.iter_update = 231
|
||||
|
||||
self.history: list[lamb.nodes.Root] = []
|
||||
self.history = collections.deque(
|
||||
[None] * 10,
|
||||
10)
|
||||
|
||||
|
||||
# If true, reduce step-by-step.
|
||||
self.step_reduction = False
|
||||
@ -71,23 +74,23 @@ class Runner:
|
||||
message = self.prompt_message
|
||||
)
|
||||
|
||||
def parse(self, line) -> tuple[lamb.nodes.Root | MacroDef | Command, list]:
|
||||
def parse(self, line): # -> tuple[lamb_engine.nodes.Root | MacroDef | Command, list]
|
||||
e = self.parser.parse_line(line)
|
||||
|
||||
w = []
|
||||
if isinstance(e, MacroDef):
|
||||
e.expr = lamb.nodes.Root(e.expr)
|
||||
e.expr = lamb_engine.nodes.Root(e.expr)
|
||||
e.set_runner(self)
|
||||
w = lamb.nodes.prepare(e.expr, ban_macro_name = e.label)
|
||||
elif isinstance(e, lamb.nodes.Node):
|
||||
e = lamb.nodes.Root(e)
|
||||
w = lamb_engine.nodes.prepare(e.expr, ban_macro_name = e.label)
|
||||
elif isinstance(e, lamb_engine.nodes.Node):
|
||||
e = lamb_engine.nodes.Root(e)
|
||||
e.set_runner(self)
|
||||
w = lamb.nodes.prepare(e)
|
||||
w = lamb_engine.nodes.prepare(e)
|
||||
|
||||
return e, w
|
||||
|
||||
|
||||
def reduce(self, node: lamb.nodes.Root, *, warnings = []) -> None:
|
||||
def reduce(self, node: lamb_engine.nodes.Root, *, warnings = []) -> None:
|
||||
|
||||
# Reduction Counter.
|
||||
# We also count macro (and church) expansions,
|
||||
@ -100,16 +103,16 @@ class Runner:
|
||||
out_text = []
|
||||
|
||||
only_macro = (
|
||||
isinstance(node.left, lamb.nodes.Macro) or
|
||||
isinstance(node.left, lamb.nodes.Church)
|
||||
isinstance(node.left, lamb_engine.nodes.Macro) or
|
||||
isinstance(node.left, lamb_engine.nodes.Church)
|
||||
)
|
||||
if only_macro:
|
||||
stop_reason = StopReason.SHOW_MACRO
|
||||
m, node = lamb.nodes.expand(node, force_all = only_macro)
|
||||
m, node = lamb_engine.nodes.expand(node, force_all = only_macro)
|
||||
macro_expansions += m
|
||||
|
||||
if len(warnings) != 0:
|
||||
printf(FormattedText(warnings), style = lamb.utils.style)
|
||||
printf(FormattedText(warnings), style = lamb_engine.utils.style)
|
||||
|
||||
if self.step_reduction:
|
||||
printf(FormattedText([
|
||||
@ -120,58 +123,59 @@ class Runner:
|
||||
("class:muted", "Press "),
|
||||
("class:cmd_key", "enter"),
|
||||
("class:muted", " to step.\n"),
|
||||
]), style = lamb.utils.style)
|
||||
]), style = lamb_engine.utils.style)
|
||||
|
||||
|
||||
skip_to_end = False
|
||||
while (
|
||||
(
|
||||
(self.reduction_limit is None) or
|
||||
(k < self.reduction_limit)
|
||||
) and not only_macro
|
||||
):
|
||||
|
||||
# Show reduction count
|
||||
if (
|
||||
( (k >= self.iter_update) and (k % self.iter_update == 0) )
|
||||
and not (self.step_reduction and not skip_to_end)
|
||||
try:
|
||||
while (
|
||||
(
|
||||
(self.reduction_limit is None) or
|
||||
(k < self.reduction_limit)
|
||||
) and not only_macro
|
||||
):
|
||||
print(f" Reducing... {k:,}", end = "\r")
|
||||
|
||||
try:
|
||||
red_type, node = lamb.nodes.reduce(node)
|
||||
except KeyboardInterrupt:
|
||||
stop_reason = StopReason.INTERRUPT
|
||||
break
|
||||
# Show reduction count
|
||||
if (
|
||||
( (k >= self.iter_update) and (k % self.iter_update == 0) )
|
||||
and not (self.step_reduction and not skip_to_end)
|
||||
):
|
||||
print(f" Reducing... {k:,}", end = "\r")
|
||||
|
||||
# If we can't reduce this expression anymore,
|
||||
# it's in beta-normal form.
|
||||
if red_type == lamb.nodes.ReductionType.NOTHING:
|
||||
stop_reason = StopReason.BETA_NORMAL
|
||||
break
|
||||
# Reduce
|
||||
red_type, node = lamb_engine.nodes.reduce(node)
|
||||
|
||||
# Count reductions
|
||||
k += 1
|
||||
if red_type == lamb.nodes.ReductionType.FUNCTION_APPLY:
|
||||
macro_expansions += 1
|
||||
# If we can't reduce this expression anymore,
|
||||
# it's in beta-normal form.
|
||||
if red_type == lamb_engine.nodes.ReductionType.NOTHING:
|
||||
stop_reason = StopReason.BETA_NORMAL
|
||||
break
|
||||
|
||||
# Pause after step if necessary
|
||||
if self.step_reduction and not skip_to_end:
|
||||
try:
|
||||
s = prompt(
|
||||
message = FormattedText([
|
||||
("class:muted", lamb.nodes.reduction_text[red_type]),
|
||||
("class:muted", f":{k:03} "),
|
||||
("class:text", str(node)),
|
||||
]),
|
||||
style = lamb.utils.style,
|
||||
key_bindings = step_bindings
|
||||
)
|
||||
except KeyboardInterrupt or EOFError:
|
||||
skip_to_end = True
|
||||
printf(FormattedText([
|
||||
("class:warn", "Skipping to end."),
|
||||
]), style = lamb.utils.style)
|
||||
# Count reductions
|
||||
k += 1
|
||||
if red_type == lamb_engine.nodes.ReductionType.FUNCTION_APPLY:
|
||||
macro_expansions += 1
|
||||
|
||||
# Pause after step if necessary
|
||||
if self.step_reduction and not skip_to_end:
|
||||
try:
|
||||
s = prompt(
|
||||
message = FormattedText([
|
||||
("class:prompt", lamb_engine.nodes.reduction_text[red_type]),
|
||||
("class:prompt", f":{k:03} ")
|
||||
] + lamb_engine.utils.lex_str(str(node))),
|
||||
style = lamb_engine.utils.style,
|
||||
key_bindings = step_bindings
|
||||
)
|
||||
except KeyboardInterrupt or EOFError:
|
||||
skip_to_end = True
|
||||
printf(FormattedText([
|
||||
("class:warn", "Skipping to end."),
|
||||
]), style = lamb_engine.utils.style)
|
||||
|
||||
# Gracefully catch keyboard interrupts
|
||||
except KeyboardInterrupt:
|
||||
stop_reason = StopReason.INTERRUPT
|
||||
|
||||
# Print a space between step messages
|
||||
if self.step_reduction:
|
||||
@ -183,7 +187,7 @@ class Runner:
|
||||
|
||||
# Expand fully if necessary
|
||||
if self.full_expansion:
|
||||
o, node = lamb.nodes.expand(node, force_all = True)
|
||||
o, node = lamb_engine.nodes.expand(node, force_all = True)
|
||||
macro_expansions += o
|
||||
|
||||
if only_macro:
|
||||
@ -192,24 +196,31 @@ class Runner:
|
||||
]
|
||||
|
||||
else:
|
||||
if not self.step_reduction:
|
||||
out_text += [
|
||||
("class:ok", f"Runtime: "),
|
||||
("class:text", f"{time.time() - start_time:.03f} seconds"),
|
||||
("class:text", "\n")
|
||||
]
|
||||
|
||||
out_text += [
|
||||
("class:ok", f"Runtime: "),
|
||||
("class:text", f"{time.time() - start_time:.03f} seconds"),
|
||||
|
||||
("class:ok", f"\nExit reason: "),
|
||||
("class:ok", f"Exit reason: "),
|
||||
stop_reason.value,
|
||||
("class:text", "\n"),
|
||||
|
||||
("class:ok", f"\nMacro expansions: "),
|
||||
("class:ok", f"Macro expansions: "),
|
||||
("class:text", f"{macro_expansions:,}"),
|
||||
("class:text", "\n"),
|
||||
|
||||
("class:ok", f"\nReductions: "),
|
||||
("class:ok", f"Reductions: "),
|
||||
("class:text", f"{k:,}\t"),
|
||||
("class:muted", f"(Limit: {self.reduction_limit:,})")
|
||||
]
|
||||
|
||||
if self.full_expansion:
|
||||
out_text += [
|
||||
("class:ok", "\nAll macros have been expanded")
|
||||
("class:text", "\n"),
|
||||
("class:ok", "All macros have been expanded")
|
||||
]
|
||||
|
||||
if (
|
||||
@ -218,19 +229,23 @@ class Runner:
|
||||
only_macro
|
||||
):
|
||||
out_text += [
|
||||
("class:ok", "\n\n => "),
|
||||
("class:text", str(node)), # type: ignore
|
||||
]
|
||||
("class:ok", "\n\n => ")
|
||||
] + lamb_engine.utils.lex_str(str(node))
|
||||
|
||||
|
||||
printf(
|
||||
FormattedText(out_text),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
|
||||
# Save to history
|
||||
# Do this at the end so we don't always fully expand.
|
||||
self.history.append(lamb.nodes.expand(node, force_all = True)[1])
|
||||
self.history.appendleft(
|
||||
lamb_engine.nodes.expand( # type: ignore
|
||||
node,
|
||||
force_all = True
|
||||
)[1]
|
||||
)
|
||||
|
||||
def save_macro(
|
||||
self,
|
||||
@ -247,7 +262,7 @@ class Runner:
|
||||
("class:code", macro.label),
|
||||
("class:text", " to "),
|
||||
("class:code", str(macro.expr))
|
||||
]), style = lamb.utils.style)
|
||||
]), style = lamb_engine.utils.style)
|
||||
|
||||
# Apply a list of definitions
|
||||
def run(
|
||||
@ -269,13 +284,13 @@ class Runner:
|
||||
FormattedText([
|
||||
("class:warn", f"Unknown command \"{e.name}\"")
|
||||
]),
|
||||
style = lamb.utils.style
|
||||
style = lamb_engine.utils.style
|
||||
)
|
||||
else:
|
||||
cmd.commands[e.name](e, self)
|
||||
|
||||
# If this line is a plain expression, reduce it.
|
||||
elif isinstance(e, lamb.nodes.Node):
|
||||
elif isinstance(e, lamb_engine.nodes.Node):
|
||||
self.reduce(e, warnings = w)
|
||||
|
||||
# We shouldn't ever get here.
|
@ -4,6 +4,7 @@ from prompt_toolkit.lexers import Lexer
|
||||
from prompt_toolkit.key_binding import KeyBindings
|
||||
from prompt_toolkit import print_formatted_text as printf
|
||||
from importlib.metadata import version
|
||||
from prompt_toolkit.document import Document
|
||||
|
||||
import re
|
||||
|
||||
@ -77,6 +78,10 @@ class LambdaLexer(Lexer):
|
||||
return inner
|
||||
|
||||
|
||||
|
||||
def lex_str(s: str) -> list[tuple[str, str]]:
|
||||
return LambdaLexer().lex_document(Document(s))(0)
|
||||
|
||||
def show_greeting():
|
||||
# | _.._ _.|_
|
||||
# |_(_|| | ||_)
|
||||
@ -96,7 +101,7 @@ def show_greeting():
|
||||
"",
|
||||
"<_h> | _.._ _.|_",
|
||||
" |_(_|| | ||_)</_h>",
|
||||
f" <_v>{version('lamb')}</_v>",
|
||||
f" <_v>{version('lamb_engine')}</_v>",
|
||||
" __ __",
|
||||
" ,-` `` `,",
|
||||
" (` <_l>\\</_l> )",
|
84
misc/demo.tape
Normal file
84
misc/demo.tape
Normal file
@ -0,0 +1,84 @@
|
||||
# See makedemo.sh
|
||||
|
||||
#Output lambdemo.mp4
|
||||
Output lambdemo.gif
|
||||
|
||||
Set FontSize 30
|
||||
Set Width 2000
|
||||
Set Height 1500
|
||||
Set FontFamily "FantasqueSansMono NF"
|
||||
Set TypingSpeed 60ms
|
||||
Set Framerate 30
|
||||
|
||||
# Intro
|
||||
Sleep 2000ms
|
||||
Type "lamb"
|
||||
Sleep 1000ms
|
||||
Enter
|
||||
Sleep 2000ms
|
||||
|
||||
# Demo 1: load
|
||||
Type ":load ../macros.lamb"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 2000ms
|
||||
|
||||
Type "NOT T"
|
||||
Sleep 1000ms
|
||||
Enter
|
||||
Sleep 6s
|
||||
|
||||
Type ":clear"
|
||||
Sleep 1000ms
|
||||
Enter
|
||||
Sleep 1500ms
|
||||
|
||||
|
||||
# Demo 2: stepping
|
||||
Type ":step"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 1500ms
|
||||
|
||||
Type "NOT T"
|
||||
Sleep 100ms
|
||||
Enter
|
||||
Sleep 1500ms
|
||||
Enter
|
||||
Sleep 760ms
|
||||
Enter
|
||||
Sleep 850ms
|
||||
Enter
|
||||
Sleep 650ms
|
||||
Enter
|
||||
Sleep 700ms
|
||||
Enter
|
||||
|
||||
Sleep 3000ms
|
||||
|
||||
Type ":step"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 6s
|
||||
Type ":clear"
|
||||
Sleep 1000ms
|
||||
Enter
|
||||
Sleep 1500ms
|
||||
|
||||
# Demo 3: macros
|
||||
Type "M = \x.x x"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 500ms
|
||||
|
||||
Type "M M"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 3s
|
||||
Ctrl+c
|
||||
Sleep 1000ms
|
||||
|
||||
Type "Y FAC 3"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 6s
|
109
misc/lamb.svg
109
misc/lamb.svg
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 30 KiB |
34
misc/makedemo.sh
Executable file
34
misc/makedemo.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
# Should be run from the misc directory.
|
||||
# Will not work with any other root.
|
||||
|
||||
# Create this file.
|
||||
# Should define two variables:
|
||||
# DAV_USER="name:password"
|
||||
# DAV_URL="https://site.com/dav-path"
|
||||
|
||||
if [[ -f "secrets.sh" ]]; then
|
||||
source secrets.sh
|
||||
else
|
||||
echo "Cannot run without secrets.sh"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Activate venv if not in venv
|
||||
if [[ "$VIRTUAL_ENV" == "" ]]; then
|
||||
source ../venv/bin/activate
|
||||
fi
|
||||
|
||||
# Make sure our venv is running the latest
|
||||
# version of lamb.
|
||||
pip install --editable ..
|
||||
|
||||
|
||||
# Make gif
|
||||
vhs < demo.tape
|
||||
|
||||
# Upload
|
||||
curl \
|
||||
--user $DAV_USER \
|
||||
--url $DAV_URL \
|
||||
--upload-file "lambdemo.gif"
|
Binary file not shown.
Before Width: | Height: | Size: 98 KiB |
@ -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]
|
||||
name = "Lamb"
|
||||
name = "lamb_engine"
|
||||
description = "A lambda calculus engine"
|
||||
|
||||
# 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 = "0.1.3"
|
||||
|
||||
version = "1.1.9"
|
||||
dependencies = [
|
||||
"prompt-toolkit==3.0.31",
|
||||
"pyparsing==3.0.9"
|
||||
]
|
||||
|
||||
authors = [
|
||||
{ name="Mark", email="mark@betalupi.com" }
|
||||
]
|
||||
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.7"
|
||||
license = {text = "GNU General Public License v3 (GPLv3)"}
|
||||
@ -35,20 +33,10 @@ classifiers = [
|
||||
"Environment :: Console"
|
||||
]
|
||||
|
||||
|
||||
[project.urls]
|
||||
"Homepage" = "https://git.betalupi.com/Mark/lamb"
|
||||
|
||||
|
||||
[build-system]
|
||||
requires = [ "setuptools>=61.0" ]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["lamb"]
|
||||
include = ["lamb*"]
|
||||
namespaces = false
|
||||
|
||||
[project.optional-dependencies]
|
||||
# Used to build a standalone executable
|
||||
pyinstaller = [ "pyinstaller==5.5" ]
|
||||
# To build:
|
||||
# pip install build twine
|
||||
# python -m build
|
||||
# twine upload dist/lamb_engine-1.1.6* (change the version)
|
Reference in New Issue
Block a user