fix: unbound substitutions, explanation tag

This commit is contained in:
2025-12-25 01:55:46 -05:00
parent a56ec808ec
commit 99703c2587
6 changed files with 82 additions and 23 deletions

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"os"
"time"
"git.maximhutz.com/max/lambda/internal/cli"
"git.maximhutz.com/max/lambda/pkg/lambda"
@@ -35,9 +36,21 @@ func main() {
cli.HandleError(err)
logger.Info("Parsed syntax tree.", "tree", lambda.Stringify(expression))
for lambda.ReduceOnce(&expression) {
logger.Info("Reduction.", "tree", lambda.Stringify(expression))
start := time.Now()
if options.Explanation {
fmt.Println(lambda.Stringify(expression))
}
for lambda.ReduceOnce(&expression) {
logger.Info("Reduction.", "tree", lambda.Stringify(expression))
if options.Explanation {
fmt.Println(" =", lambda.Stringify(expression))
}
}
elapsed := time.Since(start).Milliseconds()
fmt.Println(lambda.Stringify(expression))
fmt.Fprintln(os.Stderr, "Time Spent:", elapsed, "ms")
}