func NewEvaluator(expression string) *Evaluator {
	expressionStack := new(Stack)
	for _, token := range strings.Split(expression, " ") {
		switch token {
		case "+":
			right := expressionStack.Pop().(Expression)
			left := expressionStack.Pop().(Expression)
			subExpression := &Plus{left, right}
			expressionStack.Push(subExpression)
		case "-":
			right := expressionStack.Pop().(Expression)
			left := expressionStack.Pop().(Expression)
			subExpression := &Minus{left, right}
			expressionStack.Push(subExpression)
		default:
			expressionStack.Push(&Variable{token})
		}
	}
	syntaxTree := expressionStack.Pop().(Expression)
	return &Evaluator{syntaxTree}
}
NewEvaluator creates a new Evaluator.
package behavioral
import (
	"strings"
)
type Expression interface {
	Interpret(variables map[string]Expression) int
}
type Integer struct {
	integer int
}
func (n *Integer) Interpret(variables map[string]Expression) int {
	return n.integer
}
type Plus struct {
	leftOperand  Expression
	rightOperand Expression
}
func (p *Plus) Interpret(variables map[string]Expression) int {
	return p.leftOperand.Interpret(variables) + p.rightOperand.Interpret(variables)
}
type Minus struct {
	leftOperand  Expression
	rightOperand Expression
}
func (m *Minus) Interpret(variables map[string]Expression) int {
	return m.leftOperand.Interpret(variables) - m.rightOperand.Interpret(variables)
}
type Variable struct {
	name string
}
func (v *Variable) Interpret(variables map[string]Expression) int {
	value, found := variables[v.name]
	if !found {
		return 0
	}
	return value.Interpret(variables)
}
type Evaluator struct {
	syntaxTree Expression
}