Python 3 interpreter in Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

34 lines
572 B

package ast
import (
"fmt"
"strings"
)
type Mod interface {
Node
mod()
}
type Module struct {
Body []Statement
}
func NewModule() *Module {
return &Module{
Body: make([]Statement, 0),
}
}
func (module *Module) node() {}
func (module *Module) mod() {}
func (module *Module) Append(stmt Statement) {
module.Body = append(module.Body, stmt)
}
func (module *Module) String() string {
stmts := make([]string, 0)
for _, stmt := range module.Body {
stmts = append(stmts, stmt.String())
}
return fmt.Sprintf("Module(body=[%s])", strings.Join(stmts, ", "))
}