12345678910111213141516171819202122232425262728293031 |
- package raku
- type Scope interface {
- /* Chains a child scope to a parent scope. */
- Chain(*Scope) bool
- Classifier
- }
- type DefaultScope struct {
- DefaultClassifier
- Parent Scope
- }
- func (scope * DefaultScope) Chain(parent Scope) bool {
- scope.Parent = parent
- return true
- }
- func (scope * DefaultScope) Classify(text TokenText) (TokenType, bool) {
- typ, ok := scope.DefaultClassifier.Classify(text)
- if (!ok && scope.Parent != nil) {
- typ, ok = scope.Parent.Classify(text)
- }
- return typ, ok
- }
|