basic expression interpreter

This commit is contained in:
basil 2025-06-08 16:03:02 -04:00
parent eebaadc16e
commit b244f7e3b2
Signed by: basil
SSH key fingerprint: SHA256:y04xIFL/yqNaG9ae9Vl95vELtHfApGAIoOGLeVLP/fE
5 changed files with 186 additions and 16 deletions

View file

@ -16,7 +16,7 @@ type ExprVisitor interface {
}
type Expr interface {
accept(v ExprVisitor) any
Accept(v ExprVisitor) any
}
type BinaryExpr struct {
@ -25,7 +25,7 @@ type BinaryExpr struct {
Right Expr
}
func (b *BinaryExpr) accept(v ExprVisitor) any {
func (b *BinaryExpr) Accept(v ExprVisitor) any {
return v.VisitBinaryExpr(b)
}
@ -33,7 +33,7 @@ type GroupingExpr struct {
Expr Expr
}
func (g *GroupingExpr) accept(v ExprVisitor) any {
func (g *GroupingExpr) Accept(v ExprVisitor) any {
return v.VisitGroupingExpr(g)
}
@ -41,7 +41,7 @@ type LiteralExpr struct {
Value any
}
func (l *LiteralExpr) accept(v ExprVisitor) any {
func (l *LiteralExpr) Accept(v ExprVisitor) any {
return v.VisitLiteralExpr(l)
}
@ -50,6 +50,6 @@ type UnaryExpr struct {
Right Expr
}
func (u *UnaryExpr) accept(v ExprVisitor) any {
func (u *UnaryExpr) Accept(v ExprVisitor) any {
return v.VisitUnaryExpr(u)
}