feat: better recursive descent
This commit is contained in:
41
pkg/saccharine/ast/node.go
Normal file
41
pkg/saccharine/ast/node.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package ast
|
||||
|
||||
type Expression interface {
|
||||
IsExpression()
|
||||
}
|
||||
|
||||
/** ------------------------------------------------------------------------- */
|
||||
|
||||
type Abstraction struct {
|
||||
Parameters []string
|
||||
Body Expression
|
||||
}
|
||||
|
||||
type Application struct {
|
||||
Abstraction Expression
|
||||
Arguments []Expression
|
||||
}
|
||||
|
||||
type Atom struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
/** ------------------------------------------------------------------------- */
|
||||
|
||||
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 (a Abstraction) IsExpression() {}
|
||||
func (a Application) IsExpression() {}
|
||||
func (v Atom) IsExpression() {}
|
||||
Reference in New Issue
Block a user