Ejemplo n.º 1
0
        private void All_()
        {
            new Validator("all")
            .TwoParameters()
            .OneQuote()
            .ListAsSecond()
            .Validate(this.stack);

            var    p      = this.Pop <Value.List>();
            var    a      = this.Pop <Value.List>();
            var    saved  = this.stack.Clone();
            IValue result = new Value.Bool(true);

            foreach (var x in a.Elements)
            {
                this.Push(x);
                this.Execterm(p);
                this.stack = saved.Clone();
                if (!Value.IsTruthy(this.Pop()))
                {
                    result = new Value.Bool(false);
                    break;
                }
            }

            this.Push(result);
        }
Ejemplo n.º 2
0
        private void Name_()
        {
            new Validator("name")
            .OneParameter()
            .Validate(this.stack);

            var sym  = this.Pop();
            var name = sym switch
            {
                Value.Int x => "int",
                Value.Float x => "float",
                Value.Bool x => "bool",
                Value.Char x => "char",
                Value.String x => "string",
                Value.List x => "list",
                Value.Set x => "set",
                Value.Stream x => "stream",
                Value.Symbol x => x.Value,
                _ => throw new NotSupportedException(),
            };

            this.Push(new Value.String(name));
        }