Moved register state to scopes
This commit is contained in:
parent
3bd5b20af3
commit
545c8dd4f6
22 changed files with 230 additions and 129 deletions
|
@ -32,6 +32,21 @@ func (expr *Expression) AddChild(child *Expression) {
|
|||
child.Parent = expr
|
||||
}
|
||||
|
||||
// Count counts how often the given token appears in the expression.
|
||||
func (expr *Expression) Count(kind token.Kind, name string) int {
|
||||
count := 0
|
||||
|
||||
expr.EachLeaf(func(leaf *Expression) error {
|
||||
if leaf.Token.Kind == kind && leaf.Token.Text() == name {
|
||||
count++
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
return count
|
||||
}
|
||||
|
||||
// Reset resets all values to the default.
|
||||
func (expr *Expression) Reset() {
|
||||
for _, child := range expr.Children {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue