8e596d5979
1. moved scan/symbol.go to new package sym and adapted all files that reference Symbol type and its values. 2. new type interval defined by begin, end and step values. 3. replaced operator-range.go with operator-interval.go. 4. replaced range operator begin:end with begin..end..step. 5. new implementation of sub-collection extraction based on new interval literal.
30 lines
757 B
Go
30 lines
757 B
Go
// Copyright (c) 2024-2026 Celestino Amoroso (celestino.amoroso@gmail.com).
|
|
// All rights reserved.
|
|
|
|
// term-constructor-registry.go
|
|
package scan
|
|
|
|
import "git.portale-stac.it/go-pkg/expr/sym"
|
|
|
|
const initialRegistryCapacity = 10
|
|
|
|
type termContructor func(tk *Token) *Term
|
|
|
|
var constructorRegistry map[sym.Symbol]termContructor = nil
|
|
|
|
func RegisterTermConstructor(symmbol sym.Symbol, constructor termContructor) {
|
|
if constructorRegistry == nil {
|
|
constructorRegistry = make(map[sym.Symbol]termContructor, initialRegistryCapacity)
|
|
}
|
|
constructorRegistry[symmbol] = constructor
|
|
}
|
|
|
|
func NewTerm(tk *Token) (inst *Term) {
|
|
if constructorRegistry != nil {
|
|
if construct, exists := constructorRegistry[tk.Sym]; exists {
|
|
inst = construct(tk)
|
|
}
|
|
}
|
|
return
|
|
}
|