Beispiel #1
0
        public override Value execute(Qontext context)
        {
            Value p = new Value(true, ValueType.Boolean);

            do
            {
                if (loopType == HEAD)
                {
                    p = base.execute(context);
                }
                if (!p.isType(ValueType.Boolean))
                {
                    throw new ConditionException("expression for loop condition has to return a value of type BOOL, got " + p.type.ToString() + " instead.");
                }
                if (p.getValue <bool>())
                {
                    Funqtion fq = new Funqtion(context, new List <Segment>(body));
                    fq.execute();
                }
                else
                {
                    break;
                }
                if (loopType == FOOT)
                {
                    p = base.execute(context);
                }
            } while (true);
            return(null);
        }
Beispiel #2
0
        public override Value execute(Qontext context)
        {
            Value r = stack.Length == 0 ? Value.True : base.execute(context);

            if (!r.isType(ValueType.Boolean))
            {
                throw new ConditionException("expression for loop condition has to return a value of type BOOLEAN, got " + r.type.ToString() + " instead.");
            }
            else if (r.getValue <bool>())
            {
                Funqtion xfq = new Funqtion(context, new List <Segment>(body));
                xfq.execute();
            }
            else if (next != null)
            {
                next.execute(context);
            }
            return(null);
        }
Beispiel #3
0
        public Value readNextValue(Qontext context, ValueType expected = ValueType.Any)
        {
            Log.spam("Interpretoken.readNextValue()");
            Token t      = peek();
            Value result = null;

            if ((t.check(ValueType.Identifier)) ||
                (t.check(ValueType.Keyword) &&
                 (t.check(Keyword.CURRENT_CONTEXT.name) ||
                  t.check(Keyword.PARENT_CONTEXT.name))))
            {
                Log.spam("detected possible reference / identifier");
                Reference[] _r = rrra(context);
                Reference   r  = _r[_r.Length - 1];
                if (peek().check(Struqture.Call[OPEN]))
                {
                    Log.spam("hey, it's a funqtion call!");
                    if (r.getValueType() == ValueType.Funqtion || r.getValueType() == ValueType.NativeCall)
                    {
                        Value[] p = Funqtionizer.parseParameters(context, readBody(true));
                        result = (r.getTrueValue() as Funqtion).execute(p, (_r.Length > 1 ? _r[_r.Length - 2] : null));
                    }
                    else
                    {
                        throw new ParseException("can not call " + peek(-1) + ": not a funqtion.");
                    }
                }
                else
                {
                    result = r;
                }
            }
            else if (t.check(ValueType.Struqture))
            {
                Log.spam("detected possible structure");
                if (t.check(Struqture.Funqtion[OPEN]))
                {
                    Log.spam("...it's a funqtion");
                    Funqtion f = Funqtionizer.parse(context, readBody(true));
                    if (peek().check(Struqture.Call[OPEN]))
                    {
                        Value[] p = Funqtionizer.parseParameters(context, readBody(true));
                        result = f.execute(p);
                    }
                    else
                    {
                        result = f;
                    }
                }
                else if (t.check(Struqture.Context[OPEN]))
                {
                    Obqect o = Colleqtionizer.readObqect(context, readBody(true));
                    result = o;
                }
                else if (t.check(Struqture.Collection[OPEN]))
                {
                    Array a = Colleqtionizer.readArray(context, readBody(true));
                    result = a;
                }
                else if (t.check(Struqture.Call[OPEN]))
                {
                    Segment s = Segmentizer.parseOne(context, readBody());
                    result = s.execute(context);
                }
            }
            else if (t.check(ValueType.Primitive))
            {
                result = digest().makeValue();
            }
            else if (t.check(ValueType.Operator))
            {
                throw new ParseException("next token was unreadable as value: " + t, t);
            }

            return(result);
        }