basic expression interpreter
This commit is contained in:
parent
eebaadc16e
commit
b244f7e3b2
5 changed files with 186 additions and 16 deletions
10
ast/ast.go
10
ast/ast.go
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue