Пример #1
0
        public void RegisterFunctions()
        {
            ParserFunction.RegisterFunction(Constants.IF, new IfStatement());
            ParserFunction.RegisterFunction(Constants.WHILE, new WhileStatement());
            ParserFunction.RegisterFunction(Constants.FOR, new ForStatement());
            ParserFunction.RegisterFunction(Constants.BREAK, new BreakStatement());
            ParserFunction.RegisterFunction(Constants.COMPILED_FUNCTION, new CompiledFunctionCreator(false));
            ParserFunction.RegisterFunction(Constants.CONTINUE, new ContinueStatement());
            ParserFunction.RegisterFunction(Constants.CLASS, new ClassCreator());
            ParserFunction.RegisterFunction(Constants.ENUM, new EnumFunction());
            ParserFunction.RegisterFunction(Constants.NEW, new NewObjectFunction());
            ParserFunction.RegisterFunction(Constants.RETURN, new ReturnStatement());
            ParserFunction.RegisterFunction(Constants.FUNCTION, new FunctionCreator());
            ParserFunction.RegisterFunction(Constants.GET_PROPERTIES, new GetPropertiesFunction());
            ParserFunction.RegisterFunction(Constants.GET_PROPERTY, new GetPropertyFunction());
            ParserFunction.RegisterFunction(Constants.INCLUDE, new IncludeFile());
            ParserFunction.RegisterFunction(Constants.SET_PROPERTY, new SetPropertyFunction());
            ParserFunction.RegisterFunction(Constants.TRY, new TryBlock());
            ParserFunction.RegisterFunction(Constants.THROW, new ThrowFunction());
            ParserFunction.RegisterFunction(Constants.TYPE, new TypeFunction());
            ParserFunction.RegisterFunction(Constants.TRUE, new BoolFunction(true));
            ParserFunction.RegisterFunction(Constants.FALSE, new BoolFunction(false));

            ParserFunction.RegisterFunction(Constants.ABS, new AbsFunction());
            ParserFunction.RegisterFunction(Constants.ACOS, new AcosFunction());
            ParserFunction.RegisterFunction(Constants.ADD, new AddFunction());
            ParserFunction.RegisterFunction(Constants.ADD_TO_HASH, new AddVariableToHashFunction());
            ParserFunction.RegisterFunction(Constants.ADD_ALL_TO_HASH, new AddVariablesToHashFunction());
            ParserFunction.RegisterFunction(Constants.ASIN, new AsinFunction());
            ParserFunction.RegisterFunction(Constants.CANCEL, new CancelFunction());
            ParserFunction.RegisterFunction(Constants.CANCEL_RUN, new ScheduleRunFunction(false));
            ParserFunction.RegisterFunction(Constants.CEIL, new CeilFunction());
            ParserFunction.RegisterFunction(Constants.CHECK_LOADER_MAIN, new CheckLoaderMainFunction());
            ParserFunction.RegisterFunction(Constants.CONTAINS, new ContainsFunction());
            ParserFunction.RegisterFunction(Constants.COS, new CosFunction());
            ParserFunction.RegisterFunction(Constants.CURRENT_PATH, new CurrentPathFunction());
            ParserFunction.RegisterFunction(Constants.DATE_TIME, new DateTimeFunction(false));
            ParserFunction.RegisterFunction(Constants.DEEP_COPY, new DeepCopyFunction());
            ParserFunction.RegisterFunction(Constants.DEFINE_LOCAL, new DefineLocalFunction());
            ParserFunction.RegisterFunction(Constants.ENV, new GetEnvFunction());
            ParserFunction.RegisterFunction(Constants.EXP, new ExpFunction());
            ParserFunction.RegisterFunction(Constants.FIND_INDEX, new FindIndexFunction());
            ParserFunction.RegisterFunction(Constants.FLOOR, new FloorFunction());
            ParserFunction.RegisterFunction(Constants.GET_COLUMN, new GetColumnFunction());
            ParserFunction.RegisterFunction(Constants.GET_FILE_FROM_DEBUGGER, new GetFileFromDebugger());
            ParserFunction.RegisterFunction(Constants.GET_KEYS, new GetAllKeysFunction());
            ParserFunction.RegisterFunction(Constants.JSON, new GetVariableFromJSONFunction());
            ParserFunction.RegisterFunction(Constants.LOCK, new LockFunction());
            ParserFunction.RegisterFunction(Constants.LOG, new LogFunction());
            ParserFunction.RegisterFunction(Constants.NAMESPACE, new NamespaceFunction());
            ParserFunction.RegisterFunction(Constants.NAME_EXISTS, new NameExistsFunction());
            ParserFunction.RegisterFunction(Constants.NOW, new DateTimeFunction());
            ParserFunction.RegisterFunction(Constants.PI, new PiFunction());
            ParserFunction.RegisterFunction(Constants.POW, new PowFunction());
            ParserFunction.RegisterFunction(Constants.PRINT, new PrintFunction());
            ParserFunction.RegisterFunction(Constants.PSTIME, new ProcessorTimeFunction());
            ParserFunction.RegisterFunction(Constants.RANDOM, new GetRandomFunction());
            ParserFunction.RegisterFunction(Constants.REGEX, new RegexFunction());
            ParserFunction.RegisterFunction(Constants.REMOVE, new RemoveFunction());
            ParserFunction.RegisterFunction(Constants.REMOVE_AT, new RemoveAtFunction());
            ParserFunction.RegisterFunction(Constants.RESET_VARS, new ResetVariablesFunction());
            ParserFunction.RegisterFunction(Constants.ROUND, new RoundFunction());
            ParserFunction.RegisterFunction(Constants.SCHEDULE_RUN, new ScheduleRunFunction(true));
            ParserFunction.RegisterFunction(Constants.SHOW, new ShowFunction());
            ParserFunction.RegisterFunction(Constants.SETENV, new SetEnvFunction());
            ParserFunction.RegisterFunction(Constants.SIGNAL,new SignalWaitFunction(true));
            ParserFunction.RegisterFunction(Constants.SIN,new SinFunction());
            ParserFunction.RegisterFunction(Constants.SINGLETON,new SingletonFunction());
            ParserFunction.RegisterFunction(Constants.SIZE,new SizeFunction());
            ParserFunction.RegisterFunction(Constants.SLEEP,new SleepFunction());
            ParserFunction.RegisterFunction(Constants.SQRT,new SqrtFunction());
            ParserFunction.RegisterFunction(Constants.START_DEBUGGER,new DebuggerFunction(true));
            ParserFunction.RegisterFunction(Constants.STOP_DEBUGGER,new DebuggerFunction(false));
            ParserFunction.RegisterFunction(Constants.STR_BETWEEN,new StringManipulationFunction(StringManipulationFunction.Mode.BEETWEEN));
            ParserFunction.RegisterFunction(Constants.STR_BETWEEN_ANY,new StringManipulationFunction(StringManipulationFunction.Mode.BEETWEEN_ANY));
            ParserFunction.RegisterFunction(Constants.STR_CONTAINS,new StringManipulationFunction(StringManipulationFunction.Mode.CONTAINS));
            ParserFunction.RegisterFunction(Constants.STR_LOWER,new StringManipulationFunction(StringManipulationFunction.Mode.LOWER));
            ParserFunction.RegisterFunction(Constants.STR_ENDS_WITH,new StringManipulationFunction(StringManipulationFunction.Mode.ENDS_WITH));
            ParserFunction.RegisterFunction(Constants.STR_EQUALS,new StringManipulationFunction(StringManipulationFunction.Mode.EQUALS));
            ParserFunction.RegisterFunction(Constants.STR_INDEX_OF,new StringManipulationFunction(StringManipulationFunction.Mode.INDEX_OF));
            ParserFunction.RegisterFunction(Constants.STR_REPLACE,new StringManipulationFunction(StringManipulationFunction.Mode.REPLACE));
            ParserFunction.RegisterFunction(Constants.STR_STARTS_WITH,new StringManipulationFunction(StringManipulationFunction.Mode.STARTS_WITH));
            ParserFunction.RegisterFunction(Constants.STR_SUBSTR,new StringManipulationFunction(StringManipulationFunction.Mode.SUBSTRING));
            ParserFunction.RegisterFunction(Constants.STR_TRIM,new StringManipulationFunction(StringManipulationFunction.Mode.TRIM));
            ParserFunction.RegisterFunction(Constants.STR_UPPER,new StringManipulationFunction(StringManipulationFunction.Mode.UPPER));
            ParserFunction.RegisterFunction(Constants.THREAD,new ThreadFunction());
            ParserFunction.RegisterFunction(Constants.THREAD_ID,new ThreadIDFunction());
            ParserFunction.RegisterFunction(Constants.TOKENIZE,new TokenizeFunction());
            ParserFunction.RegisterFunction(Constants.TOKENIZE_LINES,new TokenizeLinesFunction());
            ParserFunction.RegisterFunction(Constants.TOKEN_COUNTER,new TokenCounterFunction());
            ParserFunction.RegisterFunction(Constants.TO_BOOL,new ToBoolFunction());
            ParserFunction.RegisterFunction(Constants.TO_DECIMAL,new ToDecimalFunction());
            ParserFunction.RegisterFunction(Constants.TO_DOUBLE,new ToDoubleFunction());
            ParserFunction.RegisterFunction(Constants.TO_INT,new ToIntFunction());
            ParserFunction.RegisterFunction(Constants.TO_STRING,new ToStringFunction());
            ParserFunction.RegisterFunction(Constants.WAIT,new SignalWaitFunction(false));
            ParserFunction.RegisterFunction(Constants.WEB_REQUEST,new WebRequestFunction());

            ParserFunction.RegisterFunction(Constants.ADD_DATA,new DataFunction(DataFunction.DataMode.ADD));
            ParserFunction.RegisterFunction(Constants.COLLECT_DATA,new DataFunction(DataFunction.DataMode.SUBSCRIBE));
            ParserFunction.RegisterFunction(Constants.GET_DATA,new DataFunction(DataFunction.DataMode.SEND));
        }
Пример #2
0
        string GetAllVariables(ParsingScript script)
        {
            string vars = ParserFunction.GetVariables(script);

            return(vars);
        }
Пример #3
0
 public void RegisterEnums()
 {
     ParserFunction.RegisterEnum(Constants.VARIABLE_TYPE,"SplitAndMerge.Variable.VarType");
 }
Пример #4
0
        internal async Task <Variable> ProcessTryAsync(ParsingScript script)
        {
            int       startTryCondition = script.Pointer - 1;
            int       currentStackLevel = ParserFunction.GetCurrentStackLevel();
            Exception exception         = null;

            Variable result = null;

            bool alreadyInTryBlock = script.InTryBlock;

            script.InTryBlock = true;
            try
            {
                result = await ProcessBlockAsync(script);
            }
            catch (Exception exc)
            {
                exception = exc;
            }
            finally
            {
                script.InTryBlock = alreadyInTryBlock;
            }

            if (exception != null || result.IsReturn ||
                result.Type == Variable.VarType.BREAK ||
                result.Type == Variable.VarType.CONTINUE)
            {
                // We are here from the middle of the try-block either because
                // an exception was thrown or because of a Break/Continue. Skip it.
                script.Pointer = startTryCondition;
                SkipBlock(script);
            }

            string catchToken = Utils.GetNextToken(script);

            script.Forward(); // skip opening parenthesis
                              // The next token after the try block must be a catch.
            if (Constants.CATCH != catchToken)
            {
                throw new ArgumentException("Expecting a 'catch()' but got [" +
                                            catchToken + "]");
            }

            string exceptionName = Utils.GetNextToken(script);

            script.Forward(); // skip closing parenthesis

            if (exception != null)
            {
                string excStack = CreateExceptionStack(exceptionName, currentStackLevel);
                ParserFunction.InvalidateStacksAfterLevel(currentStackLevel);

                GetVarFunction excMsgFunc = new GetVarFunction(new Variable(exception.Message));
                ParserFunction.AddGlobalOrLocalVariable(exceptionName, excMsgFunc);
                GetVarFunction excStackFunc = new GetVarFunction(new Variable(excStack));
                ParserFunction.AddGlobalOrLocalVariable(exceptionName + ".Stack", excStackFunc);

                result = await ProcessBlockAsync(script);

                ParserFunction.PopLocalVariable(exceptionName);
            }
            else
            {
                SkipBlock(script);
            }

            SkipRestBlocks(script);
            return(result);
        }
Пример #5
0
        public void Init()
        {
            ParserFunction.RegisterFunction(Constants.IF, new IfStatement());
            ParserFunction.RegisterFunction(Constants.WHILE, new WhileStatement());
            ParserFunction.RegisterFunction(Constants.FOR, new ForStatement());
            ParserFunction.RegisterFunction(Constants.BREAK, new BreakStatement());
            ParserFunction.RegisterFunction(Constants.CONTINUE, new ContinueStatement());
            ParserFunction.RegisterFunction(Constants.RETURN, new ReturnStatement());
            ParserFunction.RegisterFunction(Constants.FUNCTION, new FunctionCreator());
            ParserFunction.RegisterFunction(Constants.INCLUDE, new IncludeFile());
            ParserFunction.RegisterFunction(Constants.TRY, new TryBlock());
            ParserFunction.RegisterFunction(Constants.THROW, new ThrowFunction());
            ParserFunction.RegisterFunction(Constants.TYPE, new TypeFunction());
            ParserFunction.RegisterFunction(Constants.TRUE, new BoolFunction(true));
            ParserFunction.RegisterFunction(Constants.FALSE, new BoolFunction(false));

            ParserFunction.RegisterFunction(Constants.ABS, new AbsFunction());
            ParserFunction.RegisterFunction(Constants.ACOS, new AcosFunction());
            ParserFunction.RegisterFunction(Constants.ADD, new AddFunction());
            ParserFunction.RegisterFunction(Constants.ADD_TO_HASH, new AddVariableToHashFunction());
            ParserFunction.RegisterFunction(Constants.ADD_ALL_TO_HASH, new AddVariablesToHashFunction());
            ParserFunction.RegisterFunction(Constants.APPEND, new AppendFunction());
            ParserFunction.RegisterFunction(Constants.APPENDLINE, new AppendLineFunction());
            ParserFunction.RegisterFunction(Constants.APPENDLINES, new AppendLinesFunction());
            ParserFunction.RegisterFunction(Constants.ASIN, new AsinFunction());
            ParserFunction.RegisterFunction(Constants.CD, new CdFunction());
            ParserFunction.RegisterFunction(Constants.CD__, new Cd__Function());
            ParserFunction.RegisterFunction(Constants.CEIL, new CeilFunction());
            ParserFunction.RegisterFunction(Constants.CONNECTSRV, new ClientSocket());
            ParserFunction.RegisterFunction(Constants.CONSOLE_CLR, new ClearConsole());
            ParserFunction.RegisterFunction(Constants.CONTAINS, new ContainsFunction());
            ParserFunction.RegisterFunction(Constants.COPY, new CopyFunction());
            ParserFunction.RegisterFunction(Constants.COS, new CosFunction());
            ParserFunction.RegisterFunction(Constants.DEEP_COPY, new DeepCopyFunction());
            ParserFunction.RegisterFunction(Constants.DELETE, new DeleteFunction());
            ParserFunction.RegisterFunction(Constants.DIR, new DirFunction());
            ParserFunction.RegisterFunction(Constants.ENV, new GetEnvFunction());
            ParserFunction.RegisterFunction(Constants.EXISTS, new ExistsFunction());
            ParserFunction.RegisterFunction(Constants.EXIT, new ExitFunction());
            ParserFunction.RegisterFunction(Constants.EXP, new ExpFunction());
            ParserFunction.RegisterFunction(Constants.FINDFILES, new FindfilesFunction());
            ParserFunction.RegisterFunction(Constants.FINDSTR, new FindstrFunction());
            ParserFunction.RegisterFunction(Constants.FLOOR, new FloorFunction());
            ParserFunction.RegisterFunction(Constants.GET_COLUMN, new GetColumnFunction());
            ParserFunction.RegisterFunction(Constants.GET_KEYS, new GetAllKeysFunction());
            ParserFunction.RegisterFunction(Constants.INDEX_OF, new IndexOfFunction());
            ParserFunction.RegisterFunction(Constants.KILL, new KillFunction());
            ParserFunction.RegisterFunction(Constants.LOCK, new LockFunction());
            ParserFunction.RegisterFunction(Constants.LOG, new LogFunction());
            ParserFunction.RegisterFunction(Constants.MKDIR, new MkdirFunction());
            ParserFunction.RegisterFunction(Constants.MORE, new MoreFunction());
            ParserFunction.RegisterFunction(Constants.MOVE, new MoveFunction());
            ParserFunction.RegisterFunction(Constants.NOW, new DateTimeFunction());
            ParserFunction.RegisterFunction(Constants.PI, new PiFunction());
            ParserFunction.RegisterFunction(Constants.POW, new PowFunction());
            ParserFunction.RegisterFunction(Constants.PRINT, new PrintFunction());
            ParserFunction.RegisterFunction(Constants.PRINT_BLACK, new PrintFunction(ConsoleColor.Black));
            ParserFunction.RegisterFunction(Constants.PRINT_GRAY, new PrintFunction(ConsoleColor.DarkGray));
            ParserFunction.RegisterFunction(Constants.PRINT_GREEN, new PrintFunction(ConsoleColor.Green));
            ParserFunction.RegisterFunction(Constants.PRINT_RED, new PrintFunction(ConsoleColor.Red));
            ParserFunction.RegisterFunction(Constants.PSINFO, new PsInfoFunction());
            ParserFunction.RegisterFunction(Constants.PSTIME, new ProcessorTimeFunction());
            ParserFunction.RegisterFunction(Constants.PWD, new PwdFunction());
            ParserFunction.RegisterFunction(Constants.RANDOM, new GetRandomFunction());
            ParserFunction.RegisterFunction(Constants.READ, new ReadConsole());
            ParserFunction.RegisterFunction(Constants.READFILE, new ReadCSCSFileFunction());
            ParserFunction.RegisterFunction(Constants.READNUMBER, new ReadConsole(true));
            ParserFunction.RegisterFunction(Constants.REMOVE, new RemoveFunction());
            ParserFunction.RegisterFunction(Constants.REMOVE_AT, new RemoveAtFunction());
            ParserFunction.RegisterFunction(Constants.ROUND, new RoundFunction());
            ParserFunction.RegisterFunction(Constants.RUN, new RunFunction());
            ParserFunction.RegisterFunction(Constants.SIGNAL,new SignalWaitFunction(true));
            ParserFunction.RegisterFunction(Constants.SETENV,new SetEnvFunction());
            ParserFunction.RegisterFunction(Constants.SHOW,new ShowFunction());
            ParserFunction.RegisterFunction(Constants.SIN,new SinFunction());
            ParserFunction.RegisterFunction(Constants.SIZE,new SizeFunction());
            ParserFunction.RegisterFunction(Constants.SLEEP,new SleepFunction());
            ParserFunction.RegisterFunction(Constants.SQRT,new SqrtFunction());
            ParserFunction.RegisterFunction(Constants.STARTSRV,new ServerSocket());
            ParserFunction.RegisterFunction(Constants.STOPWATCH_ELAPSED,new StopWatchFunction(StopWatchFunction.Mode.ELAPSED));
            ParserFunction.RegisterFunction(Constants.STOPWATCH_START,new StopWatchFunction(StopWatchFunction.Mode.START));
            ParserFunction.RegisterFunction(Constants.STOPWATCH_STOP,new StopWatchFunction(StopWatchFunction.Mode.STOP));
            ParserFunction.RegisterFunction(Constants.STR_CONTAINS,new StringManipulationFunction(StringManipulationFunction.Mode.CONTAINS));
            ParserFunction.RegisterFunction(Constants.STR_LOWER,new StringManipulationFunction(StringManipulationFunction.Mode.LOWER));
            ParserFunction.RegisterFunction(Constants.STR_ENDS_WITH,new StringManipulationFunction(StringManipulationFunction.Mode.ENDS_WITH));
            ParserFunction.RegisterFunction(Constants.STR_EQUALS,new StringManipulationFunction(StringManipulationFunction.Mode.EQUALS));
            ParserFunction.RegisterFunction(Constants.STR_INDEX_OF,new StringManipulationFunction(StringManipulationFunction.Mode.INDEX_OF));
            ParserFunction.RegisterFunction(Constants.STR_REPLACE,new StringManipulationFunction(StringManipulationFunction.Mode.REPLACE));
            ParserFunction.RegisterFunction(Constants.STR_STARTS_WITH,new StringManipulationFunction(StringManipulationFunction.Mode.STARTS_WITH));
            ParserFunction.RegisterFunction(Constants.STR_SUBSTR,new StringManipulationFunction(StringManipulationFunction.Mode.SUBSTRING));
            ParserFunction.RegisterFunction(Constants.STR_TRIM,new StringManipulationFunction(StringManipulationFunction.Mode.TRIM));
            ParserFunction.RegisterFunction(Constants.STR_UPPER,new StringManipulationFunction(StringManipulationFunction.Mode.UPPER));
            ParserFunction.RegisterFunction(Constants.SUBSTR,new SubstrFunction());
            ParserFunction.RegisterFunction(Constants.TAIL,new TailFunction());
            ParserFunction.RegisterFunction(Constants.THREAD,new ThreadFunction());
            ParserFunction.RegisterFunction(Constants.THREAD_ID,new ThreadIDFunction());
            ParserFunction.RegisterFunction(Constants.TOKENIZE,new TokenizeFunction());
            ParserFunction.RegisterFunction(Constants.TOKENIZE_LINES,new TokenizeLinesFunction());
            ParserFunction.RegisterFunction(Constants.TOKEN_COUNTER,new TokenCounterFunction());
            ParserFunction.RegisterFunction(Constants.TOLOWER,new ToLowerFunction());
            ParserFunction.RegisterFunction(Constants.TOUPPER,new ToUpperFunction());
            ParserFunction.RegisterFunction(Constants.TRANSLATE,new TranslateFunction());
            ParserFunction.RegisterFunction(Constants.WAIT,new SignalWaitFunction(false));
            ParserFunction.RegisterFunction(Constants.WRITE,new PrintFunction(false));
            ParserFunction.RegisterFunction(Constants.WRITELINE,new WriteLineFunction());
            ParserFunction.RegisterFunction(Constants.WRITELINES,new WriteLinesFunction());
            ParserFunction.RegisterFunction(Constants.WRITE_CONSOLE,new WriteToConsole());

            ParserFunction.AddAction(Constants.ASSIGNMENT,new AssignFunction());
            ParserFunction.AddAction(Constants.INCREMENT,new IncrementDecrementFunction());
            ParserFunction.AddAction(Constants.DECREMENT,new IncrementDecrementFunction());

            for (int i = 0; i < Constants.OPER_ACTIONS.Length; i++)
            {
                ParserFunction.AddAction(Constants.OPER_ACTIONS[i],new OperatorAssignFunction());
            }

            Constants.ELSE_LIST.Add(Constants.ELSE);
            Constants.ELSE_IF_LIST.Add(Constants.ELSE_IF);
            Constants.CATCH_LIST.Add(Constants.CATCH);

            ReadConfig();
        }
Пример #6
0
        public Variable Run(List <Variable> args)
        {
            RegisterArguments(args);

            List <string>         argsStr    = new List <string>();
            List <double>         argsNum    = new List <double>();
            List <List <string> > argsArrStr = new List <List <string> >();
            List <List <double> > argsArrNum = new List <List <double> >();
            List <Dictionary <string, string> > argsMapStr = new List <Dictionary <string, string> >();
            List <Dictionary <string, double> > argsMapNum = new List <Dictionary <string, double> >();
            List <Variable> argsVar = new List <Variable>();

            for (int i = 0; i < m_args.Length; i++)
            {
                Variable typeVar = m_argsMap[m_args[i]];
                if (typeVar.Type == Variable.VarType.STRING)
                {
                    argsStr.Add(args[i].AsString());
                }
                else if (typeVar.Type == Variable.VarType.NUMBER)
                {
                    argsNum.Add(args[i].AsDouble());
                }
                else if (typeVar.Type == Variable.VarType.ARRAY_STR)
                {
                    List <string> subArrayStr = new List <string>();
                    var           tuple       = args[i].Tuple;
                    for (int j = 0; j < tuple.Count; j++)
                    {
                        subArrayStr.Add(tuple[j].AsString());
                    }
                    argsArrStr.Add(subArrayStr);
                }
                else if (typeVar.Type == Variable.VarType.ARRAY_NUM)
                {
                    List <double> subArrayNum = new List <double>();
                    var           tuple       = args[i].Tuple;
                    for (int j = 0; j < tuple.Count; j++)
                    {
                        subArrayNum.Add(tuple[j].AsDouble());
                    }
                    argsArrNum.Add(subArrayNum);
                }
                else if (typeVar.Type == Variable.VarType.MAP_STR)
                {
                    Dictionary <string, string> subMapStr = new Dictionary <string, string>();
                    var tuple = args[i].Tuple;
                    var keys  = args[i].GetKeys();
                    for (int j = 0; j < tuple.Count; j++)
                    {
                        subMapStr.Add(keys[j], tuple[j].AsString());
                    }
                    argsMapStr.Add(subMapStr);
                }
                else if (typeVar.Type == Variable.VarType.MAP_NUM)
                {
                    Dictionary <string, double> subMapNum = new Dictionary <string, double>();
                    var tuple = args[i].Tuple;
                    var keys  = args[i].GetKeys();
                    for (int j = 0; j < tuple.Count; j++)
                    {
                        subMapNum.Add(keys[j], tuple[j].AsDouble());
                    }
                    argsMapNum.Add(subMapNum);
                }
                else if (typeVar.Type == Variable.VarType.VARIABLE)
                {
                    argsVar.Add(args[i]);
                }
            }

            Variable result = Precompiler.AsyncMode ?
                              m_precompiler.RunAsync(argsStr, argsNum, argsArrStr, argsArrNum, argsMapStr, argsMapNum, argsVar, false) :
                              m_precompiler.Run(argsStr, argsNum, argsArrStr, argsArrNum, argsMapStr, argsMapNum, argsVar, false);

            ParserFunction.PopLocalVariables(m_stackLevel.Id);

            return(result);
        }
Пример #7
0
 public static void RegisterFunction(string name, ParserFunction function,
                                     bool isNative = true)
 {
     AddGlobal(name, function, isNative);
 }
Пример #8
0
        // Calculate
        // Изчисли
        private static List <Variable> Calculate(string data, ref int from, char[] to)
        {
            List <Variable> listToMerge = new List <Variable>(); // 32

            // Console.WriteLine(forum);

            if (from >= data.Length || to.Contains(data[from]))
            {
                listToMerge.Add(Variable.EmptyInstance);
                return(listToMerge);
            }

            StringBuilder item     = new StringBuilder();
            int           negated  = 0;     // отказване
            bool          inQuotes = false; // в Цитати

            do
            {
                // Основен цикъл на обработка на първата част.
//                string negateSymbol = Utils.IsNotSign(data.Substring(from));
//
//                //Console.WriteLine(negateSymbol);
//
//                if (negateSymbol != null)
//                {
//                    negated++;
//                    from += negateSymbol.Length;
//                    continue;
//                }

                char ch = data[from++];

                inQuotes = ch == Constants.QUOTE && (from == 0 || data[from] != '\\') ? !inQuotes : inQuotes;

                string action = null;

                bool keepCollecting = inQuotes || StillCollecting(item.ToString(), to, data, from, ref action);

                //Console.WriteLine(ch);
                if (keepCollecting)
                {
                    // Char отново принадлежи към предишния операнд.
                    item.Append(ch);

                    if (from < data.Length && (inQuotes || !to.Contains(data[from])))
                    {
                        continue;
                    }
                }

                string parsingItem = item.ToString();

                // CheckConsistency(parsingItem, listToMerge, data, from);

                Utils.MoveForwardIf(data, ref from, Constants.SPACE);

                if (action != null && action.Length > 1)
                {
                    from += (action.Length - 1);
                }

                // Ние сме готови да получим следващия знак. Призивът getValue () може да е по-долу
                // рекурсивно извиква loadAndCalculate (). Това ще стане, ако се извлече
                // елементът е функция или ако следващият елемент започва с START_ARG '('.

                ParserFunction func = new ParserFunction(data, ref from, parsingItem, ch, ref action);

                Variable current = func.GetValue(data, ref from);

                if (negated > 0 && current.Type == Variable.VarType.NUMBER)
                {
                    // Ако има знак NOT, това е булев.
                    // Използвайте XOR (вярно, ако точно един от аргументите е вярно).
                    bool boolRes = !((negated % 2 == 0) ^ Convert.ToBoolean(current.Value));
                    current = new Variable(Convert.ToDouble(boolRes));
                    negated = 0;
                }

                if (action == null)
                {
                    action = UpdateAction(data, ref from, to);
                }


                char next = from < data.Length ? data[from] : Constants.EMPTY;
                bool done = listToMerge.Count == 0 &&
                            ((action == Constants.END_ARG_STR &&
                              current.Type != Variable.VarType.NUMBER) ||
                             next == Constants.END_STATEMENT);
                if (done)
                {
                    // Ако няма числен резултат, ние не сме в математически израз.
                    listToMerge.Add(current);
                    return(listToMerge);
                }

                Variable cell = new Variable(current);
                cell.Action = action;
                listToMerge.Add(cell);
                item.Clear();
            } while (from < data.Length && (inQuotes || !to.Contains(data[from])));

            // Това се случва, когато се нарича рекурсивно вътре в математическия израз:
            Utils.MoveForwardIf(data, ref from, Constants.END_ARG);

            return(listToMerge);
        }
Пример #9
0
        public void RegisterFunctions()
        {
            ParserFunction.RegisterFunction(Constants.IF, new IfStatement());
            ParserFunction.RegisterFunction(Constants.DO, new DoWhileStatement());
            ParserFunction.RegisterFunction(Constants.WHILE, new WhileStatement());
            ParserFunction.RegisterFunction(Constants.SWITCH, new SwitchStatement());
            ParserFunction.RegisterFunction(Constants.CASE, new CaseStatement());
            ParserFunction.RegisterFunction(Constants.DEFAULT, new CaseStatement());
            ParserFunction.RegisterFunction(Constants.FOR, new ForStatement());
            ParserFunction.RegisterFunction(Constants.BREAK, new BreakStatement());
            ParserFunction.RegisterFunction(Constants.COMPILED_FUNCTION, new CompiledFunctionCreator(false));
            ParserFunction.RegisterFunction(Constants.CONTINUE, new ContinueStatement());
            ParserFunction.RegisterFunction(Constants.CLASS, new ClassCreator());
            ParserFunction.RegisterFunction(Constants.ENUM, new EnumFunction());
            ParserFunction.RegisterFunction(Constants.INFINITY, new InfinityFunction());
            ParserFunction.RegisterFunction(Constants.NEG_INFINITY, new NegInfinityFunction());
            ParserFunction.RegisterFunction(Constants.ISFINITE, new IsFiniteFunction());
            ParserFunction.RegisterFunction(Constants.ISNAN, new IsNaNFunction());
            ParserFunction.RegisterFunction(Constants.NEW, new NewObjectFunction());
            ParserFunction.RegisterFunction(Constants.NULL, new NullFunction());
            ParserFunction.RegisterFunction(Constants.RETURN, new ReturnStatement());
            ParserFunction.RegisterFunction(Constants.FUNCTION, new FunctionCreator());
            ParserFunction.RegisterFunction(Constants.GET_PROPERTIES, new GetPropertiesFunction());
            ParserFunction.RegisterFunction(Constants.GET_PROPERTY, new GetPropertyFunction());
            ParserFunction.RegisterFunction(Constants.INCLUDE, new IncludeFile());
            ParserFunction.RegisterFunction(Constants.SET_PROPERTY, new SetPropertyFunction());
            ParserFunction.RegisterFunction(Constants.TRY, new TryBlock());
            ParserFunction.RegisterFunction(Constants.THROW, new ThrowFunction());
            ParserFunction.RegisterFunction(Constants.TYPE, new TypeFunction());
            ParserFunction.RegisterFunction(Constants.TYPE_OF, new TypeOfFunction());
            ParserFunction.RegisterFunction(Constants.TRUE, new BoolFunction(true));
            ParserFunction.RegisterFunction(Constants.FALSE, new BoolFunction(false));
            ParserFunction.RegisterFunction(Constants.UNDEFINED, new UndefinedFunction());

            ParserFunction.RegisterFunction(Constants.ADD, new AddFunction());
            ParserFunction.RegisterFunction(Constants.ADD_TO_HASH, new AddVariableToHashFunction());
            ParserFunction.RegisterFunction(Constants.ADD_ALL_TO_HASH, new AddVariablesToHashFunction());
            ParserFunction.RegisterFunction(Constants.CANCEL, new CancelFunction());
            ParserFunction.RegisterFunction(Constants.CANCEL_RUN, new ScheduleRunFunction(false));
            ParserFunction.RegisterFunction(Constants.CHECK_LOADER_MAIN, new CheckLoaderMainFunction());
            ParserFunction.RegisterFunction(Constants.CONTAINS, new ContainsFunction());
            ParserFunction.RegisterFunction(Constants.CURRENT_PATH, new CurrentPathFunction());
            ParserFunction.RegisterFunction(Constants.DATE_TIME, new DateTimeFunction(false));
            ParserFunction.RegisterFunction(Constants.DEEP_COPY, new DeepCopyFunction());
            ParserFunction.RegisterFunction(Constants.DEFINE_LOCAL, new DefineLocalFunction());
            ParserFunction.RegisterFunction(Constants.ENV, new GetEnvFunction());
            ParserFunction.RegisterFunction(Constants.FIND_INDEX, new FindIndexFunction());
            ParserFunction.RegisterFunction(Constants.GET_COLUMN, new GetColumnFunction());
            ParserFunction.RegisterFunction(Constants.GET_FILE_FROM_DEBUGGER, new GetFileFromDebugger());
            ParserFunction.RegisterFunction(Constants.GET_KEYS, new GetAllKeysFunction());
            ParserFunction.RegisterFunction(Constants.INCLUDE_SECURE, new IncludeFileSecure());
            ParserFunction.RegisterFunction(Constants.JSON, new GetVariableFromJSONFunction());
            ParserFunction.RegisterFunction(Constants.LOCK, new LockFunction());
            ParserFunction.RegisterFunction(Constants.NAMESPACE, new NamespaceFunction());
            ParserFunction.RegisterFunction(Constants.NAME_EXISTS, new NameExistsFunction());
            ParserFunction.RegisterFunction(Constants.NOW, new DateTimeFunction());
            ParserFunction.RegisterFunction(Constants.PRINT, new PrintFunction());
            ParserFunction.RegisterFunction(Constants.PSTIME, new ProcessorTimeFunction());
            ParserFunction.RegisterFunction(Constants.REGEX, new RegexFunction());
            ParserFunction.RegisterFunction(Constants.REMOVE, new RemoveFunction());
            ParserFunction.RegisterFunction(Constants.REMOVE_AT, new RemoveAtFunction());
            ParserFunction.RegisterFunction(Constants.RESET_VARS, new ResetVariablesFunction());
            ParserFunction.RegisterFunction(Constants.SCHEDULE_RUN, new ScheduleRunFunction(true));
            ParserFunction.RegisterFunction(Constants.SHOW, new ShowFunction());
            ParserFunction.RegisterFunction(Constants.SETENV, new SetEnvFunction());
            ParserFunction.RegisterFunction(Constants.SIGNAL,new SignalWaitFunction(true));
            ParserFunction.RegisterFunction(Constants.SINGLETON,new SingletonFunction());
            ParserFunction.RegisterFunction(Constants.SIZE,new SizeFunction());
            ParserFunction.RegisterFunction(Constants.SLEEP,new SleepFunction());
            ParserFunction.RegisterFunction(Constants.START_DEBUGGER,new DebuggerFunction(true));
            ParserFunction.RegisterFunction(Constants.STOP_DEBUGGER,new DebuggerFunction(false));
            ParserFunction.RegisterFunction(Constants.STR_BETWEEN,new StringManipulationFunction(StringManipulationFunction.Mode.BEETWEEN));
            ParserFunction.RegisterFunction(Constants.STR_BETWEEN_ANY,new StringManipulationFunction(StringManipulationFunction.Mode.BEETWEEN_ANY));
            ParserFunction.RegisterFunction(Constants.STR_CONTAINS,new StringManipulationFunction(StringManipulationFunction.Mode.CONTAINS));
            ParserFunction.RegisterFunction(Constants.STR_LOWER,new StringManipulationFunction(StringManipulationFunction.Mode.LOWER));
            ParserFunction.RegisterFunction(Constants.STR_ENDS_WITH,new StringManipulationFunction(StringManipulationFunction.Mode.ENDS_WITH));
            ParserFunction.RegisterFunction(Constants.STR_EQUALS,new StringManipulationFunction(StringManipulationFunction.Mode.EQUALS));
            ParserFunction.RegisterFunction(Constants.STR_INDEX_OF,new StringManipulationFunction(StringManipulationFunction.Mode.INDEX_OF));
            ParserFunction.RegisterFunction(Constants.STR_REPLACE,new StringManipulationFunction(StringManipulationFunction.Mode.REPLACE));
            ParserFunction.RegisterFunction(Constants.STR_STARTS_WITH,new StringManipulationFunction(StringManipulationFunction.Mode.STARTS_WITH));
            ParserFunction.RegisterFunction(Constants.STR_SUBSTR,new StringManipulationFunction(StringManipulationFunction.Mode.SUBSTRING));
            ParserFunction.RegisterFunction(Constants.STR_TRIM,new StringManipulationFunction(StringManipulationFunction.Mode.TRIM));
            ParserFunction.RegisterFunction(Constants.STR_UPPER,new StringManipulationFunction(StringManipulationFunction.Mode.UPPER));
            ParserFunction.RegisterFunction(Constants.THREAD,new ThreadFunction());
            ParserFunction.RegisterFunction(Constants.THREAD_ID,new ThreadIDFunction());
            ParserFunction.RegisterFunction(Constants.TOKENIZE,new TokenizeFunction());
            ParserFunction.RegisterFunction(Constants.TOKENIZE_LINES,new TokenizeLinesFunction());
            ParserFunction.RegisterFunction(Constants.TOKEN_COUNTER,new TokenCounterFunction());
            ParserFunction.RegisterFunction(Constants.TO_BOOL,new ToBoolFunction());
            ParserFunction.RegisterFunction(Constants.TO_DECIMAL,new ToDecimalFunction());
            ParserFunction.RegisterFunction(Constants.TO_DOUBLE,new ToDoubleFunction());
            ParserFunction.RegisterFunction(Constants.TO_INT,new ToIntFunction());
            //ParserFunction.RegisterFunction(Constants.TO_INTEGER, new ToIntFunction());
            ParserFunction.RegisterFunction(Constants.TO_NUMBER,new ToDoubleFunction());
            ParserFunction.RegisterFunction(Constants.TO_STRING,new ToStringFunction());
            ParserFunction.RegisterFunction(Constants.VAR,new VarFunction());
            ParserFunction.RegisterFunction(Constants.WAIT,new SignalWaitFunction(false));
            ParserFunction.RegisterFunction(Constants.WEB_REQUEST,new WebRequestFunction());

            ParserFunction.RegisterFunction(Constants.ADD_DATA,new DataFunction(DataFunction.DataMode.ADD));
            ParserFunction.RegisterFunction(Constants.COLLECT_DATA,new DataFunction(DataFunction.DataMode.SUBSCRIBE));
            ParserFunction.RegisterFunction(Constants.GET_DATA,new DataFunction(DataFunction.DataMode.SEND));

            // Math Functions
            ParserFunction.RegisterFunction(Constants.MATH_ABS,new AbsFunction());
            ParserFunction.RegisterFunction(Constants.MATH_ACOS,new AcosFunction());
            ParserFunction.RegisterFunction(Constants.MATH_ACOSH,new AcoshFunction());
            ParserFunction.RegisterFunction(Constants.MATH_ASIN,new AsinFunction());
            ParserFunction.RegisterFunction(Constants.MATH_ASINH,new AsinhFunction());
            ParserFunction.RegisterFunction(Constants.MATH_ATAN,new TanFunction());
            ParserFunction.RegisterFunction(Constants.MATH_ATAN2,new Atan2Function());
            ParserFunction.RegisterFunction(Constants.MATH_ATANH,new AtanhFunction());
            ParserFunction.RegisterFunction(Constants.MATH_CBRT,new CbrtFunction());
            ParserFunction.RegisterFunction(Constants.MATH_CEIL,new CeilFunction());
            ParserFunction.RegisterFunction(Constants.MATH_COS,new CosFunction());
            ParserFunction.RegisterFunction(Constants.MATH_COSH,new CoshFunction());
            ParserFunction.RegisterFunction(Constants.MATH_E,new EFunction());
            ParserFunction.RegisterFunction(Constants.MATH_EXP,new ExpFunction());
            ParserFunction.RegisterFunction(Constants.MATH_FLOOR,new FloorFunction());
            ParserFunction.RegisterFunction(Constants.MATH_LN2,new Ln2Function());
            ParserFunction.RegisterFunction(Constants.MATH_LN10,new Ln10Function());
            ParserFunction.RegisterFunction(Constants.MATH_LOG,new LogFunction());
            ParserFunction.RegisterFunction(Constants.MATH_LOG2E,new Log2EFunction());
            ParserFunction.RegisterFunction(Constants.MATH_LOG10E,new Log10EFunction());
            ParserFunction.RegisterFunction(Constants.MATH_MIN,new MinFunction());
            ParserFunction.RegisterFunction(Constants.MATH_MAX,new MaxFunction());
            ParserFunction.RegisterFunction(Constants.MATH_PI,new PiFunction());
            ParserFunction.RegisterFunction(Constants.MATH_POW,new PowFunction());
            ParserFunction.RegisterFunction(Constants.MATH_RANDOM,new GetRandomFunction(true));
            ParserFunction.RegisterFunction(Constants.MATH_ROUND,new RoundFunction());
            ParserFunction.RegisterFunction(Constants.MATH_SQRT,new SqrtFunction());
            ParserFunction.RegisterFunction(Constants.MATH_SQRT1_2,new Sqrt1_2Function());
            ParserFunction.RegisterFunction(Constants.MATH_SQRT2,new Sqrt2Function());
            ParserFunction.RegisterFunction(Constants.MATH_SIGN,new SignFunction());
            ParserFunction.RegisterFunction(Constants.MATH_SIN,new SinFunction());
            ParserFunction.RegisterFunction(Constants.MATH_SINH,new SinhFunction());
            ParserFunction.RegisterFunction(Constants.MATH_TAN,new TanFunction());
            ParserFunction.RegisterFunction(Constants.MATH_TANH,new TanhFunction());
            ParserFunction.RegisterFunction(Constants.MATH_TRUNC,new FloorFunction());
            ParserFunction.RegisterFunction(Constants.CONSOLE_LOG,new PrintFunction());

            //SCPSL Exiled
            ParserFunction.RegisterFunction("exiled.log",new ExiledLogFunction());
            ParserFunction.RegisterFunction("scpsl.roundrestart",new SCPSLRoundRestartFunction());
            ParserFunction.RegisterFunction("scpsl.roundlock",new SCPSLRoundLockFunction());

            ParserFunction.RegisterFunction(Constants.OBJECT_DEFPROP,new ObjectPropsFunction());
        }
Пример #10
0
        public void InitStandalone()
        {
#if UNITY_EDITOR == false && UNITY_STANDALONE == false
            // Math Top level functions
            ParserFunction.RegisterFunction(Constants.ABS, new AbsFunction());
            ParserFunction.RegisterFunction(Constants.ACOS, new AcosFunction());
            ParserFunction.RegisterFunction(Constants.ASIN, new AsinFunction());
            ParserFunction.RegisterFunction(Constants.CEIL, new CeilFunction());
            ParserFunction.RegisterFunction(Constants.COS, new CosFunction());
            ParserFunction.RegisterFunction(Constants.EXP, new ExpFunction());
            ParserFunction.RegisterFunction(Constants.FLOOR, new FloorFunction());
            ParserFunction.RegisterFunction(Constants.LOG, new LogFunction());
            ParserFunction.RegisterFunction(Constants.PI, new PiFunction());
            ParserFunction.RegisterFunction(Constants.POW, new PowFunction());
            ParserFunction.RegisterFunction(Constants.ROUND, new RoundFunction());
            ParserFunction.RegisterFunction(Constants.RANDOM, new GetRandomFunction());
            ParserFunction.RegisterFunction(Constants.SIN, new SinFunction());
            ParserFunction.RegisterFunction(Constants.SQRT, new SqrtFunction());

            //ParserFunction.CleanUp();
            ParserFunction.RegisterFunction(Constants.APPEND, new AppendFunction());
            ParserFunction.RegisterFunction(Constants.APPENDLINE, new AppendLineFunction());
            ParserFunction.RegisterFunction(Constants.APPENDLINES, new AppendLinesFunction());
            ParserFunction.RegisterFunction(Constants.CALL_NATIVE, new InvokeNativeFunction());
            ParserFunction.RegisterFunction(Constants.CD, new CdFunction());
            ParserFunction.RegisterFunction(Constants.CD__, new Cd__Function());
            ParserFunction.RegisterFunction(Constants.CONNECTSRV, new ClientSocket());
            ParserFunction.RegisterFunction(Constants.COPY, new CopyFunction());
            ParserFunction.RegisterFunction(Constants.DELETE, new DeleteFunction());
            ParserFunction.RegisterFunction(Constants.DIR, new DirFunction());
            ParserFunction.RegisterFunction(Constants.EXISTS, new ExistsFunction());
            ParserFunction.RegisterFunction(Constants.EXIT, new ExitFunction());
            ParserFunction.RegisterFunction(Constants.FINDFILES, new FindfilesFunction());
            ParserFunction.RegisterFunction(Constants.FINDSTR, new FindstrFunction());
            ParserFunction.RegisterFunction(Constants.GET_NATIVE, new GetNativeFunction());
            ParserFunction.RegisterFunction(Constants.JSON, new GetVariableFromJSONFunction());
            ParserFunction.RegisterFunction(Constants.KILL, new KillFunction());
            ParserFunction.RegisterFunction(Constants.MKDIR, new MkdirFunction());
            ParserFunction.RegisterFunction(Constants.MORE, new MoreFunction());
            ParserFunction.RegisterFunction(Constants.MOVE, new MoveFunction());
            ParserFunction.RegisterFunction(Constants.PSINFO, new PsInfoFunction());
            ParserFunction.RegisterFunction(Constants.PWD, new PwdFunction());
            ParserFunction.RegisterFunction(Constants.READFILE, new ReadCSCSFileFunction());
            ParserFunction.RegisterFunction(Constants.RUN, new RunFunction());
            ParserFunction.RegisterFunction(Constants.SET_NATIVE, new SetNativeFunction());
            ParserFunction.RegisterFunction(Constants.STARTSRV, new ServerSocket());
            ParserFunction.RegisterFunction(Constants.STOPWATCH_ELAPSED, new StopWatchFunction(StopWatchFunction.Mode.ELAPSED));
            ParserFunction.RegisterFunction(Constants.STOPWATCH_START, new StopWatchFunction(StopWatchFunction.Mode.START));
            ParserFunction.RegisterFunction(Constants.STOPWATCH_STOP, new StopWatchFunction(StopWatchFunction.Mode.STOP));
            ParserFunction.RegisterFunction(Constants.TAIL, new TailFunction());
            ParserFunction.RegisterFunction(Constants.TIMESTAMP, new TimestampFunction());
            ParserFunction.RegisterFunction(Constants.WEB_REQUEST, new WebRequestFunction());
            ParserFunction.RegisterFunction(Constants.WRITE, new PrintFunction(false));
            ParserFunction.RegisterFunction(Constants.WRITELINE, new WriteLineFunction());
            ParserFunction.RegisterFunction(Constants.WRITELINES, new WriteLinesFunction());
            ParserFunction.RegisterFunction(Constants.WRITE_CONSOLE, new WriteToConsole());

#if __ANDROID__ == false && __IOS__ == false
            ParserFunction.RegisterFunction(Constants.ADD_COMP_DEFINITION, new EditCompiledEntry(EditCompiledEntry.EditMode.ADD_DEFINITION));
            ParserFunction.RegisterFunction(Constants.ADD_COMP_NAMESPACE, new EditCompiledEntry(EditCompiledEntry.EditMode.ADD_NAMESPACE));
            ParserFunction.RegisterFunction(Constants.CLEAR_COMP_DEFINITIONS, new EditCompiledEntry(EditCompiledEntry.EditMode.CLEAR_DEFINITIONS));
            ParserFunction.RegisterFunction(Constants.CLEAR_COMP_NAMESPACES, new EditCompiledEntry(EditCompiledEntry.EditMode.CLEAR_NAMESPACES));
            ParserFunction.RegisterFunction(Constants.CSHARP_FUNCTION, new CompiledFunctionCreator(true));

            ParserFunction.RegisterFunction(Constants.CONSOLE_CLR, new ClearConsole());
            ParserFunction.RegisterFunction(Constants.PRINT_BLACK, new PrintColorFunction(ConsoleColor.Black));
            ParserFunction.RegisterFunction(Constants.PRINT_GRAY, new PrintColorFunction(ConsoleColor.DarkGray));
            ParserFunction.RegisterFunction(Constants.PRINT_GREEN, new PrintColorFunction(ConsoleColor.Green));
            ParserFunction.RegisterFunction(Constants.PRINT_RED, new PrintColorFunction(ConsoleColor.Red));
            ParserFunction.RegisterFunction(Constants.READ, new ReadConsole());
            ParserFunction.RegisterFunction(Constants.READNUMBER, new ReadConsole(true));
            ParserFunction.RegisterFunction(Constants.TRANSLATE, new TranslateFunction());

            ParserFunction.RegisterFunction(Constants.ENCODE_FILE, new EncodeFileFunction(true));
            ParserFunction.RegisterFunction(Constants.DECODE_FILE, new EncodeFileFunction(false));

            CSCS_SQL.Init();
#endif
#endif
            //ReadConfig();
        }
Пример #11
0
        public void Init()
        {
            ParserFunction.RegisterFunction(Constants.IF, new IfStatement());
            ParserFunction.RegisterFunction(Constants.WHILE, new WhileStatement());
            ParserFunction.RegisterFunction(Constants.FOR, new ForStatement());
            ParserFunction.RegisterFunction(Constants.BREAK, new BreakStatement());
            ParserFunction.RegisterFunction(Constants.CONTINUE, new ContinueStatement());
            ParserFunction.RegisterFunction(Constants.RETURN, new ReturnStatement());
            ParserFunction.RegisterFunction(Constants.FUNCTION, new FunctionCreator());
            ParserFunction.RegisterFunction(Constants.INCLUDE, new IncludeFile());
            ParserFunction.RegisterFunction(Constants.TRY, new TryBlock());
            ParserFunction.RegisterFunction(Constants.THROW, new ThrowFunction());
            ParserFunction.RegisterFunction(Constants.TYPE, new TypeFunction());
            ParserFunction.RegisterFunction(Constants.TRUE, new BoolFunction(true));
            ParserFunction.RegisterFunction(Constants.FALSE, new BoolFunction(false));

            ParserFunction.RegisterFunction(Constants.ABS, new AbsFunction());
            ParserFunction.RegisterFunction(Constants.ACOS, new AcosFunction());
            ParserFunction.RegisterFunction(Constants.ADD, new AddFunction());
            ParserFunction.RegisterFunction(Constants.APPEND, new AppendFunction());
            ParserFunction.RegisterFunction(Constants.APPENDLINE, new AppendLineFunction());
            ParserFunction.RegisterFunction(Constants.APPENDLINES, new AppendLinesFunction());
            ParserFunction.RegisterFunction(Constants.ASIN, new AsinFunction());
            ParserFunction.RegisterFunction(Constants.CD, new CdFunction());
            ParserFunction.RegisterFunction(Constants.CD__, new Cd__Function());
            ParserFunction.RegisterFunction(Constants.CEIL, new CeilFunction());
            ParserFunction.RegisterFunction(Constants.CONNECTSRV, new ClientSocket());
            ParserFunction.RegisterFunction(Constants.CONSOLE_CLR, new ClearConsole());
            ParserFunction.RegisterFunction(Constants.CONTAINS, new ContainsFunction());
            ParserFunction.RegisterFunction(Constants.COPY, new CopyFunction());
            ParserFunction.RegisterFunction(Constants.COS, new CosFunction());
            ParserFunction.RegisterFunction(Constants.DELETE, new DeleteFunction());
            ParserFunction.RegisterFunction(Constants.DIR, new DirFunction());
            ParserFunction.RegisterFunction(Constants.ENV, new GetEnvFunction());
            ParserFunction.RegisterFunction(Constants.EXISTS, new ExistsFunction());
            ParserFunction.RegisterFunction(Constants.EXIT, new ExitFunction());
            ParserFunction.RegisterFunction(Constants.EXP, new ExpFunction());
            ParserFunction.RegisterFunction(Constants.FINDFILES, new FindfilesFunction());
            ParserFunction.RegisterFunction(Constants.FINDSTR, new FindstrFunction());
            ParserFunction.RegisterFunction(Constants.FLOOR, new FloorFunction());
            ParserFunction.RegisterFunction(Constants.INDEX_OF, new IndexOfFunction());
            ParserFunction.RegisterFunction(Constants.KILL, new KillFunction());
            ParserFunction.RegisterFunction(Constants.LOCK, new LockFunction());
            ParserFunction.RegisterFunction(Constants.LOG, new LogFunction());
            ParserFunction.RegisterFunction(Constants.MKDIR, new MkdirFunction());
            ParserFunction.RegisterFunction(Constants.MORE, new MoreFunction());
            ParserFunction.RegisterFunction(Constants.MOVE, new MoveFunction());
            ParserFunction.RegisterFunction(Constants.PI, new PiFunction());
            ParserFunction.RegisterFunction(Constants.POW, new PowFunction());
            ParserFunction.RegisterFunction(Constants.PRINT, new PrintFunction());
            ParserFunction.RegisterFunction(Constants.PRINT_BLACK, new PrintFunction(ConsoleColor.Black));
            ParserFunction.RegisterFunction(Constants.PRINT_GRAY, new PrintFunction(ConsoleColor.DarkGray));
            ParserFunction.RegisterFunction(Constants.PRINT_GREEN, new PrintFunction(ConsoleColor.Green));
            ParserFunction.RegisterFunction(Constants.PRINT_RED, new PrintFunction(ConsoleColor.Red));
            ParserFunction.RegisterFunction(Constants.PSINFO, new PsInfoFunction());
            ParserFunction.RegisterFunction(Constants.PSTIME, new ProcessorTimeFunction());
            ParserFunction.RegisterFunction(Constants.PWD, new PwdFunction());
            ParserFunction.RegisterFunction(Constants.READ, new ReadConsole());
            ParserFunction.RegisterFunction(Constants.READFILE, new ReadFileFunction());
            ParserFunction.RegisterFunction(Constants.READNUMBER, new ReadConsole(true));
            ParserFunction.RegisterFunction(Constants.ROUND, new RoundFunction());
            ParserFunction.RegisterFunction(Constants.RUN, new RunFunction());
            ParserFunction.RegisterFunction(Constants.SIGNAL,new SignalWaitFunction(true));
            ParserFunction.RegisterFunction(Constants.SETENV,new SetEnvFunction());
            ParserFunction.RegisterFunction(Constants.SHOW,new ShowFunction());
            ParserFunction.RegisterFunction(Constants.SIN,new SinFunction());
            ParserFunction.RegisterFunction(Constants.SIZE,new SizeFunction());
            ParserFunction.RegisterFunction(Constants.SLEEP,new SleepFunction());
            ParserFunction.RegisterFunction(Constants.SQRT,new SqrtFunction());
            ParserFunction.RegisterFunction(Constants.STARTSRV,new ServerSocket());
            ParserFunction.RegisterFunction(Constants.SUBSTR,new SubstrFunction());
            ParserFunction.RegisterFunction(Constants.TAIL,new TailFunction());
            ParserFunction.RegisterFunction(Constants.THREAD,new ThreadFunction());
            ParserFunction.RegisterFunction(Constants.THREAD_ID,new ThreadIDFunction());
            ParserFunction.RegisterFunction(Constants.TOLOWER,new ToLowerFunction());
            ParserFunction.RegisterFunction(Constants.TOUPPER,new ToUpperFunction());
            ParserFunction.RegisterFunction(Constants.TRANSLATE,new TranslateFunction());
            ParserFunction.RegisterFunction(Constants.WAIT,new SignalWaitFunction(false));
            ParserFunction.RegisterFunction(Constants.WRITE,new PrintFunction(false));
            ParserFunction.RegisterFunction(Constants.WRITELINE,new WriteLineFunction());
            ParserFunction.RegisterFunction(Constants.WRITELINES,new WriteLinesFunction());

            ParserFunction.AddAction(Constants.ASSIGNMENT,new AssignFunction());
            ParserFunction.AddAction(Constants.INCREMENT,new IncrementDecrementFunction());
            ParserFunction.AddAction(Constants.DECREMENT,new IncrementDecrementFunction());

            for (int i = 0; i < Constants.OPER_ACTIONS.Length; i++)
            {
                ParserFunction.AddAction(Constants.OPER_ACTIONS[i],new OperatorAssignFunction());
            }

            Constants.ELSE_LIST.Add(Constants.ELSE);
            Constants.ELSE_IF_LIST.Add(Constants.ELSE_IF);
            Constants.CATCH_LIST.Add(Constants.CATCH);

            ReadConfig();
        }
        public void InitStandalone()
        {
#if UNITY_EDITOR == false && UNITY_STANDALONE == false
            //ParserFunction.CleanUp();
            ParserFunction.RegisterFunction(Constants.APPEND, new AppendFunction());
            ParserFunction.RegisterFunction(Constants.APPENDLINE, new AppendLineFunction());
            ParserFunction.RegisterFunction(Constants.APPENDLINES, new AppendLinesFunction());
            ParserFunction.RegisterFunction(Constants.CALL_NATIVE, new InvokeNativeFunction());
            ParserFunction.RegisterFunction(Constants.CD, new CdFunction());
            ParserFunction.RegisterFunction(Constants.CD__, new Cd__Function());
            ParserFunction.RegisterFunction(Constants.CONNECTSRV, new ClientSocket());
            ParserFunction.RegisterFunction(Constants.COPY, new CopyFunction());
            ParserFunction.RegisterFunction(Constants.DELETE, new DeleteFunction());
            ParserFunction.RegisterFunction(Constants.DIR, new DirFunction());
            ParserFunction.RegisterFunction(Constants.EXISTS, new ExistsFunction());
            ParserFunction.RegisterFunction(Constants.EXIT, new ExitFunction());
            ParserFunction.RegisterFunction(Constants.FINDFILES, new FindfilesFunction());
            ParserFunction.RegisterFunction(Constants.FINDSTR, new FindstrFunction());
            ParserFunction.RegisterFunction(Constants.GET_NATIVE, new GetNativeFunction());
            ParserFunction.RegisterFunction(Constants.KILL, new KillFunction());
            ParserFunction.RegisterFunction(Constants.MKDIR, new MkdirFunction());
            ParserFunction.RegisterFunction(Constants.MORE, new MoreFunction());
            ParserFunction.RegisterFunction(Constants.MOVE, new MoveFunction());
            ParserFunction.RegisterFunction(Constants.PSINFO, new PsInfoFunction());
            ParserFunction.RegisterFunction(Constants.PWD, new PwdFunction());
            ParserFunction.RegisterFunction(Constants.READFILE, new ReadCSCSFileFunction());
            ParserFunction.RegisterFunction(Constants.RUN, new RunFunction());
            ParserFunction.RegisterFunction(Constants.SET_NATIVE, new SetNativeFunction());
            ParserFunction.RegisterFunction(Constants.STARTSRV, new ServerSocket());
            ParserFunction.RegisterFunction(Constants.STOPWATCH_ELAPSED, new StopWatchFunction(StopWatchFunction.Mode.ELAPSED));
            ParserFunction.RegisterFunction(Constants.STOPWATCH_START, new StopWatchFunction(StopWatchFunction.Mode.START));
            ParserFunction.RegisterFunction(Constants.STOPWATCH_STOP, new StopWatchFunction(StopWatchFunction.Mode.STOP));
            ParserFunction.RegisterFunction(Constants.TAIL, new TailFunction());
            ParserFunction.RegisterFunction(Constants.TIMESTAMP, new TimestampFunction());
            ParserFunction.RegisterFunction(Constants.WRITE, new PrintFunction(false));
            ParserFunction.RegisterFunction(Constants.WRITELINE, new WriteLineFunction());
            ParserFunction.RegisterFunction(Constants.WRITELINES, new WriteLinesFunction());
            ParserFunction.RegisterFunction(Constants.WRITE_CONSOLE, new WriteToConsole());

#if __ANDROID__ == false && __IOS__ == false
            ParserFunction.RegisterFunction(Constants.CONSOLE_CLR, new ClearConsole());
            ParserFunction.RegisterFunction(Constants.PRINT_BLACK, new PrintColorFunction(ConsoleColor.Black));
            ParserFunction.RegisterFunction(Constants.PRINT_GRAY, new PrintColorFunction(ConsoleColor.DarkGray));
            ParserFunction.RegisterFunction(Constants.PRINT_GREEN, new PrintColorFunction(ConsoleColor.Green));
            ParserFunction.RegisterFunction(Constants.PRINT_RED, new PrintColorFunction(ConsoleColor.Red));
            ParserFunction.RegisterFunction(Constants.READ, new ReadConsole());
            ParserFunction.RegisterFunction(Constants.READNUMBER, new ReadConsole(true));
            ParserFunction.RegisterFunction(Constants.TRANSLATE, new TranslateFunction());

            ParserFunction.RegisterFunction(Constants.GOTO, new GotoGosubFunction(true));
            ParserFunction.RegisterFunction(Constants.GOSUB, new GotoGosubFunction(false));

            ParserFunction.RegisterFunction(Constants.MSG, new VariableArgsFunction(true));
            ParserFunction.RegisterFunction(Constants.DEFINE, new VariableArgsFunction(true));
            ParserFunction.RegisterFunction(Constants.SET_OBJECT, new VariableArgsFunction(true));

            ParserFunction.AddAction(Constants.LABEL_OPERATOR, new LabelFunction());

            Constants.FUNCT_WITH_SPACE.Add(Constants.DEFINE);
            Constants.FUNCT_WITH_SPACE.Add(Constants.MSG);
            Constants.FUNCT_WITH_SPACE.Add(Constants.SET_OBJECT);

            CSCS_SQL.Init();
#endif
#endif
            //ReadConfig();
        }
Пример #13
0
        public void Init()
        {
            ParserFunction.RegisterFunction(Constants.IF, new IfStatement());
            ParserFunction.RegisterFunction(Constants.WHILE, new WhileStatement());
            ParserFunction.RegisterFunction(Constants.FOR, new ForStatement());
            ParserFunction.RegisterFunction(Constants.BREAK, new BreakStatement());
            ParserFunction.RegisterFunction(Constants.CONTINUE, new ContinueStatement());
            ParserFunction.RegisterFunction(Constants.RETURN, new ReturnStatement());
            ParserFunction.RegisterFunction(Constants.FUNCTION, new FunctionCreator());
            ParserFunction.RegisterFunction(Constants.COMPILED_FUNCTION, new CompiledFunctionCreator());
            ParserFunction.RegisterFunction(Constants.INCLUDE, new IncludeFile());
            ParserFunction.RegisterFunction(Constants.TRY, new TryBlock());
            ParserFunction.RegisterFunction(Constants.THROW, new ThrowFunction());
            ParserFunction.RegisterFunction(Constants.TYPE, new TypeFunction());
            ParserFunction.RegisterFunction(Constants.TRUE, new BoolFunction(true));
            ParserFunction.RegisterFunction(Constants.FALSE, new BoolFunction(false));

            ParserFunction.RegisterFunction(Constants.ABS, new AbsFunction());
            ParserFunction.RegisterFunction(Constants.ACOS, new AcosFunction());
            ParserFunction.RegisterFunction(Constants.ADD, new AddFunction());
            ParserFunction.RegisterFunction(Constants.ADD_TO_HASH, new AddVariableToHashFunction());
            ParserFunction.RegisterFunction(Constants.ADD_ALL_TO_HASH, new AddVariablesToHashFunction());
            ParserFunction.RegisterFunction(Constants.ASIN, new AsinFunction());
            ParserFunction.RegisterFunction(Constants.CEIL, new CeilFunction());
            ParserFunction.RegisterFunction(Constants.CONSOLE_CLR, new ClearConsole());
            ParserFunction.RegisterFunction(Constants.CONTAINS, new ContainsFunction());
            ParserFunction.RegisterFunction(Constants.COS, new CosFunction());
            ParserFunction.RegisterFunction(Constants.DEEP_COPY, new DeepCopyFunction());
            ParserFunction.RegisterFunction(Constants.DEFINE_LOCAL, new DefineLocalFunction());
            ParserFunction.RegisterFunction(Constants.ENV, new GetEnvFunction());
            ParserFunction.RegisterFunction(Constants.EXIT, new ExitFunction());
            ParserFunction.RegisterFunction(Constants.EXP, new ExpFunction());
            ParserFunction.RegisterFunction(Constants.FLOOR, new FloorFunction());
            ParserFunction.RegisterFunction(Constants.GET_COLUMN, new GetColumnFunction());
            ParserFunction.RegisterFunction(Constants.GET_KEYS, new GetAllKeysFunction());
            ParserFunction.RegisterFunction(Constants.INDEX_OF, new IndexOfFunction());
            ParserFunction.RegisterFunction(Constants.LOCK, new LockFunction());
            ParserFunction.RegisterFunction(Constants.LOG, new LogFunction());
            ParserFunction.RegisterFunction(Constants.NOW, new DateTimeFunction());
            ParserFunction.RegisterFunction(Constants.PI, new PiFunction());
            ParserFunction.RegisterFunction(Constants.POW, new PowFunction());
            ParserFunction.RegisterFunction(Constants.PRINT, new PrintFunction());
            ParserFunction.RegisterFunction(Constants.PRINT_BLACK, new PrintFunction(ConsoleColor.Black));
            ParserFunction.RegisterFunction(Constants.PRINT_GRAY, new PrintFunction(ConsoleColor.DarkGray));
            ParserFunction.RegisterFunction(Constants.PRINT_GREEN, new PrintFunction(ConsoleColor.Green));
            ParserFunction.RegisterFunction(Constants.PRINT_RED, new PrintFunction(ConsoleColor.Red));
            ParserFunction.RegisterFunction(Constants.PSTIME, new ProcessorTimeFunction());
            ParserFunction.RegisterFunction(Constants.RANDOM, new GetRandomFunction());
            ParserFunction.RegisterFunction(Constants.READ, new ReadConsole());
            ParserFunction.RegisterFunction(Constants.READNUMBER, new ReadConsole(true));
            ParserFunction.RegisterFunction(Constants.REMOVE, new RemoveFunction());
            ParserFunction.RegisterFunction(Constants.REMOVE_AT, new RemoveAtFunction());
            ParserFunction.RegisterFunction(Constants.ROUND, new RoundFunction());
            ParserFunction.RegisterFunction(Constants.SIGNAL,new SignalWaitFunction(true));
            ParserFunction.RegisterFunction(Constants.SETENV,new SetEnvFunction());
            ParserFunction.RegisterFunction(Constants.SHOW,new ShowFunction());
            ParserFunction.RegisterFunction(Constants.SIN,new SinFunction());
            ParserFunction.RegisterFunction(Constants.SIZE,new SizeFunction());
            ParserFunction.RegisterFunction(Constants.SLEEP,new SleepFunction());
            ParserFunction.RegisterFunction(Constants.SQRT,new SqrtFunction());
            ParserFunction.RegisterFunction(Constants.START_DEBUGGER,new DebuggerFunction());
            ParserFunction.RegisterFunction(Constants.STR_CONTAINS,new StringManipulationFunction(StringManipulationFunction.Mode.CONTAINS));
            ParserFunction.RegisterFunction(Constants.STR_LOWER,new StringManipulationFunction(StringManipulationFunction.Mode.LOWER));
            ParserFunction.RegisterFunction(Constants.STR_ENDS_WITH,new StringManipulationFunction(StringManipulationFunction.Mode.ENDS_WITH));
            ParserFunction.RegisterFunction(Constants.STR_EQUALS,new StringManipulationFunction(StringManipulationFunction.Mode.EQUALS));
            ParserFunction.RegisterFunction(Constants.STR_INDEX_OF,new StringManipulationFunction(StringManipulationFunction.Mode.INDEX_OF));
            ParserFunction.RegisterFunction(Constants.STR_REPLACE,new StringManipulationFunction(StringManipulationFunction.Mode.REPLACE));
            ParserFunction.RegisterFunction(Constants.STR_STARTS_WITH,new StringManipulationFunction(StringManipulationFunction.Mode.STARTS_WITH));
            ParserFunction.RegisterFunction(Constants.STR_SUBSTR,new StringManipulationFunction(StringManipulationFunction.Mode.SUBSTRING));
            ParserFunction.RegisterFunction(Constants.STR_TRIM,new StringManipulationFunction(StringManipulationFunction.Mode.TRIM));
            ParserFunction.RegisterFunction(Constants.STR_UPPER,new StringManipulationFunction(StringManipulationFunction.Mode.UPPER));
            ParserFunction.RegisterFunction(Constants.SUBSTR,new SubstrFunction());
            ParserFunction.RegisterFunction(Constants.THREAD,new ThreadFunction());
            ParserFunction.RegisterFunction(Constants.THREAD_ID,new ThreadIDFunction());
            ParserFunction.RegisterFunction(Constants.TOKENIZE,new TokenizeFunction());
            ParserFunction.RegisterFunction(Constants.TOKENIZE_LINES,new TokenizeLinesFunction());
            ParserFunction.RegisterFunction(Constants.TOKEN_COUNTER,new TokenCounterFunction());
            ParserFunction.RegisterFunction(Constants.TOLOWER,new ToLowerFunction());
            ParserFunction.RegisterFunction(Constants.TOUPPER,new ToUpperFunction());
            ParserFunction.RegisterFunction(Constants.TO_BOOL,new ToBoolFunction());
            ParserFunction.RegisterFunction(Constants.TO_DECIMAL,new ToDecimalFunction());
            ParserFunction.RegisterFunction(Constants.TO_DOUBLE,new ToDoubleFunction());
            ParserFunction.RegisterFunction(Constants.TO_INT,new ToIntFunction());
            ParserFunction.RegisterFunction(Constants.TO_STRING,new ToStringFunction());
            ParserFunction.RegisterFunction(Constants.WAIT,new SignalWaitFunction(false));
            ParserFunction.RegisterFunction(Constants.WRITE,new PrintFunction(false));
            ParserFunction.RegisterFunction(Constants.WRITE_CONSOLE,new WriteToConsole());

            ParserFunction.AddAction(Constants.ASSIGNMENT,new AssignFunction());
            ParserFunction.AddAction(Constants.INCREMENT,new IncrementDecrementFunction());
            ParserFunction.AddAction(Constants.DECREMENT,new IncrementDecrementFunction());

            for (int i = 0; i < Constants.OPER_ACTIONS.Length; i++)
            {
                ParserFunction.AddAction(Constants.OPER_ACTIONS[i],new OperatorAssignFunction());
            }

            Constants.ELSE_LIST.Add(Constants.ELSE);
            Constants.ELSE_IF_LIST.Add(Constants.ELSE_IF);
            Constants.CATCH_LIST.Add(Constants.CATCH);

            InitStandalone();
        }
Пример #14
0
        public static ParserFunction GetFromNamespace(string name, ParsingScript script)
        {
            ParserFunction result = GetFromNamespace(name, s_namespace, script);

            return(result);
        }
Пример #15
0
        private static List <Variable> Split(ParsingScript script, char[] to)
        {
            List <Variable> listToMerge = new List <Variable>(16);

            if (!script.StillValid() || to.Contains(script.Current))
            {
                listToMerge.Add(Variable.EmptyInstance);
                script.Forward();
                return(listToMerge);
            }

            StringBuilder item            = new StringBuilder();
            int           arrayIndexDepth = 0;
            bool          inQuotes        = false;
            int           negated         = 0;

            string rest = script.Rest;

            //if (rest == "b[a[0]];") {
            //  int stop = 1;
            //}

            do // Main processing cycle of the first part.
            {
                string negateSymbol = Utils.IsNotSign(script.Rest);
                if (negateSymbol != null && !inQuotes)
                {
                    negated++;
                    script.Forward(negateSymbol.Length);
                    continue;
                }

                char ch = script.CurrentAndForward();
                CheckQuotesIndices(script, ch, ref inQuotes, ref arrayIndexDepth);
                string action = null;

                bool keepCollecting = inQuotes || arrayIndexDepth > 0 ||
                                      StillCollecting(item.ToString(), to, script, ref action);
                if (keepCollecting)
                {
                    // The char still belongs to the previous operand.
                    item.Append(ch);

                    bool goForMore = script.StillValid() &&
                                     (inQuotes || arrayIndexDepth > 0 || !to.Contains(script.Current));
                    if (goForMore)
                    {
                        continue;
                    }
                }

                if (SkipOrAppendIfNecessary(item, ch, to))
                {
                    continue;
                }

                string token = item.ToString();

                bool ternary = UpdateIfTernary(script, token, ch, ref listToMerge);
                if (ternary)
                {
                    return(listToMerge);
                }

                CheckConsistency(token, listToMerge, script);

                script.MoveForwardIf(Constants.SPACE);

                if (action != null && action.Length > 1)
                {
                    script.Forward(action.Length - 1);
                }

                // We are done getting the next token. The getValue() call below may
                // recursively call loadAndCalculate(). This will happen if extracted
                // item is a function or if the next item is starting with a START_ARG '('.
                ParserFunction func    = new ParserFunction(script, token, ch, ref action);
                Variable       current = func.GetValue(script);
                current.ParsingToken = token;

                if (negated > 0 && current.Type == Variable.VarType.NUMBER)
                {
                    // If there has been a NOT sign, this is a boolean.
                    // Use XOR (true if exactly one of the arguments is true).
                    bool neg = !((negated % 2 == 0) ^ Convert.ToBoolean(current.Value));
                    current = new Variable(Convert.ToDouble(neg));
                    negated = 0;
                }

                if (action == null)
                {
                    action = UpdateAction(script, to);
                }
                else
                {
                    script.MoveForwardIf(action[0]);
                }

                char next = script.TryCurrent(); // we've already moved forward
                bool done = listToMerge.Count == 0 &&
                            (next == Constants.END_STATEMENT ||
                             (action == Constants.NULL_ACTION && current.Type != Variable.VarType.NUMBER) ||
                             current.IsReturn);
                if (done)
                {
                    if (action != null && action != Constants.END_ARG_STR)
                    {
                        throw new ArgumentException("Action [" +
                                                    action + "] without an argument.");
                    }
                    // If there is no numerical result, we are not in a math expression.
                    listToMerge.Add(current);
                    return(listToMerge);
                }

                Variable cell = current.Clone();
                cell.Action = action;

                bool addIt = UpdateIfBool(script, ref cell, ref listToMerge);
                if (addIt)
                {
                    listToMerge.Add(cell);
                }
                item.Clear();
            } while (script.StillValid() &&
                     (inQuotes || arrayIndexDepth > 0 || !to.Contains(script.Current)));

            // This happens when called recursively inside of the math expression:
            script.MoveForwardIf(Constants.END_ARG);

            return(listToMerge);
        }
Пример #16
0
        public static bool IsNumericFunction(string paramName, ParsingScript script = null)
        {
            ParserFunction function = ParserFunction.GetFunction(paramName, script);

            return(function is INumericFunction);
        }
Пример #17
0
 public static void addFunction(string name, ParserFunction function)
 {
     m_functions[name] = function;
 }