Added support for arguments
parent
97aecb01f0
commit
e8bd6997b9
16
README.md
16
README.md
|
@ -51,7 +51,12 @@ There are many useful macros in [macros.lamb](./macros.lamb). Download the file,
|
||||||
==> :load macros.lamb
|
==> :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!
|
Have fun!
|
||||||
|
|
||||||
|
@ -61,16 +66,18 @@ Have fun!
|
||||||
|
|
||||||
Lamb understands many commands. Prefix them with a `:` in the prompt.
|
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
|
`:clear` Clear the screen
|
||||||
|
|
||||||
`:rlimit [int | None]` Set maximum reduction limit. `:rlimit none` sets no limit.
|
`: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
|
`: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:
|
`: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
|
- `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.
|
`: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]` \
|
`:save [filename]` \
|
||||||
`:load [filename]` \
|
`:load [filename]` \
|
||||||
Save or load macros from a file.
|
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
|
- Truncate long expressions in warnings
|
||||||
- Loop detection
|
- Loop detection
|
||||||
- α-equivalence check
|
- α-equivalence check
|
||||||
- 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
|
||||||
- Complete file names and commands
|
- Complete file names and commands
|
||||||
|
|
|
@ -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 FormattedText
|
||||||
from prompt_toolkit.formatted_text import to_plain_text
|
from prompt_toolkit.formatted_text import to_plain_text
|
||||||
from pyparsing import exceptions as ppx
|
from pyparsing import exceptions as ppx
|
||||||
|
import sys
|
||||||
|
|
||||||
import lamb_engine
|
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:
|
while True:
|
||||||
try:
|
try:
|
||||||
i = r.prompt()
|
i = r.prompt()
|
||||||
|
|
|
@ -15,7 +15,7 @@ lamb = "lamb_engine:main"
|
||||||
[project]
|
[project]
|
||||||
name = "lamb_engine"
|
name = "lamb_engine"
|
||||||
description = "A lambda calculus engine"
|
description = "A lambda calculus engine"
|
||||||
version = "1.1.5"
|
version = "1.1.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"prompt-toolkit==3.0.31",
|
"prompt-toolkit==3.0.31",
|
||||||
"pyparsing==3.0.9"
|
"pyparsing==3.0.9"
|
||||||
|
|
Reference in New Issue