Compare commits
No commits in common. "69bf43f29520ac93a0f11957ed1310d8c869cf1d" and "b26d968884ae8501ebd9a58f8a5913b2a15b70d0" have entirely different histories.
69bf43f295
...
b26d968884
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
If you're reading this on PyPi, go [here](https://git.betalupi.com/Mark/lamb).
|
If you're reading this on PyPi, go [here](https://git.betalupi.com/Mark/lamb).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
@ -127,55 +127,53 @@ class Runner:
|
|||||||
|
|
||||||
|
|
||||||
skip_to_end = False
|
skip_to_end = False
|
||||||
try:
|
while (
|
||||||
while (
|
(
|
||||||
(
|
(self.reduction_limit is None) or
|
||||||
(self.reduction_limit is None) or
|
(k < self.reduction_limit)
|
||||||
(k < self.reduction_limit)
|
) and not only_macro
|
||||||
) 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)
|
||||||
):
|
):
|
||||||
|
print(f" Reducing... {k:,}", end = "\r")
|
||||||
|
|
||||||
# Show reduction count
|
try:
|
||||||
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")
|
|
||||||
|
|
||||||
# Reduce
|
|
||||||
red_type, node = lamb_engine.nodes.reduce(node)
|
red_type, node = lamb_engine.nodes.reduce(node)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
stop_reason = StopReason.INTERRUPT
|
||||||
|
break
|
||||||
|
|
||||||
# If we can't reduce this expression anymore,
|
# If we can't reduce this expression anymore,
|
||||||
# it's in beta-normal form.
|
# it's in beta-normal form.
|
||||||
if red_type == lamb_engine.nodes.ReductionType.NOTHING:
|
if red_type == lamb_engine.nodes.ReductionType.NOTHING:
|
||||||
stop_reason = StopReason.BETA_NORMAL
|
stop_reason = StopReason.BETA_NORMAL
|
||||||
break
|
break
|
||||||
|
|
||||||
# Count reductions
|
# Count reductions
|
||||||
k += 1
|
k += 1
|
||||||
if red_type == lamb_engine.nodes.ReductionType.FUNCTION_APPLY:
|
if red_type == lamb_engine.nodes.ReductionType.FUNCTION_APPLY:
|
||||||
macro_expansions += 1
|
macro_expansions += 1
|
||||||
|
|
||||||
# Pause after step if necessary
|
# Pause after step if necessary
|
||||||
if self.step_reduction and not skip_to_end:
|
if self.step_reduction and not skip_to_end:
|
||||||
try:
|
try:
|
||||||
s = prompt(
|
s = prompt(
|
||||||
message = FormattedText([
|
message = FormattedText([
|
||||||
("class:prompt", lamb_engine.nodes.reduction_text[red_type]),
|
("class:prompt", lamb_engine.nodes.reduction_text[red_type]),
|
||||||
("class:prompt", f":{k:03} ")
|
("class:prompt", f":{k:03} ")
|
||||||
] + lamb_engine.utils.lex_str(str(node))),
|
] + lamb_engine.utils.lex_str(str(node))),
|
||||||
style = lamb_engine.utils.style,
|
style = lamb_engine.utils.style,
|
||||||
key_bindings = step_bindings
|
key_bindings = step_bindings
|
||||||
)
|
)
|
||||||
except KeyboardInterrupt or EOFError:
|
except KeyboardInterrupt or EOFError:
|
||||||
skip_to_end = True
|
skip_to_end = True
|
||||||
printf(FormattedText([
|
printf(FormattedText([
|
||||||
("class:warn", "Skipping to end."),
|
("class:warn", "Skipping to end."),
|
||||||
]), style = lamb_engine.utils.style)
|
]), style = lamb_engine.utils.style)
|
||||||
|
|
||||||
# Gracefully catch keyboard interrupts
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
stop_reason = StopReason.INTERRUPT
|
|
||||||
|
|
||||||
# Print a space between step messages
|
# Print a space between step messages
|
||||||
if self.step_reduction:
|
if self.step_reduction:
|
||||||
|
Reference in New Issue
Block a user