Example #1
0
        internal Obqect createInterfaceContext()
        {
            Obqect context = new Obqect(null, false);

            foreach (var call in calls)
            {
                context.set(call.Key, new Reference(new Funqtion(context, call.Value), context, call.Key, Access.PUBLIC, true));
            }
            return(context);
        }
Example #2
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);
        }