Exemplo 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();
        }
Exemplo n.º 2
0
 static void OpFilterHPBelow(Emitter e, int args, bool returnResult)
 {
     e.Literal(FilterHPBelow);
     e.Emit(Op.FilterTargets);
 }
Exemplo n.º 3
0
 static void OpSelectRandom(Emitter e, int args, bool returnResult)
 {
     e.Literal(SelectRandom);
     e.Emit(Op.SelectTarget);
 }
Exemplo n.º 4
0
 static void OpFilterRange(Emitter e, int args, bool returnResult)
 {
     e.Literal(FilterRange);
     e.Emit(Op.FilterTargets);
 }
Exemplo n.º 5
0
 static void OpSelectEnemies(Emitter e, int args, bool returnResult)
 {
     e.Literal(SelectEnemies);
     e.Emit(Op.SelectTargets);
 }