Colors and small fixes
parent
d88a7ff77f
commit
740c562dbe
|
@ -75,7 +75,7 @@ Lamb treats each λ expression as a binary tree. Variable binding and reduction
|
||||||
|
|
||||||
|
|
||||||
## Todo (pre-release, in this order):
|
## Todo (pre-release, in this order):
|
||||||
- Prettier colors
|
- Fix :save
|
||||||
- Cleanup warnings
|
- Cleanup warnings
|
||||||
- Truncate long expressions in warnings
|
- Truncate long expressions in warnings
|
||||||
- Prevent macro-chaining recursion
|
- Prevent macro-chaining recursion
|
||||||
|
@ -83,6 +83,7 @@ Lamb treats each λ expression as a binary tree. Variable binding and reduction
|
||||||
- step-by-step reduction
|
- step-by-step reduction
|
||||||
- Cleanup files
|
- Cleanup files
|
||||||
- Update screenshot
|
- Update screenshot
|
||||||
|
- Update documentation & "internals" section.
|
||||||
- PyPi package
|
- PyPi package
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ r = lamb.Runner(
|
||||||
key_bindings = bindings
|
key_bindings = bindings
|
||||||
),
|
),
|
||||||
prompt_message = FormattedText([
|
prompt_message = FormattedText([
|
||||||
("class:prompt", "~~> ")
|
("class:prompt", "==> ")
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ def cmd_load(command, runner):
|
||||||
for i in range(len(lines)):
|
for i in range(len(lines)):
|
||||||
l = lines[i]
|
l = lines[i]
|
||||||
try:
|
try:
|
||||||
x = runner.parse(l)
|
x = runner.parse(l)[0]
|
||||||
except ppx.ParseException as e:
|
except ppx.ParseException as e:
|
||||||
printf(
|
printf(
|
||||||
FormattedText([
|
FormattedText([
|
||||||
|
|
|
@ -129,7 +129,10 @@ class Runner:
|
||||||
("class:warn", "\n")
|
("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:
|
if only_macro:
|
||||||
stop_reason = StopReason.SHOW_MACRO
|
stop_reason = StopReason.SHOW_MACRO
|
||||||
m, node = lamb.node.expand(node, force_all = only_macro)
|
m, node = lamb.node.expand(node, force_all = only_macro)
|
||||||
|
@ -181,21 +184,21 @@ class Runner:
|
||||||
|
|
||||||
if only_macro:
|
if only_macro:
|
||||||
out_text += [
|
out_text += [
|
||||||
("class:result_header", f"Displaying macro content")
|
("class:ok", f"Displaying macro content")
|
||||||
]
|
]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
out_text += [
|
out_text += [
|
||||||
("class:result_header", f"Runtime: "),
|
("class:ok", f"Runtime: "),
|
||||||
("class:text", f"{time.time() - start_time:.03f} seconds"),
|
("class:text", f"{time.time() - start_time:.03f} seconds"),
|
||||||
|
|
||||||
("class:result_header", f"\nExit reason: "),
|
("class:ok", f"\nExit reason: "),
|
||||||
stop_reason.value,
|
stop_reason.value,
|
||||||
|
|
||||||
("class:result_header", f"\nMacro expansions: "),
|
("class:ok", f"\nMacro expansions: "),
|
||||||
("class:text", f"{macro_expansions:,}"),
|
("class:text", f"{macro_expansions:,}"),
|
||||||
|
|
||||||
("class:result_header", f"\nReductions: "),
|
("class:ok", f"\nReductions: "),
|
||||||
("class:text", f"{k:,}\t"),
|
("class:text", f"{k:,}\t"),
|
||||||
("class:muted", f"(Limit: {self.reduction_limit:,})")
|
("class:muted", f"(Limit: {self.reduction_limit:,})")
|
||||||
]
|
]
|
||||||
|
@ -206,7 +209,7 @@ class Runner:
|
||||||
only_macro
|
only_macro
|
||||||
):
|
):
|
||||||
out_text += [
|
out_text += [
|
||||||
("class:result_header", "\n\n => "),
|
("class:ok", "\n\n => "),
|
||||||
("class:text", str(node)), # type: ignore
|
("class:text", str(node)), # type: ignore
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -230,7 +233,7 @@ class Runner:
|
||||||
if not silent:
|
if not silent:
|
||||||
printf(FormattedText([
|
printf(FormattedText([
|
||||||
("class:text", "Set "),
|
("class:text", "Set "),
|
||||||
("class:syn_macro", macro.label),
|
("class:code", macro.label),
|
||||||
("class:text", " to "),
|
("class:text", " to "),
|
||||||
("class:text", str(macro.expr))
|
("class:text", str(macro.expr))
|
||||||
]), style = lamb.utils.style)
|
]), style = lamb.utils.style)
|
||||||
|
|
|
@ -7,31 +7,23 @@ from importlib.metadata import version
|
||||||
style = Style.from_dict({ # type: ignore
|
style = Style.from_dict({ # type: ignore
|
||||||
# Basic formatting
|
# Basic formatting
|
||||||
"text": "#FFFFFF",
|
"text": "#FFFFFF",
|
||||||
"warn": "#FFFF00",
|
"warn": "#FFA700",
|
||||||
"err": "#FF0000",
|
"err": "#FF3809",
|
||||||
"prompt": "#00FFFF",
|
"prompt": "#05CFFF",
|
||||||
"ok": "#B4EC85",
|
"ok": "#00EF7C",
|
||||||
"code": "#AAAAAA italic",
|
"code": "#AAAAAA italic",
|
||||||
"muted": "#AAAAAA",
|
"muted": "#AAAAAA",
|
||||||
|
|
||||||
# Syntax
|
|
||||||
"syn_macro": "#FF00FF",
|
|
||||||
"syn_lambda": "#FF00FF",
|
|
||||||
"syn_bound": "#FF00FF",
|
|
||||||
|
|
||||||
# Titles for reduction results
|
|
||||||
"result_header": "#B4EC85 bold",
|
|
||||||
|
|
||||||
# Command formatting
|
# Command formatting
|
||||||
# cmd_h: section titles
|
# cmd_h: section titles
|
||||||
# cmd_key: keyboard keys, usually one character
|
# cmd_key: keyboard keys, usually one character
|
||||||
"cmd_h": "#FF6600 bold",
|
"cmd_h": "#FF3809 bold",
|
||||||
"cmd_key": "#B4EC85 bold",
|
"cmd_key": "#00EF7C bold",
|
||||||
|
|
||||||
# Only used in greeting
|
# Only used in greeting
|
||||||
"_v": "#B4EC85 bold",
|
"_v": "#00EF7C bold",
|
||||||
"_l": "#FF6600 bold",
|
"_l": "#FF3809 bold",
|
||||||
"_s": "#B4EC85 bold",
|
"_s": "#00EF7C bold",
|
||||||
"_p": "#AAAAAA"
|
"_p": "#AAAAAA"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Reference in New Issue