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.
 

42 lines
661 B

package ast
import "fmt"
type Expression interface {
Node
expr()
}
type Name struct {
Identifier string
Context ExpressionContext
}
func NewName(id string, ctx ExpressionContext) *Name {
return &Name{
Identifier: id,
Context: ctx,
}
}
func (name *Name) node() {}
func (name *Name) expr() {}
func (name *Name) String() string {
return fmt.Sprintf("Name(id=%#v, ctx=%s)", name.Identifier, name.Context.String())
}
type Num struct {
Value int64
}
func NewNum(i int64) *Num {
return &Num{
Value: i,
}
}
func (num *Num) node() {}
func (num *Num) expr() {}
func (num *Num) String() string {
return fmt.Sprintf("Num(n=%d)", num.Value)
}