package ast import "golox/token" type ExprVisitor[T any] interface { VisitErrorExpr(ee *ErrorExpr) T VisitBinaryExpr(be *BinaryExpr) T VisitGroupingExpr(ge *GroupingExpr) T VisitLiteralExpr(le *LiteralExpr) T VisitUnaryExpr(ue *UnaryExpr) T VisitVariableExpr(ve *VariableExpr) T } type Expr interface { Accept(visitor ExprVisitor[any]) any } type ErrorExpr struct { Value string } func (ee *ErrorExpr) Accept(v ExprVisitor[any]) any { return v.VisitErrorExpr(ee) } type BinaryExpr struct { Left Expr Operator token.Token Right Expr } func (be *BinaryExpr) Accept(v ExprVisitor[any]) any { return v.VisitBinaryExpr(be) } type GroupingExpr struct { Expression Expr } func (ge *GroupingExpr) Accept(v ExprVisitor[any]) any { return v.VisitGroupingExpr(ge) } type LiteralExpr struct { Value any } func (le *LiteralExpr) Accept(v ExprVisitor[any]) any { return v.VisitLiteralExpr(le) } type UnaryExpr struct { Operator token.Token Right Expr } func (ue *UnaryExpr) Accept(v ExprVisitor[any]) any { return v.VisitUnaryExpr(ue) } type VariableExpr struct { Name token.Token } func (ve *VariableExpr) Accept(v ExprVisitor[any]) any { return v.VisitVariableExpr(ve) }