wip: new folder structure, overhaul language
This commit is contained in:
41
pkg/saccharine/ast.go
Normal file
41
pkg/saccharine/ast.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package saccharine
|
||||
|
||||
type Node interface {
|
||||
IsNode()
|
||||
}
|
||||
|
||||
/** ------------------------------------------------------------------------- */
|
||||
|
||||
type Abstraction struct {
|
||||
Parameters []string
|
||||
Body Node
|
||||
}
|
||||
|
||||
type Application struct {
|
||||
Abstraction Node
|
||||
Arguments []Node
|
||||
}
|
||||
|
||||
type Variable struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
/** ------------------------------------------------------------------------- */
|
||||
|
||||
func NewAbstraction(parameter []string, body Node) *Abstraction {
|
||||
return &Abstraction{Parameters: parameter, Body: body}
|
||||
}
|
||||
|
||||
func NewApplication(abstraction Node, arguments []Node) *Application {
|
||||
return &Application{Abstraction: abstraction, Arguments: arguments}
|
||||
}
|
||||
|
||||
func NewVariable(name string) *Variable {
|
||||
return &Variable{Name: name}
|
||||
}
|
||||
|
||||
/** ------------------------------------------------------------------------- */
|
||||
|
||||
func (_ Abstraction) IsNode() {}
|
||||
func (_ Application) IsNode() {}
|
||||
func (_ Variable) IsNode() {}
|
||||
Reference in New Issue
Block a user