Improved expression parser
This commit is contained in:
parent
0ed071a7ee
commit
bb9fac1430
5 changed files with 152 additions and 138 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue