Improved expression parser

This commit is contained in:
Eduard Urbach 2024-06-16 22:48:14 +02:00
parent 0ed071a7ee
commit bb9fac1430
Signed by: eduard
GPG key ID: 49226B848C78F6C8
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)
}