Ejemplo n.º 1
0
 internal void clear()
 {
     state     = ParseStates.init;
     method    = ParseMethods.init;
     bytePos   = 0;
     bytesUsed = 0;
     charPos   = 0;
     charsUsed = 0;
     sb        = new StringBuilder();
 }
Ejemplo n.º 2
0
        // most of the code in this class is copy-pasted from PENIS for Unity
        public static object Parse(string text, Type type)
        {
            ParseMethod method;

            if (ParseMethods.TryGetValue(type, out method))
            {
                return(method(text));
            }

            if (type.IsEnum)
            {
                return(ParseEnum(text, type));
            }

            throw new Exception($"The text {text} cannot be converted into type {type}");
        }
Ejemplo n.º 3
0
        private static void MatchNormal(string data, ref int pos, int end)
        {
            for (; pos < end; pos++)
            {
                switch (data[pos])
                {
                case '\'':
                    return;

                case '\"':
                    return;

                case '/':
                    if (end > pos + 1)
                    {
                        switch (data[pos + 1])
                        {
                        case '/':
                        case '*':
                            return;
                        }
                    }
                    break;

                case '<':
                    if (ParseMethods.SubstringMatch(data, pos, end, "<!--"))
                    {
                        return;
                    }
                    break;

                case '-':
                    if (ParseMethods.SubstringMatch(data, pos, end, "-->"))
                    {
                        return;
                    }
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        public ScriptElement Next()
        {
            if (pos >= end)
            {
                return(null);
            }

            int start = pos;

            switch (data[pos++])
            {
            case '"':
            {
                int literalPos = pos;
                int literalEnd;
                ParseMethods.MatchDoubleQuotedLiteral(data, ref pos, end, out literalEnd);
                return(new ScriptLiteral(data, start, pos - start, literalPos, literalEnd - literalPos, '"'));
            }

            case '\'':
            {
                int literalPos = pos;
                int literalEnd;
                ParseMethods.MatchSingleQuotedLiteral(data, ref pos, end, out literalEnd);
                return(new ScriptLiteral(data, start, pos - start, literalPos, literalEnd - literalPos, '\''));
            }

            case '/':
                if (ParseMethods.SubstringMatch(data, pos - 1, end, "//"))
                {
                    pos++;
                    ParseMethods.MatchSingleLineComment(data, ref pos, end);
                    return(new ScriptComment(data, start, pos - start));
                }
                else if (ParseMethods.SubstringMatch(data, pos - 1, end, "/*"))
                {
                    pos++;
                    ParseMethods.MatchMultiLineComment(data, ref pos, end);
                    return(new ScriptComment(data, start, pos - start));
                }
                goto default;

            case '<':
                if (ParseMethods.SubstringMatch(data, pos - 1, end, "<!--"))
                {
                    pos += 3;
                    ParseMethods.MatchSingleLineComment(data, ref pos, end);
                    return(new ScriptComment(data, start, pos - start));
                }
                goto default;

            case '-':
                if (ParseMethods.SubstringMatch(data, pos - 1, end, "-->"))
                {
                    pos += 2;
                    ParseMethods.MatchSingleLineComment(data, ref pos, end);
                    return(new ScriptComment(data, start, pos - start));
                }
                goto default;

            default:
                MatchNormal(data, ref pos, end);
                return(new ScriptText(data, start, pos - start));
            }
        }
Ejemplo n.º 5
0
        // Main function
        private static void Main(string[] args)
        {
            // ------------------------------------------------------- //
            //      Request initialization (Uncomment wanted param)    //
            // ------------------------------------------------------- //
            var initParameters = new RequestParams();

            VkUsers.RequestParamsInit(initParameters);

            initParameters.City = 282;      // 282 - Minsk
                                            //initParameters.Country = 3;   // 3 - BY. All list here: https://vk.com/select_ajax.php?act=a_get_countries
                                            //initParameters.Sex = 1;       // 1 — женщина; 2 — мужчина;
                                            //initParameters.Status = 1;

            /*  1 — не женат (не замужем);
             *  2 — встречается;
             *  3 — помолвлен(-а);
             *  4 — женат (замужем);
             *  5 — всё сложно;
             *  6 — в активном поиске;
             *  7 — влюблен(-а).*/
            //initParameters.AgeFrom = 20;
            //initParameters.AgeTo = 25;
            //initParameters.Online = 1;
            //initParameters.Interests = "Drinking";
            //initParameters.Position = "CEO";


            Console.WriteLine("Please enter year from (ex. 1960): ");
            _yearFrom = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Please enter year to   (ex. 2002): ");
            _yearTo = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Please enter start delay (>300): ");
            _delayFrom = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Please enter max delay  (unlim): ");
            _delayTo = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Please enter number of city (ex. 282 it`s Minsk: ");
            initParameters.City = Convert.ToInt32(Console.ReadLine());

            //_yearFrom = 1970;
            //_yearTo = 2002;
            //_delayFrom = 1000;
            //_delayTo = 1800;
            initParameters.City = 282;

            Console.WriteLine("-----------------------------:-------------------------------------------------");
            Console.WriteLine("Qty names in dictionaries    : {0}", Utils.GetUsersNames().Length);
            Console.WriteLine("Qty of tokens                : {0}\n", File.ReadAllLines(ParseMethods.TokensFile).Length);
            Console.WriteLine("Parsing Name                 : {0}", initParameters.Name);
            Console.WriteLine("Parsing Count                : {0}", initParameters.Count);
            Console.WriteLine("Parsing City                 : {0}", initParameters.City);
            Console.WriteLine("Parsing Country              : {0}", initParameters.Country);
            Console.WriteLine("Parsing Sex                  : {0}", initParameters.Sex);
            Console.WriteLine("Parsing Status               : {0}", initParameters.Status);
            Console.WriteLine("Parsing Age from             : {0}", initParameters.AgeFrom);
            Console.WriteLine("Parsing Age to               : {0}", initParameters.AgeTo);
            Console.WriteLine("Parsing Online status        : {0}", initParameters.Status);
            Console.WriteLine("Parsing Interests            : {0}", initParameters.Interests);
            Console.WriteLine("Parsing Position             : {0}\n", initParameters.Position);
            Console.WriteLine("Parsing Year from            : {0}", _yearFrom);
            Console.WriteLine("Parsing Year to              : {0}", _yearTo);
            Console.WriteLine("Parsing Delay from           : {0}", _delayFrom);
            Console.WriteLine("Parsing Delay to             : {0}", _delayTo);
            Console.WriteLine("-----------------------------:-------------------------------------------------\n");

            Console.WriteLine("Please press Enter to start parsing");
            Console.ReadKey();

            if (File.Exists(OutputFile + "_" + initParameters.City + ".txt") == false)
            {
                File.WriteAllText(OutputFile + "_" + initParameters.City + ".txt", string.Format("Parsing started at: {0}\n", DateTime.Now));
            }

            // ------------------------------------------------------- //
            //     Methods initialization (Uncomment wanted method)    //
            // ------------------------------------------------------- //
            //ParseMethods.ParsingUsersByBdayDirect(out _usersFound, out _parsingStatus, initParameters, YearFrom, YearTo, DelayFrom, DelayTo, false, true, OutputFile);
            //ParseMethods.ParsingUsersByBdayRandom(out _usersFound, out _parsingStatus, initParameters, YearFrom, YearTo, DelayFrom, DelayTo, false, true, OutputFile);
            ParseMethods.ParsingUsersByBdayFullRandom(out _usersFound, out _parsingStatus, initParameters, _yearFrom, _yearTo, _delayFrom, _delayTo, false, OutputFile);
            //ParseMethods.ParsingUsersByDictionaryName(out _usersFound, out _parsingStatus, initParameters, 20, 25, DelayFrom, DelayTo, false, OutputFile);
            //ParseMethods.ParsingUsersByExecuteRandom(out _usersFound, out _parsingStatus, initParameters, _yearFrom, _yearTo, _delayFrom, _delayTo, OutputFile);

            Console.WriteLine("Qty of founded users: {0}", _usersFound);
            Console.WriteLine("-------------------------------------\n");
            Console.WriteLine(_parsingStatus);
            Console.WriteLine("Press any key to exit...");

            if (File.Exists(string.Format(OutputFile + "_" + initParameters.City + ".txt")))
            {
                File.Copy(string.Format(OutputFile + "_" + initParameters.City + ".txt"),
                          string.Format(OutputFile + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour +
                                        DateTime.Now.Minute + "_" + initParameters.City + "_finished.txt"));
                File.Delete(string.Format(OutputFile + "_" + initParameters.City + ".txt"));
            }

            Console.ReadKey();
        }