Esempio n. 1
0
        protected void Term()
        {
            bool minus = false;
            bool not   = false;

            SkipWhite();

            if (Next == Grammar.MINUS)
            {
                Consume(Grammar.MINUS);
                minus = true;
            }
            else if (Next == Grammar.EXCL)
            {
                Consume(Grammar.EXCL);
                not = true;
            }

            if (IsDigit(Next))
            {
                GetNum();

                short value = short.Parse(Current);
                if (minus)
                {
                    value = (short)-value;
                }

                emitter.Literal(value);
            }
            else if (IsString(Next))
            {
                GetString();

                if (StringResolver == null)
                {
                    throw new Exception("Tried to resolve a string without resolver set");
                }

                short sindex = StringResolver.GetStringID(Current);

                emitter.Literal(sindex);
            }
            else
            {
                GetName();
                if (IsBuiltinFunction(Current))
                {
                    BuiltinFunctionCall();
                }
                else if (IsInternal(Current))
                {
                    InternalTerm();
                }
                else if (IsScript(Current))
                {
                    ScriptTerm();
                }
                else if (variables.ContainsKey(Current))
                {
                    VarTerm();
                }
                else
                {
                    if (NameResolver == null)
                    {
                        throw new Exception("Tried to resolve a name without resolver set");
                    }

                    short id = NameResolver.GetNameValue(Current);

                    emitter.Literal(id);
                }
            }

            if (not)
            {
                emitter.Negate();
            }

            SkipWhite();
        }