feat: wogihrsoiuvjsroirgj
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user