wrote dsl for ast boiler plate generation

This commit is contained in:
basil 2025-06-08 21:18:17 -04:00
parent b244f7e3b2
commit e0dd8ff9d5
Signed by: basil
SSH key fingerprint: SHA256:y04xIFL/yqNaG9ae9Vl95vELtHfApGAIoOGLeVLP/fE
16 changed files with 915 additions and 60 deletions

View file

@ -12,7 +12,7 @@ type Printer struct {
var _ ExprVisitor = new(Printer)
func (p *Printer) VisitBinaryExpr(b *BinaryExpr) any {
return p.Parenthesize(b.Operator.Lexeme, b.Left, b.Right)
return p.Parenthesize(b.Op.Lexeme, b.Left, b.Right)
}
func (p *Printer) VisitGroupingExpr(g *GroupingExpr) any {
@ -38,7 +38,7 @@ func (p *Printer) VisitLiteralExpr(g *LiteralExpr) any {
}
func (p *Printer) VisitUnaryExpr(g *UnaryExpr) any {
return p.Parenthesize(g.Operator.Lexeme, g.Right)
return p.Parenthesize(g.Op.Lexeme, g.Right)
}
func (p *Printer) Parenthesize(name string, expressions ...Expr) string {