refactor: extract abstract Expression interface
Introduce pkg/expr.Expression as a base interface for all evaluatable expression types, enabling future support for multiple evaluation modes (SKI combinators, typed lambda calculus, etc.). - Add pkg/expr/expr.go with Expression interface requiring String() method. - Update lambda.Expression to embed expr.Expression. - Add String() method to Abstraction, Application, and Variable types. - Update plugins to use String() instead of lambda.Stringify().
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Package "engine" provides an extensible interface for users to interfact with
|
||||
// λ-calculus.
|
||||
// Package "engine" provides an extensible interface for users to interact with
|
||||
// λ-calculus and other expression evaluation modes.
|
||||
package engine
|
||||
|
||||
import (
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"git.maximhutz.com/max/lambda/pkg/lambda"
|
||||
)
|
||||
|
||||
// A process for reducing one λ-expression.
|
||||
// A process for reducing one expression.
|
||||
type Engine struct {
|
||||
Config *config.Config
|
||||
Expression *lambda.Expression
|
||||
@@ -25,7 +25,7 @@ func New(config *config.Config, expression *lambda.Expression) *Engine {
|
||||
}
|
||||
|
||||
// Begin the reduction process.
|
||||
func (e Engine) Run() {
|
||||
func (e *Engine) Run() {
|
||||
e.Emit(StartEvent)
|
||||
|
||||
lambda.ReduceAll(e.Expression, func() {
|
||||
|
||||
Reference in New Issue
Block a user