Colors and small fixes

master
Mark 2022-11-01 21:29:39 -07:00
parent d88a7ff77f
commit 740c562dbe
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
5 changed files with 24 additions and 28 deletions

View File

@ -75,7 +75,7 @@ Lamb treats each λ expression as a binary tree. Variable binding and reduction
## Todo (pre-release, in this order):
- Prettier colors
- Fix :save
- Cleanup warnings
- Truncate long expressions in warnings
- Prevent macro-chaining recursion
@ -83,6 +83,7 @@ Lamb treats each λ expression as a binary tree. Variable binding and reduction
- step-by-step reduction
- Cleanup files
- Update screenshot
- Update documentation & "internals" section.
- PyPi package

View File

@ -36,7 +36,7 @@ r = lamb.Runner(
key_bindings = bindings
),
prompt_message = FormattedText([
("class:prompt", "~~> ")
("class:prompt", "==> ")
])
)

View File

@ -103,7 +103,7 @@ def cmd_load(command, runner):
for i in range(len(lines)):
l = lines[i]
try:
x = runner.parse(l)
x = runner.parse(l)[0]
except ppx.ParseException as e:
printf(
FormattedText([

View File

@ -129,7 +129,10 @@ class Runner:
("class:warn", "\n")
]
only_macro = isinstance(node.left, lamb.node.Macro)
only_macro = (
isinstance(node.left, lamb.node.Macro) or
isinstance(node.left, lamb.node.Church)
)
if only_macro:
stop_reason = StopReason.SHOW_MACRO
m, node = lamb.node.expand(node, force_all = only_macro)
@ -181,21 +184,21 @@ class Runner:
if only_macro:
out_text += [
("class:result_header", f"Displaying macro content")
("class:ok", f"Displaying macro content")
]
else:
out_text += [
("class:result_header", f"Runtime: "),
("class:ok", f"Runtime: "),
("class:text", f"{time.time() - start_time:.03f} seconds"),
("class:result_header", f"\nExit reason: "),
("class:ok", f"\nExit reason: "),
stop_reason.value,
("class:result_header", f"\nMacro expansions: "),
("class:ok", f"\nMacro expansions: "),
("class:text", f"{macro_expansions:,}"),
("class:result_header", f"\nReductions: "),
("class:ok", f"\nReductions: "),
("class:text", f"{k:,}\t"),
("class:muted", f"(Limit: {self.reduction_limit:,})")
]
@ -206,7 +209,7 @@ class Runner:
only_macro
):
out_text += [
("class:result_header", "\n\n => "),
("class:ok", "\n\n => "),
("class:text", str(node)), # type: ignore
]
@ -230,7 +233,7 @@ class Runner:
if not silent:
printf(FormattedText([
("class:text", "Set "),
("class:syn_macro", macro.label),
("class:code", macro.label),
("class:text", " to "),
("class:text", str(macro.expr))
]), style = lamb.utils.style)

View File

@ -7,31 +7,23 @@ from importlib.metadata import version
style = Style.from_dict({ # type: ignore
# Basic formatting
"text": "#FFFFFF",
"warn": "#FFFF00",
"err": "#FF0000",
"prompt": "#00FFFF",
"ok": "#B4EC85",
"warn": "#FFA700",
"err": "#FF3809",
"prompt": "#05CFFF",
"ok": "#00EF7C",
"code": "#AAAAAA italic",
"muted": "#AAAAAA",
# Syntax
"syn_macro": "#FF00FF",
"syn_lambda": "#FF00FF",
"syn_bound": "#FF00FF",
# Titles for reduction results
"result_header": "#B4EC85 bold",
# Command formatting
# cmd_h: section titles
# cmd_key: keyboard keys, usually one character
"cmd_h": "#FF6600 bold",
"cmd_key": "#B4EC85 bold",
"cmd_h": "#FF3809 bold",
"cmd_key": "#00EF7C bold",
# Only used in greeting
"_v": "#B4EC85 bold",
"_l": "#FF6600 bold",
"_s": "#B4EC85 bold",
"_v": "#00EF7C bold",
"_l": "#FF3809 bold",
"_s": "#00EF7C bold",
"_p": "#AAAAAA"
})