예제 #1
0
        public Scope Extend(Pattern pattern)
        {
            Scope scope = this;

            if (pattern is SinglePattern)
            {
                scope = new ConsScope((pattern as SinglePattern).name, scope);
            }
            else if (pattern is ListPattern)
            {
                scope = scope.Extend((pattern as ListPattern).list.parameters);
            }
            else if (pattern is HeadConsPattern)
            {
                scope = scope.Extend((pattern as HeadConsPattern).list.parameters);
                scope = new ConsScope((pattern as HeadConsPattern).single.name, scope);
            }
            else if (pattern is TailConsPattern)
            {
                scope = new ConsScope((pattern as TailConsPattern).single.name, scope);
                scope = scope.Extend((pattern as TailConsPattern).list.parameters);
            }
            else
            {
                throw new Error("Pattern");
            }
            return(scope);
        }
예제 #2
0
        public override Scope ToScope()
        {
            Scope scope = next.ToScope();

            foreach (var kvp in builtin)
            {
                scope = new ConsScope(kvp.Key, scope);
            }
            return(scope);
        }