Improved expression parser

This commit is contained in:
2024-06-16 22:48:14 +02:00
parent ef16bdb4c7
commit 23c6134d9a
5 changed files with 152 additions and 138 deletions

View File

@ -8,9 +8,10 @@ import (
// Expression is a binary tree with an operator on each node.
type Expression struct {
Token token.Token
Parent *Expression
Children []*Expression
Token token.Token
Parent *Expression
Children []*Expression
Precedence int
}
// New creates a new expression.
@ -49,6 +50,7 @@ func (expr *Expression) Close() {
expr.Token.Reset()
expr.Parent = nil
expr.Children = expr.Children[:0]
expr.Precedence = 0
pool.Put(expr)
}