feat: wogihrsoiuvjsroirgj

This commit is contained in:
2025-12-24 14:55:33 -05:00
parent 1d8ecba118
commit 2c3ce9baf7
8 changed files with 204 additions and 26 deletions

View File

@@ -1,23 +1,65 @@
package lambda
type Expression interface {
isExpression()
Accept(ExpressionVisitor)
}
/** ------------------------------------------------------------------------- */
type Function struct {
Parameter string
Body Expression
Body Expression
}
func NewFunction(parameter string, body Expression) *Function {
return &Function{
Parameter: parameter,
Body: body,
}
}
func (f *Function) Accept(v ExpressionVisitor) {
v.VisitFunction(f)
}
/** ------------------------------------------------------------------------- */
type Call struct {
Function Expression
Argument Expression
}
func NewCall(function Expression, argument Expression) *Call {
return &Call{
Function: function,
Argument: argument,
}
}
func (c *Call) Accept(v ExpressionVisitor) {
v.VisitCall(c)
}
/** ------------------------------------------------------------------------- */
type Atom struct {
Value string
}
func (_ Function) isExpression() {}
func (_ Call) isExpression() {}
func (_ Atom) isExpression() {}
func NewAtom(name string) *Atom {
return &Atom{
Value: name,
}
}
func (a *Atom) Accept(v ExpressionVisitor) {
v.VisitAtom(a)
}
/** ------------------------------------------------------------------------- */
type ExpressionVisitor interface {
VisitFunction(*Function)
VisitCall(*Call)
VisitAtom(*Atom)
}