style: moved functions around
This commit is contained in:
49
pkg/saccharine/expression.go
Normal file
49
pkg/saccharine/expression.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package saccharine
|
||||
|
||||
type Expression interface {
|
||||
IsExpression()
|
||||
}
|
||||
|
||||
/** ------------------------------------------------------------------------- */
|
||||
|
||||
type Abstraction struct {
|
||||
Parameters []string
|
||||
Body Expression
|
||||
}
|
||||
|
||||
type Application struct {
|
||||
Abstraction Expression
|
||||
Arguments []Expression
|
||||
}
|
||||
|
||||
type Atom struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
type Clause struct {
|
||||
Statements []Statement
|
||||
Returns Expression
|
||||
}
|
||||
|
||||
func (Abstraction) IsExpression() {}
|
||||
func (Application) IsExpression() {}
|
||||
func (Atom) IsExpression() {}
|
||||
func (Clause) IsExpression() {}
|
||||
|
||||
/** ------------------------------------------------------------------------- */
|
||||
|
||||
func NewAbstraction(parameter []string, body Expression) *Abstraction {
|
||||
return &Abstraction{Parameters: parameter, Body: body}
|
||||
}
|
||||
|
||||
func NewApplication(abstraction Expression, arguments []Expression) *Application {
|
||||
return &Application{Abstraction: abstraction, Arguments: arguments}
|
||||
}
|
||||
|
||||
func NewAtom(name string) *Atom {
|
||||
return &Atom{Name: name}
|
||||
}
|
||||
|
||||
func NewClause(statements []Statement, returns Expression) *Clause {
|
||||
return &Clause{Statements: statements, Returns: returns}
|
||||
}
|
||||
Reference in New Issue
Block a user