Added support for arguments

master
Mark 2022-11-11 18:31:37 -08:00
parent 97aecb01f0
commit e8bd6997b9
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
3 changed files with 28 additions and 7 deletions

View File

@ -51,7 +51,12 @@ There are many useful macros in [macros.lamb](./macros.lamb). Download the file,
==> :load macros.lamb
```
You may use up/down arrows to recall history.
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!
@ -61,16 +66,18 @@ Have fun!
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
`: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
@ -80,8 +87,6 @@ Lamb understands many commands. Prefix them with a `:` in the prompt.
`: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.
@ -95,7 +100,6 @@ The lines in a file look exactly the same as regular entries in the prompt, but
- Truncate long expressions in warnings
- Loop detection
- α-equivalence check
- Command-line options (load a file)
- Unchurch command: make church numerals human-readable
- Better Syntax highlighting
- Complete file names and commands

View File

@ -3,6 +3,7 @@ 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
@ -22,6 +23,22 @@ def main():
])
)
# 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()

View File

@ -15,7 +15,7 @@ lamb = "lamb_engine:main"
[project]
name = "lamb_engine"
description = "A lambda calculus engine"
version = "1.1.5"
version = "1.1.6"
dependencies = [
"prompt-toolkit==3.0.31",
"pyparsing==3.0.9"